- Reorganize project structure with new electron and shared directories - Add comprehensive i18n support with Chinese, English, and Japanese locales - Update build configurations and TypeScript paths for new structure - Add various UI components including chat interface and task management - Include Windows release binaries and localization files - Update dependencies and fix import paths throughout the codebase
2 lines
6.6 KiB
JavaScript
2 lines
6.6 KiB
JavaScript
import{d as A,S as V,g as P,a as C,b,r as M,s as D,i as O,c as T,u as q,e as G,o as N,f as j,h as r,w as u,j as s,t as m,k as l,l as B,m as I,n as _,p as R,q as Y,v as K,x as F,C as J,y as k,_ as $}from"./index-Vy2R4VLt.js";import{a as W,u as H}from"./user_icon-6eIKPQ4y.js";import{i as Q}from"./request-D0YE0rr6.js";const X=""+new URL("logo-CJssmIYf.png",import.meta.url).href;function Z({body:e,options:t}){return Q("/auth/oauth2/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:e,...t||{}})}const ee=A("userInfo",{state:()=>({token:V.get("token")}),actions:{async login(e){return e.grant_type="password",e.scope="server",new Promise((t,o)=>{Z({body:{clientId:"",...e},options:{headers:{isToken:!0,"Content-Type":"application/x-www-form-urlencoded",Authorization:"Basic Y3VzdG9tUEM6Y3VzdG9tUEM="}}}).then(a=>{V.set("token",a.access_token),V.set("refresh_token",a.refresh_token),t(a)}).catch(a=>{o(a)})})},logOut(){return new Promise((e,t)=>{})}}});function te(){if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const o=a=>{const g=Number(a);return(g^crypto.getRandomValues(new Uint8Array(1))[0]&15>>g/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o)}}let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let a=Math.random()*16;return e>0?(a=(e+a)%16|0,e=Math.floor(e/16)):(a=(t+a)%16|0,t=Math.floor(t/16)),(o==="x"?a:a&3|8).toString(16)})}const z="diona-language",ae=A("locale",{state:()=>({language:"zh",initialized:!1}),getters:{currentLanguage:e=>e.language,isChinese:e=>e.language==="zh",isEnglish:e=>e.language==="en",isJapanese:e=>e.language==="ja",languageLabel:e=>T.find(o=>o.code===e.language)?.label||"中文"},actions:{async init(){if(!this.initialized)try{const e=localStorage.getItem(z);let t="zh";e&&b.includes(e)?t=e:t=C(),await this.setLanguage(t,!1),this.initialized=!0}catch(e){console.error("Failed to initialize locale store:",e),await this.setLanguage("zh",!1),this.initialized=!0}},async setLanguage(e,t=!0){const o=M(e);if(o!==this.language)try{await D(o,O),this.language=o,t&&localStorage.setItem(z,o),window.dispatchEvent(new CustomEvent("language-changed",{detail:{language:o}}))}catch(a){throw console.error("Failed to set language:",a),a}},async toggleLanguage(){const t=(b.indexOf(this.language)+1)%b.length,o=b[t];await this.setLanguage(o)},async resetToSystemLanguage(){const e=C();await this.setLanguage(e)},syncWithI18n(){const e=P();e!==this.language&&(this.language=e)}}});function oe(){const{t:e,te:t,tm:o,rt:a,d:g,n:L,...d}=q(),i=ae(),f=(c,E)=>e(c,E),v=c=>t(c),y=async c=>{await i.setLanguage(c)},w=async()=>{await i.toggleLanguage()},p=async()=>{await i.resetToSystemLanguage()},n=()=>i.currentLanguage,S=()=>i.languageLabel,U=()=>T,x=async()=>{await i.init()};return{t:f,te:v,tm:d.tm,rt:d.rt,d:d.d,n:d.n,switchLanguage:y,toggleLanguage:w,resetToSystemLanguage:p,currentLanguage:n,currentLanguageLabel:S,supportedLanguages:U,initLocale:x,...d,localeStore:i}}const ne={VITE_SERVICE_URL:"http://8.138.234.141/ingress"},se={class:"h-screen login-bg flex flex-col"},re={class:"box-border p-[8px] flex-auto flex"},le={class:"w-[836px] box-border bg-white rounded-2xl p-[32px] flex flex-col"},ie={class:"flex flex-col items-center justify-center mb-[24px] box-border pt-[40px]"},ce={class:"text-[24px] font-500 text-gray-800 line-height-[32px] mb-[4px]"},ue={class:"text-[16px] text-gray-500 line-height-[24px]"},ge={class:"text-[14px] text-gray-600"},de={class:"text-[14px] text-gray-600"},pe={class:"text-[14px] text-gray-600"},me=["src"],fe=["loading"],xe=G({__name:"index",setup(e){const{t}=oe(),o=ee(),a=R({username:"",password:"",randomStr:"",code:"",grant_type:"",scope:""}),g=I(!1),L=I(""),d=R({username:[{validator:k.overLength,trigger:"blur"},{required:!0,trigger:"blur",message:()=>t("login.usernameRequired")}],password:[{validator:k.overLength,trigger:"blur"},{required:!0,trigger:"blur",message:()=>t("login.passwordRequired")}],code:[{validator:k.overLength,trigger:"blur"},{required:!0,trigger:"blur",message:()=>t("login.codeRequired")}]}),{VITE_SERVICE_URL:i}=ne,f=async()=>{a.randomStr=te();const p=`${i}/auth/code/image?randomStr=${a.randomStr}`;console.log("验证码地址",p),L.value=p};N(()=>f());const v=Y(),y=I(),w=async()=>{if(!await y.value.validate().catch(()=>{}))return!1;g.value=!0;try{o.login(a).then(()=>{v.push({path:"/home"})})}finally{f(),g.value=!1}};return(p,n)=>{const S=_("drag-region"),U=_("header-bar"),x=_("el-input"),c=_("el-form-item"),E=_("el-form");return K(),j("div",se,[r(U,{color:"#fff"},{default:u(()=>[r(S,{class:"w-full"})]),_:1}),s("main",re,[s("div",le,[n[4]||(n[4]=s("div",{class:"flex items-center"},[s("img",{class:"w-[48px] h-[48px]",src:W})],-1)),s("div",ie,[n[3]||(n[3]=s("img",{class:"w-[80px] h-[80px] mb-[12px]",src:H},null,-1)),s("div",ce,m(l(t)("login.title")),1),s("div",ue,m(l(t)("login.subtitle")),1)]),r(E,{class:"w-[392px] ml-auto mr-auto",ref_key:"formRef",ref:y,rules:d,model:a,"label-position":"top",onKeyup:B(w,["enter"])},{default:u(()=>[r(c,{prop:"username"},{default:u(()=>[s("div",ge,m(l(t)("login.username")),1),r(x,{class:"h-[40px]",modelValue:a.username,"onUpdate:modelValue":n[0]||(n[0]=h=>a.username=h),modelModifiers:{trim:!0},placeholder:l(t)("login.usernamePlaceholder"),clearable:"",autocomplete:"off"},{prefix:u(()=>[r(l(F),{size:"20px",color:"#99A0AE"})]),_:1},8,["modelValue","placeholder"])]),_:1}),r(c,{prop:"password"},{default:u(()=>[s("div",de,m(l(t)("login.password")),1),r(x,{class:"h-[40px]",modelValue:a.password,"onUpdate:modelValue":n[1]||(n[1]=h=>a.password=h),modelModifiers:{trim:!0},type:"password",placeholder:l(t)("login.passwordPlaceholder"),clearable:"",autocomplete:"off"},{prefix:u(()=>[r(l(J),{size:"20px",color:"#99A0AE"})]),_:1},8,["modelValue","placeholder"])]),_:1}),r(c,{prop:"code"},{default:u(()=>[s("span",pe,m(l(t)("login.code")),1),r(x,{modelValue:a.code,"onUpdate:modelValue":n[2]||(n[2]=h=>a.code=h),modelModifiers:{trim:!0},placeholder:l(t)("login.codePlaceholder"),autocomplete:"off"},{suffix:u(()=>[s("img",{class:"w-[80px] h-[38px] cursor-pointer",src:L.value,onClick:f},null,8,me)]),_:1},8,["modelValue","placeholder"])]),_:1}),s("button",{type:"button",class:"w-full py-2 bg-blue-600 cursor-pointer text-white rounded-[8px] hover:bg-blue-700 disabled:bg-blue-300",loading:g.value,onClick:w},m(l(t)("login.loginButton")),9,fe)]),_:1},8,["rules","model"])]),n[5]||(n[5]=s("img",{class:"w-[540px]",src:X},null,-1))])])}}}),we=$(xe,[["__scopeId","data-v-302a5eb6"]]);export{we as default};
|