Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
miuss committed Dec 5, 2024
1 parent 954e706 commit 9878b96
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -215,6 +215,8 @@ const handleDeleteHost = async () => {
"name": deleteHostName.value
})
window.localStorage.setItem('auth_secret', authSecret.value)
Message.success('删除成功')
deleteVisible.value = false
Expand Down Expand Up @@ -260,7 +262,7 @@ const handleShowEdit = (name) => {
seller.value = ''
price.value = ''
editVisible.value = true
authSecret.value = ''
authSecret.value = window.localStorage.getItem('auth_secret') || ''
return
}
Expand All @@ -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,
Expand All @@ -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('更新失败,管理密钥错误')
Expand Down Expand Up @@ -364,7 +370,7 @@ provide('handleChangeType', handleChangeType)
</div>
<div class="uptime" style="width: 120px;">
<div class="monitor-item-title">剩余时间</div>
<div class="monitor-item-value">{{hostInfo[item.Host.Name] ? calculateRemainingDays(hostInfo[item.Host.Name].due_time) + '天' : '-'}}</div>
<div class="monitor-item-value">{{hostInfo[item.Host.Name] ? calculateRemainingDays(hostInfo[item.Host.Name].due_time) : '-'}}</div>
</div>
<div class="uptime">
<div class="monitor-item-title">上报时间</div>
Expand Down Expand Up @@ -443,7 +449,7 @@ provide('handleChangeType', handleChangeType)
</div>
<div class="detail-item" v-if="hostInfo[item.Host.Name]">
<div class="name">到期时间</div>
<div class="value">{{moment(hostInfo[item.Host.Name].due_time).format('YYYY-MM-DD')}}</div>
<div class="value">{{hostInfo[item.Host.Name].due_time ? moment(hostInfo[item.Host.Name].due_time).format('YYYY-MM-DD') : '-'}}</div>
</div>
<div class="detail-item" v-if="hostInfo[item.Host.Name]">
<div class="name">购买链接</div>
Expand Down Expand Up @@ -489,7 +495,7 @@ provide('handleChangeType', handleChangeType)
</a-button>
</div>
<div class="akile-modal-content">
<a-input v-model="authSecret" placeholder="请输入管理密钥"></a-input>
<a-input-password v-model="authSecret" placeholder="请输入管理密钥"></a-input-password>
<div class="tips">提示:删除后无法恢复,请确定后再删除操作</div>
</div>
<div class="akile-modal-action">
Expand All @@ -510,7 +516,7 @@ provide('handleChangeType', handleChangeType)
<a-input v-model="seller" placeholder="请输入卖家" style="margin-bottom: 10px;"></a-input>
<a-input v-model="price" placeholder="请输入价格" style="margin-bottom: 10px;"></a-input>
<a-input v-model="buy_url" placeholder="请输入购买链接" style="margin-bottom: 10px;"></a-input>
<a-input v-model="authSecret" placeholder="请输入管理密钥"></a-input>
<a-input-password v-model="authSecret" placeholder="请输入管理密钥"></a-input-password>
</div>
<div class="akile-modal-action">
<a-button type="primary" :long="true" @click="handleEditHost">更新信息</a-button>
Expand Down
6 changes: 4 additions & 2 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 9878b96

Please sign in to comment.