Skip to content

Commit

Permalink
feat: 删除无用的登录逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Jul 6, 2024
1 parent c9c6e05 commit 891b73b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 125 deletions.
24 changes: 0 additions & 24 deletions frontend/src/pages/admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ export default {
},
value: 2,
displayInnerWindow: '',
avatarUrl: '',
uin: '',
userGroup: 'user',
tab: null,
accounts: [],
filter: {
Expand Down Expand Up @@ -139,31 +136,10 @@ export default {
},
mounted() {
this.tokenLogin()
},
methods: {
tokenLogin() {
this.$axios.get('/v1/account/token-check')
.then(res => {
if (res.data.code === 0) {
this.uin = res.data.data.uin
this.avatarUrl = "http://q1.qlogo.cn/g?b=qq&nk=" + res.data.data.uin + "&s=100"
this.userGroup = res.data.data.user_group
} else {
this.toast('登录失败:' + res.data.msg)
}
})
.catch(err => {
if (err.response.data.code === -1) {
this.$router.push('/auth?hint=请先登录嗷')
return
}
this.toast('登录失败:' + err.response.data.msg)
console.error(err)
})
},
randomColor() {
let colors = ["#FFC107", "#42A5F5", "#9CCC65", "#F06292", "#76FF03", "#9E9E9E", "#8D6E63"]
return colors[Math.floor(Math.random() * 100) % colors.length]
Expand Down
25 changes: 0 additions & 25 deletions frontend/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,6 @@ export default {
},
methods: {
tokenLogin() {
this.$axios.get('/v1/account/token-check')
.then(res => {
if (res.data.code === 0) {
this.uin = res.data.data.uin
this.avatarUrl = "http://q1.qlogo.cn/g?b=qq&nk=" + res.data.data.uin + "&s=100"
this.userGroup = res.data.data.user_group
} else {
this.toast('登录失败:' + res.data.msg)
}
})
.catch(err => {
if (err.response.data.code === -1) {
this.$router.push('/auth?hint=请先登录嗷')
return
}
this.toast('登录失败:' + err.response.data.msg)
console.error(err)
})
},
toast(text, color = 'error') {
this.snackbar.text = text
this.snackbar.color = color
this.snackbar.show = true
},
}
}
</script>
Expand Down
28 changes: 2 additions & 26 deletions frontend/src/pages/post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div style="display: flex; padding: 16px">
<v-dialog max-width="500">
<template v-slot:activator="{ props: activatorProps }">
<img v-bind="activatorProps" :src="avatarUrl" width="50" height="50" style="border-radius: 50%;">
<img v-bind="activatorProps" :src="$store.state.account.avatarUrl" width="50" height="50" style="border-radius: 50%;">
</template>

<template v-slot:default="{ isActive }">
Expand Down Expand Up @@ -94,7 +94,7 @@
</v-dialog>

<div style="display: flex; align-items: center;">
<button v-if="!isPending && uin !== ''" @click="letsPost" class="postbtn"
<button v-if="!isPending && $store.state.account.uin !== 0" @click="letsPost" class="postbtn"
style="margin: 8px; margin-top: 16px">
<span> 投稿
</span>
Expand Down Expand Up @@ -172,18 +172,14 @@ export default {
selected: false
}
],
avatarUrl: '',
uin: '',
loading: false,
showDeleteImageDialog: false,
selectedIndex: -1,
isPending: false,
userGroup: ''
}
},
mounted() {
this.tokenLogin()
this.getPosts()
this.$store.commit('initMetadata', 'banner')
this.$store.commit('initMetadata', 'brand')
Expand Down Expand Up @@ -307,26 +303,6 @@ export default {
this.toast("标签功能暂时关闭", "warning")
this.tags[index].selected = !this.tags[index].selected
},
tokenLogin() {
this.$axios.get('/v1/account/token-check')
.then(res => {
if (res.data.code === 0) {
this.uin = res.data.data.uin
this.avatarUrl = "http://q1.qlogo.cn/g?b=qq&nk=" + res.data.data.uin + "&s=100"
this.userGroup = res.data.data.user_group
} else {
this.toast('登录失败:' + res.data.msg)
}
})
.catch(err => {
if (err.response.data.code === -1) {
this.$router.push('/auth?hint=请先登录嗷')
return
}
this.toast('登录失败:' + err.response.data.msg)
console.error(err)
})
},
toast(text, color = 'error') {
this.snackbar.text = text
this.snackbar.color = color
Expand Down
25 changes: 0 additions & 25 deletions frontend/src/pages/service.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,10 @@ export default {
},
value: 2,
displayInnerWindow: '',
avatarUrl: '',
uin: '',
userGroup: ''
}
},
mounted() {
this.tokenLogin()
this.getMetadata_('services')
},
Expand All @@ -130,27 +126,6 @@ export default {
this.$cookies.remove('access-token')
window.location.reload()
},
tokenLogin() {
this.$axios.get('/v1/account/token-check')
.then(res => {
if (res.data.code === 0) {
this.uin = res.data.data.uin
this.avatarUrl = "http://q1.qlogo.cn/g?b=qq&nk=" + res.data.data.uin + "&s=100"
this.userGroup = res.data.data.user_group
} else {
this.toast('登录失败:' + res.data.msg)
}
})
.catch(err => {
if (err.response.data.code === -1) {
this.$router.push('/auth?hint=请先登录嗷')
return
}
this.toast('登录失败:' + err.response.data.msg)
console.error(err)
})
},
randomColor() {
let colors = ["#FFC107", "#42A5F5", "#9CCC65", "#F06292", "#76FF03", "#9E9E9E", "#8D6E63"]
return colors[Math.floor(Math.random() * 100) % colors.length]
Expand Down
26 changes: 1 addition & 25 deletions frontend/src/pages/world.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<v-tabs id="tabs" v-model="tab" align-tabs="center" color="deep-purple-accent-4" show-arrows>
<v-tab value="1">📰 你的稿件</v-tab>
<v-tab value="2">🌏 动态</v-tab>
<v-tab v-if="userGroup === 'admin' || userGroup === 'member'" value="3">🤵 审核稿件</v-tab>
<v-tab v-if="$store.state.account.userGroup === 'admin' || $store.state.account.userGroup === 'member'" value="3">🤵 审核稿件</v-tab>
</v-tabs>

<v-divider id="hdivider"></v-divider>
Expand Down Expand Up @@ -100,9 +100,6 @@ export default {
posts: [],
filterStatus: ['全部', '待审核', '已通过', '已拒绝', '已取消', '队列中', '已发布', '失败', '待撤回', '已撤回'],
tab: null,
uin: "",
avatarUrl: "",
userGroup: "user",
judgePosts: [],
judgePages: 1,
judgeCurrentPage: 1,
Expand All @@ -122,7 +119,6 @@ export default {
},
mounted() {
this.tokenLogin()
},
methods: {
Expand Down Expand Up @@ -231,26 +227,6 @@ export default {
console.log(error)
})
},
tokenLogin() {
this.$axios.get('/v1/account/token-check')
.then(res => {
if (res.data.code === 0) {
this.uin = res.data.data.uin
this.avatarUrl = "http://q1.qlogo.cn/g?b=qq&nk=" + res.data.data.uin + "&s=100"
this.userGroup = res.data.data.user_group
} else {
this.toast('登录失败:' + res.data.msg)
}
})
.catch(err => {
if (err.response.data.code === -1) {
this.$router.push('/auth?hint=请先登录嗷')
return
}
this.toast('登录失败:' + err.response.data.msg)
console.error(err)
})
},
getPosts() {
console.log(this.filter)
// 检查status
Expand Down

0 comments on commit 891b73b

Please sign in to comment.