diff --git a/apps/cli/src/commands/declaration.ts b/apps/cli/src/commands/declaration.ts index 1482e245..38a705f9 100644 --- a/apps/cli/src/commands/declaration.ts +++ b/apps/cli/src/commands/declaration.ts @@ -4,6 +4,11 @@ import fs, { mkdirp } from 'fs-extra'; import path from 'path'; import ora from 'ora'; import got from 'got'; +import { withGhProxy } from '../utils'; + +const onlineDeclarationUrl = withGhProxy( + 'https://raw.githubusercontent.com/msgbyte/tailchat/master/client/web/tailchat.d.ts' +); export const declarationCommand: CommandModule = { command: 'declaration ', @@ -44,8 +49,7 @@ export const declarationCommand: CommandModule = { content = "declare module '@capital/common';\ndeclare module '@capital/component';\n"; } else if (source === 'github') { - const url = - 'https://raw.githubusercontent.com/msgbyte/tailchat/master/client/web/tailchat.d.ts'; + const url = onlineDeclarationUrl; const spinner = ora(`正在从 Github 下载插件类型声明: ${url}`).start(); diff --git a/apps/cli/src/commands/docker/init.ts b/apps/cli/src/commands/docker/init.ts index 2d36042b..7ca1498a 100644 --- a/apps/cli/src/commands/docker/init.ts +++ b/apps/cli/src/commands/docker/init.ts @@ -6,6 +6,7 @@ import path from 'path'; import chalk from 'chalk'; import inquirer from 'inquirer'; import randomString from 'crypto-random-string'; +import { withGhProxy } from '../../utils'; // https://docs.docker.com/engine/api/v1.41/ @@ -179,10 +180,3 @@ async function promptConfirm(message: string): Promise { return res; } - -/** - * 增加github资源代理以优化国内访问速度 - */ -function withGhProxy(url: string): string { - return `https://ghproxy.com/${url}`; -} diff --git a/apps/cli/src/utils.ts b/apps/cli/src/utils.ts index 8e653835..cfc5b9e4 100644 --- a/apps/cli/src/utils.ts +++ b/apps/cli/src/utils.ts @@ -4,3 +4,10 @@ export function isDev(): boolean { return process.env.NODE_ENV === 'development'; } + +/** + * 增加github资源代理以优化国内访问速度 + */ +export function withGhProxy(url: string): string { + return `https://ghproxy.com/${url}`; +} diff --git a/apps/cli/templates/client-plugin/{{id}}/src/index.tsx b/apps/cli/templates/client-plugin/{{id}}/src/index.tsx index 17eb3890..304a1da5 100644 --- a/apps/cli/templates/client-plugin/{{id}}/src/index.tsx +++ b/apps/cli/templates/client-plugin/{{id}}/src/index.tsx @@ -1,3 +1,3 @@ -const PLUGIN_NAME = '{{name}}'; +const PLUGIN_NAME = '{{id}}'; console.log(`Plugin ${PLUGIN_NAME} is loaded`); diff --git a/apps/cli/templates/client-plugin/{{id}}/src/translate.ts b/apps/cli/templates/client-plugin/{{id}}/src/translate.ts new file mode 100644 index 00000000..96b0360b --- /dev/null +++ b/apps/cli/templates/client-plugin/{{id}}/src/translate.ts @@ -0,0 +1,8 @@ +import { localTrans } from '@capital/common'; + +export const Translate = { + name: localTrans({ + 'zh-CN': '{{name}}', + 'en-US': '{{name}}', + }), +}; diff --git a/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/index.tsx b/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/index.tsx index 17eb3890..304a1da5 100644 --- a/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/index.tsx +++ b/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/index.tsx @@ -1,3 +1,3 @@ -const PLUGIN_NAME = '{{name}}'; +const PLUGIN_NAME = '{{id}}'; console.log(`Plugin ${PLUGIN_NAME} is loaded`); diff --git a/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/translate.ts b/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/translate.ts new file mode 100644 index 00000000..96b0360b --- /dev/null +++ b/apps/cli/templates/server-plugin-web/{{id}}/web/plugins/{{id}}/src/translate.ts @@ -0,0 +1,8 @@ +import { localTrans } from '@capital/common'; + +export const Translate = { + name: localTrans({ + 'zh-CN': '{{name}}', + 'en-US': '{{name}}', + }), +};