feat: 添加预算管理功能,支持分类预算和重置周期设置,优化用户界面
This commit is contained in:
@@ -7,6 +7,18 @@ export const useSettingsStore = defineStore(
|
||||
const notificationCaptureEnabled = ref(true)
|
||||
const aiAutoCategoryEnabled = ref(false)
|
||||
const monthlyBudget = ref(12000)
|
||||
const budgetResetCycle = ref('monthly') // monthly | weekly | none | custom
|
||||
const budgetMonthlyResetDay = ref(1) // 每月第几天重置,1-28
|
||||
const budgetCustomStartDate = ref('') // 自定义起始日(ISO 日期字符串)
|
||||
const categoryBudgets = ref({
|
||||
Food: 0,
|
||||
Transport: 0,
|
||||
Health: 0,
|
||||
Groceries: 0,
|
||||
Entertainment: 0,
|
||||
Uncategorized: 0,
|
||||
})
|
||||
const categoryBudgetEnabled = ref(false)
|
||||
const profileName = ref('Echo 用户')
|
||||
const profileAvatar = ref('')
|
||||
|
||||
@@ -23,6 +35,38 @@ export const useSettingsStore = defineStore(
|
||||
monthlyBudget.value = Number.isFinite(numeric) && numeric >= 0 ? numeric : 0
|
||||
}
|
||||
|
||||
const setBudgetResetCycle = (value) => {
|
||||
const allowed = ['monthly', 'weekly', 'none', 'custom']
|
||||
budgetResetCycle.value = allowed.includes(value) ? value : 'monthly'
|
||||
}
|
||||
|
||||
const setCategoryBudget = (category, value) => {
|
||||
const numeric = Number(value)
|
||||
const safe = Number.isFinite(numeric) && numeric >= 0 ? numeric : 0
|
||||
categoryBudgets.value = {
|
||||
...categoryBudgets.value,
|
||||
[category]: safe,
|
||||
}
|
||||
}
|
||||
|
||||
const setCategoryBudgetEnabled = (value) => {
|
||||
categoryBudgetEnabled.value = !!value
|
||||
}
|
||||
|
||||
const setBudgetMonthlyResetDay = (value) => {
|
||||
const n = Number(value)
|
||||
if (!Number.isFinite(n)) {
|
||||
budgetMonthlyResetDay.value = 1
|
||||
return
|
||||
}
|
||||
const clamped = Math.min(Math.max(Math.round(n), 1), 28)
|
||||
budgetMonthlyResetDay.value = clamped
|
||||
}
|
||||
|
||||
const setBudgetCustomStartDate = (value) => {
|
||||
budgetCustomStartDate.value = value || ''
|
||||
}
|
||||
|
||||
const setProfileName = (value) => {
|
||||
profileName.value = (value || '').trim() || 'Echo 用户'
|
||||
}
|
||||
@@ -35,11 +79,21 @@ export const useSettingsStore = defineStore(
|
||||
notificationCaptureEnabled,
|
||||
aiAutoCategoryEnabled,
|
||||
monthlyBudget,
|
||||
budgetResetCycle,
|
||||
budgetMonthlyResetDay,
|
||||
budgetCustomStartDate,
|
||||
categoryBudgets,
|
||||
categoryBudgetEnabled,
|
||||
profileName,
|
||||
profileAvatar,
|
||||
setNotificationCaptureEnabled,
|
||||
setAiAutoCategoryEnabled,
|
||||
setMonthlyBudget,
|
||||
setBudgetResetCycle,
|
||||
setBudgetMonthlyResetDay,
|
||||
setBudgetCustomStartDate,
|
||||
setCategoryBudget,
|
||||
setCategoryBudgetEnabled,
|
||||
setProfileName,
|
||||
setProfileAvatar,
|
||||
}
|
||||
@@ -50,6 +104,11 @@ export const useSettingsStore = defineStore(
|
||||
'notificationCaptureEnabled',
|
||||
'aiAutoCategoryEnabled',
|
||||
'monthlyBudget',
|
||||
'budgetResetCycle',
|
||||
'budgetMonthlyResetDay',
|
||||
'budgetCustomStartDate',
|
||||
'categoryBudgets',
|
||||
'categoryBudgetEnabled',
|
||||
'profileName',
|
||||
'profileAvatar',
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user