From 9383bf5b9321361331c842352c871cb2693df693 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Sun, 10 Aug 2025 16:25:09 +0800
Subject: [PATCH] 1
---
src/router/index.js | 467 ++++++++++++++-------------------------------------------
1 files changed, 117 insertions(+), 350 deletions(-)
diff --git a/src/router/index.js b/src/router/index.js
index 27e19d7..57a1121 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,357 +1,124 @@
-import Vue from 'vue'
-import Router from 'vue-router'
-import Home from '../pages/Home/index' // 首页
-import Stock from '../pages/stock/index' // 股票大厅
-import Transaction from '../pages/transaction/index' // 交易
-import Product from '../pages/product/index' // 产品介绍
-import Introduce from '../pages/introduce/index' // 公司简介
-import Down from '../pages/down/index' // 产品介绍
-import Notice from '../pages/notice/index' // 公告
-import NoticeDetail from '../pages/notice/components/detail' // 公告详情
-import User from '../pages/user/index' // 用户中心
-import CashDetail from '../pages/user/components/list' // 资金记录
-import DetailList from '../pages/user/components/table/detail' // 资金明细
-import WithdrawList from '../pages/user/components/table/withdraw' // 提现记录
-import RechargeList from '../pages/user/components/table/recharge' // 充值记录
-import Recharge from '../pages/user/components/cash/recharge' // 提现
-import Withdraw from '../pages/user/components/cash/withdraw' // 充值
-import ChangeCash from '../pages/user/components/change' // 资产互转
-import HoldPosition from '../pages/user/components/transform/holdposition' // 持仓单
-import IndexHoldPosition from '../pages/user/components/transform/indexholdposition' // 持仓单 指数
-import FuturesHoldPosition from '../pages/user/components/transform/futuresholdposition' // 持仓单 指数
-import SellOrder from '../pages/user/components/transform/sellorder' // 平仓单
-import IndexSellOrder from '../pages/user/components/transform/indexsellorder' // 平仓单 指数
-import FuturesSellOrder from '../pages/user/components/transform/futuressellorder' // 平仓单 指数
-import Bank from '../pages/user/components/save/bank' // 银行卡
-import Auth from '../pages/user/components/save/auth' // 实名认证
-import ChangePwd from '../pages/user/components/save/changepwd' // 修改银行卡
-import Exeloginexe from '../pages/login/exeloginexe' // 登录
-import Login from '../pages/login/login' // 登录
-import Register from '../pages/login/register' // 注册
-import Forget from '../pages/login/forget' // 忘记密码
-import Message from '../pages/user/components/table/message' // 站内消息
-import Xingu from '../pages/user/components/table/xingu' // 新股申购
-//============================分仓配资-相关,2020年7月25日19:14:55=========================================
-import Funds from '../pages/funds/index' // 分仓配资
-import Days from '../pages/funds/components/days' // 按天配资
-import Applyfund from '../pages/funds/components/table/applyfund' // 我的配资
-import FundsHoldPosition from '../pages/user/components/transform/fundsholdposition' // 分仓持仓单
-import FundsSellOrder from '../pages/user/components/transform/fundssellorder' // 分仓平仓单
-import Funding from '../pages/funds/components/funding' // 配资详情
-import Contract from '../pages/funds/components/contract' // 合同
-import Enterprise from '../pages/enterprise/index' // 企业公告
-import enterpriseDetails from '../pages/enterprise/enterprise-details' // 企业公告详情
+import Vue from "vue";
+import VueRouter from "vue-router";
+import store from "../store";
+Vue.use(VueRouter);
+const routes = [
+ {
+ path: "/",
+ redirect: "/home",
+ },
+ {
+ path: "/home",
+ name: "home",
+ component: () => import(/* webpackChunkName: "home" */ "../views/home/Home.vue"),
+ },
+ {
+ path: "/login",
+ name: "login",
+ component: () =>
+ import(/* webpackChunkName: "login" */ "../views/login.vue"),
+ },
+ {
+ path: "/register",
+ name: "register",
+ component: () =>
+ import(/* webpackChunkName: "register" */ "../views/register.vue"),
+ },
+ {
+ path: "/account",
+ name: "account",
+ component: () =>
+ import(/* webpackChunkName: "account" */ "../views/account/account.vue"),
+ },
+ {
+ path: "/fund",
+ name: "fund",
+ component: () =>
+ import(/* webpackChunkName: "fund" */ "../views/fund/fund.vue"),
+ },
+ {
+ path: "/ipo",
+ name: "ipo",
+ component: () =>
+ import(/* webpackChunkName: "ipo" */ "../views/ipo/ipo.vue"),
+ },
+ {
+ path: "/blockTrading",
+ name: "blockTrading",
+ component: () =>
+ import(
+ /* webpackChunkName: "blockTrading" */ "../views/blockTrading/blockTrading.vue"
+ ),
+ },
+ {
+ path: "/aiTrading",
+ name: "aiTrading",
+ component: () =>
+ import(
+ /* webpackChunkName: "aiTrading" */ "../views/aiTrading/aiTrading.vue"
+ ),
+ },
+];
-import Zixuan from '../pages/newindex/zixuan' // 自选列表
-import Hqchartdetail from '../pages/newindex/hqchartdetail' // 自选列表
-import Hushen from '../pages/newindex/hushen'
-import Zhishu from '../pages/newindex/zhishu'
-import Kechuang from '../pages/newindex/kechuang'
-import Meigu from '../pages/newindex/meigu'
-import Ganggu from '../pages/newindex/ganggu'
-import Newgu from '../pages/newindex/newgu'
-import Qualification from '../pages/newindex/Qualification'
-import Zhongzhuan from '../pages/newindex/zhongzhuan'
-import Dazongjiaoyi from "../pages/newindex/dazongjiaoyi"; // 大宗交易
-import Vipqiangchou from "../pages/newindex/vipqiangchou"; // vip抢筹
-// import HoldPositions from '@/pages/holdPositions/index'
-// import CapitalDetail from '@/pages/capitalDetail/index'
-// import Entry from '@/pages/entry/index'
-// import Exit from '@/pages/exit/index'
-// import Login from '@/pages/login/index'
-Vue.use(Router)
+const router = new VueRouter({
+ routes,
+ // 避免重复导航错误
+ scrollBehavior: () => ({ y: 0 }),
+});
-export default new Router({
- // mode :'history',
- routes: [
- {
- path: '/',
- redirect: '/hushen'
- },
- {
- path: '/hushen',
- name: 'hushen',
- meta: { title: '首页' },
- component: Hushen
- },
- {
- path: '/hushen',
- name: 'hushen',
- meta: { title: '沪深京'},
- component: Hushen
- },
- {
- path: '/zhishu',
- name: 'zhishu',
- meta: { title: '指数'},
- component: Zhishu
- },
- {
- path: '/kechuang',
- name: 'kechuang',
- meta: { title: '科创'},
- component: Kechuang
- },
- {
- path: '/meigu',
- name: 'meigu',
- meta: { title: '美股'},
- component: Meigu
- },
- {
- path: '/ganggu',
- name: 'ganggu',
- meta: { title: '港股'},
- component: Ganggu
- },
- {
- path: '/newgu',
- name: 'newgu',
- meta: { title: '新股'},
- component: Newgu
- },
- {
- path: '/Qualification',
- name: 'Qualification',
- meta: { title: '资质'},
- component: Qualification
- },
- {
- path: '/dazongjiaoyi',
- name: 'dazongjiaoyi',
- meta: { title: '大宗交易'},
- component: Dazongjiaoyi
- },
- {
- path: '/vipqiangchou',
- name: 'vipqiangchou',
- meta: { title: 'VIP抢筹'},
- component: Vipqiangchou
- },
- {
- path: '/zhongzhuan',
- name: 'zhongzhuan',
- meta: { title: '行情详情'},
- component: Zhongzhuan
- },
- {
- path: '/hqchartdetail',
- name: 'hqchartdetail',
- meta: { title: '行情详情' },
- component: Hqchartdetail
- },
- {
- path: '/home',
- name: 'home',
- meta: { title: '首页' },
- component: Home
- },
- {
- path: '/stock',
- name: 'stock',
- meta: { title: '股票大厅' },
- component: Stock
- },
- {
- path: '/transaction',
- name: 'transaction',
- meta: { title: '交易大厅' },
- component: Transaction
- },
- {
- path: '/product',
- name: 'product',
- meta: { title: '产品介绍' },
- component: Product
- },
- {
- path: '/introduce',
- name: 'introduce',
- meta: { title: '公司简介' },
- component: Introduce
- }, {
- path: '/down',
- name: 'down',
- meta: { title: '软件下载' },
- component: Down
- }, {
- path: '/notice',
- name: 'notice',
- meta: { title: '公告' },
- component: Notice
- }, {
- path: '/noticedetail',
- name: 'noticedetail',
- meta: { title: '公告详情' },
- component: NoticeDetail
- }, {
- path: '/user',
- name: 'user',
- meta: { title: '用户中心' },
- component: User
- }, {
- path: '/message',
- name: 'message',
- meta: { title: '站内消息' },
- component: Message
- }, {
- path: '/xingu',
- name: 'xingu',
- meta: { title: '新股申购' },
- component: Xingu
- },{
- path: '/cashdetail',
- name: 'cashdetail',
- meta: { title: '资金记录' },
- component: CashDetail
- }, {
- path: '/detaillist',
- name: 'detaillist',
- meta: { title: '资金明细' },
- component: DetailList
- }, {
- path: '/withdrawlist',
- name: 'withdrawlist',
- meta: { title: '提现记录' },
- component: WithdrawList
- }, {
- path: '/rechargelist',
- name: 'rechargelist',
- meta: { title: '充值记录' },
- component: RechargeList
- }, {
- path: '/recharge',
- name: 'recharge',
- meta: { title: '充值' },
- component: Recharge
- }, {
- path: '/withdraw',
- name: 'withdraw',
- meta: { title: '提现' },
- component: Withdraw
- }, {
- path: '/changeCash',
- name: 'changeCash',
- meta: { title: '资产户转' },
- component: ChangeCash
- }, {
- path: '/holdposition',
- name: 'holdposition',
- meta: { title: '股票持仓单' },
- component: HoldPosition
- }, {
- path: '/indexholdposition',
- name: 'indexholdposition',
- meta: { title: '指数持仓单' },
- component: IndexHoldPosition
- }, {
- path: '/futuressell',
- name: 'futuressell',
- meta: { title: '期货平仓' },
- component: FuturesSellOrder
- }, {
- path: '/futuresholdposition',
- name: 'futuresholdposition',
- meta: { title: '期货持仓单' },
- component: FuturesHoldPosition
- }, {
- path: '/sell',
- name: 'sell',
- meta: { title: '平仓单' },
- component: SellOrder
- }, {
- path: '/indexsell',
- name: 'indexsell',
- meta: { title: '指数平仓单' },
- component: IndexSellOrder
- }, {
- path: '/bank',
- name: 'bank',
- meta: { title: '银行卡' },
- component: Bank
- }, {
- path: '/auth',
- name: 'auth',
- meta: { title: '实名认证' },
- component: Auth
- }, {
- path: '/changepwd',
- name: 'changepwd',
- meta: { title: '修改密码' },
- component: ChangePwd
- },
- {
- path: '/login',
- name: 'login',
- meta: { title: '登录' },
- component: Exeloginexe
- },
- {
- path: '/register',
- name: 'register',
- meta: { title: '注册' },
- component: Register
- }, {
- path: '/forget',
- name: 'forget',
- meta: { title: '忘记密码' },
- component: Forget
- },
- //============================分仓配资-相关,2020年7月25日19:14:55=========================================
- {
- path: '/funds',
- name: 'funds',
- meta: { title: '配资主页' },
- component: Funds
- },
- {
- path: '/days',
- name: 'days',
- meta: { title: '按天配资' },
- component: Days
- },
- {
- path: '/applyfund',
- name: 'applyfund',
- meta: { title: '我的配资' },
- component: Applyfund
- }, {
- path: '/fundsholdposition',
- name: 'fundsholdposition',
- meta: { title: '配资持仓单' },
- component: FundsHoldPosition
- }, {
- path: '/fundssellorder',
- name: 'fundssellorder',
- meta: { title: '配资平仓单' },
- component: FundsSellOrder
- }, {
- path: '/funding',
- name: 'funding',
- meta: { title: '配资详情' },
- component: Funding
- }, {
- path: '/contract',
- name: 'contract',
- meta: { title: '合同' },
- component: Contract
- },
+// 路由守卫
+router.beforeEach((to, from, next) => {
+ // 获取token
+ const token =
+ store.state.token || window.localStorage.getItem("USERTOKEN") || null;
+ // 白名单路由,不需要登录就可以访问
+ const whiteList = ["/login", "/register"];
+ // 避免重复导航到当前位置
+ if (to.path === from.path) {
+ return next(false);
+ }
- {
- path: '/enterprise',
- name: 'enterprise',
- meta: { title: '企业公告' },
- component: Enterprise
- },
- {
- path: '/enterprise-details',
- name: 'enterprise-details',
- meta: { title: '企业公告详情' },
- component: enterpriseDetails
- }
+ // // 如果已登录且要去登录或注册页
+ // if (token && whiteList.includes(to.path)) {
+ // // 已登录,跳转到首页
+ // next("/");
+ // } else if (whiteList.includes(to.path)) {
+ // // 未登录,要去白名单页面,直接放行
+ // next();
+ // } else {
+ // // 不在白名单中,需要验证token
+ // if (token) {
+ // // 有token,放行
+ // next();
+ // } else {
+ // // 没有token,跳转到登录页
+ // next("/login");
+ // }
+ // }
- ]
-})
+ if (to.meta.requireAuth && token) {
+ next("/login");
+ return;
+ }
+ next();
+});
+
+// 捕获导航错误
+const originalPush = VueRouter.prototype.push;
+VueRouter.prototype.push = function push(location) {
+ return originalPush.call(this, location).catch((err) => {
+ if (err.name !== "NavigationDuplicated") throw err;
+ });
+};
+
+const originalReplace = VueRouter.prototype.replace;
+VueRouter.prototype.replace = function replace(location) {
+ return originalReplace.call(this, location).catch((err) => {
+ if (err.name !== "NavigationDuplicated") throw err;
+ });
+};
+
+export default router;
--
Gitblit v1.9.3