add: app update page
This commit is contained in:
+2
-2
@@ -30,9 +30,9 @@
|
|||||||
"less": "^4.3.0",
|
"less": "^4.3.0",
|
||||||
"pinia": "^3.0.2",
|
"pinia": "^3.0.2",
|
||||||
"tdesign-mobile-vue": "^1.17.1",
|
"tdesign-mobile-vue": "^1.17.1",
|
||||||
"timi-tdesign-mobile": "^1.0.1",
|
"timi-tdesign-mobile": "^1.0.2",
|
||||||
"timi-ts": "^1.0.0",
|
"timi-ts": "^1.0.0",
|
||||||
"timi-web": "^1.0.1",
|
"timi-web": "^1.0.2",
|
||||||
"timi-web-api": "^1.0.2",
|
"timi-web-api": "^1.0.2",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"vconsole": "^3.15.1",
|
"vconsole": "^3.15.1",
|
||||||
|
|||||||
Generated
+16
-15
@@ -47,17 +47,17 @@ importers:
|
|||||||
specifier: ^1.17.1
|
specifier: ^1.17.1
|
||||||
version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-tdesign-mobile:
|
timi-tdesign-mobile:
|
||||||
specifier: ^1.0.1
|
specifier: ^1.0.2
|
||||||
version: 1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3))
|
version: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-ts:
|
timi-ts:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
timi-web:
|
timi-web:
|
||||||
specifier: ^1.0.1
|
specifier: ^1.0.2
|
||||||
version: 1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
version: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-web-api:
|
timi-web-api:
|
||||||
specifier: ^1.0.2
|
specifier: ^1.0.2
|
||||||
version: 1.0.2(timi-web@1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
version: 1.0.2(timi-web@1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||||
ts-node:
|
ts-node:
|
||||||
specifier: ^10.9.2
|
specifier: ^10.9.2
|
||||||
version: 10.9.2(@types/node@24.13.3)(typescript@5.8.3)
|
version: 10.9.2(@types/node@24.13.3)(typescript@5.8.3)
|
||||||
@@ -1979,6 +1979,7 @@ packages:
|
|||||||
image-size@0.5.5:
|
image-size@0.5.5:
|
||||||
resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==}
|
resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
deprecated: Please migrate to image-size@2.x
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
import-fresh@3.3.1:
|
import-fresh@3.3.1:
|
||||||
@@ -2747,8 +2748,8 @@ packages:
|
|||||||
through2@4.0.2:
|
through2@4.0.2:
|
||||||
resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==}
|
resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==}
|
||||||
|
|
||||||
timi-tdesign-mobile@1.0.1:
|
timi-tdesign-mobile@1.0.2:
|
||||||
resolution: {integrity: sha512-HFBENjEw1+zymyaDU7u9ZNZjIqzA8J+9eZHNMGyPd8/zSSsGb9bS1a1r3zDA0Zq7g6WwqQctwaQUO4xkU4gyAw==}
|
resolution: {integrity: sha512-7qjwUUqIjMB9TJbOWguK61JfQ15PLf3gnfUDU1gY2eS4cjbgo/PD2U/eHNV6CZ0VB/hBjPNp84xKZ0qr03tsmw==}
|
||||||
engines: {node: '>=20.0.0'}
|
engines: {node: '>=20.0.0'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.5.0
|
vue: ^3.5.0
|
||||||
@@ -2765,8 +2766,8 @@ packages:
|
|||||||
timi-web: ^1.0.0
|
timi-web: ^1.0.0
|
||||||
vue: ^3.5.26
|
vue: ^3.5.26
|
||||||
|
|
||||||
timi-web@1.0.1:
|
timi-web@1.0.2:
|
||||||
resolution: {integrity: sha512-FVPQuqTc3DurS3Gfty9ZQoNZ7vyQ0v6xj0g/iouFgxFqNuzjzUNn3PA/Tl58nJcRrUNv3S/uofMMkNRmw/cUYg==}
|
resolution: {integrity: sha512-CXyWEeGTjrExnrAwstdWPc3qK5Lfyp7ipD8p7+WYcm4mcnJOS48k6SkVnrAIADAImeJAr/1e5JEV8wk+8AcvxQ==}
|
||||||
engines: {node: '>=20.0.0'}
|
engines: {node: '>=20.0.0'}
|
||||||
|
|
||||||
tinycolor2@1.6.0:
|
tinycolor2@1.6.0:
|
||||||
@@ -3125,7 +3126,7 @@ snapshots:
|
|||||||
'@babel/helper-module-imports@7.29.7':
|
'@babel/helper-module-imports@7.29.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/traverse': 7.29.13
|
'@babel/traverse': 7.29.13
|
||||||
'@babel/types': 7.29.7
|
'@babel/types': 7.29.11
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -5848,10 +5849,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
readable-stream: 3.6.2
|
readable-stream: 3.6.2
|
||||||
|
|
||||||
timi-tdesign-mobile@1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)):
|
timi-tdesign-mobile@1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
tdesign-mobile-vue: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
tdesign-mobile-vue: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-web: 1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
timi-web: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||||
vue: 3.5.40(typescript@5.8.3)
|
vue: 3.5.40(typescript@5.8.3)
|
||||||
vue-router: 4.5.1(vue@3.5.40(typescript@5.8.3))
|
vue-router: 4.5.1(vue@3.5.40(typescript@5.8.3))
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -5864,18 +5865,18 @@ snapshots:
|
|||||||
|
|
||||||
timi-ts@1.0.0: {}
|
timi-ts@1.0.0: {}
|
||||||
|
|
||||||
timi-web-api@1.0.2(timi-web@1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)):
|
timi-web-api@1.0.2(timi-web@1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
axios: 1.21.0
|
axios: 1.21.0
|
||||||
pinia: 3.0.4(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
pinia: 3.0.4(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-web: 1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
timi-web: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||||
vue: 3.5.40(typescript@5.8.3)
|
vue: 3.5.40(typescript@5.8.3)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- debug
|
- debug
|
||||||
- supports-color
|
- supports-color
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
timi-web@1.0.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)):
|
timi-web@1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@marsio/vue-split-pane': 1.0.0(typescript@5.8.3)
|
'@marsio/vue-split-pane': 1.0.0(typescript@5.8.3)
|
||||||
'@tiptap/extension-code-block': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
'@tiptap/extension-code-block': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<section class="brand" v-entrance-transition>
|
<section class="brand" v-entrance-transition>
|
||||||
<logo @click="handleLogoClick" />
|
<logo @click="handleLogoClick" />
|
||||||
<h1 v-text="appName" />
|
<h1 v-text="appName" />
|
||||||
|
<p v-text="`版本 ${displayVersion}`" />
|
||||||
<p v-text="appDescription" />
|
<p v-text="appDescription" />
|
||||||
</section>
|
</section>
|
||||||
<t-cell-group v-if="agreementItemList.length" theme="card" v-entrance-transition>
|
<t-cell-group v-if="agreementItemList.length" theme="card" v-entrance-transition>
|
||||||
@@ -32,6 +33,13 @@
|
|||||||
v-else
|
v-else
|
||||||
:description="isLoading ? '正在加载协议配置' : '暂无可用协议'"
|
:description="isLoading ? '正在加载协议配置' : '暂无可用协议'"
|
||||||
/>
|
/>
|
||||||
|
<t-cell-group v-if="updateSupported" theme="card" v-entrance-transition>
|
||||||
|
<t-cell title="版本更新" arrow hover @click="router.push({ name: 'AppUpdate' })">
|
||||||
|
<template #leftIcon>
|
||||||
|
<t-icon name="download" size="1.75rem" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
<footer class="footer" v-entrance-transition>
|
<footer class="footer" v-entrance-transition>
|
||||||
<p>技术支持:夜雨</p>
|
<p>技术支持:夜雨</p>
|
||||||
<p>联系技术:imyeyu@qq.com</p>
|
<p>联系技术:imyeyu@qq.com</p>
|
||||||
@@ -44,6 +52,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { version } from "../../../package.json";
|
||||||
|
import { useAppUpdate } from "@/composables/useAppUpdate";
|
||||||
import { SettingAPI } from "timi-web-api";
|
import { SettingAPI } from "timi-web-api";
|
||||||
import Logo from "@/pages/user/component/Logo.vue";
|
import Logo from "@/pages/user/component/Logo.vue";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -63,6 +73,8 @@ defineOptions({
|
|||||||
const appName = "糕店客户管理";
|
const appName = "糕店客户管理";
|
||||||
const appDescription = "面向门店的客户、登记、积分与经营管理工具";
|
const appDescription = "面向门店的客户、登记、积分与经营管理工具";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { supported: updateSupported, currentVersion, loadCurrent } = useAppUpdate();
|
||||||
|
const displayVersion = computed(() => currentVersion.value && currentVersion.value !== "builtin" ? currentVersion.value : version);
|
||||||
|
|
||||||
const agreementItemList = ref<AgreementItem[]>([]);
|
const agreementItemList = ref<AgreementItem[]>([]);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
@@ -127,7 +139,7 @@ async function loadSettings(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadSettings();
|
await Promise.all([loadSettings(), loadCurrent()]);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -192,3 +204,4 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -51,52 +51,6 @@
|
|||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group v-if="updateSupported" title="版本更新" theme="card" v-entrance-transition>
|
|
||||||
<t-cell title="外壳版本" :note="nativeVersion || '—'" />
|
|
||||||
<t-cell title="系统版本" :note="currentVersion || '—'" />
|
|
||||||
<t-cell v-if="latestVersionText" title="最新版本" :note="latestVersionText" />
|
|
||||||
<t-cell title="自动更新">
|
|
||||||
<template #right-icon>
|
|
||||||
<t-switch :model-value="autoUpdate" @change="handleAutoUpdateChange" />
|
|
||||||
</template>
|
|
||||||
</t-cell>
|
|
||||||
</t-cell-group>
|
|
||||||
<div v-if="updateSupported" class="update-panel" v-entrance-transition>
|
|
||||||
<center-tips v-if="updateHint" v-text="updateHint" />
|
|
||||||
<t-button
|
|
||||||
v-if="updateStage === 'check'"
|
|
||||||
class="cell-button"
|
|
||||||
theme="primary"
|
|
||||||
size="large"
|
|
||||||
:loading="checking"
|
|
||||||
@click="handleCheck"
|
|
||||||
>
|
|
||||||
检查更新
|
|
||||||
</t-button>
|
|
||||||
<t-button
|
|
||||||
v-else-if="updateStage === 'download'"
|
|
||||||
class="cell-button"
|
|
||||||
theme="primary"
|
|
||||||
size="large"
|
|
||||||
@click="handleDownload"
|
|
||||||
>
|
|
||||||
下载更新
|
|
||||||
</t-button>
|
|
||||||
<template v-else-if="updateStage === 'downloading'">
|
|
||||||
<t-progress class="progress" stroke-width=".5rem" :percentage="percent" /> <t-button theme="primary" size="large" block disabled>
|
|
||||||
下载中 {{ percent }}%
|
|
||||||
</t-button>
|
|
||||||
</template>
|
|
||||||
<t-button
|
|
||||||
v-else-if="updateStage === 'apply'"
|
|
||||||
class="cell-button"
|
|
||||||
theme="primary"
|
|
||||||
size="large"
|
|
||||||
@click="handleApply"
|
|
||||||
>
|
|
||||||
现在更新
|
|
||||||
</t-button>
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -106,8 +60,6 @@ import type { ThemeMode } from "@/store/globalUI";
|
|||||||
import { useGlobalUIStore } from "@/store/globalUI";
|
import { useGlobalUIStore } from "@/store/globalUI";
|
||||||
import SegmentedSlider from "@/components/SegmentedSlider.vue";
|
import SegmentedSlider from "@/components/SegmentedSlider.vue";
|
||||||
import { useSettingStore } from "@/store/settingStore";
|
import { useSettingStore } from "@/store/settingStore";
|
||||||
import { setAutoUpdate, useAppUpdate } from "@/composables/useAppUpdate";
|
|
||||||
import { Message } from "@/utils/message";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "AppSettings"
|
name: "AppSettings"
|
||||||
@@ -164,97 +116,7 @@ async function playSettingSoundPreview(type: "scanSuccess" | "registerSuccess"):
|
|||||||
await settingStore.playRegisterSuccessSound();
|
await settingStore.playRegisterSuccessSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 版本更新 ----------
|
|
||||||
|
|
||||||
const {
|
|
||||||
supported: updateSupported,
|
|
||||||
currentVersion,
|
|
||||||
nativeVersion,
|
|
||||||
latest,
|
|
||||||
checking,
|
|
||||||
downloading,
|
|
||||||
percent,
|
|
||||||
ready,
|
|
||||||
error: updateError,
|
|
||||||
autoUpdate,
|
|
||||||
loadCurrent,
|
|
||||||
check,
|
|
||||||
hasUpdate,
|
|
||||||
download,
|
|
||||||
apply,
|
|
||||||
restorePending
|
|
||||||
} = useAppUpdate();
|
|
||||||
|
|
||||||
/** 有更新时展示目标版本号 */
|
|
||||||
const latestVersionText = computed<string>(() => (hasUpdate() ? `v${latest.value?.version ?? ""}` : ""));
|
|
||||||
|
|
||||||
/** 当前所处的更新阶段 */
|
|
||||||
const updateStage = computed<"check" | "download" | "downloading" | "apply">(() => {
|
|
||||||
if (downloading.value) {
|
|
||||||
return "downloading";
|
|
||||||
}
|
|
||||||
if (ready.value) {
|
|
||||||
return "apply";
|
|
||||||
}
|
|
||||||
if (latest.value && hasUpdate()) {
|
|
||||||
return "download";
|
|
||||||
}
|
|
||||||
return "check";
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 阶段说明文案 */
|
|
||||||
const updateHint = computed<string>(() => {
|
|
||||||
if (!updateSupported) {
|
|
||||||
return "仅在 App 内可用";
|
|
||||||
}
|
|
||||||
if (ready.value) {
|
|
||||||
return `v${ready.value.version} 已下载,点击下方按钮重启生效`;
|
|
||||||
}
|
|
||||||
if (latest.value && hasUpdate()) {
|
|
||||||
return `发现新版本 v${latest.value.version}`;
|
|
||||||
}
|
|
||||||
if (latest.value && !checking.value) {
|
|
||||||
return "当前已是最新版本";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
await loadCurrent();
|
|
||||||
await restorePending();
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleAutoUpdateChange(value: boolean | string | number): void {
|
|
||||||
setAutoUpdate(value === true);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleCheck(): Promise<void> {
|
|
||||||
const result = await check();
|
|
||||||
if (!result) {
|
|
||||||
Message.error(updateError.value || "检查更新失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!hasUpdate()) {
|
|
||||||
Message.info("已是最新版本");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleDownload(): Promise<void> {
|
|
||||||
const bundle = await download();
|
|
||||||
if (!bundle) {
|
|
||||||
Message.error(updateError.value || "下载失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Message.success(`v${bundle.version} 已下载`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleApply(): Promise<void> {
|
|
||||||
const bundle = ready.value;
|
|
||||||
if (!bundle) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await apply(bundle);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -291,15 +153,6 @@ async function handleApply(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.update-panel {
|
|
||||||
gap: .75rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.progress {
|
|
||||||
margin: 0 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
:global(html.theme-dark) {
|
||||||
@@ -307,10 +160,6 @@ async function handleApply(): Promise<void> {
|
|||||||
.volume-field span {
|
.volume-field span {
|
||||||
color: #94a3b8;
|
color: #94a3b8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.update-hint {
|
|
||||||
color: #94a3b8;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tui-page-layout tui-navbar">
|
||||||
|
<t-navbar fixed :z-index="20" title="版本更新" left-arrow @left-click="$router.back()" />
|
||||||
|
<main class="tui-page-content scroll column">
|
||||||
|
<center-tips v-if="!updateSupported" content="仅在 App 内可用" />
|
||||||
|
<t-cell-group v-if="updateSupported" title="版本更新" theme="card" v-entrance-transition>
|
||||||
|
<t-cell title="外壳版本" :note="nativeVersion || '—'" />
|
||||||
|
<t-cell title="系统版本" :note="currentVersion || '—'" />
|
||||||
|
<t-cell v-if="latestVersionText" title="最新版本" :note="latestVersionText" />
|
||||||
|
<t-cell title="自动更新">
|
||||||
|
<template #right-icon>
|
||||||
|
<t-switch :model-value="autoUpdate" @change="handleAutoUpdateChange" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<div v-if="updateSupported" class="update-panel" v-entrance-transition>
|
||||||
|
<center-tips v-if="updateHint"><span v-text="updateHint" /></center-tips>
|
||||||
|
<t-button
|
||||||
|
v-if="updateStage === 'check'"
|
||||||
|
class="cell-button"
|
||||||
|
theme="primary"
|
||||||
|
size="large"
|
||||||
|
:loading="checking"
|
||||||
|
@click="handleCheck"
|
||||||
|
>
|
||||||
|
检查更新
|
||||||
|
</t-button>
|
||||||
|
<t-button
|
||||||
|
v-else-if="updateStage === 'download'"
|
||||||
|
class="cell-button"
|
||||||
|
theme="primary"
|
||||||
|
size="large"
|
||||||
|
@click="handleDownload"
|
||||||
|
>
|
||||||
|
下载更新
|
||||||
|
</t-button>
|
||||||
|
<template v-else-if="updateStage === 'downloading'">
|
||||||
|
<t-progress class="progress" stroke-width=".5rem" :percentage="percent" />
|
||||||
|
<t-button theme="primary" size="large" block disabled>
|
||||||
|
<span v-text="`下载中 ${percent}%`" />
|
||||||
|
</t-button>
|
||||||
|
</template>
|
||||||
|
<t-button
|
||||||
|
v-else-if="updateStage === 'apply'"
|
||||||
|
class="cell-button"
|
||||||
|
theme="primary"
|
||||||
|
size="large"
|
||||||
|
@click="handleApply"
|
||||||
|
>
|
||||||
|
现在更新
|
||||||
|
</t-button>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { setAutoUpdate, useAppUpdate } from "@/composables/useAppUpdate";
|
||||||
|
import { Message } from "@/utils/message";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "AppUpdate"
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------- 版本更新 ----------
|
||||||
|
|
||||||
|
const {
|
||||||
|
supported: updateSupported,
|
||||||
|
currentVersion,
|
||||||
|
nativeVersion,
|
||||||
|
latest,
|
||||||
|
checking,
|
||||||
|
downloading,
|
||||||
|
percent,
|
||||||
|
ready,
|
||||||
|
error: updateError,
|
||||||
|
autoUpdate,
|
||||||
|
loadCurrent,
|
||||||
|
check,
|
||||||
|
hasUpdate,
|
||||||
|
download,
|
||||||
|
apply,
|
||||||
|
restorePending
|
||||||
|
} = useAppUpdate();
|
||||||
|
|
||||||
|
/** 有更新时展示目标版本号 */
|
||||||
|
const latestVersionText = computed<string>(() => (hasUpdate() ? `v${latest.value?.version ?? ""}` : ""));
|
||||||
|
|
||||||
|
/** 当前所处的更新阶段 */
|
||||||
|
const updateStage = computed<"check" | "download" | "downloading" | "apply">(() => {
|
||||||
|
if (downloading.value) {
|
||||||
|
return "downloading";
|
||||||
|
}
|
||||||
|
if (ready.value) {
|
||||||
|
return "apply";
|
||||||
|
}
|
||||||
|
if (latest.value && hasUpdate()) {
|
||||||
|
return "download";
|
||||||
|
}
|
||||||
|
return "check";
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 阶段说明文案 */
|
||||||
|
const updateHint = computed<string>(() => {
|
||||||
|
if (!updateSupported) {
|
||||||
|
return "仅在 App 内可用";
|
||||||
|
}
|
||||||
|
if (ready.value) {
|
||||||
|
return `v${ready.value.version} 已下载,点击下方按钮重启生效`;
|
||||||
|
}
|
||||||
|
if (latest.value && hasUpdate()) {
|
||||||
|
return `发现新版本 v${latest.value.version}`;
|
||||||
|
}
|
||||||
|
if (latest.value && !checking.value) {
|
||||||
|
return "当前已是最新版本";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadCurrent();
|
||||||
|
await restorePending();
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleAutoUpdateChange(value: boolean | string | number): void {
|
||||||
|
setAutoUpdate(value === true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCheck(): Promise<void> {
|
||||||
|
const result = await check();
|
||||||
|
if (!result) {
|
||||||
|
Message.error(updateError.value || "检查更新失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!hasUpdate()) {
|
||||||
|
Message.info("已是最新版本");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDownload(): Promise<void> {
|
||||||
|
const bundle = await download();
|
||||||
|
if (!bundle) {
|
||||||
|
Message.error(updateError.value || "下载失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Message.success(`v${bundle.version} 已下载`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleApply(): Promise<void> {
|
||||||
|
const bundle = ready.value;
|
||||||
|
if (!bundle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await apply(bundle);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.update-panel {
|
||||||
|
gap: .75rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
margin: 0 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
@@ -137,6 +137,17 @@ export const managementSettingRoutes: RouteRecordRaw[] = [
|
|||||||
darkBodyBackground: "#10161f"
|
darkBodyBackground: "#10161f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/management/about/update",
|
||||||
|
name: "AppUpdate",
|
||||||
|
component: () => import("@/pages/setting/AppUpdate.vue"),
|
||||||
|
meta: {
|
||||||
|
depth: 4,
|
||||||
|
tabBarVisible: false,
|
||||||
|
bodyBackground: "#F5F5F8",
|
||||||
|
darkBodyBackground: "#10161f"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/management/about/agreement/:id",
|
path: "/management/about/agreement/:id",
|
||||||
name: "Agreement",
|
name: "Agreement",
|
||||||
|
|||||||
Reference in New Issue
Block a user