Files
accountbook/frontend/.next/static/chunks/pages/recurring-560011bee3956d16.js
T
DeveloperandClaude Opus 4.6 3347a256b2 Initial commit: accountbook project
- Node.js backend server
- Frontend application
- Backup script
- Project specification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 11:24:10 +08:00

1 line
14 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[845],{8208:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/recurring",function(){return t(5190)}])},6248:function(e,n,t){"use strict";t.d(n,{Z:function(){return o}});var a=t(5893),i=t(7294),c=t(1163),s=t(9415);let r=[{href:"/",label:"首页",icon:"home"},{href:"/stats",label:"统计",icon:"chart"},{href:"/recurring",label:"周期",icon:"repeat"},{href:"/categories",label:"分类",icon:"tags"}];function o(e){let{title:n,subtitle:t,actions:o,headerContent:l,children:u,contentClassName:d="",hideNav:m=!1,compactHeader:h=!1}=e,p=(0,c.useRouter)(),y=(0,i.useMemo)(()=>{let e=r.find(e=>e.href===p.pathname);return(null==e?void 0:e.href)||null},[p.pathname]),b=l||(n?(0,a.jsxs)("div",{className:"app-header__text",children:[(0,a.jsx)("h1",{children:n}),t?(0,a.jsx)("p",{children:t}):null]}):null),f=["app-header",h?"app-header--compact":"",b?"app-header--with-content":"app-header--actions-only",o?"app-header--with-actions":""].filter(Boolean).join(" ");return(0,a.jsxs)("div",{className:"app-shell".concat(m?" app-shell--standalone":""),children:[(0,a.jsx)("header",{className:f,children:(0,a.jsxs)("div",{className:"app-shell__container app-header__inner",children:[b?(0,a.jsx)("div",{className:"app-header__main",children:b}):(0,a.jsx)("div",{className:"app-header__spacer","aria-hidden":"true"}),o?(0,a.jsx)("div",{className:"app-header__actions",children:o}):null]})}),(0,a.jsx)("main",{className:"app-content ".concat(d).trim(),children:(0,a.jsx)("div",{className:"app-shell__container app-content__inner",children:u})}),m?null:(0,a.jsx)("nav",{className:"bottom-nav","aria-label":"主导航",children:(0,a.jsx)("div",{className:"app-shell__container bottom-nav__inner",children:r.map(e=>{let n=y===e.href;return(0,a.jsxs)("button",{type:"button",className:"bottom-nav__item".concat(n?" is-active":""),onClick:()=>p.push(e.href),"aria-current":n?"page":void 0,children:[(0,a.jsx)(s.J,{name:e.icon,size:20}),(0,a.jsx)("span",{children:e.label})]},e.href)})})})]})}},610:function(e,n,t){"use strict";async function a(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=await fetch("".concat("").concat(e),{...n,headers:{"Content-Type":"application/json",...function(){let e=localStorage.getItem("token");return e?{Authorization:"Bearer ".concat(e)}:{}}(),...n.headers}}),a=await t.json();if(!t.ok)throw Error(a.error||"请求失败");return a}async function i(e,n){let t=await a("/api/auth/login",{method:"POST",body:JSON.stringify({username:e,password:n})});return localStorage.setItem("token",t.token),t}async function c(e,n){let t=await a("/api/auth/register",{method:"POST",body:JSON.stringify({username:e,password:n})});return localStorage.setItem("token",t.token),t}function s(){localStorage.removeItem("token")}function r(){return!!localStorage.getItem("token")}async function o(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all",t="/api/records?month=".concat(e);return"all"!==n&&(t+="&type=".concat(n)),a(t)}async function l(e){return a("/api/stats?month=".concat(e))}async function u(e){return a("/api/records",{method:"POST",body:JSON.stringify(e)})}async function d(e,n){return a("/api/records/".concat(e),{method:"PUT",body:JSON.stringify(n)})}async function m(e){return a("/api/records/".concat(e),{method:"DELETE"})}async function h(e){return a("/api/records/search?q=".concat(encodeURIComponent(e)))}async function p(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"month",n=arguments.length>1?arguments[1]:void 0,t="/api/stats/trend?period=".concat(e);return n&&(t+="&month=".concat(n)),a(t)}async function y(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all",t="/api/stats/category?type=".concat(n);return e&&(t+="&month=".concat(e)),a(t)}async function b(){return a("/api/recurring")}async function f(e){return a("/api/recurring",{method:"POST",body:JSON.stringify(e)})}async function x(e,n){return a("/api/recurring/".concat(e),{method:"PUT",body:JSON.stringify(n)})}async function g(e){return a("/api/recurring/".concat(e),{method:"DELETE"})}async function j(e){return a("/api/recurring/".concat(e,"/apply"),{method:"POST"})}async function D(){return a("/api/categories")}async function v(e){return a("/api/categories",{method:"POST",body:JSON.stringify(e)})}async function N(e){return a("/api/categories/".concat(e),{method:"DELETE"})}async function _(){return a("/api/export")}async function C(e){return a("/api/import",{method:"POST",body:JSON.stringify(e)})}t.d(n,{Ap:function(){return y},CP:function(){return D},JS:function(){return m},Kp:function(){return h},Q6:function(){return o},TZ:function(){return g},Vn:function(){return b},Vs:function(){return d},Xu:function(){return j},ae:function(){return u},dk:function(){return C},fy:function(){return l},gR:function(){return p},jl:function(){return r},k4:function(){return v},kS:function(){return s},u1:function(){return _},uO:function(){return x},uu:function(){return N},x4:function(){return i},z0:function(){return f},z2:function(){return c}})},7063:function(e,n,t){"use strict";t.d(n,{S:function(){return a}});let a={expense:[{name:"餐饮",icon:"\uD83C\uDF5C"},{name:"买菜",icon:"\uD83E\uDD6C"},{name:"交通",icon:"\uD83D\uDE97"},{name:"购物",icon:"\uD83D\uDED2"},{name:"娱乐",icon:"\uD83C\uDFAE"},{name:"房租",icon:"\uD83C\uDFE0"},{name:"房贷",icon:"\uD83C\uDFE6"},{name:"亲情卡",icon:"\uD83D\uDCB3"},{name:"水电",icon:"\uD83D\uDCA7"},{name:"衣服",icon:"\uD83D\uDC54"},{name:"通讯",icon:"\uD83D\uDCF1"},{name:"日用品",icon:"\uD83E\uDDF4"},{name:"美妆",icon:"\uD83D\uDC84"},{name:"医疗",icon:"\uD83C\uDFE5"},{name:"养娃",icon:"\uD83D\uDC76"},{name:"家电",icon:"\uD83D\uDCFA"},{name:"家具",icon:"\uD83D\uDECB"},{name:"装修",icon:"\uD83D\uDD28"},{name:"宠物",icon:"\uD83D\uDC15"},{name:"其他",icon:"\uD83D\uDCDD"}],income:[{name:"工资",icon:"\uD83D\uDCB0"},{name:"奖金",icon:"\uD83C\uDF81"},{name:"理财",icon:"\uD83D\uDCC8"},{name:"红包",icon:"\uD83E\uDDE7"},{name:"其他",icon:"\uD83D\uDCDD"}]}},5190:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return m}});var a=t(5893),i=t(7294),c=t(1163),s=t(610),r=t(7063),o=t(6248),l=t(9415),u=t(5546),d=t(8846);function m(){let e=(0,c.useRouter)(),{showToast:n}=(0,u.p)(),{confirm:t}=(0,d.N)(),[m,h]=(0,i.useState)([]),[p,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(null),[x,g]=(0,i.useState)(!0),[j,D]=(0,i.useState)(!1),[v,N]=(0,i.useState)(!1),[_,C]=(0,i.useState)(null),[S,k]=(0,i.useState)(""),[w,E]=(0,i.useState)({type:"expense",amount:"",category:"",day:"1",note:"",is_active:!0});(0,i.useEffect)(()=>{if(!(0,s.jl)()){e.push("/login");return}O()},[e]);let O=async()=>{g(!0);try{let e=await (0,s.Vn)();h(e)}catch(e){console.error(e),n(e.message,{tone:"error"})}finally{g(!1)}},T=e=>{f(e),E({type:e.type,amount:e.amount.toString(),category:e.category,day:e.day.toString(),note:e.note||"",is_active:!!e.is_active}),k(""),y(!0)},J=()=>{j||v||(y(!1),f(null),k(""))},P=async e=>{if(e.preventDefault(),!w.amount||!w.category||!w.day){k("请填写完整信息");return}D(!0),k("");try{let e={type:w.type,amount:parseFloat(w.amount),category:w.category,day:parseInt(w.day),note:w.note,is_active:w.is_active?1:0};b?(await (0,s.uO)(b.id,e),n("周期账单已更新",{tone:"success"})):(await (0,s.z0)(e),n("周期账单已创建",{tone:"success"})),J(),await O()}catch(e){k(e.message),n(e.message,{tone:"error"})}finally{D(!1)}},F=async()=>{if(b&&await t({title:"删除这条周期账单?",description:"删除后将无法恢复,请确认是否继续。",confirmText:"删除"})){N(!0);try{await (0,s.TZ)(b.id),J(),n("周期账单已删除",{tone:"success"}),await O()}catch(e){k(e.message),n(e.message,{tone:"error"})}finally{N(!1)}}},z=async e=>{C(e);try{await (0,s.Xu)(e),n("已添加到账目",{tone:"success"})}catch(e){n(e.message,{tone:"error"})}finally{C(null)}},I=async(e,t)=>{t.stopPropagation();try{await (0,s.uO)(e.id,{...e,is_active:e.is_active?0:1}),n(e.is_active?"已停用周期账单":"已启用周期账单",{tone:"success"}),await O()}catch(e){n(e.message,{tone:"error"})}},A=Array.from({length:28},(e,n)=>n+1),B=(0,a.jsx)("button",{type:"button",className:"icon-button","aria-label":"设置",onClick:()=>e.push("/settings"),children:(0,a.jsx)(l.J,{name:"settings",size:18})});return(0,a.jsxs)(o.Z,{title:"周期账单",subtitle:"管理固定收入与支出节奏",actions:B,compactHeader:!0,children:[x?(0,a.jsx)("div",{className:"card loading-state",children:"加载中..."}):0===m.length?(0,a.jsxs)("div",{className:"card empty-state empty-state--card",children:[(0,a.jsx)("div",{className:"empty-state__icon",children:(0,a.jsx)(l.J,{name:"repeat",size:24})}),(0,a.jsx)("p",{children:"暂无周期性账单"}),(0,a.jsx)("p",{className:"sub",children:"点击右下角新增定期收入或支出。"})]}):(0,a.jsxs)("section",{className:"card section-card",children:[(0,a.jsx)("div",{className:"section-heading section-heading--compact",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"eyebrow",children:"账单列表"}),(0,a.jsxs)("h2",{children:[m.length," 条周期账单"]})]})}),(0,a.jsx)("div",{className:"bills-list",children:m.map(e=>{let n=r.S[e.type].find(n=>n.name===e.category)||{icon:"\uD83D\uDCDD"};return(0,a.jsxs)("button",{type:"button",className:"bill-item ".concat(e.is_active?"":"inactive"),onClick:()=>T(e),children:[(0,a.jsxs)("div",{className:"bill-left",children:[(0,a.jsx)("div",{className:"bill-icon",children:n.icon}),(0,a.jsxs)("div",{className:"bill-info",children:[(0,a.jsxs)("div",{className:"bill-row",children:[(0,a.jsx)("div",{className:"bill-category",children:e.category}),(0,a.jsx)("span",{className:"status-chip ".concat(e.is_active?"status-chip--success":""),children:e.is_active?"启用中":"已停用"})]}),(0,a.jsxs)("div",{className:"bill-day",children:["每月 ",e.day," 日"]}),e.note&&(0,a.jsx)("div",{className:"bill-note",children:e.note})]})]}),(0,a.jsxs)("div",{className:"bill-right",children:[(0,a.jsxs)("div",{className:"bill-amount ".concat(e.type),children:["income"===e.type?"+":"-",e.amount.toFixed(2)]}),(0,a.jsxs)("div",{className:"bill-actions",children:[(0,a.jsx)("button",{type:"button",className:"btn btn-secondary btn-inline btn-small",onClick:n=>{n.stopPropagation(),z(e.id)},disabled:_===e.id,children:_===e.id?"应用中...":"应用"}),(0,a.jsx)("button",{type:"button",className:"btn btn-ghost btn-inline btn-small",onClick:n=>I(e,n),children:e.is_active?"停用":"启用"})]})]})]},e.id)})})]}),(0,a.jsx)("button",{type:"button",className:"fab","aria-label":"新增账单",onClick:()=>{f(null),E({type:"expense",amount:"",category:"",day:"1",note:"",is_active:!0}),k(""),y(!0)},children:(0,a.jsx)(l.J,{name:"plus",size:24})}),p&&(0,a.jsx)("div",{className:"modal-overlay",onClick:J,children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"modal-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"eyebrow",children:b?"编辑账单":"新增账单"}),(0,a.jsx)("h2",{children:b?"更新周期账单":"创建周期账单"})]}),(0,a.jsx)("button",{type:"button",className:"icon-button icon-button--ghost","aria-label":"关闭弹窗",onClick:J,children:(0,a.jsx)(l.J,{name:"close",size:18})})]}),S&&(0,a.jsx)("div",{className:"error-msg",children:S}),(0,a.jsxs)("form",{onSubmit:P,children:[(0,a.jsxs)("div",{className:"type-switch",children:[(0,a.jsx)("button",{type:"button",className:"type-btn expense ".concat("expense"===w.type?"active":""),onClick:()=>E({...w,type:"expense",category:""}),disabled:j||v,children:"支出"}),(0,a.jsx)("button",{type:"button",className:"type-btn income ".concat("income"===w.type?"active":""),onClick:()=>E({...w,type:"income",category:""}),disabled:j||v,children:"收入"})]}),(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{htmlFor:"bill-amount",children:"金额"}),(0,a.jsx)("input",{id:"bill-amount",type:"number",className:"amount-input",value:w.amount,onChange:e=>E({...w,amount:e.target.value}),placeholder:"0.00",step:"0.01",required:!0,disabled:j||v})]}),(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{children:"分类"}),(0,a.jsx)("div",{className:"category-grid",children:r.S[w.type].map(e=>(0,a.jsxs)("button",{type:"button",className:"category-btn ".concat(w.category===e.name?"active":""),onClick:()=>E({...w,category:e.name}),disabled:j||v,children:[(0,a.jsx)("span",{className:"icon",children:e.icon}),(0,a.jsx)("span",{children:e.name})]},e.name))})]}),(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{htmlFor:"bill-day",children:"日期(每月几号)"}),(0,a.jsx)("select",{id:"bill-day",value:w.day,onChange:e=>E({...w,day:e.target.value}),disabled:j||v,children:A.map(e=>(0,a.jsxs)("option",{value:e,children:[e," 日"]},e))})]}),(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{htmlFor:"bill-note",children:"备注(可选)"}),(0,a.jsx)("input",{id:"bill-note",type:"text",value:w.note,onChange:e=>E({...w,note:e.target.value}),placeholder:"添加备注...",disabled:j||v})]}),b&&(0,a.jsx)("div",{className:"form-group form-group--inline",children:(0,a.jsxs)("label",{className:"checkbox-label",children:[(0,a.jsx)("input",{type:"checkbox",checked:w.is_active,onChange:e=>E({...w,is_active:e.target.checked}),disabled:j||v}),"启用此账单"]})}),(0,a.jsxs)("div",{className:"modal-actions",children:[(0,a.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:j||v,children:j?(0,a.jsxs)("span",{className:"button-content",children:[(0,a.jsx)(l.J,{name:"spinner",size:16,className:"is-spinning"}),"保存中..."]}):"保存"}),b&&(0,a.jsx)("button",{type:"button",className:"btn btn-danger",onClick:F,disabled:j||v,children:v?"删除中...":"删除"})]})]})]})})]})}},1163:function(e,n,t){e.exports=t(3079)}},function(e){e.O(0,[888,774,179],function(){return e(e.s=8208)}),_N_E=e.O()}]);