save
This commit is contained in:
parent
0dc727e781
commit
49a3b14797
@ -24,6 +24,7 @@ import { userHasReadGuide } from './components/guide/tour';
|
||||
|
||||
import PasswordDialog from '@/components/password-dialog/index.vue';
|
||||
import { privilegeStatus } from './components/password-dialog/status';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const bridge = useMessageBridge();
|
||||
|
||||
@ -66,7 +67,7 @@ onMounted(async () => {
|
||||
Connection.showPanel = false;
|
||||
});
|
||||
|
||||
await initialise();
|
||||
await initialise();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -73,7 +73,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, provide, ref } from 'vue';
|
||||
import Diagram from './diagram.vue';
|
||||
import { makeNodeTest, makeParallelTest, topoSortParallel, type DiagramContext, type DiagramState } from './diagram';
|
||||
import { makeNodeTest, topoSortParallel, type DiagramContext, type DiagramState } from './diagram';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
@ -36,6 +36,7 @@ export function normaliseJavascriptType(type: string) {
|
||||
}
|
||||
|
||||
export const mcpSetting = reactive({
|
||||
language: 'zh',
|
||||
timeout: 60,
|
||||
proxyServer: '',
|
||||
});
|
@ -19,6 +19,7 @@ export async function loadSetting() {
|
||||
|
||||
llmManager.currentModelIndex = persistConfig.MODEL_INDEX || 0;
|
||||
I18n.global.locale.value = persistConfig.LANG || 'zh';
|
||||
mcpSetting.language = persistConfig.LANG || 'zh';
|
||||
mcpSetting.timeout = persistConfig.MCP_TIMEOUT_SEC || 60;
|
||||
mcpSetting.proxyServer = persistConfig.PROXY_SERVER || '';
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { defineComponent, onMounted, ref } from 'vue';
|
||||
import { languageSetting } from './language';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { mcpSetting } from '@/hook/mcp';
|
||||
@ -56,19 +56,7 @@ defineComponent({ name: 'appearance' });
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
const currentLanguage = ref('简体中文');
|
||||
|
||||
|
||||
|
||||
function onlanguagechange(code: string) {
|
||||
console.log('enter lang change');
|
||||
|
||||
const option = languageSetting.options.find(item => item.value === code);
|
||||
if (option) {
|
||||
currentLanguage.value = option.text;
|
||||
}
|
||||
// languageDialogShow.value = true;
|
||||
|
||||
function onlanguagechange() {
|
||||
saveSetting();
|
||||
}
|
||||
|
||||
@ -76,6 +64,9 @@ const safeSaveSetting = debounce(() => {
|
||||
saveSetting();
|
||||
}, 10);
|
||||
|
||||
onMounted(() => {
|
||||
locale.value = mcpSetting.language;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
export let VSCODE_WORKSPACE = '';
|
||||
export let RUNNING_CWD = '';
|
||||
export let DEFAULT_LANG = 'zh';
|
||||
|
||||
export function setVscodeWorkspace(workspace: string) {
|
||||
VSCODE_WORKSPACE = workspace;
|
||||
@ -7,4 +8,8 @@ export function setVscodeWorkspace(workspace: string) {
|
||||
|
||||
export function setRunningCWD(path: string) {
|
||||
RUNNING_CWD = path;
|
||||
}
|
||||
}
|
||||
|
||||
export function setDefaultLang(lang: string) {
|
||||
DEFAULT_LANG = lang;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
export { routeMessage } from './common/router.js';
|
||||
export { VSCodeWebViewLike } from './hook/adapter.js';
|
||||
export { setVscodeWorkspace, setRunningCWD } from './hook/setting.js';
|
||||
export { setVscodeWorkspace, setRunningCWD, setDefaultLang } from './hook/setting.js';
|
||||
export { clientMap } from './mcp/connect.service.js';
|
@ -1,7 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { VSCODE_WORKSPACE } from '../hook/setting.js';
|
||||
import { DEFAULT_LANG, VSCODE_WORKSPACE } from '../hook/setting.js';
|
||||
import { IConfig } from './setting.dto.js';
|
||||
import { llms } from '../hook/llm.js';
|
||||
|
||||
@ -14,20 +14,15 @@ function getConfigurationPath() {
|
||||
return path.join(configDir, 'setting.json');
|
||||
}
|
||||
|
||||
function getDefaultLanguage() {
|
||||
if (process.env.VSCODE_PID) {
|
||||
// TODO: 获取 vscode 内部的语言
|
||||
|
||||
function getDefaultConfig() {
|
||||
return {
|
||||
MODEL_INDEX: 0,
|
||||
LLM_INFO: llms,
|
||||
LANG: DEFAULT_LANG,
|
||||
MCP_TIMEOUT_SEC: 60
|
||||
}
|
||||
return 'zh';
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG: IConfig = {
|
||||
MODEL_INDEX: 0,
|
||||
LLM_INFO: llms,
|
||||
LANG: getDefaultLanguage(), MCP_TIMEOUT_SEC: 60
|
||||
};
|
||||
|
||||
|
||||
function createConfig(): IConfig {
|
||||
const configPath = getConfigurationPath();
|
||||
@ -39,8 +34,9 @@ function createConfig(): IConfig {
|
||||
}
|
||||
|
||||
// 写入默认配置
|
||||
fs.writeFileSync(configPath, JSON.stringify(DEFAULT_CONFIG, null, 2), 'utf-8');
|
||||
return DEFAULT_CONFIG;
|
||||
const defaultConfig = getDefaultConfig();
|
||||
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf-8');
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
export function loadSetting(): IConfig {
|
||||
|
@ -13,6 +13,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const workspace = workspaceFolder?.uri.fsPath || '';
|
||||
setVscodeWorkspace(workspace);
|
||||
setRunningCWD(context.extensionPath);
|
||||
|
||||
initialiseI18n(context);
|
||||
|
||||
// 添加i18n调试信息
|
||||
|
@ -4,6 +4,14 @@ import * as path from 'path';
|
||||
|
||||
const defaultBundle: Record<string, string> = {}
|
||||
|
||||
export function getDefaultLanguage() {
|
||||
const lang = vscode.env.language || 'en';
|
||||
if (lang === 'zh-cn') {
|
||||
return 'zh';
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
|
||||
export function initialiseI18n(context: vscode.ExtensionContext) {
|
||||
if (vscode.l10n.bundle === undefined) {
|
||||
// 获取用户的语言设置
|
||||
|
Loading…
x
Reference in New Issue
Block a user