mirror of
https://github.com/vastxie/99AI.git
synced 2025-09-20 02:26:39 +08:00
2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
import{_ as y}from"./index.vue_vue_type_script_setup_true_lang-f425914e.js";import{e as j,a as L,Y as E,t as C}from"./index-d64a7cc4.js";import{u as G}from"./useBasicLayout-a4f17bae.js";import{e as R,K as B,z as x,a1 as Y,M as H,w as X,Y as q,X as z,q as K}from"./naive-ui-fedd20b1.js";import{d as N,e as I,r as w,S,U as D,a3 as e,a4 as o,X as a,M as s,W as l,c as g,a8 as W,F as Q,a6 as Z,f as ee,V as T}from"./vue-10b4afc0.js";import"./vueuse-motion-d4cdaf7b.js";function se(){const m=new Date,c=m.getDate(),d=m.getMonth()+1;return`${m.getFullYear()}-${d}-${c}`}const te={class:"p-4 space-y-5 min-h-[200px]"},ae={class:"space-y-6"},ne={class:"flex items-center space-x-4"},oe={class:"flex-shrink-0 w-[100px]"},le={class:"flex-1"},ie={class:"flex items-center space-x-4"},ce={class:"flex-shrink-0 w-[100px]"},re={class:"w-[200px]"},de={class:"flex-shrink-0 w-[100px]"},ue={class:"flex flex-wrap items-center gap-4"},pe={class:"flex items-center space-x-4"},fe={class:"flex-shrink-0 w-[100px]"},me={class:"flex flex-wrap items-center gap-4"},_e={class:"flex items-center space-x-4"},he={class:"flex-shrink-0 w-[100px]"},ve={class:"flex flex-wrap items-center gap-4"},xe=N({__name:"General",setup(m){const c=j(),d=L(),{isMobile:u}=G(),r=R(),h=I(()=>c.theme),p=I(()=>d.userInfo),f=w(p.value.avatar??""),_=w(p.value.username??""),$=w(!1),M=I({get(){return c.language},set(t){c.setLanguage(t)}}),O=[{label:"Auto",key:"auto",icon:"ri:contrast-line"},{label:"Light",key:"light",icon:"ri:sun-foggy-line"},{label:"Dark",key:"dark",icon:"ri:moon-foggy-line"}],F=[{label:"简体中文",key:"zh-CN",value:"zh-CN"}];async function U(t){try{$.value=!0;const n=await E(t);if($.value=!1,!n.success)return r.error(n.message);r.success(C("common.updateUserSuccess")),d.getUserInfo()}catch{$.value=!1}}function A(){const t=se(),n=localStorage.getItem("chatStorage")||"{}",i=JSON.stringify(JSON.parse(n),null,2),v=new Blob([i],{type:"application/json"}),b=URL.createObjectURL(v),k=document.createElement("a");k.href=b,k.download=`chat-store_${t}.json`,document.body.appendChild(k),k.click(),document.body.removeChild(k)}function J(t){const n=t.target;if(!n||!n.files)return;const i=n.files[0];if(!i)return;const v=new FileReader;v.onload=()=>{try{const b=JSON.parse(v.result);localStorage.setItem("chatStorage",JSON.stringify(b)),r.success(C("common.success")),location.reload()}catch{r.error(C("common.invalidFileFormat"))}},v.readAsText(i)}function P(){localStorage.removeItem("chatStorage"),location.reload()}function V(){const t=document.getElementById("fileInput");t&&t.click()}return(t,n)=>(S(),D("div",te,[e("div",ae,[e("div",ne,[e("span",oe,o(t.$t("setting.avatarLink")),1),e("div",le,[a(s(B),{value:f.value,"onUpdate:value":n[0]||(n[0]=i=>f.value=i),placeholder:"请填写头像地址"},null,8,["value"])]),a(s(x),{size:"tiny",disabled:$.value,text:"",type:"primary",onClick:n[1]||(n[1]=i=>U({avatar:f.value}))},{default:l(()=>[g(o(t.$t("common.update")),1)]),_:1},8,["disabled"])]),e("div",ie,[e("span",ce,o(t.$t("setting.name")),1),e("div",re,[a(s(B),{value:_.value,"onUpdate:value":n[2]||(n[2]=i=>_.value=i),placeholder:"请填写用户名"},null,8,["value"])]),a(s(x),{size:"tiny",disabled:$.value,text:"",type:"primary",onClick:n[3]||(n[3]=i=>U({username:_.value}))},{default:l(()=>[g(o(t.$t("common.update")),1)]),_:1},8,["disabled"])]),e("div",{class:W(["flex items-center space-x-4",s(u)&&"items-start"])},[e("span",de,o(t.$t("setting.chatHistory")),1),e("div",ue,[a(s(x),{size:"small",onClick:A},{icon:l(()=>[a(s(y),{icon:"ri:download-2-fill"})]),default:l(()=>[g(" "+o(t.$t("common.export")),1)]),_:1}),e("input",{id:"fileInput",type:"file",style:{display:"none"},onChange:J},null,32),a(s(x),{size:"small",onClick:V},{icon:l(()=>[a(s(y),{icon:"ri:upload-2-fill"})]),default:l(()=>[g(" "+o(t.$t("common.import")),1)]),_:1}),a(s(Y),{placement:"bottom",onPositiveClick:P},{trigger:l(()=>[a(s(x),{size:"small"},{icon:l(()=>[a(s(y),{icon:"ri:close-circle-line"})]),default:l(()=>[g(" "+o(t.$t("common.clear")),1)]),_:1})]),default:l(()=>[g(" "+o(t.$t("chat.clearHistoryConfirm")),1)]),_:1})])],2),e("div",pe,[e("span",fe,o(t.$t("setting.theme")),1),e("div",me,[(S(),D(Q,null,Z(O,i=>a(s(x),{key:i.key,size:"small",type:i.key===h.value?"primary":void 0,onClick:v=>s(c).setTheme(i.key)},{icon:l(()=>[a(s(y),{icon:i.icon},null,8,["icon"])]),_:2},1032,["type","onClick"])),64))])]),e("div",_e,[e("span",he,o(t.$t("setting.language")),1),e("div",ve,[a(s(H),{style:{width:"140px"},value:M.value,options:F,onUpdateValue:n[4]||(n[4]=i=>s(c).setLanguage(i))},null,8,["value"])])])])]))}}),ge={class:"p-4 space-y-5 min-h-[200px]"},ye={class:"flex items-center space-x-4"},$e=e("span",{class:"flex-shrink-0 w-[100px]"},"用户邮箱",-1),ke={class:"w-[200px]"},we={class:"flex items-center space-x-4"},be=e("span",{class:"flex-shrink-0 w-[100px]"},"用户姓名",-1),Ie={class:"w-[200px]"},Se={class:"flex items-center space-x-4"},Ce=e("span",{class:"flex-shrink-0 w-[100px]"},"问答余额",-1),Ne={class:"w-[200px]"},Ue={class:"flex items-center space-x-4"},Be=e("span",{class:"flex-shrink-0 w-[100px]"},"绘画余额",-1),ze={class:"w-[200px]"},De={class:"flex items-center space-x-4"},Le=e("span",{class:"flex-shrink-0 w-[100px]"},"MJToken",-1),Te={class:"w-[200px]"},Me={class:"flex items-center space-x-4"},Oe=e("span",{class:"flex-shrink-0 w-[100px]"},"使用金额",-1),Fe={class:"w-[200px]"},Ae=N({__name:"Personal",setup(m){const c=L(),{userInfo:d,userBalance:u}=c,r=w(!1);ee(async()=>{h()});async function h(){try{r.value=!0,await c.getUserInfo(),r.value=!1}catch{r.value=!1}}return(p,f)=>(S(),T(s(X),{show:r.value},{default:l(()=>[e("div",ge,[e("div",ye,[$e,e("div",ke,o(s(d).email||"--"),1)]),e("div",we,[be,e("div",Ie,o(s(d).username||"--"),1)]),e("div",Se,[Ce,e("div",Ne,o(s(u).usesLeft||"0")+" 积分 ",1)]),e("div",Ue,[Be,e("div",ze,o(s(u).paintCount||"0")+" 积分 ",1)]),e("div",De,[Le,e("div",Te,o(s(u).balance||"0")+" Token ",1)]),e("div",Me,[Oe,e("div",Fe,o(s(u).useTokens||"0")+" Token ",1)])])]),_:1},8,["show"]))}}),Je={class:"ml-2"},Pe={class:"ml-2"},Ve={class:"min-h-[100px]"},Xe=N({__name:"index",props:{visible:{type:Boolean}},emits:["update:visible"],setup(m,{emit:c}){const d=m,u=c,r=w("personalInfo"),h=I({get(){return d.visible},set(p){u("update:visible",p)}});return(p,f)=>(S(),T(s(K),{show:h.value,"onUpdate:show":f[1]||(f[1]=_=>h.value=_),title:"个人中心","auto-focus":!1,preset:"card",style:{width:"95%","max-width":"640px"}},{default:l(()=>[e("div",null,[a(s(q),{value:r.value,"onUpdate:value":f[0]||(f[0]=_=>r.value=_),type:"line",animated:""},{default:l(()=>[a(s(z),{name:"personalInfo",tab:"personalInfo"},{tab:l(()=>[a(s(y),{class:"text-lg",icon:"ri:file-user-line"}),e("span",Je,o(p.$t("setting.personalInfo")),1)]),default:l(()=>[a(Ae)]),_:1}),a(s(z),{name:"General",tab:"General"},{tab:l(()=>[a(s(y),{class:"text-lg",icon:"ri:list-settings-line"}),e("span",Pe,o(p.$t("setting.general")),1)]),default:l(()=>[e("div",Ve,[a(xe)])]),_:1})]),_:1},8,["value"])])]),_:1},8,["show"]))}});export{Xe as default};
|