合并代码
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
VITE_API_BASE_URL=/api
|
VITE_API_BASE_URL=/api
|
||||||
VITE_UPLOAD_BASE_URL=http://localhost:3001/api/upload
|
VITE_UPLOAD_BASE_URL=http://localhost:3000/api/upload
|
||||||
78
package-lock.json
generated
78
package-lock.json
generated
@@ -10,12 +10,14 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
|
"echarts": "^5.6.0",
|
||||||
"element-plus": "^2.4.4",
|
"element-plus": "^2.4.4",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"swiper": "^8.4.7",
|
"swiper": "^8.4.7",
|
||||||
"vue": "^3.3.11",
|
"vue": "^3.3.11",
|
||||||
"vue-awesome-swiper": "^5.0.1",
|
"vue-awesome-swiper": "^5.0.1",
|
||||||
|
"vue-echarts": "^7.0.3",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "^4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -1453,6 +1455,22 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/echarts": {
|
||||||
|
"version": "5.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.6.0.tgz",
|
||||||
|
"integrity": "sha512-oTbVTsXfKuEhxftHqL5xprgLoc0k7uScAwtryCgWF6hPYFLRwOUHiFmHGCBKP5NPFNkDVopOieyUqYGH8Fa3kA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.3.0",
|
||||||
|
"zrender": "5.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/echarts/node_modules/tslib": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
|
||||||
|
"license": "0BSD"
|
||||||
|
},
|
||||||
"node_modules/element-plus": {
|
"node_modules/element-plus": {
|
||||||
"version": "2.10.3",
|
"version": "2.10.3",
|
||||||
"resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.10.3.tgz",
|
"resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.10.3.tgz",
|
||||||
@@ -2620,6 +2638,51 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/vue-echarts": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-echarts/-/vue-echarts-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-/jSxNwOsw5+dYAUcwSfkLwKPuzTQ0Cepz1LxCOpj2QcHrrmUa/Ql0eQqMmc1rTPQVrh2JQ29n2dhq75ZcHvRDw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"vue-demi": "^0.13.11"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@vue/runtime-core": "^3.0.0",
|
||||||
|
"echarts": "^5.5.1",
|
||||||
|
"vue": "^2.7.0 || ^3.1.1"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@vue/runtime-core": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vue-echarts/node_modules/vue-demi": {
|
||||||
|
"version": "0.13.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.13.11.tgz",
|
||||||
|
"integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"vue-demi-fix": "bin/vue-demi-fix.js",
|
||||||
|
"vue-demi-switch": "bin/vue-demi-switch.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@vue/composition-api": "^1.0.0-rc.1",
|
||||||
|
"vue": "^3.0.0-0 || ^2.6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@vue/composition-api": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/vue-router": {
|
"node_modules/vue-router": {
|
||||||
"version": "4.5.1",
|
"version": "4.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.5.1.tgz",
|
||||||
@@ -2634,6 +2697,21 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"vue": "^3.2.0"
|
"vue": "^3.2.0"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zrender": {
|
||||||
|
"version": "5.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.1.tgz",
|
||||||
|
"integrity": "sha512-OFXkDJKcrlx5su2XbzJvj/34Q3m6PvyCZkVPHGYpcCJ52ek4U/ymZyfuV1nKE23AyBJ51E/6Yr0mhZ7xGTO4ag==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zrender/node_modules/tslib": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
|
||||||
|
"license": "0BSD"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,14 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
|
"echarts": "^5.6.0",
|
||||||
"element-plus": "^2.4.4",
|
"element-plus": "^2.4.4",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"swiper": "^8.4.7",
|
"swiper": "^8.4.7",
|
||||||
"vue": "^3.3.11",
|
"vue": "^3.3.11",
|
||||||
"vue-awesome-swiper": "^5.0.1",
|
"vue-awesome-swiper": "^5.0.1",
|
||||||
|
"vue-echarts": "^7.0.3",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "^4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -198,7 +198,19 @@ const routes = [
|
|||||||
name: 'AgentDashboard',
|
name: 'AgentDashboard',
|
||||||
component: () => import('@/views/AgentDashboard.vue'),
|
component: () => import('@/views/AgentDashboard.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '代理后台'
|
title: '代理后台',
|
||||||
|
requiresAuth: true,
|
||||||
|
isAgent: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/agent/withdrawals',
|
||||||
|
name: 'AgentWithdrawals',
|
||||||
|
component: () => import('@/views/AgentWithdrawals.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '佣金提现',
|
||||||
|
requiresAuth: true,
|
||||||
|
isAgent: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -252,17 +264,33 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
|
|
||||||
// 检查是否需要认证
|
// 检查是否需要认证
|
||||||
if (to.meta.requiresAuth) {
|
if (to.meta.requiresAuth) {
|
||||||
if (!userStore.isAuthenticated) {
|
// 检查是否是代理页面
|
||||||
// 尝试从本地存储恢复登录状态
|
if (to.meta.isAgent) {
|
||||||
await userStore.checkAuth()
|
// 代理页面认证逻辑
|
||||||
|
const agentInfo = localStorage.getItem('agentInfo')
|
||||||
|
const agentToken = localStorage.getItem('token')
|
||||||
|
|
||||||
if (!userStore.isAuthenticated) {
|
if (!agentInfo || !agentToken) {
|
||||||
next({
|
next({
|
||||||
name: 'MyLogin',
|
path: '/agent/login',
|
||||||
query: { redirect: to.fullPath }
|
query: { redirect: to.fullPath }
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 普通用户页面认证逻辑
|
||||||
|
if (!userStore.isAuthenticated) {
|
||||||
|
// 尝试从本地存储恢复登录状态
|
||||||
|
await userStore.checkAuth()
|
||||||
|
|
||||||
|
if (!userStore.isAuthenticated) {
|
||||||
|
next({
|
||||||
|
name: 'MyLogin',
|
||||||
|
query: { redirect: to.fullPath }
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,11 +64,20 @@ api.interceptors.response.use(
|
|||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 401:
|
case 401:
|
||||||
// 未授权,清除token并跳转到登录页
|
// 未授权,清除token并根据当前路由跳转到相应的登录页
|
||||||
localStorage.removeItem('token')
|
localStorage.removeItem('token')
|
||||||
|
localStorage.removeItem('agentInfo') // 清除代理信息
|
||||||
delete api.defaults.headers.common['Authorization']
|
delete api.defaults.headers.common['Authorization']
|
||||||
router.push({ name: 'Login' })
|
|
||||||
ElMessage.error('登录已过期,请重新登录')
|
// 判断当前是否在代理相关页面
|
||||||
|
const currentPath = router.currentRoute.value.path
|
||||||
|
if (currentPath.startsWith('/agent')) {
|
||||||
|
router.push('/agent/login')
|
||||||
|
ElMessage.error('代理登录已过期,请重新登录')
|
||||||
|
} else {
|
||||||
|
router.push({ name: 'Login' })
|
||||||
|
ElMessage.error('登录已过期,请重新登录')
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
case 403:
|
case 403:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -243,8 +243,9 @@ const handleLogin = async () => {
|
|||||||
const { data } = await api.post('/agents/login', loginForm)
|
const { data } = await api.post('/agents/login', loginForm)
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
// 保存代理信息到localStorage
|
// 保存代理信息和token到localStorage
|
||||||
localStorage.setItem('agentInfo', JSON.stringify(data.data))
|
localStorage.setItem('agentInfo', JSON.stringify(data.data))
|
||||||
|
localStorage.setItem('token', data.data.token)
|
||||||
ElMessage.success('登录成功')
|
ElMessage.success('登录成功')
|
||||||
router.push('/agent/dashboard')
|
router.push('/agent/dashboard')
|
||||||
}
|
}
|
||||||
|
|||||||
1204
src/views/AgentWithdrawals.vue
Normal file
1204
src/views/AgentWithdrawals.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,11 +14,11 @@ export default defineConfig({
|
|||||||
port: 5173,
|
port: 5173,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://114.55.111.44:3001',
|
target: 'http://localhost:3000',
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
},
|
},
|
||||||
'/uploads': {
|
'/uploads': {
|
||||||
target: 'http://114.55.111.44:3001',
|
target: 'http://localhost:3000',
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user