diff --git a/src/composables/useMapNavControl.ts b/src/composables/useMapNavControl.ts index 77a6ef5..429773a 100644 --- a/src/composables/useMapNavControl.ts +++ b/src/composables/useMapNavControl.ts @@ -1,6 +1,9 @@ import { ref, nextTick, onBeforeUnmount } from 'vue' export const useMapNavControl = () => { + const SPEED_NORMAL = 6 + const SPEED_FAST = 10 + const replay = ref(false) //重播 const pause = ref(false) //暂停 const speedUp = ref(false) //加速 @@ -8,7 +11,7 @@ export const useMapNavControl = () => { //重播 function handleReplay() { - window.Map_QM.util.changePlaySpeed(6) + window.Map_QM.util.changePlaySpeed(SPEED_NORMAL) replay.value = true pause.value = false speedUp.value = false @@ -37,7 +40,7 @@ export const useMapNavControl = () => { speedUp.value = !speedUp.value window.Map_QM.pathStop(true) nextTick(() => { - speedUp.value ? window.Map_QM.util.changePlaySpeed(10) : window.Map_QM.util.changePlaySpeed(6) + speedUp.value ? window.Map_QM.util.changePlaySpeed(SPEED_FAST) : window.Map_QM.util.changePlaySpeed(SPEED_NORMAL) }) } @@ -48,7 +51,7 @@ export const useMapNavControl = () => { onBeforeUnmount(() => { clearTimeout(replayTimer.value) replayTimer.value = null - window.Map_QM.util.changePlaySpeed(6) + window.Map_QM.util.changePlaySpeed(SPEED_NORMAL) }) return { replay, pause, speedUp, handleReplay, togglePause, handleSpeedUp, resetPause } diff --git a/src/composables/useRequest.ts b/src/composables/useRequest.ts deleted file mode 100644 index ba48bc6..0000000 --- a/src/composables/useRequest.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ref } from 'vue' -import { HTTP_CODE } from '@/enums' -import type { Response } from '@/http/http' - -/** - * @template ReturnData 返回的数据 - * @template Params http请求中需要向后台发送的参数 - * @param {异步请求函数} asyncFn - * @param {Params} [query] - * @example1 - * type Result = {"activity": "Do yoga","type": "recreational" "accessibility": 0.9} - type Query = { participants: number } - * const getConfig = (data: Query) => request({ url: 'https://www.boredapi.com/api/activity' }) - const { loaded, result, error } = useRequest(getConfig, { participants: 1 }) - @example2 - *const getConfig = () => request({ url: 'static/offline/JSON/config.json' }) - const { loaded, result, error } = useRequest(getConfig) - */ -export const useRequest = (asyncFn: (params?: Params) => Promise>, query?: Params) => { - const error = ref() - const result = ref() - const loaded = ref(false) - - asyncFn(query) - .then(({ code, data, msg }) => { - if (code === HTTP_CODE.ERR_OK) { - result.value = data - } else { - error.value = msg - } - }) - .catch(err => { - error.value = err - }) - .finally(() => { - loaded.value = true - }) - - return { result, loaded, error } -}