Skip to content

Commit

Permalink
[*] 修复数据写入问题,修改重置流量 API 调用
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Sep 16, 2024
1 parent cd69b50 commit 8a7d6d5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/api/v2/users/reset/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import frp_token from './frp_token'
import password from './password'
import token from './token'
import traffic from './traffic'

export default {
password: password,
token: token,
frp_token: frp_token
frp_token: frp_token,
traffic: traffic
}
12 changes: 12 additions & 0 deletions src/api/v2/users/reset/traffic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import base from '@/api/base'
//@ts-ignore
import { get } from '@/utils/request'

const traffic = async (username: string) => {
const rs = await get(`${base.api_v2_url}/users/reset/traffic`, {
username: username
})
return base.buildResponse(rs)
}

export default traffic
2 changes: 1 addition & 1 deletion src/utils/stores/userData/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default new vuex.Store({
},
// outbound
set_user_outbound(state, outbound) {
state.outbound = stateData.outbound
state.outbound = outbound
localStorage.setItem('outbound', outbound)
},
remove_user_outbound(state) {
Expand Down
16 changes: 13 additions & 3 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ import { AngleRight, Key } from '@vicons/fa'
import userData from '@/utils/stores/userData/store'
import { marked } from 'marked'
import { useDialog, useMessage } from 'naive-ui'
import { startLoadingBar } from '@/utils/loadingbar'
import { startLoadingBar, finishLoadingBar, errorLoadingBar } from '@/utils/loadingbar'
import { sendSuccessMessage, sendErrorMessage } from '@/utils/message'
import api from '@/api'
import logger from '@/utils/logger'
Expand Down Expand Up @@ -331,11 +331,21 @@ async function resetTraffic() {
const data = {
username: userData.getters.get_username
}
const rs = await get('https://api-v2.locyanfrp.cn/api/v2/users/reset/traffic', data)
let rs
try {
rs = await api.v2.users.reset.traffic(data.username)
} catch (e) {
logger.error(e)
sendErrorMessage('请求重置流量失败: ' + e)
}
if (!rs) {
errorLoadingBar()
return
}
if (rs.status === 200) {
message.success('重置成功!')
} else {
message.success('重置失败, API 返回: ' + rs.message)
message.error('重置失败, API 返回: ' + rs.message)
}
finishLoadingBar()
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Donate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
>您可以在该页面放置你的留言,同时你可以保存以下链接便于您修改你的留言(赞助数额小于 3
元留言不公开):
</n-p>
<n-p>https://preview.locyanfrp.cn/donate?out_trade_no={{ trade_no }}</n-p>
<n-p>https://dashboard.locyanfrp.cn/donate?out_trade_no={{ trade_no }}</n-p>
<template #footer>
<n-button @click="showModal = false"> 关闭</n-button>
</template>
Expand Down

0 comments on commit 8a7d6d5

Please sign in to comment.