
/**
 * 由 Fantastic-admin 提供技术支持
 * Powered by Fantastic-admin
 * https://fantastic-admin.github.io
 */

import{_ as $}from"./index.vue_vue_type_script_setup_true_lang-BTce45WY.js";import{d as q,u as B,m as E,n as H,r as _,a as M,p as r,g as j,c as N,b as e,w as n,h as P,i as R,e as g,G as d,H as D,j as F,_ as G,k as x}from"./index-nGFMSQGw.js";import{a as h}from"./config-CYXO1pNF.js";import{E as K}from"./style-CY8tkffG.js";const L=g("div",{class:"flex items-center gap-4"},"用户协议设置",-1),z=g("div",{class:"text-sm/6"},[g("div",null," 用户协议设置用于配置用户端显示的用户协议页面。支持使用Markdown语法或HTML标签来创建内容，为灵活的内容格式提供便利。 ")],-1),J=q({__name:"userAgreement",setup(Q){const A=B(),a=E({isAutoOpenAgreement:"",agreementInfo:"",agreementTitle:""});H(()=>A.settings.app.colorScheme);const V=_({agreementTitle:[{required:!0,trigger:"blur",message:"请填写用户协议标题"}],agreementInfo:[{required:!0,trigger:"blur",message:"请填写用户协议具体内容"}]}),y=_();async function v(){const o=await h.queryConfig({keys:["agreementInfo","agreementTitle","isAutoOpenAgreement"]}),{agreementInfo:t,agreementTitle:i,isAutoOpenAgreement:s}=o.data;t&&Object.assign(a,{agreementInfo:t,agreementTitle:i,isAutoOpenAgreement:s})}function C(){var o;(o=y.value)==null||o.validate(async t=>{if(t){try{await h.setConfig({settings:b(a)}),d.success("变更用户协议信息成功")}catch{}v()}else d.error("请填写完整信息")})}const I=_(`/api/upload/file?dir=${encodeURIComponent("system/others")}`);function b(o){return Object.keys(o).map(t=>({configKey:t,configVal:o[t]}))}function O(o){}async function T(o,t){const i=await Promise.all(Array.from(o).map(s=>new Promise(async(p,f)=>{var m;const c=new FormData;c.append("file",s);try{const l=await D.post(I.value,c,{headers:{"Content-Type":"multipart/form-data"}});(m=l==null?void 0:l.data)!=null&&m.data||d.error("图片上传失败，请检查您的配置信息！"),p(l.data.data)}catch(l){d.error(l||"图片上传失败，请检查您的配置信息！"),f(l)}})));t(i.map(s=>s)),d({message:"图片上传成功！",type:"success"})}return M(()=>{v()}),(o,t)=>{const i=F,s=G,p=$,f=r("el-input"),c=r("el-form-item"),m=r("el-col"),l=r("el-switch"),k=r("el-tooltip"),w=r("el-row"),U=r("el-form"),S=r("el-card");return j(),N("div",null,[e(p,null,{title:n(()=>[L]),content:n(()=>[z]),default:n(()=>[e(s,{outline:"",onClick:C},{default:n(()=>[e(i,{name:"i-ri:file-text-line"}),P(" 保存设置 ")]),_:1})]),_:1}),e(S,{style:{margin:"20px"}},{default:n(()=>[e(U,{ref_key:"formRef",ref:y,rules:V.value,model:a,"label-width":"120px"},{default:n(()=>[e(w,null,{default:n(()=>[e(m,{xs:24,md:20,lg:15,xl:10},{default:n(()=>[e(c,{label:"用户协议标题",prop:"agreementTitle"},{default:n(()=>[e(f,{modelValue:a.agreementTitle,"onUpdate:modelValue":t[0]||(t[0]=u=>a.agreementTitle=u),rows:1,placeholder:"用户协议标题",clearable:""},null,8,["modelValue"])]),_:1})]),_:1}),e(m,{xs:24,md:20,lg:15,xl:10},{default:n(()=>[e(c,{label:"开启用户协议",prop:"isAutoOpenAgreement"},{default:n(()=>[e(k,{content:"开启后，用户在注册时将会弹出用户协议页面",placement:"top","show-after":500},{default:n(()=>[e(l,{modelValue:a.isAutoOpenAgreement,"onUpdate:modelValue":t[1]||(t[1]=u=>a.isAutoOpenAgreement=u),"active-value":"1","inactive-value":"0"},null,8,["modelValue"])]),_:1})]),_:1}),e(m,{xs:24,md:20,lg:15,xl:12})]),_:1})]),_:1}),e(w,null,{default:n(()=>[e(m,{span:24},{default:n(()=>[e(c,{label:"用户协议内容",prop:"agreementInfo"},{default:n(()=>[e(R(K),{modelValue:a.agreementInfo,"onUpdate:modelValue":t[2]||(t[2]=u=>a.agreementInfo=u),style:{"min-height":"80vh"},onOnChange:O,onOnUploadImg:T},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["rules","model"])]),_:1})])}}});typeof x=="function"&&x(J);export{J as default};
