mirror of
https://github.com/KarolChang/jm-expense-vue-ts.git
synced 2024-12-26 03:38:35 +00:00
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
var ne=Object.defineProperty;var ae=(e,t,o)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var w=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);import{S as X,a as Y,d as ie,o as i,c as u,b as le,e as ue,f as x,u as I,i as Z,g as ce,r as ee,h as s,j as y,w as h,F as E,k as q,t as $,l as O,n as J,m as v,p as L,q as N,s as de,v as B,x as A,y as D,z as K,A as pe,B as me,C as M,D as W,T as F,E as _e,G as te,H as fe,I as he,J as ge,N as ve}from"./vendor.495b01ec.js";const be=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function o(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerpolicy&&(a.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?a.credentials="include":r.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(r){if(r.ep)return;r.ep=!0;const a=o(r);fetch(r.href,a)}};be();const ye="modulepreload",Q={},we="/",m=function(t,o){return!o||o.length===0?t():Promise.all(o.map(n=>{if(n=`${we}${n}`,n in Q)return;Q[n]=!0;const r=n.endsWith(".css"),a=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${n}"]${a}`))return;const l=document.createElement("link");if(l.rel=r?"stylesheet":ye,r||(l.as="script",l.crossOrigin=""),l.href=n,document.head.appendChild(l),r)return new Promise((_,c)=>{l.addEventListener("load",_),l.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${n}`)))})})).then(()=>t())},P=X.mixin({toast:!0,position:"bottom-end",showConfirmButton:!1,timer:3e3}),Bt=X.mixin({showConfirmButton:!0,showCancelButton:!0}),$e="http://jm-expense-mysql.herokuapp.com",d=Y.create({baseURL:$e}),Ue="http://linebot20220114.herokuapp.com",Dt=Y.create({baseURL:Ue});var se={user:{firebase_email_register(e){return d.post("/user/register",e)},create(e){return d.post("/user/create",e)},edit(e,t){return d.put(`/user/edit/${e}`,t)},getAll(){return d.get("/user/all")},getUserByEmail(e){return d.get(`/user/${e}`)}},role:{getAll(){return d.get("/role/all")},getOne(e){return d.get(`/role/${e}`)},create(e){return d.post("/role/create",e)},edit(e,t){return d.put(`/role/edit/${e}`,t)},delete(e){return d.delete(`/role/delete/${e}`)}},permission:{getAll(){return d.get("/permission/all")},create(e){return d.post("/permission/create",e)},edit(e,t){return d.put(`/permission/edit/${e}`,t)},delete(e){return d.delete(`/permission/delete/${e}`)}}};const C=ie("index",{state:()=>({firebaseUser:null,currentUser:null}),getters:{nickName:e=>{var t,o;return((t=e.currentUser)==null?void 0:t.email)==="super000999888@gmail.com"?"\u8C6C\u6DB5":((o=e.currentUser)==null?void 0:o.email)==="bir840124@gmail.com"?"\u5EFA\u55B5":""},icon:e=>{var t,o;return((t=e.currentUser)==null?void 0:t.email)==="super000999888@gmail.com"?"\u{1F437}":((o=e.currentUser)==null?void 0:o.email)==="bir840124@gmail.com"?"\u{1F423}":""}},actions:{async getCurrentUser(e){try{const{data:t}=await se.user.getUserByEmail(e);this.currentUser=t.data,console.log("[getCurrentUser] this.currentUser",this.currentUser)}catch{console.error("error")}},login(e){this.firebaseUser=e,this.getCurrentUser(e.email)},logout(){this.firebaseUser=null,this.currentUser=null}}});var V=(e,t)=>{const o=e.__vccOpts||e;for(const[n,r]of t)o[n]=r;return o};const Ee={};function Re(e,t){return i(),u("div")}var Ae=V(Ee,[["render",Re]]);const f="/jm-expense-vue-ts",oe=[{path:"/",redirect:`${f}/`},{path:`${f}/register`,name:"Register",component:()=>m(()=>import("./Register.6118c7d7.js"),["assets/Register.6118c7d7.js","assets/Register.19cfce96.css","assets/vendor.495b01ec.js","assets/logo2.e884e5c2.js"]),meta:{pageTitle:"\u8A3B\u518A\u9801",show:!1}},{path:`${f}/login`,name:"Login",component:()=>m(()=>import("./Login.8ea55626.js"),["assets/Login.8ea55626.js","assets/Login.d0192f29.css","assets/vendor.495b01ec.js","assets/logo2.e884e5c2.js"]),meta:{pageTitle:"\u767B\u5165\u9801",show:!1}},{path:`${f}/`,name:"Home",component:()=>m(()=>import("./Home.b58b65e8.js"),["assets/Home.b58b65e8.js","assets/record.faac3df9.js","assets/CreateRecordModalButton.e30c1d0f.js","assets/vendor.495b01ec.js","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css"]),meta:{pageTitle:"\u9996\u9801",show:!0}},{path:`${f}/record`,name:"Record",component:()=>m(()=>import("./Record.598ee635.js"),["assets/Record.598ee635.js","assets/Record.e0b853ce.css","assets/record.faac3df9.js","assets/dateFormat.26b8f760.js","assets/vendor.495b01ec.js","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css","assets/CreateRecordModalButton.e30c1d0f.js"]),meta:{pageTitle:"\u672A\u7D50\u7B97\u7D00\u9304",show:!0}},{path:`${f}/closedRecord`,name:"ClosedRecord",component:()=>m(()=>import("./ClosedRecord.69250e9b.js"),["assets/ClosedRecord.69250e9b.js","assets/ClosedRecord.87e73f4b.css","assets/record.faac3df9.js","assets/dateFormat.26b8f760.js","assets/vendor.495b01ec.js","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css","assets/dateFilter.34232561.js"]),meta:{pageTitle:"\u5DF2\u7D50\u7B97\u7D00\u9304",show:!0}},{path:`${f}/logs`,name:"Logs",component:()=>m(()=>import("./Logs.4ace55bd.js"),["assets/Logs.4ace55bd.js","assets/Logs.d7f33462.css","assets/dateFormat.26b8f760.js","assets/vendor.495b01ec.js","assets/record.faac3df9.js","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css"]),meta:{pageTitle:"\u66F4\u52D5\u7D00\u9304",show:!0}},{path:`${f}/expense`,name:"Expense",component:()=>m(()=>import("./Expense.e2bf2766.js"),["assets/Expense.e2bf2766.js","assets/Expense.f22af147.css","assets/vendor.495b01ec.js","assets/dateFormat.26b8f760.js","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css","assets/dateFilter.34232561.js"]),meta:{pageTitle:"\u8C6C\u6DB5\u8A18\u5E33",show:!0}},{path:`${f}/tools`,name:"Tools",component:()=>m(()=>import("./Tools.da9ee16f.js"),["assets/Tools.da9ee16f.js","assets/vendor.495b01ec.js"]),meta:{pageTitle:"\u5C0F\u5DE5\u5177",show:!0}},{path:`${f}/game`,name:"Game",component:()=>m(()=>import("./Game.d0eb1356.js"),["assets/Game.d0eb1356.js","assets/Game.62e692cc.css","assets/vendor.495b01ec.js"]),meta:{pageTitle:"\u5C0F\u904A\u6232",show:!0}},{path:`${f}/admin`,name:"Admin",redirect:{name:"Admin-Role"},component:Ae,meta:{pageTitle:"\u7BA1\u7406\u9762\u677F",show:!0}},{path:"/admin/role",name:"Admin-Role",component:()=>m(()=>import("./Role.3adec45e.js"),["assets/Role.3adec45e.js","assets/Role.d4565b5d.css","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css","assets/vendor.495b01ec.js"]),meta:{pageTitle:"\u89D2\u8272\u7BA1\u7406",show:!0}},{path:"/admin/role/:id/access",name:"Admin-Role-Access",component:()=>m(()=>import("./Access.83adb1a9.js"),["assets/Access.83adb1a9.js","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css","assets/vendor.495b01ec.js"]),meta:{pageTitle:"\u89D2\u8272\u7BA1\u7406 / \u8A2D\u7F6E\u6B0A\u9650[\u89D2\u8272\u540D\u7A31]",show:!1}},{path:"/admin/permission",name:"Admin-Permission",component:()=>m(()=>import("./Permission.25be350c.js"),["assets/Permission.25be350c.js","assets/Permission.3c9c7f92.css","assets/Spinner.5acc2245.js","assets/Spinner.0a3c7a4a.css","assets/vendor.495b01ec.js"]),meta:{pageTitle:"\u6B0A\u9650\u7BA1\u7406",show:!0}},{path:"/:pathMatch(.*)*",name:"NotFound",component:()=>m(()=>import("./NotFound.52f07c53.js"),["assets/NotFound.52f07c53.js","assets/vendor.495b01ec.js"])}],S=le({history:ue(),routes:oe});S.beforeEach(async(e,t,o)=>{var r;const n=C();console.log("[router]firebaseUser",n.firebaseUser),console.log("[router]currentUser ID",(r=n.currentUser)==null?void 0:r.id),n.firebaseUser?e.name==="Login"||e.name==="Register"?o({name:"Home"}):o():e.name!=="Login"&&e.name!=="Register"?(o({name:"Login"}),P.fire({icon:"error",title:"\u8ACB\u5148\u767B\u5165"})):o()});const xe={class:"d-flex flex-column flex-shrink-0 p-3 text-white bg-primary",style:{width:"180px",height:"100vh"}},Ce=s("div",{class:"fs-4 mx-auto"},[s("i",{class:"fas fa-star"}),O(" JM\u8A18\u5E33 "),s("i",{class:"fas fa-star"})],-1),ke=s("hr",{class:"my-1"},null,-1),Le={class:"nav nav-pills mb-auto"},Be=["data-bs-target","aria-controls"],De={class:"me-3"},Pe=s("i",{class:"fa-solid fa-angle-down"},null,-1),Te=["id"],Oe={class:"btn-toggle-nav list-unstyled fw-normal pb-1 small"},Fe=s("hr",null,null,-1),Ie={class:"dropdown"},Ne={href:"#",class:"d-flex align-items-center text-white text-decoration-none dropdown-toggle",id:"dropdownUser1","data-bs-toggle":"dropdown","aria-expanded":"false"},Ve=["src"],Se=x({emits:["openUserRP"],setup(e,{emit:t}){const o=I(),n=C(),r=Z("sidebarOpen"),a=ce(()=>oe.filter(c=>{var p;return(p=c.meta)==null?void 0:p.show})),l=()=>{const c=N();de(c).then(()=>{n.logout(),r.value=!1,S.push({name:"Login"}),P.fire({icon:"success",title:"\u96E2\u958B\u8C6C\u8C6C\u4E16\u754C\u56C9~"})}).catch(p=>{console.log("error",p)})},_=()=>{r.value=!1,t("openUserRP",!0)};return(c,p)=>{var j,H;const g=ee("router-link");return i(),u("div",null,[s("div",xe,[y(g,{to:{name:"Home"},class:"d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none"},{default:h(()=>[Ce]),_:1}),ke,s("ul",Le,[(i(!0),u(E,null,q(v(a),(U,k)=>{var z,G;return i(),u("li",{class:"nav-item",key:k},[(z=U.children)!=null&&z.length?(i(),u(E,{key:0},[s("button",{class:"nav-link fw-bold text-white",type:"button","data-bs-toggle":"collapse","data-bs-target":`#collapse-${k}`,"aria-expanded":"false","aria-controls":`#collapse-${k}`},[s("span",De,$((G=U.meta)==null?void 0:G.pageTitle),1),Pe],8,Be),s("div",{class:"collapse",id:`collapse-${k}`},[s("ul",Oe,[(i(!0),u(E,null,q(U.children,b=>(i(),u("li",{key:b.name},[y(g,{to:{name:b.name},class:J("nav-link fw-bold "+(b.name===v(o).name?"text-danger":"text-white")),onClick:p[0]||(p[0]=T=>r.value=!1)},{default:h(()=>{var T;return[O($((T=b.meta)==null?void 0:T.pageTitle),1)]}),_:2},1032,["to","class"])]))),128))])],8,Te)],64)):(i(),L(g,{key:1,to:{name:U.name},class:J("nav-link fw-bold "+(U.name===v(o).name?"text-danger":"text-white")),onClick:p[1]||(p[1]=b=>r.value=!1)},{default:h(()=>{var b;return[O($((b=U.meta)==null?void 0:b.pageTitle),1)]}),_:2},1032,["to","class"]))])}),128))]),Fe,s("div",Ie,[s("a",Ne,[s("img",{src:((j=v(n).firebaseUser)==null?void 0:j.photoURL)||"../assets/capoo.gif",alt:"photo",width:"55",height:"55",class:"rounded-circle me-2"},null,8,Ve),s("strong",null,$((H=v(n).firebaseUser)==null?void 0:H.displayName),1)]),s("ul",{class:"dropdown-menu dropdown-menu-dark text-small shadow","aria-labelledby":"dropdownUser1"},[s("li",null,[s("a",{class:"dropdown-item",onClick:_},"\u500B\u4EBA\u8CC7\u6599")]),s("li",null,[s("a",{class:"dropdown-item",onClick:l},"\u767B\u51FA")])])])])])}}});const je={id:"panel"},He={class:"d-flex flex-column flex-shrink-0 p-3 text-white bg-light",style:{width:"250px",height:"100vh"}},ze=x({emits:["RPOpen"],setup(e,{emit:t}){return(o,n)=>(i(),u("div",je,[s("div",He,[s("i",{class:"fas fa-chevron-right hide-icon",onClick:n[0]||(n[0]=r=>t("RPOpen",!1))}),B(o.$slots,"title",{},void 0,!0),B(o.$slots,"content",{},void 0,!0)])]))}});var Ge=V(ze,[["__scopeId","data-v-e4a34786"]]);class Pt{constructor(){w(this,"email");w(this,"password");w(this,"displayName");w(this,"photoURL")}}class qe{constructor(){w(this,"displayName");w(this,"photoURL")}}const R=e=>(pe("data-v-f5c9ff2a"),e=e(),me(),e),Je=R(()=>s("h5",{class:"text-dark mb-3"},"\u500B\u4EBA\u8CC7\u6599",-1)),Ke={class:"my-3"},Me={class:"text-dark fw-bold"},We=R(()=>s("span",{class:"badge rounded-pill bg-success ms-2 mb-1"},"\u4FE1\u7BB1",-1)),Qe={class:"ms-2"},Xe={class:"mb-3"},Ye={class:"text-dark fw-bold"},Ze=R(()=>s("span",{class:"badge rounded-pill bg-success ms-2"},"\u540D\u7A31",-1)),et={class:"ms-2"},tt={key:0,class:"spinner-border spinner-border-sm text-success ms-2",role:"status"},st=R(()=>s("span",{class:"visually-hidden"},"Loading...",-1)),ot=[st],rt={class:"mb-3"},nt={class:"text-dark fw-bold"},at=R(()=>s("span",{class:"badge rounded-pill bg-success ms-2"},"\u5927\u982D\u8CBC(url)",-1)),it={class:"ms-2"},lt={key:0,class:"d-flex"},ut={class:"input-group mt-2"},ct={key:0,class:"spinner-border spinner-border-sm text-success ms-2 mt-4",role:"status"},dt=R(()=>s("span",{class:"visually-hidden"},"Loading...",-1)),pt=[dt],mt=["src"],_t=x({setup(e){const t=C(),o=Z("userRPOpen"),n=A(""),r=A(new qe),a=A(!1),l=async function(){try{if(t.currentUser){a.value=!0;const{data:_}=await se.user.edit(t.currentUser.id,r.value);if(t.getCurrentUser(t.currentUser.email),_.status!=="success")throw new Error(`[SERVER ERROR] ${_.message}`);n.value="",P.fire({icon:"success",title:"\u6210\u529F\u7DE8\u8F2F\u500B\u4EBA\u8CC7\u6599\uFF01"}),a.value=!1}}catch(_){console.error("error",_),P.fire({icon:"error",title:"\u7DE8\u8F2F\u500B\u4EBA\u8CC7\u6599\u5931\u6557\uFF01"})}};return t.currentUser&&(r.value={displayName:t.currentUser.displayName,photoURL:t.currentUser.photoURL}),(_,c)=>(i(),L(Ge,{onRPOpen:c[4]||(c[4]=p=>o.value=!1)},{title:h(()=>[Je]),content:h(()=>{var p;return[s("div",Ke,[s("div",Me,[We,s("span",Qe,$((p=v(t).currentUser)==null?void 0:p.email),1)])]),s("div",Xe,[s("div",Ye,[Ze,s("span",et,[n.value==="displayName"?(i(),u(E,{key:0},[D(s("input",{type:"text",class:"form-control d-inline-block",id:"displayName",style:{width:"120px"},"onUpdate:modelValue":c[0]||(c[0]=g=>r.value.displayName=g)},null,512),[[K,r.value.displayName]]),a.value?(i(),u("div",tt,ot)):(i(),u("i",{key:1,class:"far fa-check-circle fa-lg ms-2",onClick:l}))],64)):(i(),u(E,{key:1},[s("span",null,$(r.value.displayName),1),s("i",{class:"far fa-edit ms-2",onClick:c[1]||(c[1]=g=>n.value="displayName")})],64))])])]),s("div",rt,[s("div",nt,[at,s("span",it,[n.value==="photoURL"?(i(),u("div",lt,[s("div",ut,[D(s("textarea",{class:"form-control","aria-label":"With textarea","onUpdate:modelValue":c[2]||(c[2]=g=>r.value.photoURL=g)},null,512),[[K,r.value.photoURL]])]),a.value?(i(),u("div",ct,pt)):(i(),u("i",{key:1,class:"far fa-check-circle fa-lg ms-2 mt-4",onClick:l}))])):(i(),u(E,{key:1},[s("img",{src:r.value.photoURL||"",alt:"photoURL",width:"55",height:"55",class:"rounded-circle"},null,8,mt),s("i",{class:"far fa-edit ms-2",onClick:c[3]||(c[3]=g=>n.value="photoURL")})],64))])])])]}),_:1}))}});var ft=V(_t,[["__scopeId","data-v-f5c9ff2a"]]);const ht={key:0,class:"d-flex"},gt={class:"m-2",style:{width:"100vw"}},vt={class:"d-flex"},bt={class:"ms-3"},yt={class:"m-3"},wt={key:1},$t=x({setup(e){const t=C(),o=I(),n=A(!1),r=A(!1);return M("sidebarOpen",n),M("userRPOpen",r),(a,l)=>v(t).firebaseUser?(i(),u("div",ht,[y(F,{name:"slide-x"},{default:h(()=>[D(y(Se,{onOpenUserRP:l[0]||(l[0]=_=>r.value=!0)},null,512),[[W,n.value]])]),_:1}),s("div",gt,[s("div",vt,[s("i",{class:"fas fa-bars fa-2x",onClick:l[1]||(l[1]=_=>n.value=!n.value)}),s("h4",bt,$(v(o).meta.pageTitle),1)]),s("div",yt,[B(a.$slots,"main"),y(F,{name:"slide-right"},{default:h(()=>[D(y(ft,null,null,512),[[W,r.value]])]),_:1})])])])):(i(),u("div",wt,[B(a.$slots,"main")]))}}),re=[],Ut=async function(){const e=window.location.search;if(e.indexOf("?")!==-1){const o=e.substr(1).split("&");for(let n=0;n<o.length;n++)re[o[n].split("=")[0]]=unescape(o[n].split("=")[1])}},Tt=async function(e,...t){const o=re.host;o&&window.parent.postMessage({method:e,value:t},o)};const Et=x({setup(e){const t=I();return{}.NODE_ENV==="production"&&Ut(),(o,n)=>{const r=ee("router-view");return i(),L($t,null,{main:h(()=>[y(r,null,{default:h(({Component:a})=>[y(F,{name:"fade-fast",mode:"out-in"},{default:h(()=>[(i(),L(_e(a),{key:v(t).fullPath}))]),_:2},1024)]),_:1})]),_:1})}}}),Rt=()=>{const e=C();return new Promise(t=>{te(N(),async o=>{console.log("[firebase] onAuthStateChanged"),o?(console.log("[auth] Get Firebase User",o),e.login(o)):e.logout(),t()})})},At={apiKey:"AIzaSyATA2ffsJsf0E3Q1uBVGBoQYqXXKEEDNSA",authDomain:"jm-expense-2022.firebaseapp.com",projectId:"jm-expense-2022",storageBucket:"jm-expense-2022.appspot.com",messagingSenderId:"349734230365",appId:"1:349734230365:web:282c090db1f0ac1489f0b4",measurementId:"G-CEZ4WJRKGQ"},xt=()=>{fe(At)};console.log("[main] Initialize Firebase");xt();const Ct=te(N(),async e=>{const t=he(Et);console.log("[main] Initialize Vue App"),t.use(ge()),await Rt(),t.use(S),t.component("Datepicker",ve),t.mount("#app"),Ct()});export{Tt as C,Pt as F,Ge as R,P as T,V as _,d as a,Dt as b,C as c,Bt as d,se as u};
|