Skip to content

Commit

Permalink
feat: add remote config api
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondYuan committed Jun 22, 2021
1 parent e738fd6 commit 5d34d80
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ const request = extend({
request.interceptors.request.use(
(url, options) => {
const powerpackService = Container.get(IPowerpackService);
let requestId = generateUuid();
if (!localStorageService.get('d-request-id')) {
localStorageService.set('d-request-id', generateUuid());
localStorageService.set('d-request-id', requestId);
}
return {
url,
Expand All @@ -32,7 +33,8 @@ request.interceptors.request.use(
headers: {
...options.headers,
token: powerpackService.accessToken || '',
'd-request-id': localStorageService.get('d-request-id', generateUuid()),
'd-request-id': localStorageService.get('d-request-id', requestId),
'web-clipper-version': `${WEB_CLIPPER_VERSION}`,
locale: localStorageService.get(LOCAL_USER_PREFERENCE_LOCALE_KEY, getLanguage()),
},
},
Expand Down Expand Up @@ -93,6 +95,12 @@ export const refresh = () => {
return request.get<IResponse<string>>('refresh');
};

export interface WebClipperRemoteConfig {}

export const fetchRemoteConfig = () => {
return request.get<IResponse<WebClipperRemoteConfig>>('v1/config');
};

export interface OCRRequestBody {
image: string;
language_type: 'CHN_ENG' | 'ENG' | 'JAP' | 'GER';
Expand Down
3 changes: 3 additions & 0 deletions src/vendor/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ interface Type<T> extends Function {
/// <reference path="../../node_modules/@types/chrome/index.d.ts"/>

interface Window {
WEB_CLIPPER_VERSION: string;
_gaq: string[][];
}

declare const WEB_CLIPPER_VERSION: string;
7 changes: 7 additions & 0 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ module.exports = {
],
},
plugins: [
new webpack.DefinePlugin({
WEB_CLIPPER_VERSION: JSON.stringify(
process.env.NODE_ENV === 'development'
? getVersion(packageJson.version, true)
: getVersion(packageJson.version, false)
),
}),
process.env.NODE_ENV === 'development'
? new ExtensionReloader({
port: 9091,
Expand Down

0 comments on commit 5d34d80

Please sign in to comment.