jm-expense-vue-ts/assets/index.baafafcd.js
2022-04-24 10:09:18 +08:00

2 lines
15 KiB
JavaScript

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