Browse Source

路由守卫

zhangrenyuan/feature-20250623164058-金币前端
lihuilin 4 weeks ago
parent
commit
3f86315c76
  1. 7
      .env.development
  2. 2
      .env.production
  3. 42
      src/router/index.js
  4. 6
      src/views/home.vue
  5. 2
      stats.html

7
.env.development

@ -1,9 +1,4 @@
#VITE_API_BASE='https://hwjb.homilychart.com/admin'
VITE_API_BASE='https://hwjb.homilychart.com/dev/admin'
# VITE_API_BASE='https://hwjb.homilychart.com/gold_htms_dev'
VITE_API_BASE='https://hwjb.homilychart.com/admin'
# VITE_API_BASE='http://192.168.8.242:8081/'
# VITE_API_BASE='http://18.143.76.3:10704/'
# VITE_API_BASE='http://192.168.9.28:8081/'
# VITE_API_BASE='http://192.168.8.94:8081/'
VITE_UPLOAD_URL=http://39.101.133.168:8828/hljw/api/aws/upload

2
.env.production

@ -1,5 +1,3 @@
# VITE_API_BASE='http://54.251.137.151:10702/'
VITE_API_BASE='https://hwjb.homilychart.com/prod'
# VITE_API_BASE='https://hwjb.homilychart.com/gold_htms_dev'
# VITE_API_BASE='http://192.168.8.232:8080/'
VITE_UPLOAD_URL=https://api.homilychart.com/hljw/api/aws/upload

42
src/router/index.js

@ -76,43 +76,11 @@ const router = createRouter({
});
router.beforeEach((to, from, next) => {
// const token = localStorage.getItem("token");
// const permission = localStorage.getItem("permission");
// if (to.name != "login" && !token) {
// next({ name: "login" });
// } else {
// if (permission == "4" && to.name != "noPermission") {
// next({ name: "noPermission" });
// } else if (permission == "3") {
// if (to.name == "addConsume" || to.name == "allConsume"
// || to.name == "addRecharge" || to.name == "adminRecharge" || to.name == "allRecharge"
// || to.name == "addRefund" || to.name == "allRefund"
// || to.name == "permissions") {
// next({ name: "workspace" });
// } else {
// next();
// }
// } else if (permission == '2') {
// if (to.name == "rechargeAudit" || to.name == "refundAudit"
// || to.name == "activity" || to.name == "rate"
// || to.name == "permissions") {
// next({ name: "workspace" })
// } else {
// next();
// }
// } else if (permission == '5') {
// if (to.name == "permissions") {
// next({ name: "workspace" })
// } else {
// next();
// }
// }
// else {
// next();
// }
// }
const token = localStorage.getItem("token");
const machineId = localStorage.getItem("machineId");
if (to.name != "login" && !token) {
next('/login?machineId=' + machineId);
}
next();
})
export default router;

6
src/views/home.vue

@ -93,7 +93,6 @@ const downloadExportFile = (item) => {
function logout() {
const machineId = localStorage.getItem('machineId')
localStorage.removeItem('token')
// localStorage.clear();
router.push('/login?machineId=' + machineId)
ElMessage.success('退出成功')
}
@ -225,8 +224,7 @@ const openExportList = () => {
<span style="margin-left: 10px">{{ adminData.name }}</span>
</template>
<el-menu-item @click="message()">查看个人信息</el-menu-item>
<el-menu-item index="1-2" @click="logout">退出登录</el-menu-item>
<el-menu-item index="1-3" @click="openExportList">查看下载列表</el-menu-item>
<el-menu-item @click="logout">退出登录</el-menu-item>
</el-sub-menu>
</el-menu>
</el-header>
@ -266,7 +264,7 @@ const openExportList = () => {
<el-table-column prop="state" label="状态">
<template #default="scope">
<el-tag :type="scope.row.state === 2 ? 'success' : 'warning'">
{{ scope.row.state === 2 ? '已完成' : '处理中' }}
{{ scope.row.state === 2 ? '已完成' : '导出失败' }}
</el-tag>
</template>
</el-table-column>

2
stats.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save