fix: cros promblem

This commit is contained in:
Joel 2024-10-29 15:19:47 +08:00
parent 6726ca102e
commit 36c01d89c9
3 changed files with 7 additions and 4 deletions

View File

@ -74,9 +74,8 @@ const PluginPage = ({
(async () => { (async () => {
await sleep(100) await sleep(100)
if (packageId) { if (packageId) {
const data = await fetchManifestFromMarketPlace(encodeURIComponent(packageId)) const { data } = await fetchManifestFromMarketPlace(encodeURIComponent(packageId))
// wait for add cors setManifest(data.plugin)
setManifest(data)
showInstallFromMarketplace() showInstallFromMarketplace()
} }
})() })()

View File

@ -290,11 +290,15 @@ const baseFetch = <T>(
}: IOtherOptions, }: IOtherOptions,
): Promise<T> => { ): Promise<T> => {
const options: typeof baseOptions & FetchOptionType = Object.assign({}, baseOptions, fetchOptions) const options: typeof baseOptions & FetchOptionType = Object.assign({}, baseOptions, fetchOptions)
if (isMarketplaceAPI)
options.credentials = 'omit'
if (getAbortController) { if (getAbortController) {
const abortController = new AbortController() const abortController = new AbortController()
getAbortController(abortController) getAbortController(abortController)
options.signal = abortController.signal options.signal = abortController.signal
} }
if (isPublicAPI) { if (isPublicAPI) {
const sharedToken = globalThis.location.pathname.split('/').slice(-1)[0] const sharedToken = globalThis.location.pathname.split('/').slice(-1)[0]
const accessToken = localStorage.getItem('token') || JSON.stringify({ [sharedToken]: '' }) const accessToken = localStorage.getItem('token') || JSON.stringify({ [sharedToken]: '' })

View File

@ -80,7 +80,7 @@ export const fetchManifest = async (uniqueIdentifier: string) => {
} }
export const fetchManifestFromMarketPlace = async (uniqueIdentifier: string) => { export const fetchManifestFromMarketPlace = async (uniqueIdentifier: string) => {
return getMarketplace<PluginDeclaration>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`) return getMarketplace<{ data: { plugin: PluginDeclaration } }>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`)
} }
export const installPackageFromMarketPlace = async (uniqueIdentifier: string) => { export const installPackageFromMarketPlace = async (uniqueIdentifier: string) => {