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 () => {
await sleep(100)
if (packageId) {
const data = await fetchManifestFromMarketPlace(encodeURIComponent(packageId))
// wait for add cors
setManifest(data)
const { data } = await fetchManifestFromMarketPlace(encodeURIComponent(packageId))
setManifest(data.plugin)
showInstallFromMarketplace()
}
})()

View File

@ -290,11 +290,15 @@ const baseFetch = <T>(
}: IOtherOptions,
): Promise<T> => {
const options: typeof baseOptions & FetchOptionType = Object.assign({}, baseOptions, fetchOptions)
if (isMarketplaceAPI)
options.credentials = 'omit'
if (getAbortController) {
const abortController = new AbortController()
getAbortController(abortController)
options.signal = abortController.signal
}
if (isPublicAPI) {
const sharedToken = globalThis.location.pathname.split('/').slice(-1)[0]
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) => {
return getMarketplace<PluginDeclaration>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`)
return getMarketplace<{ data: { plugin: PluginDeclaration } }>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`)
}
export const installPackageFromMarketPlace = async (uniqueIdentifier: string) => {