3 lines
9.1 KiB
JavaScript
3 lines
9.1 KiB
JavaScript
import{aE as $,bs as H,bc as I,b4 as c,aA as x,ax as p,aD as l,x as K,bD as t,ah as U,be as M,ay as k,N as D,bn as v,ai as R,O as P,z as W,bk as A,r as L,aC as u,a$ as G,ac as j,az as B,at as J,aL as X,X as _,y as Y,aj as N,b2 as Z,bb as q,t as Q,S as ee,H as le,a3 as te,Z as oe,a7 as ae,R as ne,h as se}from"./index-C6ULY2Si.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{C as ie}from"./ConfigPageBase-DmCcZeia.js";/* empty css *//* empty css */import{a as O,m as me}from"./mapEdit-D6_KBS33.js";/* empty css */import"./PermissionGuard-DIZkcwyW.js";/* empty css */import"./reflection-CKXyOCM_.js";const de={class:"theme-customizer"},re={class:"tc-title-row"},ue={class:"tc-name"},pe={class:"tc-panel"},ce={class:"tc-picker-row"},fe={class:"tc-hex"},_e={class:"tc-field-hint"},be={class:"tc-actions"},ge={class:"tc-footer"},ve=$({__name:"ThemeCustomizer",setup(F){const o=H(),V=I(o.themeId),w=["#7c3aed","#8b5cf6","#c4b5fd","#5b21b6","#4c1d95","#6366f1","#a855f7","#9333ea","#1565c0","#00796b","#b71c1c","#455a64","#e65100"],S=J(()=>o.availableThemes.some(d=>C(d.id)));function C(d){const n=o.themeOverrides[d];return!!n&&Object.keys(n).length>0}function r(d){const n=o.getMergedTheme(X(d));return{background:`linear-gradient(135deg, ${n.preview} 0%, ${n.previewAccent} 100%)`}}function a(d,n,b){b&&(o.setThemeColor(d,n,b),d===o.themeId&&_.success("已应用当前主题配色"))}function f(d){o.clearThemeOverrides(d),_.info("已恢复该主题默认配色")}function i(){o.clearAllThemeOverrides(),_.info("已恢复全部主题默认配色")}return(d,n)=>{const b=j,z=W,g=P,E=D,y=L,T=Y,h=K;return c(),x("div",de,[n[6]||(n[6]=p("p",{class:"tc-hint"}," 为各主题单独调色;修改后立即预览。当前生效主题会同步应用到全站。保存系统配置时一并写入本地。 ",-1)),l(h,{modelValue:V.value,"onUpdate:modelValue":n[0]||(n[0]=e=>V.value=e),accordion:""},{default:t(()=>[(c(!0),x(U,null,M(v(o).availableThemes,e=>(c(),k(T,{key:e.id,name:e.id},{title:t(()=>[p("div",re,[p("span",{class:"tc-swatch",style:G(r(e.id))},null,4),p("span",ue,A(e.name),1),C(e.id)?(c(),k(b,{key:0,size:"small",type:"warning",effect:"plain"},{default:t(()=>[...n[1]||(n[1]=[u("已自定义",-1)])]),_:1})):B("",!0),e.id===v(o).themeId?(c(),k(b,{key:1,size:"small",type:"success",effect:"plain"},{default:t(()=>[...n[2]||(n[2]=[u("当前",-1)])]),_:1})):B("",!0)])]),default:t(()=>[p("div",pe,[l(E,{"label-width":"100px",class:"tc-form"},{default:t(()=>[(c(!0),x(U,null,M(v(R),m=>(c(),k(g,{key:m.key,label:m.label},{default:t(()=>[p("div",ce,[l(z,{"model-value":v(o).getThemeColor(e.id,m.key),"color-format":"hex",predefine:w,"onUpdate:modelValue":s=>a(e.id,m.key,s)},null,8,["model-value","onUpdate:modelValue"]),p("span",fe,A(v(o).getThemeColor(e.id,m.key)),1),p("span",_e,A(m.hint),1)])]),_:2},1032,["label"]))),128))]),_:2},1024),p("div",be,[l(y,{size:"small",onClick:m=>v(o).setThemeId(e.id)},{default:t(()=>[...n[3]||(n[3]=[u("切换到此主题",-1)])]),_:1},8,["onClick"]),l(y,{size:"small",disabled:!C(e.id),onClick:m=>f(e.id)},{default:t(()=>[...n[4]||(n[4]=[u("恢复默认",-1)])]),_:1},8,["disabled","onClick"])])])]),_:2},1032,["name"]))),128))]),_:1},8,["modelValue"]),p("div",ge,[l(y,{size:"small",type:"warning",plain:"",disabled:!S.value,onClick:i},{default:t(()=>[...n[5]||(n[5]=[u(" 重置全部主题配色 ",-1)])]),_:1},8,["disabled"])])])}}}),Ve=N(ve,[["__scopeId","data-v-8a725bd2"]]),ye=$({__name:"SystemConfigView",setup(F){const o=q({endpoint:"https://api.openai.com/v1/chat/completions",apiKey:"",model:"gpt-4o-mini",systemPrompt:"你是一个 AGV 路网设计师。",temperature:.4,maxTokens:4096,timeoutSec:60,configured:!1}),V=I(!1),w=I(!1);Z(async()=>{try{const r=await O.get();Object.assign(o,r)}catch(r){_.warning(`无法读取 AI 配置:${r.message}`)}});async function S(){try{V.value=!0,await O.save({...o}),_.success("AI 配置已保存"),o.configured=!!o.apiKey}catch(r){_.error(`保存失败:${r.message}`)}finally{V.value=!1}}async function C(){try{w.value=!0;const r=await me.aiMapGenerate({prompt:'测试连通:仅返回 "ok",不要生成任何站点或路径。',mode:"sites",bounds:[0,0,0,0]});_.success(`AI 服务连通正常:返回工具调用 ${r.usedTools} 次`)}catch(r){_.error(`连通失败:${r.message}`)}finally{w.value=!1}}return(r,a)=>{const f=ee,i=P,d=le,n=oe,b=te,z=ae,g=ne,E=D,y=j,T=L,h=Q;return c(),x(U,null,[l(ie,{section:"system",title:"系统级配置",description:"运行参数、日志策略、安全策略(对齐 SystemConfig)",defaults:v(se)},{default:t(({payload:e,update:m})=>[l(E,{"label-width":"160px",model:e},{default:t(()=>[l(i,{label:"调度循环 (Hz)"},{default:t(()=>[l(f,{"model-value":e.dispatchLoopHz,min:1,max:200,"onUpdate:modelValue":s=>m({...e,dispatchLoopHz:s??0})},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(d,{"content-position":"left"},{default:t(()=>[...a[7]||(a[7]=[u("日志策略",-1)])]),_:1}),l(i,{label:"日志级别"},{default:t(()=>[l(b,{"model-value":e.log.level,"onUpdate:modelValue":s=>m({...e,log:{...e.log,level:s}})},{default:t(()=>[(c(),x(U,null,M(["trace","debug","info","warn","error"],s=>l(n,{key:s,label:s,value:s},null,8,["label","value"])),64))]),_:1},8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(i,{label:"日志保留 (天)"},{default:t(()=>[l(f,{"model-value":e.log.rollDays,min:1,max:365,"onUpdate:modelValue":s=>m({...e,log:{...e.log,rollDays:s??0}})},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(i,{label:"单文件上限 (MB)"},{default:t(()=>[l(f,{"model-value":e.log.maxSizeMB,min:1,max:4096,"onUpdate:modelValue":s=>m({...e,log:{...e.log,maxSizeMB:s??0}})},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(d,{"content-position":"left"},{default:t(()=>[...a[8]||(a[8]=[u("安全策略",-1)])]),_:1}),l(i,{label:"JWT 过期 (分钟)"},{default:t(()=>[l(f,{"model-value":e.security.jwtExpireMin,min:5,max:43200,"onUpdate:modelValue":s=>m({...e,security:{...e.security,jwtExpireMin:s??0}})},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(i,{label:"启用 Swagger"},{default:t(()=>[l(z,{"model-value":e.security.enableSwagger,"onUpdate:modelValue":s=>m({...e,security:{...e.security,enableSwagger:!!s}})},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(i,{label:"CORS 白名单"},{default:t(()=>[l(g,{type:"textarea",rows:3,"model-value":e.security.corsWhitelist.join(`
|
||
`),"onUpdate:modelValue":s=>m({...e,security:{...e.security,corsWhitelist:s.split(/\s+/).filter(Boolean)}})},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024),l(d,{"content-position":"left"},{default:t(()=>[...a[9]||(a[9]=[u("界面主题配色",-1)])]),_:1}),l(i,{label:"主题取色盘"},{default:t(()=>[l(Ve)]),_:1})]),_:2},1032,["model"])]),_:1},8,["defaults"]),l(h,{class:"ai-service-card",shadow:"never"},{header:t(()=>[a[12]||(a[12]=p("span",null,"AI 服务(地图编辑器「AI 生图」依赖)",-1)),o.configured?(c(),k(y,{key:0,type:"success",size:"small",effect:"dark",class:"ml-8"},{default:t(()=>[...a[10]||(a[10]=[u("已配置",-1)])]),_:1})):(c(),k(y,{key:1,type:"warning",size:"small",effect:"dark",class:"ml-8"},{default:t(()=>[...a[11]||(a[11]=[u("未配置",-1)])]),_:1}))]),default:t(()=>[l(E,{"label-width":"140px",size:"default"},{default:t(()=>[l(i,{label:"Endpoint"},{default:t(()=>[l(g,{modelValue:o.endpoint,"onUpdate:modelValue":a[0]||(a[0]=e=>o.endpoint=e),placeholder:"https://api.openai.com/v1/chat/completions"},null,8,["modelValue"])]),_:1}),l(i,{label:"API Key"},{default:t(()=>[l(g,{modelValue:o.apiKey,"onUpdate:modelValue":a[1]||(a[1]=e=>o.apiKey=e),type:"password","show-password":"",placeholder:"sk-..."},null,8,["modelValue"])]),_:1}),l(i,{label:"模型"},{default:t(()=>[l(g,{modelValue:o.model,"onUpdate:modelValue":a[2]||(a[2]=e=>o.model=e),placeholder:"gpt-4o-mini"},null,8,["modelValue"])]),_:1}),l(i,{label:"System Prompt"},{default:t(()=>[l(g,{modelValue:o.systemPrompt,"onUpdate:modelValue":a[3]||(a[3]=e=>o.systemPrompt=e),type:"textarea",rows:4},null,8,["modelValue"])]),_:1}),l(i,{label:"Temperature"},{default:t(()=>[l(f,{modelValue:o.temperature,"onUpdate:modelValue":a[4]||(a[4]=e=>o.temperature=e),min:0,max:2,step:.1},null,8,["modelValue"])]),_:1}),l(i,{label:"Max Tokens"},{default:t(()=>[l(f,{modelValue:o.maxTokens,"onUpdate:modelValue":a[5]||(a[5]=e=>o.maxTokens=e),min:64,max:32e3,step:64},null,8,["modelValue"])]),_:1}),l(i,{label:"超时 (秒)"},{default:t(()=>[l(f,{modelValue:o.timeoutSec,"onUpdate:modelValue":a[6]||(a[6]=e=>o.timeoutSec=e),min:5,max:600},null,8,["modelValue"])]),_:1}),l(i,null,{default:t(()=>[l(T,{type:"primary",loading:V.value,onClick:S},{default:t(()=>[...a[13]||(a[13]=[u("保存 AI 配置",-1)])]),_:1},8,["loading"]),l(T,{loading:w.value,onClick:C},{default:t(()=>[...a[14]||(a[14]=[u("测试连通",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1})],64)}}}),Fe=N(ye,[["__scopeId","data-v-b66101c5"]]);export{Fe as default};
|