fix(system): app update notify

This commit is contained in:
Timi
2026-11-13 16:50:16 +08:00
parent 3e2e8ece49
commit af1c95c8dd
3 changed files with 26 additions and 41 deletions
-3
View File
@@ -7,7 +7,6 @@
title="客户" title="客户"
> >
<template #right> <template #right>
<app-update-button />
<navbar-notify-button /> <navbar-notify-button />
</template> </template>
</t-navbar> </t-navbar>
@@ -32,7 +31,6 @@
<store-overview ref="storeOverviewRef" compact /> <store-overview ref="storeOverviewRef" compact />
</template> </template>
<template #right-actions> <template #right-actions>
<app-update-button />
<navbar-notify-button /> <navbar-notify-button />
</template> </template>
<template #right> <template #right>
@@ -55,7 +53,6 @@ import { useLayout } from "timi-tdesign-mobile";
import PendingNoticeBar from "./component/PendingNoticeBar.vue"; import PendingNoticeBar from "./component/PendingNoticeBar.vue";
import CustomerEntryPanel from "./component/CustomerEntryPanel.vue"; import CustomerEntryPanel from "./component/CustomerEntryPanel.vue";
import NavbarNotifyButton from "./component/NavbarNotifyButton.vue"; import NavbarNotifyButton from "./component/NavbarNotifyButton.vue";
import AppUpdateButton from "./component/AppUpdateButton.vue";
import StoreOverview from "./component/StoreOverview.vue"; import StoreOverview from "./component/StoreOverview.vue";
import TabSplitView from "./component/TabSplitView.vue"; import TabSplitView from "./component/TabSplitView.vue";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
@@ -1,32 +0,0 @@
<template>
<t-button
v-if="visible"
aria-label="有新版本"
@click="router.push('/management/settings')"
theme="default"
shape="square"
variant="text"
size="small"
>
<t-badge dot :offset="[-4, 4]">
<t-icon name="download" size="1.25rem" />
</t-badge>
</t-button>
</template>
<script setup lang="ts">
import { useAppUpdate } from "@/composables/useAppUpdate";
defineOptions({
name: "AppUpdateButton"
});
const router = useRouter();
const { supported, latest, autoUpdate, hasUpdate } = useAppUpdate();
// 只在有更新且未开启自动更新时出现,开启自动更新后由启动弹窗负责提醒
const visible = computed(() => {
void latest.value;
return supported && hasUpdate() && !autoUpdate.value;
});
</script>
+26 -6
View File
@@ -1,13 +1,14 @@
<template> <template>
<t-notice-bar <t-notice-bar
v-if="noticeContent.length" v-if="noticeList.length"
:key="noticeContent.join(',')" :key="noticeContent.join(',')"
class="pending-notice" class="pending-notice"
theme="warning" theme="warning"
:visible="true" :visible="true"
direction="vertical" direction="vertical"
:interval="4000"
:content="1 < noticeContent.length ? noticeContent : noticeContent[0]" :content="1 < noticeContent.length ? noticeContent : noticeContent[0]"
@change="currentIndex = $event" @change="handleChange"
@click="openNotice" @click="openNotice"
> >
<template #suffix-icon> <template #suffix-icon>
@@ -17,17 +18,32 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useAppUpdate } from "@/composables/useAppUpdate";
import { usePendingNoticeStore } from "@/store/pendingNoticeStore"; import { usePendingNoticeStore } from "@/store/pendingNoticeStore";
const pendingNoticeStore = usePendingNoticeStore(); const pendingNoticeStore = usePendingNoticeStore();
const router = useRouter(); const router = useRouter();
const currentIndex = ref(0); const { supported, latest, autoUpdate, hasUpdate } = useAppUpdate();
const noticeContent = computed(() => pendingNoticeStore.pendingNoticeList.map(notice => notice.content)); const noticeList = computed(() => {
const notices = [...pendingNoticeStore.pendingNoticeList];
if (supported && !autoUpdate.value && hasUpdate() && latest.value) {
notices.push({ content: `有可用新版本 v${latest.value.version} 更新`, name: "AppUpdate", query: {} });
}
return notices;
});
const noticeContent = computed(() => noticeList.value.map(notice => notice.content));
let currentIndex = 0;
watch(noticeContent, () => { currentIndex.value = 0; }); watch(noticeContent, () => {
currentIndex = 0;
});
function handleChange(index: number): void {
currentIndex = index;
}
async function openNotice(): Promise<void> { async function openNotice(): Promise<void> {
const notice = pendingNoticeStore.pendingNoticeList[currentIndex.value]; const notice = noticeList.value[currentIndex];
if (notice) { if (notice) {
await router.push({ name: notice.name, query: notice.query }); await router.push({ name: notice.name, query: notice.query });
} }
@@ -38,6 +54,10 @@ async function openNotice(): Promise<void> {
.pending-notice { .pending-notice {
margin-top: -1rem; margin-top: -1rem;
:deep(.t-swiper__container) {
transition-duration: .5s !important;
}
:deep(.t-swiper-nav__dots) { :deep(.t-swiper-nav__dots) {
display: none; display: none;
} }