Skip to content

Commit a63e03a

Browse files
author
guqiankun
committed
fix: 修复editor主题初始化未注册fromExtension
1 parent 597400e commit a63e03a

5 files changed

Lines changed: 12 additions & 18 deletions

File tree

packages/alex/src/core/editor/editor.extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ExtensionServiceImplOverride extends ExtensionServiceImpl {
2323
await this.initExtensionMetaData();
2424
await this.initExtensionInstanceData();
2525
await this.runExtensionContributes();
26+
await this.initThemeAndColor();
2627
this.doActivate();
2728
}
2829
}

packages/alex/src/core/editor/editor.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class ThemeContribution extends Disposable implements ClientAppContribution {
149149
GeekTheme.packageJSON.contributes!.themes,
150150
URI.parse(getExtensionPath(GeekTheme.extension, 'public'))
151151
);
152+
await this.themeService.applyTheme(undefined, true);
152153
// 强制用集成设置的默认主题
153154
await this.themeService.applyTheme(this.defaultPreferenceProvider.get('general.theme'));
154155
}

packages/alex/src/core/extension/metadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ export const GeekTheme: IExtensionBasicMetadata = {
8787
themes: [
8888
{
8989
id: 'alipay-geek-dark',
90-
label: 'IDE Dark',
90+
label: 'IDE Geek Dark',
9191
uiTheme: 'vs-dark',
9292
path: './themes/dark/plus.json',
9393
},
9494
{
9595
id: 'alipay-geek-light',
96-
label: 'IDE Light',
96+
label: 'IDE Geek Light',
9797
uiTheme: 'vs',
9898
path: './themes/light/plus.json',
9999
},

packages/integrations/src/editor/index.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Select from 'antd/lib/select';
1111
import Cascader from 'antd/lib/cascader';
1212
import Button from 'antd/lib/button';
1313
import './style.less';
14-
import editorPlugin from '../common/plugin';
14+
import * as editorPlugin from './plugin';
1515
import { LocalExtensionModule } from '../common/local-extension.module';
1616

1717
(window as any).alex = Alex;
@@ -131,27 +131,15 @@ const App = () => {
131131
</Select>
132132
<Button
133133
onClick={() => {
134-
const commands = editorPlugin.commands;
134+
const commands = editorPlugin.api.commands;
135135
if (commands) {
136-
commands.executeCommand('plugin.command.test', 1, 2);
136+
commands.executeCommand('plugin.command.changeTheme', 'ide-dark');
137137
}
138138
}}
139139
size="small"
140140
>
141141
command test
142142
</Button>
143-
<Button
144-
onClick={() => {
145-
const commands = editorPlugin.commands;
146-
if (commands) {
147-
commands.executeCommand('alex.settings');
148-
}
149-
}}
150-
size="small"
151-
style={{ marginLeft: 8 }}
152-
>
153-
更改偏好设置
154-
</Button>
155143
</div>
156144
<div style={{ display: 'flex' }}>
157145
<div style={{ width: '50%', minHeight: 500 }}>

packages/integrations/src/editor/plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ export const api = {
1313
export const activate = ({ context, commands }: IPluginAPI) => {
1414
_commands = commands;
1515
context.subscriptions.push(
16-
commands.registerCommand('plugin.command.add', (x: number) => {
16+
commands.registerCommand('plugin.command.add', async (x: number) => {
1717
commands.executeCommand('plugin.command.say', 'alex is great');
18+
await commands.executeCommand('theme.toggle');
1819
return x + x;
20+
}),
21+
commands.registerCommand('plugin.command.changeTheme', (value) => {
22+
commands.executeCommand('alex.setDefaultPreference', 'general.theme', value, 1);
1923
})
2024
);
2125
};

0 commit comments

Comments
 (0)