mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-28 19:47:49 +08:00
feat(aboutDialog): 添加清除缓存按钮
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { formatDateDifference } from '@/@core/utils/formatters'
|
import { formatDateDifference } from '@/@core/utils/formatters'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
|
import { clearCachesAndServiceWorker } from '@/composables/useVersionChecker'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useDisplay } from 'vuetify'
|
import { useDisplay } from 'vuetify'
|
||||||
|
|
||||||
@@ -120,6 +121,13 @@ function releaseTime(releaseDate: string) {
|
|||||||
return formatDateDifference(releaseDate)
|
return formatDateDifference(releaseDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 强制清除缓存
|
||||||
|
async function cleanCache() {
|
||||||
|
await clearCachesAndServiceWorker()
|
||||||
|
// 刷新页面
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
querySystemEnv()
|
querySystemEnv()
|
||||||
queryAllRelease()
|
queryAllRelease()
|
||||||
@@ -181,6 +189,17 @@ onMounted(() => {
|
|||||||
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
|
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
|
||||||
<span class="flex-grow flex flex-row items-center truncate">
|
<span class="flex-grow flex flex-row items-center truncate">
|
||||||
<code class="truncate">{{ appVersion }}</code>
|
<code class="truncate">{{ appVersion }}</code>
|
||||||
|
<VBtn
|
||||||
|
size="x-small"
|
||||||
|
variant="tonal"
|
||||||
|
class="ms-2"
|
||||||
|
@click="cleanCache"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<VIcon icon="mdi-refresh" size="14" />
|
||||||
|
</template>
|
||||||
|
{{ t('setting.about.cleanCache') }}
|
||||||
|
</VBtn>
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,20 +15,9 @@ const needsUpdate = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 版本检查 Composable
|
|
||||||
*
|
|
||||||
* 功能:
|
|
||||||
* - 检查前端版本与服务端版本是否一致
|
|
||||||
* - 检测到版本更新时清除缓存和 Service Worker
|
|
||||||
* - 显示持久化更新通知
|
|
||||||
*/
|
|
||||||
export function useVersionChecker() {
|
|
||||||
const toast = useToast()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清除所有缓存和 Service Worker
|
* 清除所有缓存和 Service Worker
|
||||||
*/
|
*/
|
||||||
const clearCachesAndServiceWorker = async (): Promise<void> => {
|
export const clearCachesAndServiceWorker = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
// 1. 清除所有缓存
|
// 1. 清除所有缓存
|
||||||
if ('caches' in window) {
|
if ('caches' in window) {
|
||||||
@@ -46,7 +35,18 @@ export function useVersionChecker() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[VersionChecker] 清除缓存失败:', error)
|
console.error('[VersionChecker] 清除缓存失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本检查 Composable
|
||||||
|
*
|
||||||
|
* 功能:
|
||||||
|
* - 检查前端版本与服务端版本是否一致
|
||||||
|
* - 检测到版本更新时清除缓存和 Service Worker
|
||||||
|
* - 显示持久化更新通知
|
||||||
|
*/
|
||||||
|
export function useVersionChecker() {
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示版本更新通知(带刷新按钮)
|
* 显示版本更新通知(带刷新按钮)
|
||||||
|
|||||||
@@ -1249,6 +1249,7 @@ export default {
|
|||||||
dataDirectory: '/moviepilot',
|
dataDirectory: '/moviepilot',
|
||||||
expand: 'Expand',
|
expand: 'Expand',
|
||||||
collapse: 'Collapse',
|
collapse: 'Collapse',
|
||||||
|
cleanCache: 'Clear Cache',
|
||||||
},
|
},
|
||||||
system: {
|
system: {
|
||||||
custom: 'Custom',
|
custom: 'Custom',
|
||||||
|
|||||||
@@ -1246,6 +1246,7 @@ export default {
|
|||||||
dataDirectory: '/moviepilot',
|
dataDirectory: '/moviepilot',
|
||||||
expand: '展开',
|
expand: '展开',
|
||||||
collapse: '收起',
|
collapse: '收起',
|
||||||
|
cleanCache: '清除缓存',
|
||||||
},
|
},
|
||||||
system: {
|
system: {
|
||||||
custom: '自定义',
|
custom: '自定义',
|
||||||
|
|||||||
@@ -1234,6 +1234,7 @@ export default {
|
|||||||
dataDirectory: '/moviepilot',
|
dataDirectory: '/moviepilot',
|
||||||
expand: '展開',
|
expand: '展開',
|
||||||
collapse: '收起',
|
collapse: '收起',
|
||||||
|
cleanCache: '清除緩存',
|
||||||
},
|
},
|
||||||
system: {
|
system: {
|
||||||
custom: '自定義',
|
custom: '自定義',
|
||||||
|
|||||||
Reference in New Issue
Block a user