{"repo": "bob-bobo/llm-to-agent", "files": {"code/agent/bob_pet/src/renderer/settings/settings.js": {"679cfc2cf68761b4a9107082a259f1badec19097": {"t": 1785674642.657466, "n": 20904, "h": "c7d6ee48212ed2a4", "c": "let modelType = 'cloud';\nlet selectedPersona = 'neko';\nlet selectedTheme = 'blue';\nlet i18n = {};\nlet currentLang = 'zh-CN';\nlet modelProfiles = [];\nlet editingProfileId = null;\nlet editingPersonaName = null;\n\nconst BUILTIN_PERSONAS = ['neko', 'chatty_friend', 'smiling_sister', 'funny_bro', 'cautious_mentor'];\n\nconst CLOUD_PRESETS = {\n openai: { baseUrl: 'https://api.openai.com/v1', model: 'gpt-4o-mini', keyHint: 'sk-...' },\n deepseek: { baseUrl: 'https://api.deepseek.com/v1', model: 'deepseek-chat', keyHint: 'sk-...' },\n zhipu: { baseUrl: 'https://open.bigmodel.cn/api/paas/v4', model: 'glm-4-flash', keyHint: 'xxx.yyy' },\n moonshot: { baseUrl: 'https://api.moonshot.cn/v1', model: 'moonshot-v1-8k', keyHint: 'sk-...' },\n volcengine: { baseUrl: 'https://ark.cn-beijing.volces.com/api/v3', model: 'ep-xxxxxxxx', keyHint: 'ARK API Key' },\n volcengine_plan:{ baseUrl: 'https://ark.cn-beijing.volces.com/api/plan/v3', model: 'ep-xxxxxxxx', keyHint: 'ARK API Key' },\n aliyun: { baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1', model: 'qwen-turbo', keyHint: 'sk-...' },\n yi: { baseUrl: 'https://api.lingyiwanwu.com/v1', model: 'yi-lightning', keyHint: 'sk-...' },\n minimax: { baseUrl: 'https://api.minimax.chat/v1', model: 'MiniMax-Text-01', keyHint: 'sk-...' }\n};\n\nconst THEMES = [\n { name: 'blue', labelKey: 'themeBlue', color: '#3b82f6' },\n { name: 'white', labelKey: 'themeWhite', color: '#6b7280' },\n { name: 'black', labelKey: 'themeBlack', color: '#262626' },\n { name: 'green', labelKey: 'themeGreen', color: '#22c55e' },\n { name: 'orange', labelKey: 'themeOrange', color: '#f97316' },\n { name: 'purple', labelKey: 'themePurple', color: '#a855f7' },\n { name: 'pink', labelKey: 'themePink', color: '#ec4899' }\n];\n\nfunction t(key) { return i18n[key] || key; }\n\nfunction applyI18n() {\n document.querySelectorAll('[data-i18n]').forEach((el) => {\n const key = el.dataset.i18n;\n if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') return;\n const firstText = el.childNodes[0];\n if (firstText && firstText.nodeType === 3) {\n firstText.textContent = t(key);\n } else if (!el.querySelector('input, textarea')) {\n el.textContent = t(key);\n }\n });\n const navTexts = ['tabModel', 'tabPersona', 'tabTheme', 'tabLanguage', 'tabShortcuts', 'tabGeneral'];\n document.querySelectorAll('.nav-item').forEach((btn, i) => {\n if (navTexts[i]) btn.textContent = t(navTexts[i]);\n });\n}\n\nasync function loadI18n() {\n const data = await window.bobpet.getI18n();\n i18n = data.strings;\n currentLang = data.lang;\n applyI18n();\n}\n\nasync function loadConfig() {\n const cfg = await window.bobpet.getConfig();\n modelType = cfg.model?.type || 'cloud';\n selectedPersona = cfg.persona || 'neko';\n selectedTheme = cfg.theme || 'blue';\n modelProfiles = cfg.modelProfiles || [];\n\n document.getElementById('local-url').value = cfg.model?.local?.baseUrl || 'http://127.0.0.1:11434';\n document.getElementById('local-model').value = cfg.model?.local?.model || 'llama3.2';\n document.getElementById('cloud-url').value = cfg.model?.cloud?.baseUrl || '';\n document.getElementById('cloud-key').value = cfg.model?.cloud?.apiKey || '';\n document.getElementById('cloud-model').value = cfg.model?.cloud?.model || '';\n document.getElementById('auto-start').checked = !!cfg.autoStart;\n document.getElementById('show-thinking').checked = !!cfg.showThinking;\n document.getElementById('deep-think').checked = !!cfg.deepThink;\n\n updateModelPanels();\n renderPersonas();\n renderThemes();\n renderLanguages();\n renderProfiles();\n loadMultiAgentConfig();\n}\n\nfunction updateModelPanels() {\n document.querySelectorAll('[data-model-type]').forEach((btn) => {\n btn.classList.toggle('active', btn.dataset.modelType === modelType);\n });\n document.getElementById('panel-local').classList.toggle('hidden', modelType !== 'local');\n document.getElementById('panel-cloud').classList.toggle('hidden', modelType !== 'cloud');\n}\n\n// --- Model Profiles ---\nfunction renderProfiles() {\n const el = document.getElementById('profile-list');\n el.innerHTML = '';\n if (modelProfiles.length === 0) {\n el.innerHTML = `
${t('noProfiles') || '暂无保存的配置'}
`;\n return;\n }\n modelProfiles.forEach((profile) => {\n const card = document.createElement('div');\n card.className = 'profile-card';\n const typeLabel = profile.type === 'local' ? 'Ollama' : 'Cloud';\n const modelLabel = profile.type === 'local'\n ? (profile.local?.model || 'llama3.2')\n : (profile.cloud?.model || 'gpt-4o-mini');\n const roleLabel = profile.role ? ` · ${profile.role}` : '';\n card.innerHTML = `\n${p.description || ''}
`;\n if (!isBuiltin) {\n html += `请先在模型配置中添加配置
';\n return;\n }\n\n const selectedIds = ma.agentIds || [];\n modelProfiles.forEach((profile) => {\n const card = document.createElement('div');\n card.className = 'ma-agent-card' + (selectedIds.includes(profile.id) ? ' selected' : '');\n const typeLabel = profile.type === 'local' ? 'Ollama' : 'Cloud';\n const modelLabel = profile.type === 'local'\n ? (profile.local?.model || 'llama3.2')\n : (profile.cloud?.model || 'gpt-4o-mini');\n card.innerHTML = `\n \n