mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
fix: 更新站点 Cookie 处理逻辑,添加请求失败提示,优化服务工作者缓存策略
This commit is contained in:
@@ -50,23 +50,34 @@ async function updateSiteCookie() {
|
|||||||
progressDialog.value = true
|
progressDialog.value = true
|
||||||
progressText.value = t('dialog.siteCookieUpdate.updating', { site: cardProps.site?.name })
|
progressText.value = t('dialog.siteCookieUpdate.updating', { site: cardProps.site?.name })
|
||||||
|
|
||||||
const result: { [key: string]: any } = await api.get(`site/cookie/${cardProps.site?.id}`, {
|
const result: { [key: string]: any } = await api.post(`site/cookie/${cardProps.site?.id}`, {
|
||||||
params: {
|
username: userPwForm.value.username,
|
||||||
username: userPwForm.value.username,
|
password: userPwForm.value.password,
|
||||||
password: userPwForm.value.password,
|
code: userPwForm.value.code,
|
||||||
code: userPwForm.value.code,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success(t('dialog.siteCookieUpdate.success', { site: cardProps.site?.name }))
|
$toast.success(t('dialog.siteCookieUpdate.success', { site: cardProps.site?.name }))
|
||||||
emit('done')
|
emit('done')
|
||||||
} else $toast.error(t('dialog.siteCookieUpdate.failed', { site: cardProps.site?.name, message: result.message }))
|
} else {
|
||||||
|
$toast.error(
|
||||||
|
t('dialog.siteCookieUpdate.failed', {
|
||||||
|
site: cardProps.site?.name,
|
||||||
|
message: result.message || t('dialog.siteCookieUpdate.requestFailed'),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error(error)
|
||||||
|
const detail = error?.response?.data?.detail
|
||||||
|
const message =
|
||||||
|
error?.response?.data?.message ||
|
||||||
|
(typeof detail === 'string' ? detail : error?.message) ||
|
||||||
|
t('dialog.siteCookieUpdate.requestFailed')
|
||||||
|
$toast.error(t('dialog.siteCookieUpdate.failed', { site: cardProps.site?.name, message }))
|
||||||
|
} finally {
|
||||||
progressDialog.value = false
|
progressDialog.value = false
|
||||||
updateButtonDisable.value = false
|
updateButtonDisable.value = false
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2452,6 +2452,7 @@ export default {
|
|||||||
updating: 'Updating {site} Cookie & UA...',
|
updating: 'Updating {site} Cookie & UA...',
|
||||||
success: '{site} Cookie & UA updated successfully!',
|
success: '{site} Cookie & UA updated successfully!',
|
||||||
failed: '{site} update failed: {message}',
|
failed: '{site} update failed: {message}',
|
||||||
|
requestFailed: 'Request failed, please try again later',
|
||||||
updateButton: 'Start Update',
|
updateButton: 'Start Update',
|
||||||
},
|
},
|
||||||
siteAddEdit: {
|
siteAddEdit: {
|
||||||
|
|||||||
@@ -2406,6 +2406,7 @@ export default {
|
|||||||
updating: '正在更新 {site} Cookie & UA...',
|
updating: '正在更新 {site} Cookie & UA...',
|
||||||
success: '{site} 更新Cookie & UA成功!',
|
success: '{site} 更新Cookie & UA成功!',
|
||||||
failed: '{site} 更新失败:{message}',
|
failed: '{site} 更新失败:{message}',
|
||||||
|
requestFailed: '请求失败,请稍后重试',
|
||||||
updateButton: '开始更新',
|
updateButton: '开始更新',
|
||||||
},
|
},
|
||||||
siteAddEdit: {
|
siteAddEdit: {
|
||||||
|
|||||||
@@ -2407,6 +2407,7 @@ export default {
|
|||||||
updating: '正在更新 {site} Cookie & UA...',
|
updating: '正在更新 {site} Cookie & UA...',
|
||||||
success: '{site} 更新Cookie & UA成功!',
|
success: '{site} 更新Cookie & UA成功!',
|
||||||
failed: '{site} 更新失敗:{message}',
|
failed: '{site} 更新失敗:{message}',
|
||||||
|
requestFailed: '請求失敗,請稍後重試',
|
||||||
updateButton: '開始更新',
|
updateButton: '開始更新',
|
||||||
},
|
},
|
||||||
siteAddEdit: {
|
siteAddEdit: {
|
||||||
|
|||||||
@@ -148,13 +148,16 @@ registerRoute(
|
|||||||
url.pathname.includes('/api/v1/') &&
|
url.pathname.includes('/api/v1/') &&
|
||||||
request.method === 'GET' &&
|
request.method === 'GET' &&
|
||||||
!url.pathname.includes('/api/v1/search/') && // 搜索接口结果动态变化,避免缓存导致重复搜索失效
|
!url.pathname.includes('/api/v1/search/') && // 搜索接口结果动态变化,避免缓存导致重复搜索失效
|
||||||
|
!url.pathname.includes('/api/v1/site/cookie/') && // 站点 Cookie 更新是副作用请求,不能缓存
|
||||||
!url.pathname.includes('/api/v1/system/message') && // SSE实时消息流
|
!url.pathname.includes('/api/v1/system/message') && // SSE实时消息流
|
||||||
!url.pathname.includes('/api/v1/system/progress/') && // SSE实时进度流
|
!url.pathname.includes('/api/v1/system/progress/') && // SSE实时进度流
|
||||||
!url.pathname.includes('/api/v1/system/logging') && // SSE实时日志流
|
!url.pathname.includes('/api/v1/system/logging') && // SSE实时日志流
|
||||||
!url.pathname.includes('/api/v1/message/') && // 用户消息接口
|
!url.pathname.includes('/api/v1/message/') && // 用户消息接口
|
||||||
!url.pathname.includes('/api/v1/system/global') && // 系统配置接口
|
!url.pathname.includes('/api/v1/system/global') && // 系统配置接口
|
||||||
!url.pathname.includes('/api/v1/mfa/') && // 多因素认证接口
|
!url.pathname.includes('/api/v1/mfa/') && // 多因素认证接口
|
||||||
!url.pathname.includes('/api/v1/dashboard/'), // Dashboard实时监控数据
|
!url.pathname.includes('/api/v1/dashboard/') && // Dashboard实时监控数据
|
||||||
|
!url.pathname.includes('/api/v1/plugin/')&& // 插件接口
|
||||||
|
!url.pathname.includes('/api/v1/subscribe/'), // 订阅接口
|
||||||
new NetworkFirst({
|
new NetworkFirst({
|
||||||
cacheName: `api-cache-${CACHE_VERSION}`,
|
cacheName: `api-cache-${CACHE_VERSION}`,
|
||||||
networkTimeoutSeconds: 5,
|
networkTimeoutSeconds: 5,
|
||||||
|
|||||||
Reference in New Issue
Block a user