Skip to content

Commit

Permalink
fix: theme extension i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Jan 20, 2023
1 parent 5e9b1eb commit 805af93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ ${log}
this.isOperating = true;
switch (operate) {
case 'install': {
const { name, version, main } = this.extensionDetail;
const { name, version, main, i18n } = this.extensionDetail;
this.extensionDetail.installed = await this.extensionService.installExtension({
name,
version,
main
main,
i18n
});
this.extensionDetail['enabled'] = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export class ExtensionService {
}),
...debugExtensions
];

//Handle featue data
result.data = result.data.map(module => {
let result = this.webExtensionService.translateModule(module);
Expand Down Expand Up @@ -149,7 +148,7 @@ export class ExtensionService {
* @param id
* @returns if install success
*/
async installExtension({ name, version = 'latest', main = '' }): Promise<boolean> {
async installExtension({ name, version = 'latest', main = '', i18n = [] }): Promise<boolean> {
const successCallback = () => {
this.updateInstalledInfo(this.getExtensions(), {
action: 'install',
Expand All @@ -160,7 +159,9 @@ export class ExtensionService {
}
};
if (this.electron.isElectron) {
const { code, data, modules } = await window.electron.installExtension(name);
const { code, data, modules } = await window.electron.installExtension(name, {
i18n
});
if (code === 0) {
successCallback();
return true;
Expand All @@ -169,7 +170,11 @@ export class ExtensionService {
return false;
}
} else {
const isSuccess = await this.webExtensionService.installExtension(name, version, main);
const isSuccess = await this.webExtensionService.installExtension(name, {
version,
entry: main,
i18n
});
if (isSuccess) {
successCallback();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ export class WebExtensionService {
resourceUrl = 'https://unpkg.com';
constructor(private web: WebService, private language: LanguageService) {
this.debugExtensionNames =
!APP_CONFIG.production || this.web.isVercel || 'http://54.255.141.14:8080'.includes(window.location.hostname)
? ['vscode-postcat-abyss', 'vscode-postcat-dracula', 'vscode-postcat-purple']
: [];
!APP_CONFIG.production || this.web.isVercel || 'http://54.255.141.14:8080'.includes(window.location.hostname) ? [] : [];
}
async installExtension(extName: string, version = 'latest', entry = '') {
async installExtension(extName: string, { version = 'latest', entry = '', i18n = [] }) {
const url = `${extName}@${version}${entry ? `/${entry}` : entry}`;
const fullPath = new URL(url, this.resourceUrl);
const install = async pkgJson => {
Expand Down Expand Up @@ -80,6 +78,7 @@ export class WebExtensionService {
}
}
const oldIndex = this.installedList.findIndex(n => n.name === extName);
pkgJson.i18n = i18n;
pkgObj = this.translateModule(pkgObj);
this.installedList.splice(oldIndex, oldIndex === -1 ? 0 : 1, {
name: extName,
Expand Down

0 comments on commit 805af93

Please sign in to comment.