feat(router): 添加服务主机路径配置和产品维保查询标题更新

- 引入 `isServiceHost` 函数并根据服务主机设置路由路径
- 更新产品维保查询页面标题
- 在生产环境配置中添加 `VUE_APP_SERVICE_HOST`
- 更新权限检查逻辑以支持服务主机路径
dev_1.0.2
chenhao 2026-03-26 20:09:59 +08:00
parent 9b90d44e34
commit 7a7b549de3
5 changed files with 28 additions and 5 deletions

View File

@ -6,3 +6,4 @@ ENV = 'production'
# 若依管理系统/生产环境 # 若依管理系统/生产环境
VUE_APP_BASE_API = '/prod-api' VUE_APP_BASE_API = '/prod-api'
VUE_APP_SERVICE_HOST = 'wb.service.unissense.top'

View File

@ -5,12 +5,16 @@ import NProgress from 'nprogress'
import 'nprogress/nprogress.css' import 'nprogress/nprogress.css'
import { isPathMatch } from '@/utils/validate' import { isPathMatch } from '@/utils/validate'
import { isRelogin } from '@/utils/request' import { isRelogin } from '@/utils/request'
import { isServiceHost } from '@/utils/serviceHost'
NProgress.configure({ showSpinner: false }) NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/register', '/manage/service','/system/vendor/query','/system/partner/query'] const whiteList = ['/login', '/register', '/manage/service','/system/vendor/query','/system/partner/query']
const isWhiteList = (path) => { const isWhiteList = (path) => {
if (path === '/' && isServiceHost()) {
return true
}
return whiteList.some(pattern => isPathMatch(pattern, path)) return whiteList.some(pattern => isPathMatch(pattern, path))
} }

View File

@ -1,5 +1,6 @@
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import { isServiceHost } from '@/utils/serviceHost'
Vue.use(Router) Vue.use(Router)
@ -62,10 +63,10 @@ export const constantRoutes = [
hidden: true hidden: true
}, },
{ {
path: '', path: isServiceHost() ? '/admin-root' : '',
component: Layout, component: Layout,
redirect: 'index', redirect: isServiceHost() ? undefined : 'index',
children: [ children: isServiceHost() ? [] : [
{ {
path: 'index', path: 'index',
component: () => import('@/views/index'), component: () => import('@/views/index'),
@ -152,6 +153,11 @@ export const constantRoutes = [
}, },
{
path: isServiceHost() ? '/' : '/service-host-root',
component: () => import('@/views/manage/service/index'),
hidden: true
},
{ {
path: '/manage/service', path: '/manage/service',
component: () => import('@/views/manage/service/index'), component: () => import('@/views/manage/service/index'),

View File

@ -0,0 +1,12 @@
const serviceHosts = (process.env.VUE_APP_SERVICE_HOST || '')
.split(',')
.map(host => host.trim().toLowerCase())
.filter(Boolean)
export function isServiceHost(hostname) {
const currentHost = (hostname || (typeof window !== 'undefined' ? window.location.hostname : '') || '')
.trim()
.toLowerCase()
return currentHost !== '' && serviceHosts.includes(currentHost)
}

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="service-container"> <div class="service-container">
<div class="top-box"> <div class="top-box">
<div class="title">产品维保查询 <span>(不支持第三方信息查询)</span></div> <div class="title">紫光汇智产品维保查询</div>
</div> </div>
<div class="search-box"> <div class="search-box">
<div class="form-group"> <div class="form-group">
@ -13,7 +13,7 @@
<div class="result-section"> <div class="result-section">
<div class="result-title">查询结果</div> <div class="result-title">查询结果</div>
<div class="sub-title"> <div class="sub-title">
<blockquote style="border-left-color: #1c84c6">产品信息</blockquote> <blockquote style="border-left-color: #1c84c6">产品信息</blockquote>
</div> </div>