依然 use strict

This commit is contained in:
shenjack 2024-04-04 01:07:09 +08:00
parent 1837e0e40f
commit 7245c7014d
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -1,8 +1,9 @@
// let document = document; // let document = document;
// let window = window; // let window = window;
// 'use strict'; 'use strict';
// 兼容nodejs, 要不然 window = {}; 会崩 // 兼容nodejs, 要不然 window = {}; 会崩
// 使用 global.window 修复了这个问题, 还是 strict 舒服
let name_input = "test\ntest2"; let name_input = "test\ntest2";
let assets_data = { let assets_data = {
@ -23,6 +24,10 @@ if (run_env.from_code) {
// 整一套虚拟的window和document // 整一套虚拟的window和document
// 但说实话十分生草 // 但说实话十分生草
global.window = {
sessionStorage: function () {},
localStorage: function () {},
};
let fake_element = { let fake_element = {
style: {}, style: {},
@ -33,7 +38,7 @@ if (run_env.from_code) {
addEventListener: function () {}, addEventListener: function () {},
} }
document = { global.document = {
createElement: function (tag) { createElement: function (tag) {
return fake_element; return fake_element;
}, },
@ -42,6 +47,8 @@ if (run_env.from_code) {
}], }],
}; };
global.self = global.window;
// 读取文件 // 读取文件
let fs = require("fs"); let fs = require("fs");
let path = require("path"); let path = require("path");
@ -20701,7 +20708,7 @@ function main() {
case 0: case 0:
if (run_env.from_code) { if (run_env.from_code) {
console.log("initing from node") console.log("initing from node")
$.ox = "" $.ox = assets_data.gAd
// 后面填一下这玩意 // 后面填一下这玩意
} else { } else {
a8 = LangData.oC(true).c a8 = LangData.oC(true).c