feat: add types

This commit is contained in:
Qiuxia Fan 2021-12-08 20:21:08 +08:00
parent ffcdd1939a
commit a174b18c23
8 changed files with 16 additions and 12 deletions

View File

@ -62,7 +62,7 @@
"parserOptions": { "parserOptions": {
"ecmaVersion": 2020 "ecmaVersion": 2020
}, },
"rules": {}, "rules": {"@typescript-eslint/no-explicit-any": ["off"]},
"overrides": [ "overrides": [
{ {
"files": [ "files": [

View File

@ -103,6 +103,6 @@ export const appStore = defineStore({
}, },
}, },
}); });
export function useAppStoreWithOut() { export function useAppStoreWithOut(): any {
return appStore(store); return appStore(store);
} }

View File

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable */
import axios from "axios"; import axios from "axios";
const CancelToken = axios.CancelToken; const CancelToken = axios.CancelToken;

View File

@ -141,7 +141,7 @@ class Vec3 extends Float32Array {
return this; return this;
} }
/** Copy in vector data */ /** Copy in vector data */
copy(v: any[] | Float32Array): Vec3 { copy(v: number[] | Float32Array): Vec3 {
this[0] = v[0]; this[0] = v[0];
this[1] = v[1]; this[1] = v[1];
this[2] = v[2]; this[2] = v[2];

View File

@ -79,7 +79,7 @@ import timeFormat from "@/utils/timeFormat";
import { ElSwitch } from "element-plus"; import { ElSwitch } from "element-plus";
const { t, locale } = useI18n(); const { t, locale } = useI18n();
const state = reactive<{ timer: any }>({ const state = reactive<{ timer: ReturnType<typeof setInterval> | null }>({
timer: null, timer: null,
}); });
const lang = ref<boolean>(locale.value === "zh" ? false : true); const lang = ref<boolean>(locale.value === "zh" ? false : true);
@ -105,14 +105,18 @@ const handleAuto = (status: boolean) => {
handleReload(); handleReload();
state.timer = setInterval(handleReload, autoTime.value * 1000); state.timer = setInterval(handleReload, autoTime.value * 1000);
} else { } else {
clearInterval(state.timer); if (state.timer) {
clearInterval(state.timer);
}
} }
}; };
const changeAutoTime = () => { const changeAutoTime = () => {
if (autoTime.value < 1) { if (autoTime.value < 1) {
return; return;
} }
clearInterval(state.timer); if (state.timer) {
clearInterval(state.timer);
}
if (auto.value) { if (auto.value) {
handleReload(); handleReload();
state.timer = setInterval(handleReload, autoTime.value * 1000); state.timer = setInterval(handleReload, autoTime.value * 1000);

View File

@ -16,7 +16,7 @@ limitations under the License. -->
<div class="infrastructure-box"> <div class="infrastructure-box">
<div ref="mapRef" class="map"></div> <div ref="mapRef" class="map"></div>
<div class="info-box" v-show="showInfo"> <div class="info-box" v-show="showInfo">
{{ nodeTypes[type] }} Information {{ NodeTypes[type] }} Information
</div> </div>
</div> </div>
</template> </template>
@ -37,7 +37,6 @@ const animateCallbacks: Array<() => void> = [];
const showInfo = ref<boolean>(false); const showInfo = ref<boolean>(false);
const objSelected = ref<any>(null); const objSelected = ref<any>(null);
const meshColors = ref([0xa1cffb, 0x333333, 0x333840, 0x999999]); //[0xa489b2, 0xf2bfd0, 0xf0eaea, 0xef6775, 0xfbc580]; const meshColors = ref([0xa1cffb, 0x333333, 0x333840, 0x999999]); //[0xa489b2, 0xf2bfd0, 0xf0eaea, 0xef6775, 0xfbc580];
const nodeTypes = ref(NodeTypes);
const type = ref<number>(0); const type = ref<number>(0);
const width = ref<number>(1920); const width = ref<number>(1920);
const height = ref<number>(900); const height = ref<number>(900);
@ -89,7 +88,7 @@ function init(dom: HTMLDivElement): void {
const helper = new THREE.GridHelper(10000, 40, 0x04002c, 0x04002c); const helper = new THREE.GridHelper(10000, 40, 0x04002c, 0x04002c);
helper.position.y = -1000; helper.position.y = -1000;
// this.scene.add(helper); // this.scene.add(helper);
const axis = new THREE.AxesHelper(15000); // const axis = new THREE.AxesHelper(15000);
// this.scene.add(axis); // this.scene.add(axis);
// add mesh // add mesh
createInfrastructure(); createInfrastructure();

View File

@ -74,7 +74,7 @@ class HexagonPillar {
const poly = createPolygon(radius, 6, pointyUp ? (30 * Math.PI) / 180 : 0); // Create Base Shape const poly = createPolygon(radius, 6, pointyUp ? (30 * Math.PI) / 180 : 0); // Create Base Shape
toVec3(rtn, poly); toVec3(rtn, poly);
const vertices = []; const vertices: any[] = [];
for (let i = 0; i < rtn.vertices.length / 3; i++) { for (let i = 0; i < rtn.vertices.length / 3; i++) {
vertices.push( vertices.push(
new Vec3( new Vec3(
@ -90,7 +90,7 @@ class HexagonPillar {
} }
// Create the basic 2d polygon shape // Create the basic 2d polygon shape
function createPolygon(radius: number, sides = 6, offset = 0) { function createPolygon(radius: number, sides = 6, offset = 0) {
const poly = []; const poly: number[] = [];
let i, rad; let i, rad;
for (i = 0; i < sides; i++) { for (i = 0; i < sides; i++) {
rad = Math.PI * 2 * (i / sides); rad = Math.PI * 2 * (i / sides);
@ -180,7 +180,7 @@ function polyCapBevel(
) { ) {
// eslint-disable-next-line // eslint-disable-next-line
const v: any = new Vec2(); const v: any = new Vec2();
const lerp = []; const lerp: any[] = [];
let pivot, top, pnt, i, vlen, tlen; let pivot, top, pnt, i, vlen, tlen;
offset = offset || [0, 0, 0]; offset = offset || [0, 0, 0];