From 47d9efd67746a0e78648686cf2c8b9aea4d815f2 Mon Sep 17 00:00:00 2001 From: plightfield <1207120484@qq.com> Date: Fri, 15 Nov 2024 19:30:06 +0800 Subject: [PATCH] change --- src/config.ts | 3 --- src/layout/grid/index.tsx | 12 +++++++++--- src/settings/SettingsOverlay.tsx | 3 +-- src/utils/parent.ts | 16 ++++++++++++++-- src/utils/request.ts | 6 +++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/config.ts b/src/config.ts index ebb6f68..560c33a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -17,9 +17,6 @@ export const ossCdnBase = import.meta.env.PROD export const apiBase = import.meta.env.PROD ? 'https://goosetab.com/api' : 'http://192.168.110.28:8300' - -// 后端 cdn 加速地址 -export const cdnBase = import.meta.env.PROD ? apiBase : apiBase // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NzJkYjg5OGUxMjY5NDc1ODYwMmYwMTgifQ.8fpdr_HPgxyU0yr-8f6nGdbHYjsFRlBa2lvjc0Zhe-A // 图片后缀名 export const imgArr = [ diff --git a/src/layout/grid/index.tsx b/src/layout/grid/index.tsx index a9e4985..b09c2c5 100644 --- a/src/layout/grid/index.tsx +++ b/src/layout/grid/index.tsx @@ -7,6 +7,7 @@ import { globalToast } from '@/main' import useSortable, { dragging, resetDragging } from './useSortable' import BlockWrapper from './BlockWrapper' import useSettingsStore from '@/settings/useSettingsStore' +import { listenParent } from '@/utils/parent' addIcons(MdAdd) @@ -19,10 +20,16 @@ export default defineComponent(() => { ref('page') ) + listenParent('openSetting', (d) => { + if (d === 'profile') { + router.go('settings-user') + } + if (d === 'setting') { + router.go('settings-ai') + } + }) return () => (
{ const h = (e.target as any).scrollTop @@ -59,7 +66,6 @@ export default defineComponent(() => { }} >
import('./SettingsOverlayContent')) @@ -107,7 +106,7 @@ export default defineComponent(() => { onClick={() => { if (profile.id) { router.go('settings-user') - }else { + } else { router.go('global-login') } // router.go('settings-user') diff --git a/src/utils/parent.ts b/src/utils/parent.ts index 01739da..f8e26c1 100644 --- a/src/utils/parent.ts +++ b/src/utils/parent.ts @@ -1,5 +1,17 @@ // 发送消息 -export function sendParent(data: ['openSide'] | ['login', string] | ['logout']) { +export function sendParent( + data: + | ['openSide'] + | ['login', string] + | ['logout'] + | [ + 'configAI', + { + autoSearch: true + showTabButton: true + } + ] +) { parent.window.postMessage( { type: data[0], @@ -12,7 +24,7 @@ export function sendParent(data: ['openSide'] | ['login', string] | ['logout']) // 接收消息 export function listenParent(type: string, cb: (data: T) => void) { window.addEventListener('message', (e) => { - if (e.data?.type === 'uitab-' + type) { + if (e.data?.type === 'fatfox-' + type) { cb(e.data.data) } }) diff --git a/src/utils/request.ts b/src/utils/request.ts index f2a8079..c0da103 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,4 +1,4 @@ -import { apiBase, cdnBase } from '@/config' +import { apiBase } from '@/config' import { UAParser } from 'ua-parser-js' const ua = new UAParser(navigator.userAgent) // 设备型号:例如 Mac Os-Chrome @@ -12,7 +12,7 @@ const device = ua.getOS().name + '-' + ua.getBrowser().name */ export default function request( method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', - url: `${'/api' | '/cdn'}${string}`, + url: `/api${string}`, requestConfig?: { data?: any dataType?: 'json' | 'form' @@ -40,7 +40,7 @@ export default function request( } } } - const path = url.replace(/^\/api/, apiBase).replace(/^\/cdn/, cdnBase) + const path = url.replace(/^\/api/, apiBase) return fetch(path, config).then((res) => { if (res.status >= 200 && res.status < 400) { return res[returnType]()