fix(demo): macro include & fetch

This commit is contained in:
purocean
2021-11-13 11:33:25 +08:00
parent c3a1159533
commit a3d079febd
2 changed files with 10 additions and 4 deletions
+10 -2
View File
@@ -34,7 +34,7 @@ if (FLAG_DEMO) {
}
}, true)
window.fetch = (uri: any, init: any) => Promise.resolve({
const fakeFetch = (uri: any, init: any) => Promise.resolve({
json: () => {
console.log('mock api >', uri, init)
@@ -121,7 +121,7 @@ if (FLAG_DEMO) {
})
}
const path = '/' + (url.searchParams.get('doc') || 'FEATURES.md')
const path = '/' + (url.searchParams.get('doc')?.replace(/^\//, '') || 'FEATURES.md')
const data = {
status: 'ok',
message: 'success',
@@ -159,6 +159,14 @@ if (FLAG_DEMO) {
}
} as any)
window.fetch = (uri: any, init: any) => {
if (uri.startsWith('https://') || uri.startsWith('http://')) {
return xFetch(uri, init)
}
return fakeFetch(uri, init)
}
window.open = function (...args: any[]) {
const win = xOpen(...args)
win!.fetch = window.fetch
-2
View File
@@ -138,8 +138,6 @@ export default {
let posOffset = 0
state.src = state.src.replace(reg, (match, matchPos) => {
try {
console.log('xxx', match, { ...vars })
const exp = match
.substring(2, match.length - 2)
.trim()