jm-expense-vue-ts/assets/index.6b72a0c0.js
2022-04-24 13:11:48 +08:00

2 lines
15 KiB
JavaScript

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