From a174b18c23fb1e05b2f26951306edaacb5396e12 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Wed, 8 Dec 2021 20:21:08 +0800 Subject: [PATCH] feat: add types --- {workflows => .github/workflows}/nodejs.yml | 0 package.json | 2 +- src/store/modules/app/index.ts | 2 +- src/utils/cancelToken.ts | 1 + src/utils/vec3.ts | 2 +- src/views/Settings.vue | 10 +++++++--- src/views/infrastructure/InfrastructureMap.vue | 5 ++--- src/views/infrastructure/geometry/hexagon-pillar.ts | 6 +++--- 8 files changed, 16 insertions(+), 12 deletions(-) rename {workflows => .github/workflows}/nodejs.yml (100%) diff --git a/workflows/nodejs.yml b/.github/workflows/nodejs.yml similarity index 100% rename from workflows/nodejs.yml rename to .github/workflows/nodejs.yml diff --git a/package.json b/package.json index ba0eaf1a..5c2689ce 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "parserOptions": { "ecmaVersion": 2020 }, - "rules": {}, + "rules": {"@typescript-eslint/no-explicit-any": ["off"]}, "overrides": [ { "files": [ diff --git a/src/store/modules/app/index.ts b/src/store/modules/app/index.ts index e042aa09..e3bc570e 100644 --- a/src/store/modules/app/index.ts +++ b/src/store/modules/app/index.ts @@ -103,6 +103,6 @@ export const appStore = defineStore({ }, }, }); -export function useAppStoreWithOut() { +export function useAppStoreWithOut(): any { return appStore(store); } diff --git a/src/utils/cancelToken.ts b/src/utils/cancelToken.ts index a4a5b402..f5e65dee 100644 --- a/src/utils/cancelToken.ts +++ b/src/utils/cancelToken.ts @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable */ import axios from "axios"; const CancelToken = axios.CancelToken; diff --git a/src/utils/vec3.ts b/src/utils/vec3.ts index 03a3e88d..55613d5d 100644 --- a/src/utils/vec3.ts +++ b/src/utils/vec3.ts @@ -141,7 +141,7 @@ class Vec3 extends Float32Array { return this; } /** Copy in vector data */ - copy(v: any[] | Float32Array): Vec3 { + copy(v: number[] | Float32Array): Vec3 { this[0] = v[0]; this[1] = v[1]; this[2] = v[2]; diff --git a/src/views/Settings.vue b/src/views/Settings.vue index c67b48e8..a4d8c6f0 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -79,7 +79,7 @@ import timeFormat from "@/utils/timeFormat"; import { ElSwitch } from "element-plus"; const { t, locale } = useI18n(); -const state = reactive<{ timer: any }>({ +const state = reactive<{ timer: ReturnType | null }>({ timer: null, }); const lang = ref(locale.value === "zh" ? false : true); @@ -105,14 +105,18 @@ const handleAuto = (status: boolean) => { handleReload(); state.timer = setInterval(handleReload, autoTime.value * 1000); } else { - clearInterval(state.timer); + if (state.timer) { + clearInterval(state.timer); + } } }; const changeAutoTime = () => { if (autoTime.value < 1) { return; } - clearInterval(state.timer); + if (state.timer) { + clearInterval(state.timer); + } if (auto.value) { handleReload(); state.timer = setInterval(handleReload, autoTime.value * 1000); diff --git a/src/views/infrastructure/InfrastructureMap.vue b/src/views/infrastructure/InfrastructureMap.vue index 17c622de..e4868b8a 100644 --- a/src/views/infrastructure/InfrastructureMap.vue +++ b/src/views/infrastructure/InfrastructureMap.vue @@ -16,7 +16,7 @@ limitations under the License. -->
- {{ nodeTypes[type] }} Information + {{ NodeTypes[type] }} Information
@@ -37,7 +37,6 @@ const animateCallbacks: Array<() => void> = []; const showInfo = ref(false); const objSelected = ref(null); const meshColors = ref([0xa1cffb, 0x333333, 0x333840, 0x999999]); //[0xa489b2, 0xf2bfd0, 0xf0eaea, 0xef6775, 0xfbc580]; -const nodeTypes = ref(NodeTypes); const type = ref(0); const width = ref(1920); const height = ref(900); @@ -89,7 +88,7 @@ function init(dom: HTMLDivElement): void { const helper = new THREE.GridHelper(10000, 40, 0x04002c, 0x04002c); helper.position.y = -1000; // this.scene.add(helper); - const axis = new THREE.AxesHelper(15000); + // const axis = new THREE.AxesHelper(15000); // this.scene.add(axis); // add mesh createInfrastructure(); diff --git a/src/views/infrastructure/geometry/hexagon-pillar.ts b/src/views/infrastructure/geometry/hexagon-pillar.ts index bb2f570f..1e714f8a 100644 --- a/src/views/infrastructure/geometry/hexagon-pillar.ts +++ b/src/views/infrastructure/geometry/hexagon-pillar.ts @@ -74,7 +74,7 @@ class HexagonPillar { const poly = createPolygon(radius, 6, pointyUp ? (30 * Math.PI) / 180 : 0); // Create Base Shape toVec3(rtn, poly); - const vertices = []; + const vertices: any[] = []; for (let i = 0; i < rtn.vertices.length / 3; i++) { vertices.push( new Vec3( @@ -90,7 +90,7 @@ class HexagonPillar { } // Create the basic 2d polygon shape function createPolygon(radius: number, sides = 6, offset = 0) { - const poly = []; + const poly: number[] = []; let i, rad; for (i = 0; i < sides; i++) { rad = Math.PI * 2 * (i / sides); @@ -180,7 +180,7 @@ function polyCapBevel( ) { // eslint-disable-next-line const v: any = new Vec2(); - const lerp = []; + const lerp: any[] = []; let pivot, top, pnt, i, vlen, tlen; offset = offset || [0, 0, 0];