From 74ac7c30c1d9ce4eb8040205727e2966f43db10a Mon Sep 17 00:00:00 2001 From: ChenX Date: Fri, 11 Jun 2021 14:33:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91:=E5=8D=87=E7=BA=A7=E5=88=B0j?= =?UTF-8?q?est27=E5=B9=B6=E4=B8=94=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81,?= =?UTF-8?q?=E4=BD=BF=E5=BE=97=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8=E8=B7=91?= =?UTF-8?q?=E5=9C=A8node=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/FileSystem/Purge.test.ts | 2 +- package.json | 18 +++++++++--------- src/Common/HostUrl.ts | 4 ++-- src/Editor/UserConfig.ts | 2 +- src/Loader/ImageLoader.ts | 12 ++++++++---- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/__test__/FileSystem/Purge.test.ts b/__test__/FileSystem/Purge.test.ts index a93938c22..91948ff19 100644 --- a/__test__/FileSystem/Purge.test.ts +++ b/__test__/FileSystem/Purge.test.ts @@ -1,5 +1,5 @@ import { Purge } from "../../src/Add-on/Purge"; -import { CADFiler } from "../../src/api"; +import { CADFiler } from "../../src/DatabaseServices/CADFiler"; import { Database } from "../../src/DatabaseServices/Database"; import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; LoadEntityFromFileData; diff --git a/package.json b/package.json index 3b1ece43d..da949baba 100644 --- a/package.json +++ b/package.json @@ -30,16 +30,16 @@ "@types/flatbush": "^3.3.0", "@types/html-webpack-plugin": "^3.2.5", "@types/jest": "^26.0.23", - "@types/node": "^14.14.43", + "@types/node": "^14.17.3", "@types/pako": "^1.0.1", - "@types/react": "^17.0.4", + "@types/react": "^17.0.11", "@types/react-color": "^3.0.4", - "@types/react-dom": "^17.0.3", + "@types/react-dom": "^17.0.7", "@types/request-promise-native": "^1.0.17", "@types/stats.js": "^0.17.0", "@types/terser-webpack-plugin": "^5.0.3", - "@types/webpack": "^4.41.28", - "@types/webpack-dev-server": "^3.11.3", + "@types/webpack": "^4.41.29", + "@types/webpack-dev-server": "^3.11.4", "@types/webpack-env": "^1.16.0", "@types/webpack-merge": "^4.1.5", "@wessberg/rollup-plugin-ts": "^1.3.14", @@ -55,8 +55,8 @@ "gitlog": "^4.0.4", "html-loader": "^1.3.2", "html-webpack-plugin": "^4.5.2", - "jest": "^26.6.3", - "jest-snapshot": "^27.0.2", + "jest": "^27.0.4", + "jest-snapshot": "^27.0.4", "less": "^4.1.1", "less-loader": "7.3.0", "react-hot-loader": "^4.13.0", @@ -64,7 +64,7 @@ "request-promise-native": "^1.0.9", "required-loader": "^1.3.16", "resize-observer-polyfill": "^1.5.1", - "rollup": "^2.45.2", + "rollup": "^2.51.2", "rollup-plugin-dts": "^1.4.14", "rollup-plugin-shader": "0.0.3", "rollup-plugin-sourcemaps": "^0.6.3", @@ -73,7 +73,7 @@ "style-loader": "^2.0.0", "terser-webpack-plugin": "^4.2.3", "ts-declaration-webpack-plugin": "^1.2.3", - "ts-jest": "^26.5.5", + "ts-jest": "^27.0.3", "ts-loader": "^8.3.0", "ts-node": "^9.1.1", "tsconfig-paths": "^3.9.0", diff --git a/src/Common/HostUrl.ts b/src/Common/HostUrl.ts index 4e904be43..2252db4af 100644 --- a/src/Common/HostUrl.ts +++ b/src/Common/HostUrl.ts @@ -1,9 +1,9 @@ function GetCurHost() { - let searchParams = new URLSearchParams(location.search); + let searchParams = new URLSearchParams(globalThis.location?.search); if (searchParams.has("server")) return searchParams.get("server"); - else if (window.location.hostname === "cfcad.cn" || window.location.hostname === "www.cfcad.cn") + else if (globalThis.location?.hostname === "cfcad.cn" || globalThis.location?.hostname === "www.cfcad.cn") return "https://cad.leye.site"; else return "https://chenfeng.tech:7779"; diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index fe721a872..72290148a 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -111,7 +111,7 @@ export class UserConfig implements IConfigStore } Init() { - let type = Number(localStorage.getItem(StoreageKeys.RenderType)); + let type = Number(globalThis.localStorage?.getItem(StoreageKeys.RenderType)); if (type && type !== RenderType.Edge) this._renderType = type; } diff --git a/src/Loader/ImageLoader.ts b/src/Loader/ImageLoader.ts index d2190d104..3c1f14bd4 100644 --- a/src/Loader/ImageLoader.ts +++ b/src/Loader/ImageLoader.ts @@ -32,11 +32,15 @@ export async function LoadImageFromUrl(url: string): Promise { return new Promise(async (res, rej) => { - loader.load(url, img => + if (!globalThis.document) { - res(img); - }, e => { }, - err => { res(undefined); } + res(undefined); + return; + }; + + loader.load(url, + img => res(img), e => { }, + err => res(undefined) ); }); }