mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 02:12:08 +08:00
冻结lx对象
This commit is contained in:
parent
b3e987f2ff
commit
56f78ea160
@ -484,6 +484,13 @@ globalThis.lx_setup = (key, id, name, description, rawScript) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const freezeObject = (obj) => {
|
||||||
|
if (typeof obj != 'object') return
|
||||||
|
Object.freeze(obj)
|
||||||
|
for (const subObj of Object.values(obj)) freezeObject(subObj)
|
||||||
|
}
|
||||||
|
freezeObject(globalThis.lx)
|
||||||
|
|
||||||
const _toString = Function.prototype.toString
|
const _toString = Function.prototype.toString
|
||||||
// eslint-disable-next-line no-extend-native
|
// eslint-disable-next-line no-extend-native
|
||||||
Function.prototype.toString = function() {
|
Function.prototype.toString = function() {
|
||||||
@ -497,7 +504,7 @@ globalThis.lx_setup = (key, id, name, description, rawScript) => {
|
|||||||
Function.prototype.toLocaleString,
|
Function.prototype.toLocaleString,
|
||||||
Object.prototype.toString,
|
Object.prototype.toString,
|
||||||
]
|
]
|
||||||
const freezeObject = (obj, freezedObj = new Set()) => {
|
const freezeObjectProperty = (obj, freezedObj = new Set()) => {
|
||||||
if (obj == null) return
|
if (obj == null) return
|
||||||
switch (typeof obj) {
|
switch (typeof obj) {
|
||||||
case 'object':
|
case 'object':
|
||||||
@ -511,11 +518,11 @@ globalThis.lx_setup = (key, id, name, description, rawScript) => {
|
|||||||
if (config.configurable) config.configurable = false
|
if (config.configurable) config.configurable = false
|
||||||
Object.defineProperty(obj, name, config)
|
Object.defineProperty(obj, name, config)
|
||||||
}
|
}
|
||||||
freezeObject(config.value, freezedObj)
|
freezeObjectProperty(config.value, freezedObj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freezeObject(globalThis)
|
freezeObjectProperty(globalThis)
|
||||||
|
|
||||||
console.log('Preload finished.')
|
console.log('Preload finished.')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user