import{_ as T}from"./index-M_JNBppB.js";/* empty css                *//* empty css                     *//* empty css                       *//* empty css                  *//* empty css                 *//* empty css                        *//* empty css                   *//* empty css                  */import{d as z,s as A}from"./resource-Dz96LlGH.js";import{a as D,y as F,b as M,c as q,n as L,r as R,A as S,Q as $,f as G,R as O,q as u,p as j}from"./element-3_pOinej.js";import{r as b,c as K,B as f,z as r,O as d,F as n,D as m,M as E,a7 as h,L as P,y as p,K as i}from"./vue-BJk78QHK.js";import"./threejs-BafxXW5-.js";import"./utils-YI6ye1sf.js";import"./vxe-Dx3zSILm.js";const Q={class:"config-container"},H={class:"card-header"},J={class:"actions"},W={class:"form-wrapper"},X={class:"group-title"},Y={__name:"setting",setup(Z){const o=b({}),v=b([]);async function y(){try{const a=await z();a&&Array.isArray(a.data)?(v.value=a.data,a.data.forEach(e=>{o.value[e.field]=e.default})):u.warning("未获取到配置数据")}catch(a){console.error("加载配置失败:",a),u.error("加载配置失败")}}const V=K(()=>{const a={};return v.value.forEach(e=>{const t=e.collections||"通用配置";a[t]||(a[t]={name:t,items:[]}),a[t].items.push(e)}),Object.values(a)});function w(){j.confirm("确定要保存当前配置吗？","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{const a=[];for(const e of V.value)for(const t of e.items)a.push({_id:t._id,collections:t.collections,field:t.field,type:t.type,default:o.value[t.field],description:t.description,status:t.status});try{const e=await A({configs:a});e.code===200?u.success("配置保存成功！"):u.error(`保存失败：${e.msg}`)}catch(e){u.error("保存配置时发生错误"),console.error(e)}}).catch(()=>{u.info("取消保存")})}return y(),(a,e)=>{const t=G,k=F,g=q,U=L,B=R,c=$,x=S,I=M,C=D,N=O;return r(),f("div",Q,[d(N,{shadow:"never",class:"config-card"},{header:n(()=>[m("div",H,[e[2]||(e[2]=m("h3",null,"系统配置",-1)),m("div",J,[d(t,{onClick:y,size:"small",plain:""},{default:n(()=>e[0]||(e[0]=[i(" 刷新 ")])),_:1}),d(t,{onClick:w,type:"primary",size:"small"},{default:n(()=>e[1]||(e[1]=[i(" 保存配置 ")])),_:1})])])]),default:n(()=>[m("div",W,[d(C,{model:o.value,"label-width":"250px","label-position":"left",size:"default"},{default:n(()=>[(r(!0),f(E,null,h(V.value,_=>(r(),f("div",{key:_.name,class:"config-group"},[m("h4",X,P(_.name),1),d(k,{direction:"horizontal"}),(r(!0),f(E,null,h(_.items,l=>(r(),f("div",{key:l.field,class:"form-item-wrapper"},[d(I,{label:l.description||l.field},{default:n(()=>[l.type==="String"||l.type==="Text"?(r(),p(g,{key:0,modelValue:o.value[l.field],"onUpdate:modelValue":s=>o.value[l.field]=s,rows:l.type==="Text"?6:1,type:l.type==="Text"?"textarea":"text",placeholder:`请输入 ${l.description||l.field}`,class:"input-field"},null,8,["modelValue","onUpdate:modelValue","rows","type","placeholder"])):l.type==="Number"?(r(),p(U,{key:1,modelValue:o.value[l.field],"onUpdate:modelValue":s=>o.value[l.field]=s,modelModifiers:{number:!0},class:"input-field",min:-1/0,max:1/0,"controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])):l.type==="Boolean"?(r(),p(B,{key:2,modelValue:o.value[l.field],"onUpdate:modelValue":s=>o.value[l.field]=s,"active-text":"开启","inactive-text":"关闭","active-value":"true","inactive-value":"false"},null,8,["modelValue","onUpdate:modelValue"])):l.type==="radio"&&l.field==="ai_type"?(r(),p(x,{key:3,modelValue:o.value[l.field],"onUpdate:modelValue":s=>o.value[l.field]=s},{default:n(()=>[d(c,{value:"qiniu"},{default:n(()=>e[3]||(e[3]=[i(" 七牛云 ")])),_:1}),d(c,{label:"ali"},{default:n(()=>e[4]||(e[4]=[i(" 阿里云 ")])),_:1}),d(c,{label:"huawei"},{default:n(()=>e[5]||(e[5]=[i(" 华为云 ")])),_:1})]),_:2},1032,["modelValue","onUpdate:modelValue"])):l.type==="radio"&&l.field==="upload_type"?(r(),p(x,{key:4,modelValue:o.value[l.field],"onUpdate:modelValue":s=>o.value[l.field]=s},{default:n(()=>[d(c,{value:"qiniu"},{default:n(()=>e[6]||(e[6]=[i(" 七牛云 ")])),_:1}),d(c,{label:"server_local"},{default:n(()=>e[7]||(e[7]=[i(" 服务器本地 ")])),_:1})]),_:2},1032,["modelValue","onUpdate:modelValue"])):(r(),p(g,{key:5,modelValue:o.value[l.field],"onUpdate:modelValue":s=>o.value[l.field]=s,placeholder:`请输入 ${l.description||l.field}`,class:"input-field"},null,8,["modelValue","onUpdate:modelValue","placeholder"]))]),_:2},1032,["label"])]))),128))]))),128))]),_:1},8,["model"])])]),_:1})])}}},_e=T(Y,[["__scopeId","data-v-2b3f6623"]]);export{_e as default};
