mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
perf: fix some types and delete some redundant
This commit is contained in:
parent
8cb2d896ad
commit
89162dee1e
Binary file not shown.
Before Width: | Height: | Size: 112 KiB |
Binary file not shown.
Before Width: | Height: | Size: 127 KiB |
@ -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) {
|
||||
|
@ -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.
|
||||
// 翻牌动画时间,与CSS中设置的animation-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>
|
||||
|
||||
|
@ -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
|
||||
);
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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 {
|
||||
|
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user