feat: 更新创建插件客户端模板,增加翻译

并优化了国内网络在请求在线声明时的网络体验
pull/70/head
moonrailgun 2 years ago
parent 3b951f8a6a
commit cda54ebdb6

@ -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 <source>',
@ -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();

@ -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<boolean> {
return res;
}
/**
* github访
*/
function withGhProxy(url: string): string {
return `https://ghproxy.com/${url}`;
}

@ -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}`;
}

@ -1,3 +1,3 @@
const PLUGIN_NAME = '{{name}}';
const PLUGIN_NAME = '{{id}}';
console.log(`Plugin ${PLUGIN_NAME} is loaded`);

@ -0,0 +1,8 @@
import { localTrans } from '@capital/common';
export const Translate = {
name: localTrans({
'zh-CN': '{{name}}',
'en-US': '{{name}}',
}),
};

@ -1,3 +1,3 @@
const PLUGIN_NAME = '{{name}}';
const PLUGIN_NAME = '{{id}}';
console.log(`Plugin ${PLUGIN_NAME} is loaded`);

@ -0,0 +1,8 @@
import { localTrans } from '@capital/common';
export const Translate = {
name: localTrans({
'zh-CN': '{{name}}',
'en-US': '{{name}}',
}),
};
Loading…
Cancel
Save