import { computed, ref } from 'vue'
-import { useRouter } from 'vue-router'
import { storeToRefs } from 'pinia'
import { useTransactionStore } from '../stores/transactions'
+import { useUiStore } from '../stores/ui'
-const router = useRouter()
const transactionStore = useTransactionStore()
+const uiStore = useUiStore()
const { groupedTransactions, filters, loading } = storeToRefs(transactionStore)
const deletingId = ref('')
@@ -36,7 +36,7 @@ const formatTime = (value) =>
)
const handleEdit = (item) => {
- router.push({ name: 'add', query: { id: item.id } })
+ uiStore.openAddEntry(item.id)
}
const handleDelete = async (item) => {
@@ -63,7 +63,7 @@ transactionStore.ensureInitialized()
diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue
index f582248..7f7429d 100644
--- a/src/views/SettingsView.vue
+++ b/src/views/SettingsView.vue
@@ -3,7 +3,12 @@ import { computed, onMounted, ref } from 'vue'
import NotificationBridge, { isNativeNotificationBridgeAvailable } from '../lib/notificationBridge'
import { useSettingsStore } from '../stores/settings'
+// 从 Vite 注入的版本号(来源于 package.json),用于在设置页展示
+// eslint-disable-next-line no-undef
+const appVersion = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0'
+
const settingsStore = useSettingsStore()
+const fileInputRef = ref(null)
const notificationCaptureEnabled = computed({
get: () => settingsStore.notificationCaptureEnabled,
@@ -51,6 +56,35 @@ const toggleAiAutoCategory = () => {
aiAutoCategoryEnabled.value = !aiAutoCategoryEnabled.value
}
+const handleEditProfileName = () => {
+ const current = settingsStore.profileName || 'Echo 用户'
+ const input = window.prompt('修改昵称', current)
+ if (input == null) return
+ settingsStore.setProfileName(input)
+}
+
+const handleAvatarClick = () => {
+ if (fileInputRef.value) {
+ fileInputRef.value.click()
+ }
+}
+
+const handleAvatarChange = (event) => {
+ const [file] = event.target.files || []
+ if (!file) return
+ if (!file.type || !file.type.startsWith('image/')) {
+ window.alert('请选择图片文件作为头像')
+ return
+ }
+ const reader = new FileReader()
+ reader.onload = () => {
+ if (typeof reader.result === 'string') {
+ settingsStore.setProfileAvatar(reader.result)
+ }
+ }
+ reader.readAsDataURL(file)
+}
+
const handleExportData = () => {
window.alert('导出功能即将上线:届时可以一键导出 CSV / Excel。当前版本建议先通过截图或复制方式备份关键信息。')
}
@@ -78,13 +112,42 @@ onMounted(() => {
-

+
+
![Avatar]()
+
+
+
-
Echo 用户
+
+
+ {{ settingsStore.profileName }}
+
+
+
本地优先 · 数据只存这台设备
@@ -222,7 +285,7 @@ onMounted(() => {
-
Echo · Local-first Beta
+
Echo · Local-first · v{{ appVersion }}
diff --git a/vite.config.js b/vite.config.js
index bbcf80c..6698196 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1,7 +1,14 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
+// 从 package.json 注入版本号,便于前端展示
+// eslint-disable-next-line no-undef
+const appVersion = (process && process.env && process.env.npm_package_version) || '0.0.0'
+
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
+ define: {
+ __APP_VERSION__: JSON.stringify(appVersion),
+ },
})