import Vue from 'vue' import VueRouter from 'vue-router' import Layout from '../layout/index.vue' import { Message } from 'element-ui'; import i18n from '../i18n/index' Vue.use(VueRouter) // 提取子路由配置 const childrenRoutes = [ { path: '', name: 'Home', component: () => import('../views/home/index.vue'), meta: { title: '首页', description: i18n.t(`seo.Home`), allAuthority: [`all`], // keywords: 'M2Pool, cryptocurrency mining pool, bitcoin mining, DGB mining, mining pool service, 加密货币矿池, 比特币挖矿, DGB挖矿, 矿池服务' keywords:{ en: 'M2Pool, cryptocurrency mining pool, bitcoin mining, DGB mining, mining pool service, 加密货币矿池, 比特币挖矿, DGB挖矿, 矿池服务', zh: 'M2Pool, 加密货币矿池, 比特币挖矿, DGB挖矿, 矿池服务' } } }, {//只读页面挖矿账户页 path: 'miningAccount', name: 'MiningAccount', component: () => import('../views/miningAccount/index.vue'), meta: {title: '挖矿账户页面', description:i18n.t(`seo.miningAccount`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool mining account, crypto mining stats, mining rewards, hashrate monitor, 矿池账户, 挖矿收益, 算力监控' keywords:{ en: 'M2Pool mining account, crypto mining stats, mining rewards, hashrate monitor, 矿池账户, 挖矿收益, 算力监控', zh: 'M2Pool 挖矿账户, 加密挖矿统计, 挖矿奖励, 算力监控, 矿池账户, 挖矿收益, 算力监控' } } }, {//只读页面展示页 path: 'readOnlyDisplay', name: 'ReadOnlyDisplay', component: () => import('../views/readOnlyDisplay/index.vue'), meta: {title: '只读页面展示页', description:i18n.t(`seo.readOnlyDisplay`), allAuthority:[`all`], // keywords: 'M2Pool 矿池,只读页面,收益状况,矿工信息,Read only page,Revenue situation,Mining Pool,Miner information' keywords:{ en: 'Read only page,Revenue situation,Mining Pool,Miner information', zh: 'M2Pool 矿池,只读页面,收益状况,矿工信息' } } }, {//报块页面 path: 'reportBlock', name: 'ReportBlock', component: () => import('../views/reportBlock/index.vue'), meta: {title: '报块页面', description:i18n.t(`seo.reportBlock`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,报块页面,幸运值,区块高度,Block page,Lucky Value,block height,Mining Pool' keywords:{ en: 'Block page,Lucky Value,block height,Mining Pool', zh: 'M2Pool 矿池,报块页面,幸运值,区块高度' } } }, {//费率 path: 'rate', name: 'Rate', component: () => import('../views/rate/index.vue'), meta: {title: '费率页面', description:i18n.t(`seo.rate`), allAuthority:[`all`], // keywords: 'M2Pool 矿池,费率页面,挖矿费率,收益计算,Mining Pool,Rate,Mining fee rate,Profit calculation' keywords:{ en: 'Mining Pool,Rate,Mining fee rate,Profit calculation', zh: 'M2Pool 矿池,费率页面,挖矿费率,收益计算' } } }, {//分配说明 path: 'allocationExplanation', name: 'AllocationExplanation', component: () => import('../views/allocationExplanation/index.vue'), meta: {title: '分配说明页面', description:i18n.t(`seo.rate`), allAuthority:[`all`], // keywords: '分配、转账说明,矿池分配,转账说明,Allocation,Transfer,Mining Pool,Pool allocation,Transfer instructions' keywords:{ en: 'Allocation,Transfer,Mining Pool,Pool allocation,Transfer instructions', zh: '分配、转账说明,矿池分配,转账说明' } } }, {//API文档 path: 'apiFile', name: 'ApiFile', component: () => import('../views/apiFile/index.vue'), meta: {title: 'API文档页面', description:i18n.t(`seo.apiFile`), allAuthority:[`all`], // keywords: 'M2Pool 矿池,API 文档,认证 token,接口调用,API file,authentication token,Interface call' keywords:{ en: 'API file,authentication token,Interface call', zh: 'M2Pool 矿池,API 文档,认证 token,接口调用' } } }, {//在线客服 path: 'customerService', name: 'CustomerService', component: () => import('../views/customerService/index.vue'), meta: {title: '在线客服', description:i18n.t(`seo.apiFile`), allAuthority:[`customer_service`],//客服权限 // keywords: 'M2Pool 矿池,API 文档,认证 token,接口调用,API file,authentication token,Interface call' keywords:{ en: 'API file,authentication token,Interface call', zh: 'M2Pool 矿池,API 文档,认证 token,接口调用' } } }, {//接入矿池页面 path: '/:lang/AccessMiningPool', name: 'AccessMiningPool', component: () => import('../views/AccessMiningPool/index.vue'), meta: {title: '接入矿池页面', description:i18n.t(`seo.allocationExplanation`), allAuthority:[`all`], // keywords: 'M2Pool 矿池,接入矿池,币种接入,挖矿指南,Access to Mining Pools,Coin Access,Mining Guide' keywords:{ en: 'Access to Mining Pools,Coin Access,Mining Guide', zh: 'M2Pool 矿池,接入矿池,币种接入,挖矿指南' } }, children: [ {//nexa 挖矿页面 path: 'nexaAccess', name: 'NexaAccess', component: () => import('../views/AccessMiningPool/nexaAccess/index.vue'), meta: {title: 'nexa 挖矿页面', description:i18n.t(`seo.nexaAccess`), allAuthority:[`all`], keepAlive: true, requiresAuth: false, // keywords: 'nexa,挖矿教程,Nexa接入,Nexa Access,Mining Tutorial' keywords:{ en: 'Nexa Access,Mining Tutorial', zh: 'nexa,挖矿教程,Nexa接入,Nexa Access,Mining Tutorial' } } }, {//rxd 挖矿页面 path: 'rxdAccess', name: 'RxdAccess', component: () => import('../views/AccessMiningPool/rxdAccess/index.vue'), meta: {title: 'rxd 挖矿页面', description:i18n.t(`seo.rxdAccess`), allAuthority:[`all`], // keywords: 'rxd,挖矿教程,Radiant接入,rxd Access,Radiant Access,Mining Tutorial,radiant' keywords:{ en: 'rxd Access,Radiant Access,Mining Tutorial,radiant', zh: 'rxd,矿池挖矿教程,Radiant接入,' } } }, {//mona 挖矿页面 path: 'monaAccess', name: 'MonaAccess', component: () => import('../views/AccessMiningPool/monaAccess/index.vue'), meta: {title: 'mona 挖矿页面', description:i18n.t(`seo.monaAccess`), allAuthority:[`all`], // keywords: 'mona,挖矿教程,mona接入,Mona Access,MONA Access,Mining Tutorial' keywords:{ en: 'Mona Access,MONA Access,Mining Tutorial', zh: 'mona,挖矿教程,mona接入,' } }, }, {//grs 挖矿页面 path: 'grsAccess', name: 'GrsAccess', component: () => import('../views/AccessMiningPool/grsAccess/index.vue'), meta: {title: 'grs 挖矿页面', description:i18n.t(`seo.grsAccess`), allAuthority:[`all`], // keywords: 'GRS,Grs接入,GRS Access,grs Access,Mining Tutorial' keywords:{ en: 'GRS Access,grs Access,Mining Tutorial', zh: 'GRS,Grs接入,GRS挖矿教程' } }, }, {//dgbqA挖矿页面 dgboAccess path: 'dgbqAccess', name: 'DgbqAccess', component: () => import('../views/AccessMiningPool/dgbqAccess/index.vue'), meta: {title: 'Dgbq 挖矿页面', description:i18n.t(`seo.dgbAccess`), allAuthority:[`all`], // keywords: 'Dgbq,dgb(qubit)接入,Dgb(qubit) Access,DGB(qubit) Access,Mining Tutorial,DGB' keywords:{ en: 'Dgb(qubit) Access,DGB(qubit) Access,Mining Tutorial,DGB', zh: 'Dgbq,dgb(qubit)接入,dgb(qubit)挖矿教程' } }, }, {//dgboAccess 挖矿页面 path: 'dgboAccess', name: 'DgboAccess', component: () => import('../views/AccessMiningPool/dgboAccess/index.vue'), meta: {title: 'Dgbo 挖矿页面', description:i18n.t(`seo.dgbAccess`), allAuthority:[`all`], // keywords: 'dgbo,dgb(odocrypt)接入,Dgb(odocrypt) Access,DGB(odocrypt) Access,Mining Tutorial,DGB' keywords:{ en: 'Dgb(odocrypt) Access,DGB(odocrypt) Access,Mining Tutorial,DGB', zh: 'dgbo,dgb(odocrypt)接入,dgb(odocrypt)挖矿教程' } }, }, {//dgbsAccess 挖矿页面 path: 'dgbsAccess', name: 'DgbsAccess', component: () => import('../views/AccessMiningPool/dgbsAccess/index.vue'), meta: {title: 'Dgbs 挖矿页面', description:i18n.t(`seo.dgbAccess`), allAuthority:[`all`], // keywords: 'dgbs,dgb(skein)接入,Dgb(skein) Access,DGB(skein) Access,Mining Tutorial,DGB' keywords:{ en: 'Dgb(skein) Access,DGB(skein) Access,Mining Tutorial,DGB', zh: 'dgbs,dgb(skein)接入,dgb(skein)挖矿教程' } }, }, {//enxAccess 挖矿页面 path: 'enxAccess', name: 'EnxAccess', component: () => import('../views/AccessMiningPool/enxAccess/index.vue'), meta: {title: ' Entropyx(enx) 挖矿页面', description:i18n.t(`seo.enxAccess`), allAuthority:[`all`], // keywords: 'Entropyx(Enx), Entropyx(enx)接入,enx,ENX,Mining Tutorial' keywords:{ en: 'Entropyx(Enx), enx,ENX,Mining Tutorial', zh: 'Entropyx(enx)接入,Entropyx挖矿教程' } }, }, {//alphminingPool 挖矿页面 path: 'alphminingPool', name: 'AlphminingPool', component: () => import('../views/AccessMiningPool/alphminingPool/index.vue'), meta: {title: ' alephium 挖矿页面', description:i18n.t(`seo.alphAccess`), allAuthority:[`all`], // keywords: 'Entropyx(Enx), Entropyx(enx)接入,enx,ENX,Mining Tutorial' keywords:{ en: 'alephium(alph), Alephium,Mining Tutorial', zh: 'alephium(alph)接入,alephium挖矿教程' } }, }, ] }, {//服务条款 path: 'ServiceTerms', name: 'ServiceTerms', component: () => import('../views/ServiceTerms/index.vue'), meta: {title: '服务条款页面', description:i18n.t(`seo.ServiceTerms`), allAuthority:[`all`], // keywords: 'M2Pool 矿池,服务条款,用户权益,权利义务,Terms of Service, User Rights, Rights and Obligations' keywords:{ en: 'Terms of Service, User Rights, Rights and Obligations', zh: 'M2Pool 矿池,服务条款,用户权益,权利义务' } } }, {//提交工单 path: 'submitWorkOrder', name: 'SubmitWorkOrder', component: () => import('../views/submitWorkOrder/index.vue'), meta: {title: '提交工单页面', description:i18n.t(`seo.submitWorkOrder`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,提交工单,技术支持,问题处理,Mining Pool,Work Order Submission, Technical Support, Troubleshooting' keywords:{ en: 'Mining Pool,Work Order Submission, Technical Support, Troubleshooting', zh: 'M2Pool 矿池,提交工单,技术支持,问题处理' } } }, {//用户查看工单记录 path: 'workOrderRecords', name: 'WorkOrderRecords', component: () => import('../views/workOrderRecords/index.vue'), meta: {title: '工单记录页面(用户)', description:i18n.t(`seo.workOrderRecords`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,用户工单记录,处理状态,问题进度,User Work Order Records, Processing Status, Issue Progress' keywords:{ en: 'User Work Order Records, Processing Status, Issue Progress', zh: 'M2Pool 矿池,用户工单记录,处理状态,问题进度' } } }, {//用户查看工单详情 path: 'userWorkDetails', name: 'UserWorkDetails', component: () => import('../views/userWorkDetails/index.vue'), meta: {title: '工单详情页面(用户)', description:i18n.t(`seo.userWorkDetails`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,用户工单详情,问题描述,补充提交,User Work Order Details, Problem Description, Additional Submissions' keywords:{ en: 'User Work Order Details, Problem Description, Additional Submissions', zh: 'M2Pool 矿池,用户工单详情,问题描述,补充提交' } } }, {//后台工单管理 path: 'workOrderBackend', name: 'WorkOrderBackend', component: () => import('../views/workOrderBackend/index.vue'), meta: {title: '工单管理页面(后台)', description:"M2Pool 矿池后台工单管理页面,供 M2Pool 管理员查看和管理用户提交的工单记录,确保问题及时处理,提升用户体验。", allAuthority:[`admin`], // keywords: 'M2Pool 矿池,后台工单管理,用户工单,及时处理,Back-office work order management, user work orders, timely processing' keywords:{ en: 'Back-office work order management, user work orders, timely processing', zh: 'M2Pool 矿池,后台工单管理,用户工单,及时处理' } } }, {//后台工单详情页面 path: 'BKWorkDetails', name: 'BKWorkDetails', component: () => import('../views/BKWorkDetails/index.vue'), meta: {title: '工单详情页面(后台)', description:"M2Pool 矿池后台工单详情页面,管理员可在此查看提交工单的详细情况,包括提交时间、详细问题描述以及处理过程,并通过本页面对该工单进行回复处理。", allAuthority:[`admin`], // keywords: 'M2Pool 矿池,后台工单详情,问题处理,回复工单,Backend Work Order Details, Problem Handling, Responding to Work Orders' keywords:{ en: 'Backend Work Order Details, Problem Handling, Responding to Work Orders', zh: 'M2Pool 矿池,后台工单详情,问题处理,回复工单' } } }, {//数据展示 path: 'dataDisplay', name: 'DataDisplay', component: () => import('../views/dataDisplay/index.vue'), meta: {title: '数据展示页面', description:"M2Pool 矿池数据展示页面", allAuthority:[`all`], // keywords: 'M2Pool 矿池,数据展示,Mining Pool,Data Display' keywords:{ en: 'Mining Pool,Data Display', zh: 'M2Pool 矿池,数据展示' } } }, {//警报通知 path: 'alerts', name: 'Alerts', component: () => import('../views/alerts/index.vue'), meta: {title: '警报通知', description:i18n.t(`seo.alerts`), allAuthority:[`admin`,`registered`], // keywords: 'M2Pool, 矿池,离线告警设置,矿机离线,Mining Pool,Offline Alarm Setting,Mining Machine Offline' keywords:{ en: 'Mining Pool,Offline Alarm Setting,Mining Machine Offline', zh: 'M2Pool 矿池,离线告警设置,矿机离线' } } }, {//个人中心 path: 'personalCenter', name: 'PersonalCenter', // redirect: "/personalCenter/personalMining", component: () => import('../views/personalCenter/index.vue'), meta: {title: '个人中心页面', description:i18n.t(`seo.personalCenter`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,个人中心,挖矿账户,只读页面设置,安全设置,API密钥生成,Personal Center,Mining Account,Read-Only Page Setup,Security Settings,API Key Generation' keywords:{ en: 'Personal Center,Mining Account,Read-Only Page Setup,Security Settings,API Key Generation', zh: 'M2Pool 矿池,个人中心,挖矿账户,只读页面设置,安全设置,API密钥生成' } }, children: [ {//个人中心挖矿账户 path: 'personalMining', name: 'PersonalMining', component: () => import('../views/personalCenter/personalMining/index.vue'), meta: {title: '挖矿账户设置页面', description:i18n.t(`seo.personalMining`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,个人中心,挖矿账户设置,币种账户,Personal Center,Mining Account Settings,Coin Accounts' keywords:{ en: 'Personal Center,Mining Account Settings,Coin Accounts', zh: 'M2Pool 矿池,个人中心,挖矿账户设置,币种账户' } } }, {//个人中心只读页面 securitySetting path: 'readOnly', name: 'ReadOnly', component: () => import('../views/personalCenter/readOnly/index.vue'), meta: {title: '只读页面设置', description:i18n.t(`seo.readOnly`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,个人中心,只读页面设置,矿池分享,Personal Center,Read-Only Page Setting,Mining Pool Sharing' keywords:{ en: 'Personal Center,Read-Only Page Setting,Mining Pool Sharing', zh: 'M2Pool 矿池,个人中心,只读页面设置,矿池分享' } } }, {//个人中心安全设置personal path: 'securitySetting', name: 'SecuritySetting', component: () => import('../views/personalCenter/securitySetting/index.vue'), meta: {title: '安全设置页面', description:i18n.t(`seo.securitySetting`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,安全设置,密码修改,Security settings, password change' keywords:{ en: 'Security settings, password change', zh: 'M2Pool 矿池,安全设置,密码修改' } } }, {//个人中心 path: 'personal', name: 'personal', component: () => import('../views/personalCenter/personal/index.vue'), meta: {title: '个人信息页面', description:i18n.t(`seo.personal`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,个人信息,登录历史,Personal Information, Login History' keywords:{ en: 'Personal Information, Login History', zh: 'M2Pool 矿池,个人信息,登录历史' } } }, {//个人中心 挖矿报告 (隐藏) path: 'miningReport', name: 'MiningReport', component: () => import('../views/personalCenter/miningReport/index.vue'), meta: {title: '挖矿报告页面', description:i18n.t(`seo.miningReport`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,个人中心,挖矿报告,订阅服务,Mining Report, Subscription Service' keywords:{ en: 'Mining Report, Subscription Service', zh: 'M2Pool 矿池,个人中心,挖矿报告,订阅服务' } } }, {//个人中心 API path: 'personalAPI', name: 'PersonalAPI', component: () => import('../views/personalCenter/personalAPI/index.vue'), meta: {title: 'API页面', description:i18n.t(`seo.personalAPI`), allAuthority:[`admin`,`registered`,`customer_service`], // keywords: 'M2Pool 矿池,个人中心,API 页面,API密钥生成,API Page,API Key Generation' keywords:{ en: 'API Page,API Key Generation', zh: 'M2Pool 矿池,个人中心,API 页面,API密钥生成' } } }, ] }, ] // 独立页面路由 const staticRoutes = [ { path: '/:lang/login', name: 'Login', component: () => import('../views/login/login.vue'), meta: { title: '登录页面', description: "M2Pool 矿池登录页面", allAuthority: [`all`], // keywords: 'M2Pool 矿池,登录页面,账号密码,安全登录' keywords:{ en: 'M2Pool Mining Pool,login page,account password', zh: 'M2Pool 矿池,登录页面,账号密码,安全登录' } } }, { path: '/:lang/register', name: 'Register', component: () => import('../views/register/register.vue'), meta: {title: '注册页面',description:"M2Pool 矿池注册页面,新用户可在此便捷注册账号,加入 M2Pool 矿池大家庭。",allAuthority:[`all`], // keywords: 'M2Pool 矿池,注册页面,新用户注册,账号创建' keywords:{ en: 'M2Pool Mining Pool,register page,new user registration,account creation', zh: 'M2Pool 矿池,注册页面,新用户注册,账号创建' } } }, { path: '/:lang/simulation', name: 'simulation', component: () => import('../views/simulation.vue'), meta: {title: '测试页面',description:"M2Pool 矿池测试页面,用于进行系统功能的模拟和测试,确保矿池稳定运行",allAuthority:[`all`], // keywords: 'M2Pool 矿池,测试页面,系统测试,稳定运行' keywords:{ en: 'M2Pool Mining Pool,test page,system test,stable operation', zh: 'M2Pool 矿池,测试页面,系统测试,稳定运行' } } }, { path: '/:lang/resetPassword', name: 'ResetPassword', component: () => import('../views/resetPassword/index.vue'), meta: {title: '重置密码页面',description:"M2Pool 矿池重置密码页面,用户可在此修改矿池网站账号密码,保障账户安全。",allAuthority:[`all`], // keywords: 'M2Pool 矿池,重置密码,修改密码,账户安全' keywords:{ en: 'M2Pool Mining Pool,reset password,modify password,account security', zh: 'M2Pool 矿池,重置密码,修改密码,账户安全' } } }, {//404 path: '/:lang/404', component: () => import('../views/page404.vue'), meta: {title: '404页面',description:"M2Pool 矿池 404 页面,当 URL 错误时将跳转至此页面,提示用户页面不存在。",allAuthority:[`all`], // keywords: 'M2Pool 矿池,404 页面,页面不存在,错误跳转' keywords:{ en: 'M2Pool Mining Pool,404 page,page not found,error redirect', zh: 'M2Pool 矿池,404 页面,页面不存在,错误跳转' } } }, ] const routes = [ { path: '/:lang', component: Layout, beforeEnter: (to, from, next) => { const lang = to.params.lang const supportedLanguages = ['zh', 'en'] // 检查语言参数 if (!supportedLanguages.includes(lang)) { return next(`/en${to.path}`) } // 设置语言 if (i18n.locale !== lang) { i18n.locale = lang localStorage.setItem('lang', lang) } return next() }, children: childrenRoutes }, // 根路径重定向 { path: '/', redirect: () => { const defaultLang = localStorage.getItem('lang') || 'en' return `/${defaultLang}` } }, // 添加所有静态路由 ...staticRoutes, // 404页面 { path: '*', redirect: to => { const lang = localStorage.getItem('lang') || 'en' return `/${lang}/404` } } ] const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes, strict: true, // 启用严格模式,不允许尾部斜杠 }) router.beforeEach((to, from, next) => { // 检查语言参数 const lang = to.params.lang; const supportedLanguages = ['zh', 'en']; // 如果路径以斜杠结尾且不是根路径,则重定向 if (to.path.endsWith('/') && to.path.length > 1) { const path = to.path.slice(0, -1); return next({ path, query: to.query, hash: to.hash, params: to.params }); } if (!lang && to.path !== '/') { const defaultLang = localStorage.getItem('lang') || 'en'; return next(`/${defaultLang}${to.path}`); } let data = localStorage.getItem("jurisdiction"); let jurisdiction =JSON.parse(data); console.log(jurisdiction,"权限"); localStorage.setItem('superReportError',"") let element = document.getElementsByClassName('el-main')[0]; if(element){ element.scrollTop = 0 } let token try{ token =JSON.parse(localStorage.getItem('token')) }catch(e){ console.log(e); } if (token) { if (to.path === `/${lang}/login`|| to.path === `/${lang}/register`) { next({ path: `/${lang}` }) }else if(to.meta.allAuthority && to.meta.allAuthority[0] ==`all`){ next() }else if(jurisdiction.roleKey && to.meta.allAuthority&&to.meta.allAuthority.some(item=>item == jurisdiction.roleKey )){ next() }else{ console.log(to.meta.allAuthority,to.path,"权限"); Message({//权限不足 showClose: true, message:i18n.t(`mining.jurisdiction`), type: 'error' }); next({ path: `/${lang}` }) // 添加这行,重定向到首页 } }else{ let paths = [`/${lang}/miningAccount`,`/${lang}/workOrderRecords`,`/${lang}/userWorkDetails`,`/${lang}/submitWorkOrder`,`/${lang}/workOrderBackend`,`/${lang}/BKWorkDetails`] if (paths.includes(to.path) || to.path.includes(`personalCenter`) ) { Message({//权限不足 showClose: true, message:i18n.t(`mining.logInFirst`), type: 'error' }); next({ path: `/${lang}/login` }) } else { next() } } }) // 解决报错 此方法只针对VueRouter3.0以上 const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } export default router