From 9878b96ee774ed47069338cefb4f01b26fc3ef40 Mon Sep 17 00:00:00 2001 From: Miuss Date: Thu, 5 Dec 2024 20:19:08 +0800 Subject: [PATCH] update --- src/App.vue | 24 +++++++++++++++--------- src/utils/utils.js | 6 ++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/App.vue b/src/App.vue index 5c0e06d..471de58 100644 --- a/src/App.vue +++ b/src/App.vue @@ -203,7 +203,7 @@ const authSecret = ref('') const deleteHostName = ref('') const handleShowDelete = (name) => { - authSecret.value = '' + authSecret.value = window.localStorage.getItem('auth_secret') || '' deleteHostName.value = name deleteVisible.value = true } @@ -215,6 +215,8 @@ const handleDeleteHost = async () => { "name": deleteHostName.value }) + window.localStorage.setItem('auth_secret', authSecret.value) + Message.success('删除成功') deleteVisible.value = false @@ -260,7 +262,7 @@ const handleShowEdit = (name) => { seller.value = '' price.value = '' editVisible.value = true - authSecret.value = '' + authSecret.value = window.localStorage.getItem('auth_secret') || '' return } @@ -270,13 +272,13 @@ const handleShowEdit = (name) => { seller.value = hostInfo.value[name].seller price.value = hostInfo.value[name].price editVisible.value = true - authSecret.value = '' + authSecret.value = window.localStorage.getItem('auth_secret') || '' } -const handleEditHost = () => { +const handleEditHost = async () => { try { - axios.post(apiURL.value + '/info', { + await axios.post(apiURL.value + '/info', { "name": editHostName.value, "due_time": new Date(duetime.value).getTime(), "buy_url": buy_url.value, @@ -285,8 +287,12 @@ const handleEditHost = () => { "price": price.value }) + window.localStorage.setItem('auth_secret', authSecret.value) + Message.success('更新成功') + handleFetchHostInfo() + editVisible.value = false } catch (e) { Message.error('更新失败,管理密钥错误') @@ -364,7 +370,7 @@ provide('handleChangeType', handleChangeType)
剩余时间
-
{{hostInfo[item.Host.Name] ? calculateRemainingDays(hostInfo[item.Host.Name].due_time) + '天' : '-'}}
+
{{hostInfo[item.Host.Name] ? calculateRemainingDays(hostInfo[item.Host.Name].due_time) : '-'}}
上报时间
@@ -443,7 +449,7 @@ provide('handleChangeType', handleChangeType)
到期时间
-
{{moment(hostInfo[item.Host.Name].due_time).format('YYYY-MM-DD')}}
+
{{hostInfo[item.Host.Name].due_time ? moment(hostInfo[item.Host.Name].due_time).format('YYYY-MM-DD') : '-'}}
购买链接
@@ -489,7 +495,7 @@ provide('handleChangeType', handleChangeType)
- +
提示:删除后无法恢复,请确定后再删除操作
@@ -510,7 +516,7 @@ provide('handleChangeType', handleChangeType) - +
更新信息 diff --git a/src/utils/utils.js b/src/utils/utils.js index a79d938..0caf457 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -11,11 +11,13 @@ export const formatBytes = (bytes) => { // 计算剩余天数的函数 export const calculateRemainingDays = (expireTime) => { - if (!expireTime) return null + if (!expireTime) { + return '-' + } const expireDate = new Date(expireTime) const today = new Date() const diffTime = expireDate - today - return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + '天' } export const formatBandwithBytes = (bytes) => {