Skip to content

Commit

Permalink
[*]automatic refresh dashboard info
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Jun 2, 2024
1 parent 18e8db7 commit ea98ee9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ setInterval(() => {
)
rs.then((res) => {
if (res.status === 0) {
store.set_user_info(res);
store.commit('set_user_info', res);
// localStorage.setItem('proxies', res.proxies_num)
// localStorage.setItem('traffic', res.traffic)
// localStorage.setItem('set_limit', res)
Expand Down
8 changes: 7 additions & 1 deletion src/utils/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const store = new vuex.Store({
inbound: 0,
outbound: 0,
avatar: '',
traffic: ''
traffic: '',
proxies_num: 0
},
getters: {
get_token(state) {
Expand All @@ -37,6 +38,9 @@ const store = new vuex.Store({
},
get_traffic(state) {
return Number(state.traffic) / 1024 || Number(localStorage.getItem('traffic')) / 1024 || 0
},
get_proxies_num(state) {
return state.proxies_num || localStorage.getItem('proxies_num') || 0
}
},
mutations: {
Expand All @@ -58,13 +62,15 @@ const store = new vuex.Store({
state.outbound = userdata.outbound
state.avatar = userdata.avatar
state.traffic = userdata.traffic
state.proxies_num = userdata.proxies_num
localStorage.setItem('username', userdata.username)
localStorage.setItem('email', userdata.email)
localStorage.setItem('traffic', userdata.traffic)
localStorage.setItem('frptoken', userdata.frp_token)
localStorage.setItem('inbound', userdata.inbound)
localStorage.setItem('outbound', userdata.outbound)
localStorage.setItem('avatar', userdata.avatar)
localStorage.setItem('proxies_num', userdata.proxies_num)
},
set_limit(state, limit_info) {
state.inbound = limit_info.inbound
Expand Down
8 changes: 4 additions & 4 deletions src/views/DashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<a>您的邮箱为:{{ email }}</a>
<br />
<div v-if="DontShowFrptoken">
<n-tag type="info" @click="changeShouFrptoken($event)">
<n-tag type="info" @click="changeShowFrptoken($event)">
<template #icon>
<n-icon :component="Key" />
</template>
Expand Down Expand Up @@ -182,7 +182,7 @@ notice_res.then((res) => {
}
})
async function changeShouFrptoken(event) {
async function changeShowFrptoken(event) {
DontShowFrptoken.value = !DontShowFrptoken.value
clipboard(frptoken, event)
setTimeout(() => {
Expand All @@ -191,7 +191,7 @@ async function changeShouFrptoken(event) {
}
const traffic = ref(Number(localStorage.getItem('traffic')) / 1024 + 'GB')
const Proxiesanimation = ref(Number(localStorage.getItem('proxies')))
const Proxiesanimation = ref(Number(localStorage.getItem('proxies_num')))
const TrafficRef = ref(null)
const boardcast_html = ref('')
const boardcast_show = ref(true)
Expand Down Expand Up @@ -255,7 +255,7 @@ function howtosayhi() {
}
setInterval(() => {
Proxiesanimation.value = Number(localStorage.getItem('proxies'))
Proxiesanimation.value = Number(localStorage.getItem('proxies_num'))
traffic.value = Number(localStorage.getItem('traffic')) / 1024 + 'GB'
inbound.value = store.getters.get_in_bound + 'Mbps 下行'
outbound.value = store.getters.get_out_bound + 'Mbps 上行'
Expand Down

0 comments on commit ea98ee9

Please sign in to comment.