feat: 更新助手配置,添加应用ID和URL,优化身份验证和代理逻辑

This commit is contained in:
2025-12-18 20:56:18 +08:00
parent c77578805a
commit 91fdd6abc3
10 changed files with 259 additions and 44 deletions

View File

@@ -51,11 +51,11 @@ export class AssistantInit extends AssistantConfig {
return this.#query;
}
get baseURL() {
return `${this.getConfig()?.pageApi || 'https://kevisual.cn'}/api/router`;
return `${this.getConfig()?.app?.url || 'https://kevisual.cn'}/api/router`;
}
setQuery(query?: Query) {
this.#query = query || new Query({
url: `${this.getConfig()?.pageApi || 'https://kevisual.cn'}/api/router`,
url: `${this.getConfig()?.app?.url || 'https://kevisual.cn'}/api/router`,
});
}
checkConfigPath() {
@@ -92,6 +92,16 @@ export class AssistantInit extends AssistantConfig {
if (!checkFileExists(assistantPath, true)) {
this.setConfig(this.getDefaultInitAssistantConfig());
console.log(chalk.green('助手配置文件assistant-config.json创建成功'));
} else {
const config = this.getConfig();
if (!config?.app?.id) {
if (!config.app) {
config.app = {};
}
config.app.id = randomId();
this.setConfig(config);
console.log(chalk.green('助手配置文件assistant-config.json更新成功'));
}
}
}
initPnpm() {
@@ -120,7 +130,7 @@ export class AssistantInit extends AssistantConfig {
"type": "module",
"scripts": {
"start": "pm2 start apps/root/code-center/app.mjs --name root/code-center",
"proxy": "pm2 start apps/root/page-proxy/app.mjs --name root/page-proxy"
"cnb": "ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 7878"
},
"keywords": [],
"author": "",
@@ -194,20 +204,18 @@ export class AssistantInit extends AssistantConfig {
protected getDefaultInitAssistantConfig() {
const id = randomId();
return {
id,
app: {
url: 'https://kevisual.cn',
id,
},
description: '助手配置文件',
docs: "https://kevisual.cn/root/cli-docs/",
docs: "https://kevisual.cn/root/cli/docs/",
home: '/root/home',
proxy: [],
apiProxyList: [],
share: {
enabled: false,
name: 'abc',
url: 'https://kevisual.cn/ws/proxy',
},
watch: {
enabled: true,
},
} as AssistantConfigData;
}
getHttps() {