mirror of
https://github.com/KarolChang/jm-expense-vue-ts.git
synced 2024-12-26 03:38:35 +00:00
2 lines
15 KiB
JavaScript
2 lines
15 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 Q,a as X,d as ie,c as le,b as ue,e as k,u as I,i as Y,f as ce,r as Z,o as l,g as c,h as s,j as y,w as _,F as x,k as G,t as U,l as F,n as q,m as v,p as A,q as N,s as de,v as B,x as R,y as P,z as J,A as pe,B as me,C as K,D as M,T,E as _e,G as ee,H as fe,I as he,J as ge,N as ve}from"./vendor.961f4417.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 i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).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",W={},we="/jm-expense-vue-ts/",h=function(t,o){return!o||o.length===0?t():Promise.all(o.map(n=>{if(n=`${we}${n}`,n in W)return;W[n]=!0;const r=n.endsWith(".css"),a=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${n}"]${a}`))return;const i=document.createElement("link");if(i.rel=r?"stylesheet":ye,r||(i.as="script",i.crossOrigin=""),i.href=n,document.head.appendChild(i),r)return new Promise((m,u)=>{i.addEventListener("load",m),i.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${n}`)))})})).then(()=>t())};const O=Q.mixin({toast:!0,position:"bottom-end",showConfirmButton:!1,timer:3e3}),Et=Q.mixin({showConfirmButton:!0,showCancelButton:!0}),Ue="http://jm-expense-mysql.herokuapp.com",d=X.create({baseURL:Ue}),$e="http://linebot20220114.herokuapp.com",Lt=X.create({baseURL:$e});var te={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 E=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 te.user.getUserByEmail(e);this.currentUser=t.data,console.log("[getCurrentUser] this.currentUser",this.currentUser)}catch{console.error("error")}},async login(e){this.firebaseUser=e,await this.getCurrentUser(e.email)},logout(){this.firebaseUser=null,this.currentUser=null}}}),g="/jm-expense-vue-ts",se=[{path:"/",redirect:`${g}/`},{path:`${g}/register`,name:"Register",component:()=>h(()=>import("./Register.de1d04f4.js"),["assets/Register.de1d04f4.js","assets/Register.19cfce96.css","assets/vendor.961f4417.js","assets/logo2.e884e5c2.js"]),meta:{pageTitle:"\u8A3B\u518A\u9801",show:!1}},{path:`${g}/login`,name:"Login",component:()=>h(()=>import("./Login.9e11d02c.js"),["assets/Login.9e11d02c.js","assets/Login.d0192f29.css","assets/vendor.961f4417.js","assets/logo2.e884e5c2.js"]),meta:{pageTitle:"\u767B\u5165\u9801",show:!1}},{path:`${g}/`,name:"Home",component:()=>h(()=>import("./Home.881cf962.js"),["assets/Home.881cf962.js","assets/record.2f186259.js","assets/CreateRecordModalButton.5a2991ad.js","assets/vendor.961f4417.js","assets/Spinner.33b65f67.js","assets/Spinner.0a3c7a4a.css"]),meta:{pageTitle:"\u9996\u9801",show:!0}},{path:`${g}/record`,name:"Record",component:()=>h(()=>import("./Record.1ea5d102.js"),["assets/Record.1ea5d102.js","assets/Record.f001a8f1.css","assets/record.2f186259.js","assets/dateFormat.a9df66b7.js","assets/vendor.961f4417.js","assets/Spinner.33b65f67.js","assets/Spinner.0a3c7a4a.css","assets/CreateRecordModalButton.5a2991ad.js"]),meta:{pageTitle:"\u672A\u7D50\u7B97\u7D00\u9304",show:!0}},{path:`${g}/closedRecord`,name:"ClosedRecord",component:()=>h(()=>import("./ClosedRecord.a9664b6b.js"),["assets/ClosedRecord.a9664b6b.js","assets/ClosedRecord.87e73f4b.css","assets/record.2f186259.js","assets/dateFormat.a9df66b7.js","assets/vendor.961f4417.js","assets/Spinner.33b65f67.js","assets/Spinner.0a3c7a4a.css","assets/dateFilter.a11ea60c.js"]),meta:{pageTitle:"\u5DF2\u7D50\u7B97\u7D00\u9304",show:!0}},{path:`${g}/logs`,name:"Logs",component:()=>h(()=>import("./Logs.2b5251aa.js"),["assets/Logs.2b5251aa.js","assets/Logs.d7f33462.css","assets/dateFormat.a9df66b7.js","assets/vendor.961f4417.js","assets/record.2f186259.js","assets/Spinner.33b65f67.js","assets/Spinner.0a3c7a4a.css"]),meta:{pageTitle:"\u66F4\u52D5\u7D00\u9304",show:!0}},{path:`${g}/expense`,name:"Expense",component:()=>h(()=>import("./Expense.fb5a705a.js"),["assets/Expense.fb5a705a.js","assets/Expense.76d6b23d.css","assets/vendor.961f4417.js","assets/dateFormat.a9df66b7.js","assets/Spinner.33b65f67.js","assets/Spinner.0a3c7a4a.css","assets/dateFilter.a11ea60c.js"]),meta:{pageTitle:"\u8C6C\u6DB5\u8A18\u5E33",show:!0}},{path:`${g}/game`,name:"Game",component:()=>h(()=>import("./Game.d403d955.js"),["assets/Game.d403d955.js","assets/Game.62e692cc.css","assets/vendor.961f4417.js"]),meta:{pageTitle:"\u5C0F\u904A\u6232",show:!0}},{path:"/:pathMatch(.*)*",name:"NotFound",component:()=>h(()=>import("./NotFound.fe527ce3.js"),["assets/NotFound.fe527ce3.js","assets/vendor.961f4417.js"])}],S=le({history:ue(),routes:se});S.beforeEach(async(e,t,o)=>{var r;const n=E();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"}),O.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"}),F(" JM\u8A18\u5E33 "),s("i",{class:"fas fa-star"})],-1),Re=s("hr",{class:"my-1"},null,-1),ke={class:"nav nav-pills mb-auto"},Ee=["data-bs-target","aria-controls"],Le={class:"me-3"},Ae=s("i",{class:"fa-solid fa-angle-down"},null,-1),Be=["id"],Pe={class:"btn-toggle-nav list-unstyled fw-normal pb-1 small"},Oe=s("hr",null,null,-1),De={class:"dropdown"},Fe={href:"#",class:"d-flex align-items-center text-white text-decoration-none dropdown-toggle",id:"dropdownUser1","data-bs-toggle":"dropdown","aria-expanded":"false"},Te=["src"],Ie=k({emits:["openUserRP"],setup(e,{emit:t}){const o=I(),n=E(),r=Y("sidebarOpen"),a=ce(()=>se.filter(u=>{var p;return(p=u.meta)==null?void 0:p.show})),i=()=>{const u=N();de(u).then(()=>{n.logout(),r.value=!1,S.push({name:"Login"}),O.fire({icon:"success",title:"\u96E2\u958B\u8C6C\u8C6C\u4E16\u754C\u56C9~"})}).catch(p=>{console.log("error",p)})},m=()=>{r.value=!1,t("openUserRP",!0)};return(u,p)=>{var V,j;const f=Z("router-link");return l(),c("div",null,[s("div",xe,[y(f,{to:{name:"Home"},class:"d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none"},{default:_(()=>[Ce]),_:1}),Re,s("ul",ke,[(l(!0),c(x,null,G(v(a),($,L)=>{var H,z;return l(),c("li",{class:"nav-item",key:L},[(H=$.children)!=null&&H.length?(l(),c(x,{key:0},[s("button",{class:"nav-link fw-bold text-white",type:"button","data-bs-toggle":"collapse","data-bs-target":`#collapse-${L}`,"aria-expanded":"false","aria-controls":`#collapse-${L}`},[s("span",Le,U((z=$.meta)==null?void 0:z.pageTitle),1),Ae],8,Ee),s("div",{class:"collapse",id:`collapse-${L}`},[s("ul",Pe,[(l(!0),c(x,null,G($.children,b=>(l(),c("li",{key:b.name},[y(f,{to:{name:b.name},class:q("nav-link fw-bold "+(b.name===v(o).name?"text-danger":"text-white")),onClick:p[0]||(p[0]=D=>r.value=!1)},{default:_(()=>{var D;return[F(U((D=b.meta)==null?void 0:D.pageTitle),1)]}),_:2},1032,["to","class"])]))),128))])],8,Be)],64)):(l(),A(f,{key:1,to:{name:$.name},class:q("nav-link fw-bold "+($.name===v(o).name?"text-danger":"text-white")),onClick:p[1]||(p[1]=b=>r.value=!1)},{default:_(()=>{var b;return[F(U((b=$.meta)==null?void 0:b.pageTitle),1)]}),_:2},1032,["to","class"]))])}),128))]),Oe,s("div",De,[s("a",Fe,[s("img",{src:((V=v(n).firebaseUser)==null?void 0:V.photoURL)||"../assets/capoo.gif",alt:"photo",width:"55",height:"55",class:"rounded-circle me-2"},null,8,Te),s("strong",null,U((j=v(n).firebaseUser)==null?void 0:j.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:m},"\u500B\u4EBA\u8CC7\u6599")]),s("li",null,[s("a",{class:"dropdown-item",onClick:i},"\u767B\u51FA")])])])])])}}});var oe=(e,t)=>{const o=e.__vccOpts||e;for(const[n,r]of t)o[n]=r;return o};const Ne={id:"panel"},Se={class:"d-flex flex-column flex-shrink-0 p-3 text-white bg-light",style:{width:"250px",height:"100vh"}},Ve=k({emits:["RPOpen"],setup(e,{emit:t}){return(o,n)=>(l(),c("div",Ne,[s("div",Se,[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 je=oe(Ve,[["__scopeId","data-v-e4a34786"]]);class At{constructor(){w(this,"email");w(this,"password");w(this,"displayName");w(this,"photoURL")}}class He{constructor(){w(this,"displayName");w(this,"photoURL")}}const C=e=>(pe("data-v-f5c9ff2a"),e=e(),me(),e),ze=C(()=>s("h5",{class:"text-dark mb-3"},"\u500B\u4EBA\u8CC7\u6599",-1)),Ge={class:"my-3"},qe={class:"text-dark fw-bold"},Je=C(()=>s("span",{class:"badge rounded-pill bg-success ms-2 mb-1"},"\u4FE1\u7BB1",-1)),Ke={class:"ms-2"},Me={class:"mb-3"},We={class:"text-dark fw-bold"},Qe=C(()=>s("span",{class:"badge rounded-pill bg-success ms-2"},"\u540D\u7A31",-1)),Xe={class:"ms-2"},Ye={key:0,class:"spinner-border spinner-border-sm text-success ms-2",role:"status"},Ze=C(()=>s("span",{class:"visually-hidden"},"Loading...",-1)),et=[Ze],tt={class:"mb-3"},st={class:"text-dark fw-bold"},ot=C(()=>s("span",{class:"badge rounded-pill bg-success ms-2"},"\u5927\u982D\u8CBC(url)",-1)),rt={class:"ms-2"},nt={key:0,class:"d-flex"},at={class:"input-group mt-2"},it={key:0,class:"spinner-border spinner-border-sm text-success ms-2 mt-4",role:"status"},lt=C(()=>s("span",{class:"visually-hidden"},"Loading...",-1)),ut=[lt],ct=["src"],dt=k({setup(e){const t=E(),o=Y("userRPOpen"),n=R(""),r=R(new He),a=R(!1),i=async function(){try{if(t.currentUser){a.value=!0;const{data:m}=await te.user.edit(t.currentUser.id,r.value);if(t.getCurrentUser(t.currentUser.email),m.status!=="success")throw new Error(`[SERVER ERROR] ${m.message}`);n.value="",O.fire({icon:"success",title:"\u6210\u529F\u7DE8\u8F2F\u500B\u4EBA\u8CC7\u6599\uFF01"}),a.value=!1}}catch(m){console.error("error",m),O.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}),(m,u)=>(l(),A(je,{onRPOpen:u[4]||(u[4]=p=>o.value=!1)},{title:_(()=>[ze]),content:_(()=>{var p;return[s("div",Ge,[s("div",qe,[Je,s("span",Ke,U((p=v(t).currentUser)==null?void 0:p.email),1)])]),s("div",Me,[s("div",We,[Qe,s("span",Xe,[n.value==="displayName"?(l(),c(x,{key:0},[P(s("input",{type:"text",class:"form-control d-inline-block",id:"displayName",style:{width:"120px"},"onUpdate:modelValue":u[0]||(u[0]=f=>r.value.displayName=f)},null,512),[[J,r.value.displayName]]),a.value?(l(),c("div",Ye,et)):(l(),c("i",{key:1,class:"far fa-check-circle fa-lg ms-2",onClick:i}))],64)):(l(),c(x,{key:1},[s("span",null,U(r.value.displayName),1),s("i",{class:"far fa-edit ms-2",onClick:u[1]||(u[1]=f=>n.value="displayName")})],64))])])]),s("div",tt,[s("div",st,[ot,s("span",rt,[n.value==="photoURL"?(l(),c("div",nt,[s("div",at,[P(s("textarea",{class:"form-control","aria-label":"With textarea","onUpdate:modelValue":u[2]||(u[2]=f=>r.value.photoURL=f)},null,512),[[J,r.value.photoURL]])]),a.value?(l(),c("div",it,ut)):(l(),c("i",{key:1,class:"far fa-check-circle fa-lg ms-2 mt-4",onClick:i}))])):(l(),c(x,{key:1},[s("img",{src:r.value.photoURL||"",alt:"photoURL",width:"55",height:"55",class:"rounded-circle"},null,8,ct),s("i",{class:"far fa-edit ms-2",onClick:u[3]||(u[3]=f=>n.value="photoURL")})],64))])])])]}),_:1}))}});var pt=oe(dt,[["__scopeId","data-v-f5c9ff2a"]]);const mt={key:0,class:"d-flex"},_t={class:"m-2",style:{width:"100vw"}},ft={class:"d-flex"},ht={class:"ms-3"},gt={class:"m-3"},vt={key:1},bt=k({setup(e){const t=E(),o=I(),n=R(!1),r=R(!1);return K("sidebarOpen",n),K("userRPOpen",r),(a,i)=>v(t).firebaseUser?(l(),c("div",mt,[y(T,{name:"slide-x"},{default:_(()=>[P(y(Ie,{onOpenUserRP:i[0]||(i[0]=m=>r.value=!0)},null,512),[[M,n.value]])]),_:1}),s("div",_t,[s("div",ft,[s("i",{class:"fas fa-bars fa-2x",onClick:i[1]||(i[1]=m=>n.value=!n.value)}),s("h4",ht,U(v(o).meta.pageTitle),1)]),s("div",gt,[B(a.$slots,"main"),y(T,{name:"slide-right"},{default:_(()=>[P(y(pt,null,null,512),[[M,r.value]])]),_:1})])])])):(l(),c("div",vt,[B(a.$slots,"main")]))}}),re=[],yt=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])}},Bt=async function(e,...t){const o=re.host;o&&window.parent.postMessage({method:e,value:t},o)};const wt=k({setup(e){const t=I();return yt(),(o,n)=>{const r=Z("router-view");return l(),A(bt,null,{main:_(()=>[y(r,null,{default:_(({Component:a})=>[y(T,{name:"fade-fast",mode:"out-in"},{default:_(()=>[(l(),A(_e(a),{key:v(t).fullPath}))]),_:2},1024)]),_:1})]),_:1})}}}),Ut=()=>{const e=E();return new Promise(t=>{ee(N(),async o=>{console.log("[firebase] onAuthStateChanged"),o?(console.log("[auth] Get Firebase User",o),await e.login(o)):e.logout(),t()})})},$t={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($t)};console.log("[main] Initialize Firebase");xt();const Ct=ee(N(),async e=>{const t=he(wt);console.log("[main] Initialize Vue App"),t.use(ge()),await Ut(),t.use(S),t.component("Datepicker",ve),t.mount("#app"),Ct()});export{Bt as C,At as F,je as R,O as T,oe as _,d as a,Lt as b,E as c,Et as d,te as u};
|