Fix monkey cache

This commit is contained in:
the1812 2022-05-25 21:42:59 +08:00
parent 9e93313b6c
commit fc78c3ada7
3 changed files with 6 additions and 2 deletions

View File

@ -143,7 +143,7 @@ export class DevClient extends EventTarget {
if (!oldComponent) { if (!oldComponent) {
return return
} }
const code: string = await coreApis.ajax.monkey({ url }) const code: string = await monkey({ url })
const { installFeatureFromCode } = await import( const { installFeatureFromCode } = await import(
'@/core/install-feature' '@/core/install-feature'
) )

View File

@ -151,6 +151,7 @@ export const postJsonWithCredentials = (url: string, json: any) => send<string>(
export const monkey = <T = any>(details: MonkeyXhrBasicDetails) => ( export const monkey = <T = any>(details: MonkeyXhrBasicDetails) => (
new Promise<T>((resolve, reject) => { new Promise<T>((resolve, reject) => {
const fullDetails: MonkeyXhrDetails = { const fullDetails: MonkeyXhrDetails = {
nocache: true,
...details, ...details,
onload: (r: MonkeyXhrResponse) => resolve(r.response), onload: (r: MonkeyXhrResponse) => resolve(r.response),
onerror: (r: MonkeyXhrResponse) => { onerror: (r: MonkeyXhrResponse) => {

5
src/global.d.ts vendored
View File

@ -51,14 +51,17 @@ declare global {
method?: 'GET' | 'POST' | 'HEAD' method?: 'GET' | 'POST' | 'HEAD'
headers?: { [name: string]: string }, headers?: { [name: string]: string },
data?: string data?: string
cookie?: string
binary?: boolean binary?: boolean
nocache?: boolean
revalidate?: boolean
timeout?: number timeout?: number
context?: any context?: any
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'
overrideMimeType?: string overrideMimeType?: string
anonymous?: boolean anonymous?: boolean
fetch?: boolean fetch?: boolean
username?: string user?: string
password?: string password?: string
} }
interface MonkeyXhrDetails extends MonkeyXhrBasicDetails { interface MonkeyXhrDetails extends MonkeyXhrBasicDetails {