This commit is contained in:
plightfield 2024-11-15 19:30:06 +08:00
parent 35be5445b6
commit 47d9efd677
5 changed files with 27 additions and 13 deletions

View File

@ -17,9 +17,6 @@ export const ossCdnBase = import.meta.env.PROD
export const apiBase = import.meta.env.PROD export const apiBase = import.meta.env.PROD
? 'https://goosetab.com/api' ? 'https://goosetab.com/api'
: 'http://192.168.110.28:8300' : 'http://192.168.110.28:8300'
// 后端 cdn 加速地址
export const cdnBase = import.meta.env.PROD ? apiBase : apiBase
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NzJkYjg5OGUxMjY5NDc1ODYwMmYwMTgifQ.8fpdr_HPgxyU0yr-8f6nGdbHYjsFRlBa2lvjc0Zhe-A // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NzJkYjg5OGUxMjY5NDc1ODYwMmYwMTgifQ.8fpdr_HPgxyU0yr-8f6nGdbHYjsFRlBa2lvjc0Zhe-A
// 图片后缀名 // 图片后缀名
export const imgArr = [ export const imgArr = [

View File

@ -7,6 +7,7 @@ import { globalToast } from '@/main'
import useSortable, { dragging, resetDragging } from './useSortable' import useSortable, { dragging, resetDragging } from './useSortable'
import BlockWrapper from './BlockWrapper' import BlockWrapper from './BlockWrapper'
import useSettingsStore from '@/settings/useSettingsStore' import useSettingsStore from '@/settings/useSettingsStore'
import { listenParent } from '@/utils/parent'
addIcons(MdAdd) addIcons(MdAdd)
@ -19,10 +20,16 @@ export default defineComponent(() => {
ref('page') ref('page')
) )
listenParent('openSetting', (d) => {
if (d === 'profile') {
router.go('settings-user')
}
if (d === 'setting') {
router.go('settings-ai')
}
})
return () => ( return () => (
<div <div
class="absolute left-0 top-0 w-full h-screen overflow-y-auto no-scrollbar pt-[240px] px-[calc((100%_-_var(--main-width))_/_2)]" class="absolute left-0 top-0 w-full h-screen overflow-y-auto no-scrollbar pt-[240px] px-[calc((100%_-_var(--main-width))_/_2)]"
onScroll={(e) => { onScroll={(e) => {
const h = (e.target as any).scrollTop const h = (e.target as any).scrollTop
@ -59,7 +66,6 @@ export default defineComponent(() => {
}} }}
> >
<div <div
class="w-full grid justify-center grid-flow-row-dense pb-[200px]" class="w-full grid justify-center grid-flow-row-dense pb-[200px]"
style="grid-template-columns:repeat(auto-fill, var(--block-size));grid-auto-rows:var(--block-size)" style="grid-template-columns:repeat(auto-fill, var(--block-size));grid-auto-rows:var(--block-size)"
ref={container} ref={container}

View File

@ -4,7 +4,6 @@ import useUserStore from '@/user/useUserStore'
import useRouterStore from '@/useRouterStore' import useRouterStore from '@/useRouterStore'
import asyncLoader from '@/utils/asyncLoader' import asyncLoader from '@/utils/asyncLoader'
import clsx from 'clsx' import clsx from 'clsx'
import { OhVueIcon } from 'oh-vue-icons'
import { computed, defineComponent, Transition } from 'vue' import { computed, defineComponent, Transition } from 'vue'
import SettingLineImg from '~/icons/settingLine.png' import SettingLineImg from '~/icons/settingLine.png'
const Content = asyncLoader(() => import('./SettingsOverlayContent')) const Content = asyncLoader(() => import('./SettingsOverlayContent'))
@ -107,7 +106,7 @@ export default defineComponent(() => {
onClick={() => { onClick={() => {
if (profile.id) { if (profile.id) {
router.go('settings-user') router.go('settings-user')
}else { } else {
router.go('global-login') router.go('global-login')
} }
// router.go('settings-user') // router.go('settings-user')

View File

@ -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( parent.window.postMessage(
{ {
type: data[0], type: data[0],
@ -12,7 +24,7 @@ export function sendParent(data: ['openSide'] | ['login', string] | ['logout'])
// 接收消息 // 接收消息
export function listenParent<T>(type: string, cb: (data: T) => void) { export function listenParent<T>(type: string, cb: (data: T) => void) {
window.addEventListener('message', (e) => { window.addEventListener('message', (e) => {
if (e.data?.type === 'uitab-' + type) { if (e.data?.type === 'fatfox-' + type) {
cb(e.data.data) cb(e.data.data)
} }
}) })

View File

@ -1,4 +1,4 @@
import { apiBase, cdnBase } from '@/config' import { apiBase } from '@/config'
import { UAParser } from 'ua-parser-js' import { UAParser } from 'ua-parser-js'
const ua = new UAParser(navigator.userAgent) const ua = new UAParser(navigator.userAgent)
// 设备型号:例如 Mac Os-Chrome // 设备型号:例如 Mac Os-Chrome
@ -12,7 +12,7 @@ const device = ua.getOS().name + '-' + ua.getBrowser().name
*/ */
export default function request<R>( export default function request<R>(
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
url: `${'/api' | '/cdn'}${string}`, url: `/api${string}`,
requestConfig?: { requestConfig?: {
data?: any data?: any
dataType?: 'json' | 'form' dataType?: 'json' | 'form'
@ -40,7 +40,7 @@ export default function request<R>(
} }
} }
} }
const path = url.replace(/^\/api/, apiBase).replace(/^\/cdn/, cdnBase) const path = url.replace(/^\/api/, apiBase)
return fetch(path, config).then((res) => { return fetch(path, config).then((res) => {
if (res.status >= 200 && res.status < 400) { if (res.status >= 200 && res.status < 400) {
return res[returnType]() return res[returnType]()