Files
Document_Translator/frontend/dist/js/ProfileView-edc0fc70.js
2025-09-02 10:31:35 +08:00

2 lines
11 KiB
JavaScript

import{_ as A}from"./_plugin-vue_export-helper-af00840d.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{u as M,r as T,a as W,A as N,o as B,c as R,d as s,t as u,m as n,K as F,f as a,h as q,e as t,i as G,R as g,V as H,E as K,z as X,j as Y,l as $,s as _,Y as Z,Z as Q,$ as ee,ap as se,_ as D,W as te,X as ae,aj as le,as as oe,q as ie,at as ne,ad as de,ae as re,x as ce,y as ue,au as _e}from"./index-cb898b04.js";import{u as ve}from"./jobs-6be64b92.js";const fe={class:"profile-view"},me={class:"content-card"},pe={class:"card-body"},ge={class:"user-profile"},be={class:"avatar-section"},ye={class:"user-avatar"},he={class:"avatar-circle"},we={class:"user-basic-info"},ke={class:"user-name"},Se={class:"user-email"},Le={class:"user-details"},Te={class:"detail-row"},Ve={class:"detail-item"},Ce={class:"detail-value"},Ee={class:"detail-item"},xe={class:"detail-value"},je={class:"detail-row"},Ne={class:"detail-item"},$e={class:"detail-value"},De={class:"detail-item"},Oe={class:"detail-value"},ze={class:"content-card"},Ie={class:"card-header"},Je={class:"card-actions"},Pe={class:"card-body"},Ue={class:"stats-grid"},Ae={class:"stat-card"},Me={class:"stat-icon primary"},We={class:"stat-value"},Be={class:"stat-card"},Re={class:"stat-icon success"},Fe={class:"stat-value"},qe={class:"stat-card"},Ge={class:"stat-icon warning"},He={class:"stat-value"},Ke={class:"stat-card"},Xe={class:"stat-icon info"},Ye={class:"stat-value"},Ze={class:"content-card"},Qe={class:"card-body"},es={class:"content-card"},ss={class:"card-body"},ts={class:"quick-actions"},as={class:"content-card"},ls={class:"card-body"},os={class:"security-info"},is={class:"security-item"},ns={class:"security-icon"},ds={class:"security-item"},rs={class:"security-icon"},cs={class:"security-content"},us={class:"security-description"},_s={class:"security-item"},vs={class:"security-icon"},fs={class:"security-content"},ms={class:"security-description"},ps={__name:"ProfileView",setup(gs){G();const d=M(),h=ve(),w=T(!1),k=T(!1),S=T(!1),r=W({defaultSourceLang:"auto",defaultTargetLangs:["en"],notifications:["email"],interfaceLang:"zh-TW"}),O=N(()=>{var e;return(d.userName||((e=d.user)==null?void 0:e.username)||"U").charAt(0).toUpperCase()}),b=N(()=>{const i=h.jobs,e=i.filter(l=>l.status==="COMPLETED"),m=i.reduce((l,f)=>l+(f.total_cost||0),0),o=e.filter(l=>l.processing_started_at&&l.completed_at).map(l=>{const f=new Date(l.processing_started_at);return new Date(l.completed_at)-f});let c="無資料";if(o.length>0){const l=o.reduce((y,L)=>y+L,0)/o.length,f=Math.floor(l/6e4),p=Math.floor(l%6e4/1e3);c=`${f}${p}`}return{totalJobs:i.length,completedJobs:e.length,totalCost:m,avgProcessingTime:c}}),V=async()=>{w.value=!0;try{await h.fetchJobs({per_page:100}),g.success("統計資料已刷新")}catch(i){console.error("刷新統計失敗:",i),g.error("刷新統計失敗")}finally{w.value=!1}},z=async()=>{k.value=!0;try{localStorage.setItem("userPreferences",JSON.stringify(r)),localStorage.setItem("translation_settings",JSON.stringify({sourceLanguage:r.defaultSourceLang,targetLanguages:r.defaultTargetLangs})),g.success("設定已儲存")}catch(i){console.error("儲存設定失敗:",i),g.error("儲存設定失敗")}finally{k.value=!1}},I=()=>{Object.assign(r,{defaultSourceLang:"auto",defaultTargetLangs:["en"],notifications:["email"],interfaceLang:"zh-TW"}),g.info("設定已重置為預設值")},J=async()=>{var i;S.value=!0;try{const e={userInfo:{username:(i=d.user)==null?void 0:i.username,displayName:d.userName,email:d.userEmail,department:d.department,isAdmin:d.isAdmin},jobs:h.jobs,statistics:b.value,preferences:r,exportTime:new Date().toISOString()},m=JSON.stringify(e,null,2),o=new Blob([m],{type:"application/json"}),c=URL.createObjectURL(o),l=document.createElement("a");l.href=c,l.download=`我的翻譯資料_${new Date().toISOString().slice(0,10)}.json`,l.click(),URL.revokeObjectURL(c),g.success("資料匯出完成")}catch(e){console.error("匯出資料失敗:",e),g.error("匯出資料失敗")}finally{S.value=!1}},P=()=>{g.info("登入記錄功能開發中,敬請期待")},C=i=>{if(!i)return"未知";const e=new Date,m=new Date(i),o=e-m;return o<6e4?"剛剛":o<36e5?`${Math.floor(o/6e4)} 分鐘前`:o<864e5?`${Math.floor(o/36e5)} 小時前`:o<2592e6?`${Math.floor(o/864e5)} 天前`:m.toLocaleDateString("zh-TW",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})};return B(async()=>{try{const i=localStorage.getItem("userPreferences");i&&Object.assign(r,JSON.parse(i))}catch(i){console.error("載入偏好設定失敗:",i)}await V()}),(i,e)=>{var E,x,j;const m=H,o=K,c=X,l=de,f=re,p=ce,y=ue,L=_e,U=Y;return $(),R("div",fe,[e[34]||(e[34]=s("div",{class:"page-header"},[s("h1",{class:"page-title"},"個人設定")],-1)),s("div",me,[e[12]||(e[12]=s("div",{class:"card-header"},[s("h3",{class:"card-title"},"基本資訊")],-1)),s("div",pe,[s("div",ge,[s("div",be,[s("div",ye,[s("div",he,u(O.value),1)]),s("div",we,[s("h3",ke,u(n(d).userName),1),s("p",Se,u(n(d).userEmail),1),n(d).isAdmin?($(),F(m,{key:0,type:"warning",size:"small"},{default:a(()=>[...e[7]||(e[7]=[_(" 管理員 ",-1)])]),_:1})):q("",!0)])]),s("div",Le,[s("div",Te,[s("div",Ve,[e[8]||(e[8]=s("div",{class:"detail-label"},"AD 帳號",-1)),s("div",Ce,u((E=n(d).user)==null?void 0:E.username),1)]),s("div",Ee,[e[9]||(e[9]=s("div",{class:"detail-label"},"部門",-1)),s("div",xe,u(n(d).department||"未設定"),1)])]),s("div",je,[s("div",Ne,[e[10]||(e[10]=s("div",{class:"detail-label"},"最後登入",-1)),s("div",$e,u(C((x=n(d).user)==null?void 0:x.last_login)),1)]),s("div",De,[e[11]||(e[11]=s("div",{class:"detail-label"},"權限等級",-1)),s("div",Oe,u(n(d).isAdmin?"管理員":"一般使用者"),1)])])])])])]),s("div",ze,[s("div",Ie,[e[14]||(e[14]=s("h3",{class:"card-title"},"使用統計",-1)),s("div",Je,[t(c,{type:"text",onClick:V,loading:w.value},{default:a(()=>[t(o,null,{default:a(()=>[t(n(Z))]),_:1}),e[13]||(e[13]=_(" 刷新 ",-1))]),_:1},8,["loading"])])]),s("div",Pe,[s("div",Ue,[s("div",Ae,[s("div",Me,[t(o,null,{default:a(()=>[t(n(Q))]),_:1})]),s("div",We,u(b.value.totalJobs),1),e[15]||(e[15]=s("div",{class:"stat-label"},"總任務數",-1))]),s("div",Be,[s("div",Re,[t(o,null,{default:a(()=>[t(n(ee))]),_:1})]),s("div",Fe,u(b.value.completedJobs),1),e[16]||(e[16]=s("div",{class:"stat-label"},"已完成",-1))]),s("div",qe,[s("div",Ge,[t(o,null,{default:a(()=>[t(n(se))]),_:1})]),s("div",He,"$"+u(b.value.totalCost.toFixed(4)),1),e[17]||(e[17]=s("div",{class:"stat-label"},"總成本",-1))]),s("div",Ke,[s("div",Xe,[t(o,null,{default:a(()=>[t(n(D))]),_:1})]),s("div",Ye,u(b.value.avgProcessingTime),1),e[18]||(e[18]=s("div",{class:"stat-label"},"平均處理時間",-1))])])])]),s("div",Ze,[e[23]||(e[23]=s("div",{class:"card-header"},[s("h3",{class:"card-title"},"偏好設定")],-1)),s("div",Qe,[t(U,{model:r,"label-width":"120px",size:"default"},{default:a(()=>[t(p,{label:"預設來源語言"},{default:a(()=>[t(f,{modelValue:r.defaultSourceLang,"onUpdate:modelValue":e[0]||(e[0]=v=>r.defaultSourceLang=v),style:{width:"200px"}},{default:a(()=>[t(l,{label:"自動偵測",value:"auto"}),t(l,{label:"繁體中文",value:"zh-TW"}),t(l,{label:"簡體中文",value:"zh-CN"}),t(l,{label:"英文",value:"en"}),t(l,{label:"日文",value:"ja"}),t(l,{label:"韓文",value:"ko"}),t(l,{label:"越南文",value:"vi"})]),_:1},8,["modelValue"])]),_:1}),t(p,{label:"預設目標語言"},{default:a(()=>[t(f,{modelValue:r.defaultTargetLangs,"onUpdate:modelValue":e[1]||(e[1]=v=>r.defaultTargetLangs=v),multiple:"",style:{width:"300px"},placeholder:"請選擇常用的目標語言"},{default:a(()=>[t(l,{label:"英文",value:"en"}),t(l,{label:"越南文",value:"vi"}),t(l,{label:"繁體中文",value:"zh-TW"}),t(l,{label:"簡體中文",value:"zh-CN"}),t(l,{label:"日文",value:"ja"}),t(l,{label:"韓文",value:"ko"})]),_:1},8,["modelValue"])]),_:1}),t(p,{label:"通知設定"},{default:a(()=>[t(L,{modelValue:r.notifications,"onUpdate:modelValue":e[2]||(e[2]=v=>r.notifications=v)},{default:a(()=>[t(y,{label:"email",name:"notifications"},{default:a(()=>[...e[19]||(e[19]=[_(" 翻譯完成時發送郵件通知 ",-1)])]),_:1}),t(y,{label:"browser",name:"notifications"},{default:a(()=>[...e[20]||(e[20]=[_(" 瀏覽器桌面通知 ",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),t(p,{label:"介面語言"},{default:a(()=>[t(f,{modelValue:r.interfaceLang,"onUpdate:modelValue":e[3]||(e[3]=v=>r.interfaceLang=v),style:{width:"150px"}},{default:a(()=>[t(l,{label:"繁體中文",value:"zh-TW"}),t(l,{label:"English",value:"en"})]),_:1},8,["modelValue"])]),_:1}),t(p,null,{default:a(()=>[t(c,{type:"primary",onClick:z,loading:k.value},{default:a(()=>[...e[21]||(e[21]=[_(" 儲存設定 ",-1)])]),_:1},8,["loading"]),t(c,{onClick:I},{default:a(()=>[...e[22]||(e[22]=[_(" 重置為預設值 ",-1)])]),_:1})]),_:1})]),_:1},8,["model"])])]),s("div",es,[e[28]||(e[28]=s("div",{class:"card-header"},[s("h3",{class:"card-title"},"快速操作")],-1)),s("div",ss,[s("div",ts,[t(c,{onClick:e[4]||(e[4]=v=>i.$router.push("/upload"))},{default:a(()=>[t(o,null,{default:a(()=>[t(n(te))]),_:1}),e[24]||(e[24]=_(" 上傳新檔案 ",-1))]),_:1}),t(c,{onClick:e[5]||(e[5]=v=>i.$router.push("/jobs"))},{default:a(()=>[t(o,null,{default:a(()=>[t(n(ae))]),_:1}),e[25]||(e[25]=_(" 查看我的任務 ",-1))]),_:1}),t(c,{onClick:e[6]||(e[6]=v=>i.$router.push("/history"))},{default:a(()=>[t(o,null,{default:a(()=>[t(n(D))]),_:1}),e[26]||(e[26]=_(" 瀏覽歷史記錄 ",-1))]),_:1}),t(c,{onClick:J,loading:S.value},{default:a(()=>[t(o,null,{default:a(()=>[t(n(le))]),_:1}),e[27]||(e[27]=_(" 匯出我的資料 ",-1))]),_:1},8,["loading"])])])]),s("div",as,[e[33]||(e[33]=s("div",{class:"card-header"},[s("h3",{class:"card-title"},"帳號安全")],-1)),s("div",ls,[s("div",os,[s("div",is,[s("div",ns,[t(o,null,{default:a(()=>[t(n(oe))]),_:1})]),e[29]||(e[29]=s("div",{class:"security-content"},[s("div",{class:"security-title"},"密碼管理"),s("div",{class:"security-description"}," 本系統使用公司 AD 帳號認證,如需變更密碼請聯繫 IT 部門 ")],-1))]),s("div",ds,[s("div",rs,[t(o,null,{default:a(()=>[t(n(ie))]),_:1})]),s("div",cs,[e[31]||(e[31]=s("div",{class:"security-title"},"登入記錄",-1)),s("div",us," 最後登入時間: "+u(C((j=n(d).user)==null?void 0:j.last_login)),1),t(c,{type:"text",onClick:P},{default:a(()=>[...e[30]||(e[30]=[_(" 查看詳細記錄 ",-1)])]),_:1})])]),s("div",_s,[s("div",vs,[t(o,null,{default:a(()=>[t(n(ne))]),_:1})]),s("div",fs,[e[32]||(e[32]=s("div",{class:"security-title"},"權限說明",-1)),s("div",ms,u(n(d).isAdmin?"您擁有系統管理員權限,可以查看所有用戶的任務和系統統計":"您為一般使用者,只能查看和管理自己的翻譯任務"),1)])])])])])])}}},Vs=A(ps,[["__scopeId","data-v-d7779166"]]);export{Vs as default};