hookehuyr

refactor(config, tabbar): 调整API环境baseURL并优化tabbar回退逻辑

- 更新生产和本地Mock环境的API基础URL为 https://juelin.onwall.cn
- 重构tabbar工具函数,将默认回退导航项改为仅包含首页的项,并更新所有相关引用
......@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
import { getTabbarConfigAPI } from '@/api/tabbar'
import {
getDefaultTabbarItem,
getDefaultTabbarItems,
getHomeOnlyTabbarItems,
normalizeTabbarKey,
normalizeTabbarPayload,
} from '@/utils/tabbar'
......@@ -11,7 +11,7 @@ let tabbarRequestPromise = null
export const useTabbarStore = defineStore('tabbar', {
state: () => ({
tabItems: getDefaultTabbarItems(),
tabItems: getHomeOnlyTabbarItems(),
loaded: false,
loading: false,
}),
......@@ -41,11 +41,11 @@ export const useTabbarStore = defineStore('tabbar', {
if (response?.code === 1) {
this.tabItems = normalizeTabbarPayload(response?.data)
} else {
this.tabItems = getDefaultTabbarItems()
this.tabItems = getHomeOnlyTabbarItems()
}
} catch (error) {
console.error('获取底部导航配置失败:', error)
this.tabItems = getDefaultTabbarItems()
this.tabItems = getHomeOnlyTabbarItems()
} finally {
this.loaded = true
this.loading = false
......
......@@ -10,7 +10,7 @@ export const API_ENVIRONMENTS = {
production: {
key: 'production',
label: '正式环境',
baseURL: 'https://oa.onwall.cn',
baseURL: 'https://juelin.onwall.cn',
requestDefaultParams: {
f: F,
client_id: CLIENT_ID,
......@@ -20,7 +20,7 @@ export const API_ENVIRONMENTS = {
mock: {
key: 'mock',
label: '本地 Mock 环境',
baseURL: 'https://oa.onwall.cn',
baseURL: 'https://juelin.onwall.cn',
requestDefaultParams: {
f: F,
client_id: CLIENT_ID,
......
......@@ -98,6 +98,8 @@ export const getDefaultTabbarItems = () => (
.filter(Boolean)
)
export const getHomeOnlyTabbarItems = () => [getDefaultTabbarItem('home')]
const buildTabbarPageUrl = (key, webviewUrl, webviewTitle, rawPageUrl = '') => {
if (key === 'home') {
return rawPageUrl || '/pages/index/index'
......@@ -203,14 +205,14 @@ const normalizeTabbarObjectItems = (rawMap = {}) => {
export const normalizeTabbarItems = (rawItems = []) => {
if (!Array.isArray(rawItems) || !rawItems.length) {
return getDefaultTabbarItems()
return getHomeOnlyTabbarItems()
}
const normalizedItems = rawItems
.map((item) => normalizeTabbarItem(item))
.filter(Boolean)
return normalizedItems.length ? normalizedItems : getDefaultTabbarItems()
return normalizedItems.length ? normalizedItems : getHomeOnlyTabbarItems()
}
export const normalizeTabbarPayload = (rawPayload = null) => {
......@@ -226,5 +228,5 @@ export const normalizeTabbarPayload = (rawPayload = null) => {
const objectPayload = rawPayload?.tab_items || rawPayload?.tabs || rawPayload?.menus || rawPayload
const normalizedItems = normalizeTabbarObjectItems(objectPayload)
return normalizedItems.length ? normalizedItems : getDefaultTabbarItems()
return normalizedItems.length ? normalizedItems : getHomeOnlyTabbarItems()
}
......