diff --git a/src/router/index.js b/src/router/index.js index b92e144..68bb74f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -20,7 +20,7 @@ const routes = [ { path: 'mock', name: 'Mock', - component: () => import('@/views/mock/index.vue') + component: () => import('@/views/mock/index.vue'), } ] } @@ -28,4 +28,5 @@ const routes = [ const router = createRouter({history: createWebHashHistory(), routes}) + export default router diff --git a/src/views/mock/index.vue b/src/views/mock/index.vue index 4bcd66e..28d50f2 100644 --- a/src/views/mock/index.vue +++ b/src/views/mock/index.vue @@ -13,6 +13,7 @@ import {ref, computed} from "vue"; import {InfoFilled} from "@element-plus/icons-vue"; import JsonEditorVue from "json-editor-vue3"; import Api_block from "@/components/mock/api_block.vue"; +import {onBeforeRouteLeave} from "vue-router"; const mockConfigPost = ref() let cinema_items = ref([]); @@ -322,6 +323,10 @@ const handleStart = () => { console.log(selectedOvertimeShowType.value) console.log(selectedShowInfo.value) console.log(selectedStatus.value) + if (selectIp.value === '') { + alert('请先选择影院IP!') + return + } if (checkedMockConfig.value.indexOf('get_overtime_ticket_status') >= 0) { if (selectedOvertimeShowType.value === '' || selectedShowInfo.value === '' || selectedStatus.value === '') { alert('请先设置‘超时票务查询’中的选项!') @@ -347,6 +352,10 @@ const handleStart = () => { } const handleEnd = () => { + if (selectIp.value === '') { + alert('请先选择影院IP!') + return + } running.value = false startBtn_disable.value = false startBtn_loading.value = false @@ -400,6 +409,17 @@ onMounted( await get_cinema_items(); } ) +onBeforeRouteLeave((from, to, next) => { + console.log(selectIp.value) + console.log(to.path) + console.log(from.path) + if (to.path === '/mock' && running.value === true) { + alert('请先停止运行!') + }else{ + next() + } + +})