mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 19:39:30 +08:00
29 lines
729 B
Text
29 lines
729 B
Text
declare const __MODE__: string
|
|
declare const __DEFINES__: Record<string, any>
|
|
|
|
const context = (() => {
|
|
if (typeof globalThis !== 'undefined') {
|
|
return globalThis
|
|
} else if (typeof self !== 'undefined') {
|
|
return self
|
|
} else if (typeof window !== 'undefined') {
|
|
return window
|
|
} else {
|
|
return Function('return this')()
|
|
}
|
|
})()
|
|
|
|
// assign defines
|
|
const defines = __DEFINES__
|
|
Object.keys(defines).forEach((key) => {
|
|
const segments = key.split('.')
|
|
let target = context
|
|
for (let i = 0; i < segments.length; i++) {
|
|
const segment = segments[i]
|
|
if (i === segments.length - 1) {
|
|
target[segment] = defines[key]
|
|
} else {
|
|
target = target[segment] || (target[segment] = {})
|
|
}
|
|
}
|
|
})
|