diff --git a/src/App.vue b/src/App.vue
index 6bbca27..cb34b25 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -2,6 +2,7 @@
import { getToken } from '@/utils/auth'
import { initializeLocale, translateLiteral } from '@/locales'
import useUserStore from '@/store/modules/user'
+import { initializeTerminalType } from '@/utils/terminal'
let wrapped = false
@@ -48,6 +49,7 @@ function wrapUniTextApi() {
export default {
onLaunch: function () {
initializeLocale()
+ initializeTerminalType()
wrapUniTextApi()
if (getToken()) {
useUserStore().getInfo().catch(() => {})
diff --git a/src/api/login.js b/src/api/login.js
index 8302fcd..d44bc01 100644
--- a/src/api/login.js
+++ b/src/api/login.js
@@ -1,4 +1,5 @@
import request from '@/utils/request'
+import { getTerminalType } from '@/utils/terminal'
const permissionInfoCache = new Map()
const permissionInfoPending = new Map()
@@ -12,16 +13,35 @@ function normalizePermissionParams(params = {}) {
function createPermissionCacheKey(params = {}) {
const normalizedParams = normalizePermissionParams(params)
+ const terminalType = getTerminalType()
return JSON.stringify(
- Object.keys(normalizedParams)
+ Object.keys({ ...normalizedParams, terminalType })
.sort()
.reduce((result, key) => {
- result[key] = normalizedParams[key]
+ result[key] = key === 'terminalType' ? terminalType : normalizedParams[key]
return result
}, {})
)
}
+function filterPermissionMenus(menus, terminalType) {
+ if (!Array.isArray(menus)) {
+ return []
+ }
+
+ return menus.filter((menu) => {
+ if (!menu || typeof menu !== 'object') {
+ return false
+ }
+
+ if (menu.terminalType === null || typeof menu.terminalType === 'undefined' || menu.terminalType === '') {
+ return true
+ }
+
+ return Number(menu.terminalType) === Number(terminalType)
+ })
+}
+
export function clearPermissionInfoCache() {
permissionInfoCache.clear()
permissionInfoPending.clear()
@@ -62,6 +82,7 @@ export function register(data) {
function getPermissionInfo(params = {}) {
const normalizedParams = normalizePermissionParams(params)
+ const terminalType = getTerminalType()
const cacheKey = createPermissionCacheKey(normalizedParams)
if (permissionInfoCache.has(cacheKey)) {
@@ -80,8 +101,15 @@ function getPermissionInfo(params = {}) {
const wrappedPromise = requestPromise
.then((res) => {
- permissionInfoCache.set(cacheKey, res)
- return res
+ const nextRes = {
+ ...res,
+ data: {
+ ...res?.data,
+ menus: filterPermissionMenus(res?.data?.menus, terminalType)
+ }
+ }
+ permissionInfoCache.set(cacheKey, nextRes)
+ return nextRes
})
.finally(() => {
permissionInfoPending.delete(cacheKey)
diff --git a/src/components/common/TabBar.vue b/src/components/common/TabBar.vue
index 293ee41..24cb2bd 100644
--- a/src/components/common/TabBar.vue
+++ b/src/components/common/TabBar.vue
@@ -4,10 +4,12 @@
:fixed="true" :placeholder="true" :border="false" @change="handleChange" zIndex="1000">
-
+
+
-
+
+
@@ -61,6 +63,14 @@ function normalizeRoute(path = '') {
return String(path || '').trim().replace(/^\/+/, '')
}
+function isUniIcon(icon) {
+ return String(icon || '').startsWith('uni-icons:')
+}
+
+function getUniIconName(icon) {
+ return String(icon || '').replace(/^uni-icons:/, '').trim()
+}
+
function resolveTabIcons(path, index) {
const route = normalizeRoute(path)
if (route === 'pages/index') {
@@ -84,6 +94,23 @@ function resolveTabIcons(path, index) {
return dynamicTabIconList[index % dynamicTabIconList.length]
}
+function resolveTabIconMeta(menu, index) {
+ if (isUniIcon(menu?.icon)) {
+ return {
+ iconType: 'uni-icons',
+ iconName: getUniIconName(menu.icon)
+ }
+ }
+
+ const icons = resolveTabIcons(menu?.path, index)
+ return {
+ iconType: 'image',
+ iconName: '',
+ icon: icons.icon,
+ selectedIcon: icons.selectedIcon
+ }
+}
+
function getCurrentActiveIndex() {
const pages = getCurrentPages()
if (pages && pages.length > 0) {
@@ -97,11 +124,13 @@ function getCurrentActiveIndex() {
const tabList = computed(() => {
const dynamicTabList = getTabBarMenus(menus.value)
.map((menu, index) => {
- const icons = resolveTabIcons(menu.path, index)
+ const iconMeta = resolveTabIconMeta(menu, index)
return {
text: String(menu.name || menu.enName || '').trim() || `菜单${index + 1}`,
- icon: icons.icon,
- selectedIcon: icons.selectedIcon,
+ icon: iconMeta.icon,
+ selectedIcon: iconMeta.selectedIcon,
+ iconType: iconMeta.iconType,
+ iconName: iconMeta.iconName,
path: menu.path
}
})
@@ -112,6 +141,8 @@ const tabList = computed(() => {
text: t('nav.mine'),
icon: mineIcon,
selectedIcon: mineSelectedIcon,
+ iconType: 'image',
+ iconName: '',
path: '/pages/mine'
}
]
diff --git a/src/locales/en-US.js b/src/locales/en-US.js
index e65bc5d..0a4354c 100644
--- a/src/locales/en-US.js
+++ b/src/locales/en-US.js
@@ -514,10 +514,16 @@ export default {
setting: {
language: 'System Language',
currentLanguage: 'Current: {language}',
+ terminalMode: 'Terminal Mode',
+ currentTerminal: 'Current Terminal: {terminal}',
+ switchingTerminal: 'Switching terminal...',
+ terminalSwitched: 'Switched to {terminal}',
switchLanguage: 'Switch Language',
checkUpdate: 'Check Updates',
cleanCache: 'Clear Cache',
logout: 'Log Out',
+ mobile: 'Mobile',
+ scanner: 'Scanner',
zhCN: 'Chinese',
enUS: 'English'
},
diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js
index f72d755..c0e5170 100644
--- a/src/locales/zh-CN.js
+++ b/src/locales/zh-CN.js
@@ -514,10 +514,16 @@ export default {
setting: {
language: '系统语言',
currentLanguage: '当前语言:{language}',
+ terminalMode: '终端模式',
+ currentTerminal: '当前终端:{terminal}',
+ switchingTerminal: '正在切换终端...',
+ terminalSwitched: '已切换到{terminal}',
switchLanguage: '切换语言',
checkUpdate: '检查更新',
cleanCache: '清理缓存',
logout: '退出登录',
+ mobile: '手机',
+ scanner: '扫码器',
zhCN: '中文',
enUS: '英文'
},
diff --git a/src/pages_mine/pages/setting/index.vue b/src/pages_mine/pages/setting/index.vue
index 79a69d7..2ac52b2 100644
--- a/src/pages_mine/pages/setting/index.vue
+++ b/src/pages_mine/pages/setting/index.vue
@@ -15,6 +15,13 @@
{{ t('mine.changePassword') }}
+
+
+ {{ t('setting.currentTerminal', { terminal: currentTerminalLabel }) }}
+