diff --git a/build/proxy.ts b/build/proxy.ts index d11829d..669731d 100644 --- a/build/proxy.ts +++ b/build/proxy.ts @@ -3,7 +3,7 @@ import type { ProxyOptions } from 'vite' /** 不同请求服务的环境配置 */ export const proxyConfig: Record<ServiceEnvType, ServiceEnvConfig> = { dev: { - url: 'http://localhost:3000', + url: 'https://mock.apifox.com/m1/4071143-0-default', urlPattern: '/url-pattern', }, test: { diff --git a/src/layouts/components/tab/TabBar.vue b/src/layouts/components/tab/TabBar.vue index 3cb5d85..8d1f885 100644 --- a/src/layouts/components/tab/TabBar.vue +++ b/src/layouts/components/tab/TabBar.vue @@ -1,7 +1,8 @@ <script setup lang="ts"> import type { RouteLocationNormalized } from 'vue-router' -import { useAppStore, useTabStore } from '@/store' +import { NIcon } from 'naive-ui' import { renderIcon } from '@/utils' +import { useAppStore, useTabStore } from '@/store' const tabStore = useTabStore() const appStore = useAppStore() @@ -90,6 +91,17 @@ function handleContextMenu(e: MouseEvent, route: RouteLocationNormalized) { function onClickoutside() { showDropdown.value = false } + +function renderDropTabsLabel(option: any) { + return option.meta.title +} +function renderDropTabsIcon(option: any) { + return renderIcon(option.meta.icon)!() +} + +function handleDropTabs(key: string, option: any) { + router.push(option.path) +} </script> <template> @@ -121,6 +133,20 @@ function onClickoutside() { <e-icon :icon="item.meta.icon" /> {{ item.meta.title }} </div> </n-tab> + <template #suffix> + <n-dropdown + :options="tabStore.allTabs" + :render-label="renderDropTabsLabel" + :render-icon="renderDropTabsIcon" + trigger="click" + size="small" + @select="handleDropTabs" + > + <n-button tertiary circle type="primary"> + <i-icon-park-outline-application-menu /> + </n-button> + </n-dropdown> + </template> </n-tabs> <n-dropdown placement="bottom-start" diff --git a/src/service/api/test.ts b/src/service/api/test.ts index 69c64c4..c2a76b9 100644 --- a/src/service/api/test.ts +++ b/src/service/api/test.ts @@ -11,7 +11,7 @@ export function fetchPost(data: any) { } /* formPost方法测试 */ export function fetchFormPost(data: any) { - const methodInstance = alovaInstance.Post('/postAPI', data) + const methodInstance = alovaInstance.Post('/postFormAPI', data) methodInstance.meta = { isFormPost: true, } diff --git a/src/service/http/index.ts b/src/service/http/index.ts index 763ea15..0aacb51 100644 --- a/src/service/http/index.ts +++ b/src/service/http/index.ts @@ -5,12 +5,8 @@ const { url, urlPattern } = proxyConfig[import.meta.env.MODE] const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'Y' || false -export const request = createAlovaInstance({ - baseURL: isHttpProxy ? urlPattern : url, -}) - export const alovaInstance = createAlovaInstance({ - baseURL: 'https://mock.apifox.com/m1/4071143-0-default', + baseURL: isHttpProxy ? urlPattern : url, }) export const blankInstance = createAlovaInstance({ diff --git a/src/store/tab.ts b/src/store/tab.ts index 7d6b748..7116d9a 100644 --- a/src/store/tab.ts +++ b/src/store/tab.ts @@ -14,6 +14,9 @@ export const useTabStore = defineStore('tab-store', { currentTabPath: '', } }, + getters: { + allTabs: state => [...state.pinTabs, ...state.tabs], + }, actions: { addTab(route: RouteLocationNormalized) { // 根据meta确定是否不添加,可用于错误页,登录页等 diff --git a/src/typings/service.d.ts b/src/typings/service.d.ts index f96cef6..f4b04ce 100644 --- a/src/typings/service.d.ts +++ b/src/typings/service.d.ts @@ -20,7 +20,7 @@ declare namespace Service { successCode?: number | string } - type RequestErrorType = 'Alova' | 'Response' | 'Business' + type RequestErrorType = 'Response' | 'Business' type RequestCode = string | number interface RequestError {