2025-11-28 11:37:33 +08:00
|
|
|
|
<script setup>
|
2025-12-02 17:50:26 +08:00
|
|
|
|
import { onMounted, onBeforeUnmount } from 'vue'
|
2025-11-24 17:23:46 +08:00
|
|
|
|
import { RouterView } from 'vue-router'
|
2025-12-02 17:50:26 +08:00
|
|
|
|
import { App } from '@capacitor/app'
|
2025-11-24 17:23:46 +08:00
|
|
|
|
import BottomDock from './components/BottomDock.vue'
|
2025-12-02 16:22:46 +08:00
|
|
|
|
import AddEntryView from './views/AddEntryView.vue'
|
2025-11-25 17:12:09 +08:00
|
|
|
|
import { useTransactionStore } from './stores/transactions'
|
2025-12-02 16:22:46 +08:00
|
|
|
|
import { useUiStore } from './stores/ui'
|
2025-11-25 17:12:09 +08:00
|
|
|
|
|
|
|
|
|
|
const transactionStore = useTransactionStore()
|
2025-12-02 16:22:46 +08:00
|
|
|
|
const uiStore = useUiStore()
|
2025-11-25 17:12:09 +08:00
|
|
|
|
|
2025-12-02 17:50:26 +08:00
|
|
|
|
let backButtonListener = null
|
|
|
|
|
|
|
2025-11-25 17:12:09 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
transactionStore.ensureInitialized()
|
2025-12-02 17:50:26 +08:00
|
|
|
|
|
|
|
|
|
|
// Android 物理返回键:如果新增记录面板打开,则优先关闭面板而不是直接退出应用
|
|
|
|
|
|
if (typeof App?.addListener === 'function') {
|
|
|
|
|
|
App.addListener('backButton', ({ canGoBack }) => {
|
|
|
|
|
|
if (uiStore.addEntryVisible) {
|
|
|
|
|
|
uiStore.closeAddEntry()
|
|
|
|
|
|
} else if (!canGoBack) {
|
|
|
|
|
|
// 这里保留默认行为(由 Capacitor 处理),不强制 exitApp
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.then((handle) => {
|
|
|
|
|
|
backButtonListener = handle
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
backButtonListener = null
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
if (backButtonListener && typeof backButtonListener.remove === 'function') {
|
|
|
|
|
|
backButtonListener.remove()
|
|
|
|
|
|
backButtonListener = null
|
|
|
|
|
|
}
|
2025-11-25 17:12:09 +08:00
|
|
|
|
})
|
2025-11-24 17:23:46 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-11-28 11:37:33 +08:00
|
|
|
|
<!-- 整体应用容器:居中展示移动端画布,配合沉浸式状态栏使用安全区域内边距 -->
|
2025-11-24 17:23:46 +08:00
|
|
|
|
<div class="min-h-screen bg-warmOffwhite text-stone-800 flex items-center justify-center">
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="h-screen max-h-[844px] max-w-md w-full mx-auto bg-warmOffwhite shadow-2xl relative overflow-hidden flex flex-col"
|
2025-11-28 11:37:33 +08:00
|
|
|
|
style="padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);"
|
2025-11-24 17:23:46 +08:00
|
|
|
|
>
|
|
|
|
|
|
<!-- 主内容区域:由 vue-router 控制具体页面 -->
|
|
|
|
|
|
<main class="flex-1 overflow-y-auto hide-scrollbar px-5 pt-2 pb-28 relative">
|
|
|
|
|
|
<RouterView />
|
|
|
|
|
|
</main>
|
|
|
|
|
|
|
2025-11-28 11:37:33 +08:00
|
|
|
|
<!-- 底部 Dock 导航 -->
|
2025-11-24 17:23:46 +08:00
|
|
|
|
<BottomDock />
|
2025-12-02 16:22:46 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 新增记录底部弹窗:在任意 Tab 上浮层显示 -->
|
|
|
|
|
|
<AddEntryView v-if="uiStore.addEntryVisible" />
|
2025-11-24 17:23:46 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|