mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
fix(demo): macro include & fetch
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user