From 7d4bc37c09a9d0b4d719b29d28e0f12d804005cb Mon Sep 17 00:00:00 2001 From: abearxiong Date: Mon, 15 Dec 2025 23:02:06 +0800 Subject: [PATCH] update --- assistant/src/module/assistant/proxy/proxy.ts | 2 +- assistant/src/module/local-proxy/proxy.ts | 2 +- .../src/module/local-proxy/proxy/proxy.ts | 2 +- assistant/src/services/init/index.ts | 40 ++++++++++++++++++- .../src/services/proxy/proxy-page-index.ts | 2 +- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/assistant/src/module/assistant/proxy/proxy.ts b/assistant/src/module/assistant/proxy/proxy.ts index bec35a1..162a534 100644 --- a/assistant/src/module/assistant/proxy/proxy.ts +++ b/assistant/src/module/assistant/proxy/proxy.ts @@ -1,6 +1,6 @@ export type ProxyInfo = { /** - * 代理路径, 比如/root/center, 匹配的路径 + * 代理路径, 比如/root/home, 匹配的路径 */ path?: string; /** diff --git a/assistant/src/module/local-proxy/proxy.ts b/assistant/src/module/local-proxy/proxy.ts index 18682ab..b7ba16e 100644 --- a/assistant/src/module/local-proxy/proxy.ts +++ b/assistant/src/module/local-proxy/proxy.ts @@ -2,7 +2,7 @@ import { LocalProxy, LocalProxyOpts } from './index.ts'; import http from 'node:http'; import { fileProxy } from './proxy/file-proxy.ts'; const localProxy = new LocalProxy({}); -let home = '/root/center'; +let home = '/root/home'; export const initProxy = (data: LocalProxyOpts & { home?: string }) => { localProxy.pagesDir = data.pagesDir || ''; localProxy.watch = data.watch ?? false; diff --git a/assistant/src/module/local-proxy/proxy/proxy.ts b/assistant/src/module/local-proxy/proxy/proxy.ts index bec35a1..162a534 100644 --- a/assistant/src/module/local-proxy/proxy/proxy.ts +++ b/assistant/src/module/local-proxy/proxy/proxy.ts @@ -1,6 +1,6 @@ export type ProxyInfo = { /** - * 代理路径, 比如/root/center, 匹配的路径 + * 代理路径, 比如/root/home, 匹配的路径 */ path?: string; /** diff --git a/assistant/src/services/init/index.ts b/assistant/src/services/init/index.ts index 32c8646..f829562 100644 --- a/assistant/src/services/init/index.ts +++ b/assistant/src/services/init/index.ts @@ -10,6 +10,7 @@ export type AssistantInitOptions = { path?: string; init?: boolean; }; +const randomId = () => Math.random().toString(36).substring(2, 8); /** * 助手初始化类 * @class AssistantInit @@ -41,6 +42,7 @@ export class AssistantInit extends AssistantConfig { this.createEnvConfig(); this.createOtherConfig(); this.initPnpm(); + this.initIgnore(); } get query() { if (!this.#query) { @@ -153,10 +155,46 @@ export class AssistantInit extends AssistantConfig { create, }; } + initIgnore() { + const gitignorePath = path.join(this.configDir, '.gitignore'); + let content = ''; + if (checkFileExists(gitignorePath, true)) { + content = fs.readFileSync(gitignorePath, 'utf-8'); + } + const ignoreLines = [ + 'node_modules', + '.DS_Store', + 'dist', + 'pack-dist', + 'cache-file', + 'build', + 'apps/**/node_modules/', + 'pages/**/node_modules/', + '.env', + '!.env*development', + '.pnpm-store', + '.vite', + '.astro' + ]; + let updated = false; + ignoreLines.forEach((line) => { + if (!content.includes(line)) { + content += `\n${line}`; + updated = true; + } + }); + if (updated) { + fs.writeFileSync(gitignorePath, content.trim() + '\n'); + console.log(chalk.green('.gitignore 文件更新成功')); + } + } protected getDefaultInitAssistantConfig() { + const id = randomId(); return { + id, description: '助手配置文件', - home: '/root/center', + docs: "https://kevisual.cn/root/cli-docs/", + home: '/root/home', proxy: [], apiProxyList: [], share: { diff --git a/assistant/src/services/proxy/proxy-page-index.ts b/assistant/src/services/proxy/proxy-page-index.ts index 8d94603..3c36cd4 100644 --- a/assistant/src/services/proxy/proxy-page-index.ts +++ b/assistant/src/services/proxy/proxy-page-index.ts @@ -58,7 +58,7 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp return res.end(`Not Found [${proxyApi.path}] rootPath`); } return fileProxy(req, res, { - path: proxyApi.path, // 代理路径, 比如/root/center + path: proxyApi.path, // 代理路径, 比如/root/home rootPath: proxyApi.rootPath, ...proxyApi, indexPath: _indexPath, // 首页路径