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