todo
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 28s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 28s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="page-container-flex">
|
||||
<van-nav-bar
|
||||
title="设置"
|
||||
@@ -115,6 +115,12 @@
|
||||
is-link
|
||||
@click="handleScheduledTasks"
|
||||
/>
|
||||
<van-cell
|
||||
title="切换版本"
|
||||
is-link
|
||||
:value="versionStore.currentVersion.toUpperCase()"
|
||||
@click="handleVersionSwitch"
|
||||
/>
|
||||
</van-cell-group>
|
||||
|
||||
<div
|
||||
@@ -139,14 +145,16 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showLoadingToast, showSuccessToast, showToast, closeToast, showConfirmDialog } from 'vant'
|
||||
import { showLoadingToast, showSuccessToast, showToast, closeToast, showConfirmDialog, showDialog } from 'vant'
|
||||
import { uploadBillFile } from '@/api/billImport'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useVersionStore } from '@/stores/version'
|
||||
import { getVapidPublicKey, subscribe, testNotification } from '@/api/notification'
|
||||
import { updateServiceWorker } from '@/registerServiceWorker'
|
||||
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
const versionStore = useVersionStore()
|
||||
const fileInputRef = ref(null)
|
||||
const currentType = ref('')
|
||||
const notificationEnabled = ref(false)
|
||||
@@ -381,6 +389,64 @@ const handleReloadFromNetwork = async () => {
|
||||
const handleScheduledTasks = () => {
|
||||
router.push({ name: 'scheduled-tasks' })
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理版本切换
|
||||
*/
|
||||
const handleVersionSwitch = async () => {
|
||||
try {
|
||||
await showDialog({
|
||||
title: '选择版本',
|
||||
message: '请选择要使用的版本',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'V2',
|
||||
cancelButtonText: 'V1'
|
||||
}).then(() => {
|
||||
// 选择 V2
|
||||
versionStore.setVersion('v2')
|
||||
showSuccessToast('已切换到 V2')
|
||||
// 尝试跳转到当前路由的 V2 版本
|
||||
redirectToVersionRoute()
|
||||
}).catch(() => {
|
||||
// 选择 V1
|
||||
versionStore.setVersion('v1')
|
||||
showSuccessToast('已切换到 V1')
|
||||
// 尝试跳转到当前路由的 V1 版本
|
||||
redirectToVersionRoute()
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('版本切换失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前版本重定向路由
|
||||
*/
|
||||
const redirectToVersionRoute = () => {
|
||||
const currentRoute = router.currentRoute.value
|
||||
const currentRouteName = currentRoute.name
|
||||
|
||||
if (versionStore.isV2()) {
|
||||
// 尝试跳转到 V2 路由
|
||||
const v2RouteName = `${currentRouteName}-v2`
|
||||
const v2Route = router.getRoutes().find(route => route.name === v2RouteName)
|
||||
|
||||
if (v2Route) {
|
||||
router.push({ name: v2RouteName })
|
||||
}
|
||||
// 如果没有 V2 路由,保持当前路由
|
||||
} else {
|
||||
// V1 版本:如果当前在 V2 路由,跳转到 V1
|
||||
if (currentRouteName && currentRouteName.toString().endsWith('-v2')) {
|
||||
const v1RouteName = currentRouteName.toString().replace(/-v2$/, '')
|
||||
const v1Route = router.getRoutes().find(route => route.name === v1RouteName)
|
||||
|
||||
if (v1Route) {
|
||||
router.push({ name: v1RouteName })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user