Skip to content

Commit 6f7896a

Browse files
author
winjo
committed
chore: startup
1 parent fa04be8 commit 6f7896a

2 files changed

Lines changed: 37 additions & 24 deletions

File tree

packages/alex/src/integration/startup/index.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ isFilesystemReady().then(async () => {
3333
// );
3434
});
3535

36-
const query = location.search
37-
.slice(1)
38-
.split('&')
39-
.reduce<Record<string, string>>((obj, pair) => {
40-
const [key, value] = pair.split('=');
41-
obj[decodeURIComponent(key)] = decodeURIComponent(value || '');
42-
return obj;
43-
}, {});
36+
// const query = location.search
37+
// .slice(1)
38+
// .split('&')
39+
// .reduce<Record<string, string>>((obj, pair) => {
40+
// const [key, value] = pair.split('=');
41+
// obj[decodeURIComponent(key)] = decodeURIComponent(value || '');
42+
// return obj;
43+
// }, {});
4444

4545
const platformConfig = {
4646
antcode: {
@@ -70,17 +70,21 @@ const platformConfig = {
7070

7171
const layoutConfig = getDefaultLayoutConfig();
7272

73-
const platform = (Object.keys(platformConfig).includes(query.platform)
74-
? query.platform
75-
: 'antcode') as CodeServiceConfig['platform'];
73+
let pathParts = location.pathname.split('/').filter(Boolean);
74+
75+
const platform = pathParts[0] in platformConfig ? pathParts[0] : 'antcode';
76+
77+
// const platform = (Object.keys(platformConfig).includes(query.platform)
78+
// ? query.platform
79+
// : 'antcode') as CodeServiceConfig['platform'];
7680
const { module: CodeAPIModule, ...config } = platformConfig[platform];
77-
if (query.project) {
78-
const [owner, name] = decodeURIComponent(query.project).split('/');
79-
Object.assign(config, { owner, name });
81+
if (pathParts[1]) {
82+
config.owner = pathParts[1];
83+
}
84+
if (pathParts[2]) {
85+
config.name = pathParts[2];
8086
}
81-
delete query.platform;
82-
delete query.project;
83-
Object.assign(config, query);
87+
config.refPath = pathParts.slice(3).join('/');
8488

8589
if (platform === 'github' || platform === 'gitlab') {
8690
layoutConfig[SlotLocation.left].modules.push(platform);
@@ -96,11 +100,7 @@ const App = () => (
96100
extensionMetadata: [css, html, json, markdown, typescript],
97101
workspaceDir: `${platform}/${config.owner}/${config.name}`,
98102
layoutConfig,
99-
defaultPreferences: {
100-
'editor.readonlyFiles': [
101-
'/workspace/antcode/internal_release/ifcriskcloudus/app/plugin/tcomponent/src/main/java/com/alipay/fc/riskcloud/plugin/tcomponent/util/StrategyDrmParserUtil.java',
102-
],
103-
},
103+
defaultPreferences: {},
104104
}}
105105
runtimeConfig={{
106106
codeService: config as CodeServiceConfig,

packages/alex/src/integration/startup/startup.module.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
CommandContribution,
99
CommandRegistry,
1010
getLanguageId,
11+
ClientAppContribution,
12+
Disposable,
1113
} from '@ali/ide-core-browser';
1214
import { ExtensionServiceClientImpl, IExtensionNodeClientService } from '@alipay/alex-core';
1315
import { IExtensionMetadata } from '@alipay/alex-shared';
@@ -71,14 +73,25 @@ class ExtensionServiceClient extends ExtensionServiceClientImpl {
7173
}
7274
}
7375

74-
@Domain(CommandContribution)
75-
export class AlexAppContribution implements CommandContribution {
76+
@Domain(CommandContribution, ClientAppContribution)
77+
export class AlexAppContribution
78+
extends Disposable
79+
implements CommandContribution, ClientAppContribution {
7680
@Autowired()
7781
codeModel: CodeModelService;
7882

7983
private ticket: number = 0;
8084
private tickets: number[] = [];
8185

86+
initialize() {
87+
this.addDispose(
88+
this.codeModel.onDidChangeRefPath((path) => {
89+
const fullPath = `/${this.codeModel.platform}${path}`;
90+
window.history.replaceState(null, '', fullPath);
91+
})
92+
);
93+
}
94+
8295
registerCommands(commands: CommandRegistry): void {
8396
// 保持和 api-server 一致
8497
commands.registerCommand(

0 commit comments

Comments
 (0)