mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
feat(changelog): allow disabling automatic popup
This commit is contained in:
1 parent
b12018b916
commit
b002fbebec
5 files changed
+25
-4
No files matched your search
@@ -36,6 +36,8 @@ const hoveredVersion = ref<string | null>(null)
|
||||
const currentAppVersion = ref<string | null>(null)
|
||||
|
||||
const CHANGELOG_READ_KEY = 'chatlab_changelog_read_version'
|
||||
const CHANGELOG_AUTO_OPEN_DISABLED_KEY = 'chatlab_changelog_auto_open_disabled'
|
||||
const autoOpenDisabled = ref(false)
|
||||
|
||||
// summary 的白名单配置(可按需扩展)
|
||||
const SUMMARY_SANITIZE_OPTIONS = {
|
||||
@@ -132,6 +134,8 @@ function markVersionAsRead(version: string) {
|
||||
// 检查是否需要显示新版本日志(冷启动时自动检查)
|
||||
async function checkNewVersion() {
|
||||
try {
|
||||
if (localStorage.getItem(CHANGELOG_AUTO_OPEN_DISABLED_KEY) === '1') return
|
||||
|
||||
// 1. 获取当前软件版本号
|
||||
const rawVersion = await usePlatformService().getVersion()
|
||||
const currentVersion = normalizeChangelogVersion(rawVersion)
|
||||
@@ -188,6 +192,7 @@ async function checkNewVersion() {
|
||||
|
||||
// 手动打开弹窗(用户点击时调用),会自动获取数据
|
||||
async function open() {
|
||||
autoOpenDisabled.value = localStorage.getItem(CHANGELOG_AUTO_OPEN_DISABLED_KEY) === '1'
|
||||
// 手动打开也标记当前版本,避免标签缺失
|
||||
try {
|
||||
currentAppVersion.value = normalizeChangelogVersion(await usePlatformService().getVersion())
|
||||
@@ -204,6 +209,7 @@ async function open() {
|
||||
|
||||
// 使用预设数据打开弹窗(自动检查新版本时调用)
|
||||
function openWithData(data: ChangelogItem[], appVersion?: string) {
|
||||
autoOpenDisabled.value = localStorage.getItem(CHANGELOG_AUTO_OPEN_DISABLED_KEY) === '1'
|
||||
changelogs.value = data
|
||||
currentAppVersion.value = appVersion || null
|
||||
expandedState.value.clear() // 重置展开状态
|
||||
@@ -214,6 +220,12 @@ function close() {
|
||||
showModal.value = false
|
||||
}
|
||||
|
||||
function disableAutomaticOpen() {
|
||||
localStorage.setItem(CHANGELOG_AUTO_OPEN_DISABLED_KEY, '1')
|
||||
autoOpenDisabled.value = true
|
||||
close()
|
||||
}
|
||||
|
||||
// 获取最新版本号(供外部使用)
|
||||
function getLatestVersion() {
|
||||
return changelogs.value[0]?.version || null
|
||||
@@ -379,14 +391,19 @@ defineExpose({ open, openWithData, close, fetchChangelogs, getLatestVersion, che
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="border-t border-gray-200 px-6 py-4 dark:border-gray-700">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<p v-if="changelogs.length > 0" class="text-sm text-gray-500 dark:text-gray-400">
|
||||
{{ t('home.changelog.total', { count: changelogs.length }) }}
|
||||
</p>
|
||||
<span v-else />
|
||||
<UButton color="primary" variant="soft" @click="close">
|
||||
{{ t('home.changelog.close') }}
|
||||
</UButton>
|
||||
<div class="ml-auto flex flex-wrap items-center justify-end gap-2">
|
||||
<UButton v-if="!autoOpenDisabled" color="neutral" variant="ghost" @click="disableAutomaticOpen">
|
||||
{{ t('home.changelog.disableAutoOpen') }}
|
||||
</UButton>
|
||||
<UButton color="primary" variant="soft" @click="close">
|
||||
{{ t('home.changelog.close') }}
|
||||
</UButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"current": "Current",
|
||||
"total": "{count} versions in total",
|
||||
"close": "Close",
|
||||
"disableAutoOpen": "Don't open automatically after updates",
|
||||
"loadError": "Failed to load changelog",
|
||||
"retry": "Retry",
|
||||
"types": {
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"current": "現在のバージョン",
|
||||
"total": "全 {count} バージョン",
|
||||
"close": "閉じる",
|
||||
"disableAutoOpen": "アップデート後に自動表示しない",
|
||||
"loadError": "バージョン履歴の読み込みに失敗しました",
|
||||
"retry": "リトライ",
|
||||
"types": {
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"current": "当前版本",
|
||||
"total": "共 {count} 个版本",
|
||||
"close": "关闭",
|
||||
"disableAutoOpen": "更新后不再自动弹出",
|
||||
"loadError": "加载版本日志失败",
|
||||
"retry": "重试",
|
||||
"types": {
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"current": "目前版本",
|
||||
"total": "共 {count} 個版本",
|
||||
"close": "關閉",
|
||||
"disableAutoOpen": "更新後不再自動顯示",
|
||||
"loadError": "載入更新紀錄失敗",
|
||||
"retry": "重試",
|
||||
"types": {
|
||||
|
||||
Reference in new issue
Block a user