99AI/AIWebQuickDeploy/public/admin/assets/baseConfiguration-XpujmNvx.js
2025-03-04 17:36:53 +08:00

9 lines
8.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 由 Fantastic-admin 提供技术支持
* Powered by Fantastic-admin
* https://fantastic-admin.github.io
*/
import{_ as W}from"./index.vue_vue_type_script_setup_true_lang-BhIKqf2a.js";import{d as Q,m as X,r as F,a as Y,p,g as s,c as v,b as e,w as a,h as Z,z as _,i as g,B as V,C as P,A as U,e as I,G as k,j as ee,_ as ae,H as R,k as S}from"./index-6QRvoxq4.js";import{a as B}from"./config-DBls5jtO.js";const te=I("div",{class:"flex items-center gap-4"},"网站基础配置",-1),le=I("div",{class:"text-sm/6"},[I("div",null," 网站基础配置支持即时更新网站的主要视觉与功能元素。配置内容包括网站名称、备案号、版权信息、LOGO与ICO、默认AI头像与用户头像以及首页设置等。 "),I("div",null,"请认真填写各项配置,确保提供给用户的信息准确无误。")],-1),oe=["src"],ne=["src"],se=["src"],re=["src"],ie=Q({__name:"baseConfiguration",setup(ce){const t=X({siteName:"",robotAvatar:"",userDefautlAvatar:"",filingNumber:"",companyName:"",buyCramiAddress:"",siteUrl:"",isShowAppCatIcon:"",clientFavoIconPath:"",clientLogoPath:""}),G=F({siteName:[{required:!0,trigger:"blur",message:"请填写网站名称"}]}),N=F(),h=F(`/api/upload/file?dir=${encodeURIComponent("system/others")}`);async function L(){const l=await B.queryConfig({keys:["siteName","robotAvatar","userDefautlAvatar","filingNumber","companyName","isShowAppCatIcon","clientLogoPath","clientFavoIconPath","siteUrl"]});Object.assign(t,l.data)}function T(){var l;(l=N.value)==null||l.validate(async o=>{if(o){try{await B.setConfig({settings:K(t)}),k.success("变更配置信息成功")}catch{}L()}else k.error("请填写完整信息")})}async function b(l){const o=await R.get(l,{responseType:"blob"});let r="downloaded_file";const i=o.headers["content-disposition"];if(i){const y=/filename="([^"]+)"/.exec(i);y!=null&&y[1]&&(r=y[1])}else r=$(l);return new File([o.data],r,{type:o.data.type})}function $(l){const r=new URL(l).pathname;return r.substring(r.lastIndexOf("/")+1)}function x(l,o){const r=new FormData;r.append("file",l),R.post(h.value,r,{headers:{"Content-Type":"multipart/form-data"}}).then(i=>{o(i.data)}).catch(i=>{console.error("上传失败",i)})}const C=(l,o)=>{console.log("response: ",l.data),t.clientLogoPath=l.data};async function q(){if(t.clientLogoPath){const l=await b(t.clientLogoPath);x(l,C)}}async function E(){if(t.clientFavoIconPath){const l=await b(t.clientFavoIconPath);x(l,D)}}async function H(){if(t.robotAvatar){const l=await b(t.robotAvatar);x(l,j)}}async function z(){if(t.userDefautlAvatar){const l=await b(t.userDefautlAvatar);x(l,O)}}const D=(l,o)=>{console.log("response: ",l.data),t.clientFavoIconPath=l.data},j=(l,o)=>{console.log("response: ",l.data),t.robotAvatar=l.data},O=(l,o)=>{console.log("response: ",l.data),t.userDefautlAvatar=l.data},w=l=>{if(["image/png","image/jpeg","image/gif","image/webp"].includes(l.type)){if(l.size/1024>300)return k.error("当前限制文件最大不超过 300KB!"),!1}else return k.error("当前系统仅支持 PNG、JPEG、GIF、和 WebP 格式的图片!"),!1};function K(l){return Object.keys(l).map(o=>({configKey:o,configVal:l[o]}))}return Y(()=>{L()}),(l,o)=>{const r=ee,i=ae,y=W,c=p("el-input"),u=p("el-form-item"),d=p("el-col"),f=p("el-row"),m=p("el-icon"),A=p("el-upload"),M=p("el-form"),J=p("el-card");return s(),v("div",null,[e(y,null,{title:a(()=>[te]),content:a(()=>[le]),default:a(()=>[e(i,{outline:"",onClick:T},{default:a(()=>[e(r,{name:"i-ri:file-text-line"}),Z(" 保存设置 ")]),_:1})]),_:1}),e(J,{style:{margin:"20px"}},{default:a(()=>[e(M,{ref_key:"formRef",ref:N,rules:G.value,model:t,"label-width":"150px"},{default:a(()=>[e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"网站名称",prop:"siteName"},{default:a(()=>[e(c,{modelValue:t.siteName,"onUpdate:modelValue":o[0]||(o[0]=n=>t.siteName=n),placeholder:"网站名称",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"网站地址",prop:"siteUrl"},{default:a(()=>[e(c,{modelValue:t.siteUrl,"onUpdate:modelValue":o[1]||(o[1]=n=>t.siteUrl=n),placeholder:"网站地址",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"公司/组织名称",prop:"companyName"},{default:a(()=>[e(c,{modelValue:t.companyName,"onUpdate:modelValue":o[2]||(o[2]=n=>t.companyName=n),placeholder:"填入具体的公司或组织名称",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"网站备案号",prop:"filingNumber"},{default:a(()=>[e(c,{modelValue:t.filingNumber,"onUpdate:modelValue":o[3]||(o[3]=n=>t.filingNumber=n),placeholder:"填写网站备案信息的备案号",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"用户端LOGO",prop:"clientLogoPath"},{default:a(()=>[e(c,{modelValue:t.clientLogoPath,"onUpdate:modelValue":o[4]||(o[4]=n=>t.clientLogoPath=n),placeholder:"请填写或上传网站 LOGO 图片 URL",clearable:""},{append:a(()=>[e(A,{class:"avatar-uploader",action:h.value,"show-file-list":!1,"on-success":C,"before-upload":w,style:{display:"flex","align-items":"center","justify-content":"center"}},{default:a(()=>[t.clientLogoPath?(s(),v("img",{key:0,src:t.clientLogoPath,style:{"max-width":"1.5rem","max-height":"1.5rem",margin:"5px 0","object-fit":"contain"}},null,8,oe)):(s(),_(m,{key:1,style:{width:"1rem"}},{default:a(()=>[e(g(V))]),_:1}))]),_:1},8,["action"]),t.clientLogoPath?(s(),_(m,{key:0,onClick:q,style:{"margin-left":"35px",width:"1rem"}},{default:a(()=>[e(g(P))]),_:1})):U("",!0)]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"网站 ico",prop:"clientFavoIconPath"},{default:a(()=>[e(c,{modelValue:t.clientFavoIconPath,"onUpdate:modelValue":o[5]||(o[5]=n=>t.clientFavoIconPath=n),placeholder:"请填写或上传网站 ico URL",clearable:""},{append:a(()=>[e(A,{class:"avatar-uploader",action:h.value,"show-file-list":!1,"on-success":D,"before-upload":w,style:{display:"flex","align-items":"center","justify-content":"center"}},{default:a(()=>[t.clientFavoIconPath?(s(),v("img",{key:0,src:t.clientFavoIconPath,style:{"max-width":"1.5rem","max-height":"1.5rem",margin:"5px 0","object-fit":"contain"}},null,8,ne)):(s(),_(m,{key:1,style:{width:"1rem"}},{default:a(()=>[e(g(V))]),_:1}))]),_:1},8,["action"]),t.clientFavoIconPath?(s(),_(m,{key:0,onClick:E,style:{"margin-left":"35px",width:"1rem"}},{default:a(()=>[e(g(P))]),_:1})):U("",!0)]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"AI头像",prop:"robotAvatar"},{default:a(()=>[e(c,{modelValue:t.robotAvatar,"onUpdate:modelValue":o[6]||(o[6]=n=>t.robotAvatar=n),placeholder:"请填写或上传网站 AI 头像 URL、为空将根据模型自动显示",clearable:""},{append:a(()=>[e(A,{class:"avatar-uploader",action:h.value,"show-file-list":!1,"on-success":j,"before-upload":w,style:{display:"flex","align-items":"center","justify-content":"center"}},{default:a(()=>[t.robotAvatar?(s(),v("img",{key:0,src:t.robotAvatar,style:{"max-width":"1.5rem","max-height":"1.5rem",margin:"5px 0","object-fit":"contain"}},null,8,se)):(s(),_(m,{key:1,style:{width:"1rem"}},{default:a(()=>[e(g(V))]),_:1}))]),_:1},8,["action"]),t.robotAvatar?(s(),_(m,{key:0,onClick:H,style:{"margin-left":"35px",width:"1rem"}},{default:a(()=>[e(g(P))]),_:1})):U("",!0)]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(d,{xs:24,md:20,lg:15,xl:12},{default:a(()=>[e(u,{label:"用户默认头像",prop:"userDefautlAvatar"},{default:a(()=>[e(c,{modelValue:t.userDefautlAvatar,"onUpdate:modelValue":o[7]||(o[7]=n=>t.userDefautlAvatar=n),placeholder:"请填写或上传网站新用户默认的头像 URL",clearable:""},{append:a(()=>[e(A,{class:"avatar-uploader",action:h.value,"show-file-list":!1,"on-success":O,"before-upload":w,style:{display:"flex","align-items":"center","justify-content":"center"}},{default:a(()=>[t.userDefautlAvatar?(s(),v("img",{key:0,src:t.userDefautlAvatar,style:{"max-width":"1.5rem","max-height":"1.5rem",margin:"5px 0","object-fit":"contain"}},null,8,re)):(s(),_(m,{key:1,style:{width:"1rem"}},{default:a(()=>[e(g(V))]),_:1}))]),_:1},8,["action"]),t.userDefautlAvatar?(s(),_(m,{key:0,onClick:z,style:{"margin-left":"35px",width:"1rem"}},{default:a(()=>[e(g(P))]),_:1})):U("",!0)]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["rules","model"])]),_:1})])}}});typeof S=="function"&&S(ie);export{ie as default};