Commit b91b11740a57b7f0b280492fefd0d6187a243d79
1 parent
f110b4f4
fix: 修复hjwl公司菜单权限及接口地址更新
- hjwl公司隐藏智能灯菜单,访问时自动跳转能耗页 - 根路由重定向保留corpCode查询参数 - 更新生产环境及开发代理API地址
Showing
4 changed files
with
19 additions
and
5 deletions
| @@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
| 15 | text-color="#bfcbd9" | 15 | text-color="#bfcbd9" |
| 16 | active-text-color="#409eff" | 16 | active-text-color="#409eff" |
| 17 | > | 17 | > |
| 18 | - <el-menu-item index="/smart-light" @click="navigateTo('/smart-light')"> | 18 | + <el-menu-item v-if="!isHjwl" index="/smart-light" @click="navigateTo('/smart-light')"> |
| 19 | <el-icon><Monitor /></el-icon> | 19 | <el-icon><Monitor /></el-icon> |
| 20 | <span>智能灯</span> | 20 | <span>智能灯</span> |
| 21 | </el-menu-item> | 21 | </el-menu-item> |
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | </template> | 33 | </template> |
| 34 | 34 | ||
| 35 | <script setup> | 35 | <script setup> |
| 36 | -import { computed, provide, watchEffect } from 'vue' | 36 | +import { computed, provide, watch, watchEffect } from 'vue' |
| 37 | import { useRoute, useRouter } from 'vue-router' | 37 | import { useRoute, useRouter } from 'vue-router' |
| 38 | import { setCorpCode } from './config/api.js' | 38 | import { setCorpCode } from './config/api.js' |
| 39 | 39 | ||
| @@ -57,6 +57,20 @@ function withCorpCode(path) { | @@ -57,6 +57,20 @@ function withCorpCode(path) { | ||
| 57 | return `${path}${sep}corpCode=${encodeURIComponent(corpCode.value)}` | 57 | return `${path}${sep}corpCode=${encodeURIComponent(corpCode.value)}` |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | +// hjwl 公司只展示能耗,不展示智能灯 | ||
| 61 | +const isHjwl = computed(() => (corpCode.value || '').toLowerCase() === 'hjwl') | ||
| 62 | + | ||
| 63 | +// hjwl 访问智能灯时自动跳转到能耗页 | ||
| 64 | +watch( | ||
| 65 | + () => [isHjwl.value, route.path], | ||
| 66 | + () => { | ||
| 67 | + if (isHjwl.value && route.path.startsWith('/smart-light')) { | ||
| 68 | + router.replace(withCorpCode('/energy')) | ||
| 69 | + } | ||
| 70 | + }, | ||
| 71 | + { immediate: true } | ||
| 72 | +) | ||
| 73 | + | ||
| 60 | // 菜单导航:保留corpCode参数 | 74 | // 菜单导航:保留corpCode参数 |
| 61 | function navigateTo(path) { | 75 | function navigateTo(path) { |
| 62 | router.push(withCorpCode(path)) | 76 | router.push(withCorpCode(path)) |
| @@ -3,7 +3,7 @@ import { createRouter, createWebHashHistory } from 'vue-router' // 改用 Hash | @@ -3,7 +3,7 @@ import { createRouter, createWebHashHistory } from 'vue-router' // 改用 Hash | ||
| 3 | const routes = [ | 3 | const routes = [ |
| 4 | { | 4 | { |
| 5 | path: '/', | 5 | path: '/', |
| 6 | - redirect: '/smart-light' | 6 | + redirect: to => ({ path: '/smart-light', query: to.query }) |
| 7 | }, | 7 | }, |
| 8 | { | 8 | { |
| 9 | path: '/h5', | 9 | path: '/h5', |
| @@ -12,7 +12,7 @@ export default defineConfig({ | @@ -12,7 +12,7 @@ export default defineConfig({ | ||
| 12 | server: { | 12 | server: { |
| 13 | proxy: { | 13 | proxy: { |
| 14 | '/api': { | 14 | '/api': { |
| 15 | - target: 'http://182.127.106.19:81', | 15 | + target: 'http://124.64.20.47:81', |
| 16 | changeOrigin: true, | 16 | changeOrigin: true, |
| 17 | rewrite: (path) => path.replace(/^\/api/, '/iot-scheduler'), | 17 | rewrite: (path) => path.replace(/^\/api/, '/iot-scheduler'), |
| 18 | }, | 18 | }, |