feat: 添加 UI 状态管理,支持新增记录底部弹窗功能,优化设置和主页交互
This commit is contained in:
@@ -6,6 +6,9 @@ export const useSettingsStore = defineStore(
|
||||
() => {
|
||||
const notificationCaptureEnabled = ref(true)
|
||||
const aiAutoCategoryEnabled = ref(false)
|
||||
const monthlyBudget = ref(12000)
|
||||
const profileName = ref('Echo 用户')
|
||||
const profileAvatar = ref('')
|
||||
|
||||
const setNotificationCaptureEnabled = (value) => {
|
||||
notificationCaptureEnabled.value = !!value
|
||||
@@ -15,16 +18,41 @@ export const useSettingsStore = defineStore(
|
||||
aiAutoCategoryEnabled.value = !!value
|
||||
}
|
||||
|
||||
const setMonthlyBudget = (value) => {
|
||||
const numeric = Number(value)
|
||||
monthlyBudget.value = Number.isFinite(numeric) && numeric >= 0 ? numeric : 0
|
||||
}
|
||||
|
||||
const setProfileName = (value) => {
|
||||
profileName.value = (value || '').trim() || 'Echo 用户'
|
||||
}
|
||||
|
||||
const setProfileAvatar = (value) => {
|
||||
profileAvatar.value = value || ''
|
||||
}
|
||||
|
||||
return {
|
||||
notificationCaptureEnabled,
|
||||
aiAutoCategoryEnabled,
|
||||
monthlyBudget,
|
||||
profileName,
|
||||
profileAvatar,
|
||||
setNotificationCaptureEnabled,
|
||||
setAiAutoCategoryEnabled,
|
||||
setMonthlyBudget,
|
||||
setProfileName,
|
||||
setProfileAvatar,
|
||||
}
|
||||
},
|
||||
{
|
||||
persist: {
|
||||
paths: ['notificationCaptureEnabled', 'aiAutoCategoryEnabled'],
|
||||
paths: [
|
||||
'notificationCaptureEnabled',
|
||||
'aiAutoCategoryEnabled',
|
||||
'monthlyBudget',
|
||||
'profileName',
|
||||
'profileAvatar',
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
26
src/stores/ui.js
Normal file
26
src/stores/ui.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
// 负责全局 UI 状态,例如新增记录的底部弹窗
|
||||
export const useUiStore = defineStore('ui', () => {
|
||||
const addEntryVisible = ref(false)
|
||||
const editingTransactionId = ref('')
|
||||
|
||||
const openAddEntry = (id = '') => {
|
||||
editingTransactionId.value = id || ''
|
||||
addEntryVisible.value = true
|
||||
}
|
||||
|
||||
const closeAddEntry = () => {
|
||||
addEntryVisible.value = false
|
||||
editingTransactionId.value = ''
|
||||
}
|
||||
|
||||
return {
|
||||
addEntryVisible,
|
||||
editingTransactionId,
|
||||
openAddEntry,
|
||||
closeAddEntry,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user