perf: fix some types and delete some redundant

This commit is contained in:
xiaoxian521 2021-04-28 16:48:03 +08:00
parent 8cb2d896ad
commit 89162dee1e
14 changed files with 59 additions and 65 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

View File

@ -59,12 +59,6 @@ export default defineComponent({
() => getBreadcrumb()
);
// const pathCompile = (path: string): string | Object => {
// const { params } = route;
// var toPath = pathToRegexp.compile(path);
// return toPath(params);
// };
const handleLink = (item: RouteLocationMatched): any => {
const { redirect, path } = item;
if (redirect) {

View File

@ -13,20 +13,20 @@ export default defineComponent({
//
frontText: {
type: [Number, String],
default: 0,
default: 0
},
// back paper text
//
backText: {
type: [Number, String],
default: 1,
default: 1
},
// flipping duration, please be consistent with the CSS animation-duration value.
// CSSanimation-duration
duration: {
type: Number,
default: 600,
},
default: 600
}
},
setup(props) {
const { frontText, backText, duration } = props;
@ -86,9 +86,9 @@ export default defineComponent({
flipDown,
flipUp,
setFront,
setBack,
setBack
};
},
}
});
</script>

View File

@ -31,16 +31,16 @@ import { templateRef } from "@vueuse/core";
export default defineComponent({
name: "Control",
props: {
lf: Object || String,
lf: <ElRef>Object,
catTurboData: Boolean
},
emits: ["catData"],
setup(props, { emit }) {
const controlButton3 = templateRef<HTMLElement | null>(
const controlButton3 = templateRef<HTMLElement | any>(
"controlButton3",
null
);
const controlButton4 = templateRef<HTMLElement | null>(
const controlButton4 = templateRef<HTMLElement | any>(
"controlButton4",
null
);

View File

@ -16,24 +16,24 @@ import {
toRefs,
defineComponent,
onBeforeMount,
getCurrentInstance,
getCurrentInstance
} from "vue";
import { mapJson } from "/@/api/mock";
import { deviceDetection } from "/@/utils/deviceDetection"
import { deviceDetection } from "/@/utils/deviceDetection";
import greenCar from "/@/assets/green.png";
let MarkerCluster = null;
let MarkerCluster = <ElRef>null;
export interface MapConfigureInter {
on: any;
destroy?: any;
clearEvents?: any;
plugin?: any;
addControl?: any;
setCenter?: any;
setZoom?: any;
on: Fn;
destroy?: Fn;
clearEvents?: Fn;
addControl?: Fn;
setCenter?: Fn;
setZoom?: Fn;
plugin?: Fn;
}
export interface mapInter {
@ -47,7 +47,7 @@ export default defineComponent({
let map: MapConfigureInter;
const mapSet: mapInter = reactive({
loading: deviceDetection() ? false : true,
loading: deviceDetection() ? false : true
});
// ()
@ -71,18 +71,18 @@ export default defineComponent({
if (!vm) return;
let {
MapConfigure,
options,
options
} = vm.appContext.config.globalProperties.$config;
AMapLoader.load({
key: MapConfigure.amapKey,
version: "2.0",
plugins: ["AMap.MarkerCluster"],
plugins: ["AMap.MarkerCluster"]
})
.then((AMap) => {
.then(AMap => {
//
map = new AMap.Map(vm.refs.mapview, {
options,
options
});
//ToolBar
@ -91,7 +91,7 @@ export default defineComponent({
//
map.addControl(
new AMap.MapType({
defaultType: 0,
defaultType: 0
})
);
});
@ -103,14 +103,13 @@ export default defineComponent({
let { marker, data } = ctx;
if (Array.isArray(data) && data[0]) {
var { driver, plateNumber, orientation } = data[0];
var content = `<img style="transform: scale(1) rotate(${
360 - Number(orientation)
}deg);" src='${greenCar}' />`;
var content = `<img style="transform: scale(1) rotate(${360 -
Number(orientation)}deg);" src='${greenCar}' />`;
marker.setContent(content);
marker.setLabel({
direction: "bottom",
offset: new AMap.Pixel(-4, 0), //
content: `<div> ${plateNumber}(${driver})</div>`, //
content: `<div> ${plateNumber}(${driver})</div>` //
});
marker.setOffset(new AMap.Pixel(-18, -10));
marker.on("click", ({ lnglat }) => {
@ -118,27 +117,27 @@ export default defineComponent({
map.setCenter(lnglat);
});
}
},
}
});
//
mapJson()
.then((res) => {
.then(res => {
let points: object = res.info.map((v: any) => {
return {
lnglat: [v.lng, v.lat],
...v,
...v
};
});
if (MarkerCluster) MarkerCluster.setData(points);
})
.catch((err) => {
.catch(err => {
console.log("err:", err);
});
complete();
})
.catch((err) => {
.catch(err => {
mapSet.loading = false;
throw "地图加载失败,请重新加载";
});
@ -148,9 +147,9 @@ export default defineComponent({
...toRefs(mapSet),
complete,
destroyMap,
greenCar,
greenCar
};
},
}
});
</script>

View File

@ -1,11 +1,12 @@
// 延迟函数
export const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, timeout))
export const delay = (timeout: number) =>
new Promise((resolve) => setTimeout(resolve, timeout));
// 防抖函数
export const debounce = (fn: () => any, timeout: number) => {
let timmer: any
export const debounce = (fn: () => Fn, timeout: number) => {
let timmer: TimeoutHandle;
return () => {
timmer ? clearTimeout(timmer) : null
timmer = setTimeout(fn, timeout)
}
}
timmer ? clearTimeout(timmer) : null;
timmer = setTimeout(fn, timeout);
};
};

View File

@ -1,18 +1,18 @@
interface deviceInter {
match: any
match: Fn;
}
// 检测设备类型(手机返回true,反之)
export const deviceDetection = () => {
let sUserAgent: deviceInter = navigator.userAgent.toLowerCase()
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad"
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"
let bIsMidp = sUserAgent.match(/midp/i) == "midp"
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"
let bIsAndroid = sUserAgent.match(/android/i) == "android"
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"
let sUserAgent: deviceInter = navigator.userAgent.toLowerCase();
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
let bIsAndroid = sUserAgent.match(/android/i) == "android";
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
return bIsIphoneOs ||
bIsMidp ||
bIsUc7 ||
@ -21,5 +21,5 @@ export const deviceDetection = () => {
bIsCE ||
bIsWM
? true
: false
};
: false;
};

View File

@ -39,7 +39,7 @@ export default {
SeamlessScroll
},
setup() {
const scroll = templateRef<HTMLElement | null>("scroll", null);
const scroll = templateRef<ElRef | null>("scroll", null);
let listData = ref([
{
@ -76,8 +76,8 @@ export default {
});
function changeDirection(val) {
scroll.value.reset();
classOption.value.direction = val;
unref(scroll).reset();
unref(classOption).direction = val;
}
return {

View File

@ -30,7 +30,7 @@ import demoData from "./dataTurbo.json";
export default {
components: { NodePanel, Control, DataDialog },
setup() {
let lf = ref(null);
let lf = ref<ElRef>(null);
let graphData = ref(null);
let dataVisible = ref(false);
let config = ref({