From 70020d643abeee1a1a507fb5ec70da3675873963 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Mon, 18 Nov 2024 01:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/partials/StrengthSettings.vue | 71 -------------- .../FadeAndSlideTransitionGroup.vue | 67 +++++++++----- frontend/src/main.ts | 10 +- frontend/src/pages/Controller.vue | 26 +++--- .../controller}/GameConnection.vue | 0 .../controller}/PulseSettings.vue | 92 +++++++++---------- .../src/pages/controller/StrengthSettings.vue | 75 +++++++++++++++ frontend/vite.config.ts | 1 + 8 files changed, 190 insertions(+), 152 deletions(-) delete mode 100644 frontend/src/components/partials/StrengthSettings.vue rename frontend/src/{components/partials => pages/controller}/GameConnection.vue (100%) rename frontend/src/{components/partials => pages/controller}/PulseSettings.vue (58%) create mode 100644 frontend/src/pages/controller/StrengthSettings.vue diff --git a/frontend/src/components/partials/StrengthSettings.vue b/frontend/src/components/partials/StrengthSettings.vue deleted file mode 100644 index 83328e5..0000000 --- a/frontend/src/components/partials/StrengthSettings.vue +++ /dev/null @@ -1,71 +0,0 @@ - - - \ No newline at end of file diff --git a/frontend/src/components/transitions/FadeAndSlideTransitionGroup.vue b/frontend/src/components/transitions/FadeAndSlideTransitionGroup.vue index 6ea3a9e..97502e8 100644 --- a/frontend/src/components/transitions/FadeAndSlideTransitionGroup.vue +++ b/frontend/src/components/transitions/FadeAndSlideTransitionGroup.vue @@ -1,47 +1,70 @@ \ No newline at end of file diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 3b988af..cf7078c 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -20,7 +20,15 @@ import App from './App.vue' const appName = '战败惩罚'; const routes: RouteRecordRaw[] = [ - { path: '/', component: () => import('./pages/Controller.vue'), name: '控制器' }, + { + path: '/', component: () => import('./pages/Controller.vue'), name: '控制器', + children: [ + { path: '', redirect: 'strength' }, + { path: 'strength', component: () => import('./pages/controller/StrengthSettings.vue'), name: '控制器 - 强度设置' }, + { path: 'pulse', component: () => import('./pages/controller/PulseSettings.vue'), name: '控制器 - 波形设置' }, + { path: 'game', component: () => import('./pages/controller/GameConnection.vue'), name: '控制器 - 游戏连接' }, + ], + }, ]; const router = createRouter({ diff --git a/frontend/src/pages/Controller.vue b/frontend/src/pages/Controller.vue index 8828251..22c65fc 100644 --- a/frontend/src/pages/Controller.vue +++ b/frontend/src/pages/Controller.vue @@ -14,7 +14,6 @@ import { PulseItemInfo } from '../type/pulse'; import { useConfirm } from 'primevue/useconfirm'; import { ConnectorType, CoyoteDeviceVersion } from '../type/common'; import CoyoteBluetoothService from '../components/partials/CoyoteBluetoothService.vue'; -import PulseSettings from '../components/partials/PulseSettings.vue'; import ClientInfoDialog from '../components/dialogs/ClientInfoDialog.vue'; import { useClientsStore } from '../stores/ClientsStore'; import ConnectToSavedClientsDialog from '../components/dialogs/ConnectToSavedClientsDialog.vue'; @@ -93,6 +92,8 @@ const state = reactive({ showConnectToSavedClientsDialog: false, }); +const router = useRouter(); + const coyoteBTRef = ref | null>(null); const controllerPageTabs = [ @@ -101,6 +102,10 @@ const controllerPageTabs = [ { title: '游戏连接', id: 'game', icon: 'pi pi-map' }, ]; +watch(() => state.controllerPage, (newVal) => { + router.push({ path: newVal }); +}); + // 在收到服务器的配置后设置为true,防止触发watch let receivedConfig = false; @@ -391,6 +396,7 @@ const postCustomPulseConfig = async () => { console.error('Cannot post custom pulse config:', error); } }; +provide('postCustomPulseConfig', postCustomPulseConfig); const handleStartGame = async () => { if (!dgClientConnected) { @@ -533,17 +539,13 @@ watch([gameConfig, strengthConfig], () => { diff --git a/frontend/src/components/partials/GameConnection.vue b/frontend/src/pages/controller/GameConnection.vue similarity index 100% rename from frontend/src/components/partials/GameConnection.vue rename to frontend/src/pages/controller/GameConnection.vue diff --git a/frontend/src/components/partials/PulseSettings.vue b/frontend/src/pages/controller/PulseSettings.vue similarity index 58% rename from frontend/src/components/partials/PulseSettings.vue rename to frontend/src/pages/controller/PulseSettings.vue index a9aaa74..3c3cf3f 100644 --- a/frontend/src/components/partials/PulseSettings.vue +++ b/frontend/src/pages/controller/PulseSettings.vue @@ -40,9 +40,7 @@ const state = reactive({ showRenamePulseDialog: false, }); -const emit = defineEmits<{ - postCustomPulseConfig: [] -}>(); +const postCustomPulseConfig = inject<() => void>('postCustomPulseConfig'); const toast = inject('parentToast'); const confirm = inject<{ @@ -75,7 +73,7 @@ const handlePulseImported = async (pulseInfo: PulseItemInfo) => { parentState.customPulseList.push(pulseInfo); toast?.add({ severity: 'success', summary: '导入成功', detail: '波形已导入', life: 3000 }); - emit('postCustomPulseConfig'); + postCustomPulseConfig?.(); }; const togglePulse = (pulseId: string) => { @@ -110,7 +108,7 @@ const handleRenamePulseConfirm = async (newName: string) => { let pulse = parentState.customPulseList.find((item) => item.id === renamePulseId); if (pulse) { pulse.name = newName; - emit('postCustomPulseConfig'); + postCustomPulseConfig?.(); } }; @@ -135,7 +133,7 @@ const handleDeletePulse = async (pulseId: string) => { parentState.selectPulseIds = [fullPulseList.value[0].id]; } - emit('postCustomPulseConfig'); + postCustomPulseConfig?.(); }, }); }; @@ -143,47 +141,49 @@ const handleDeletePulse = async (pulseId: string) => { \ No newline at end of file diff --git a/frontend/src/pages/controller/StrengthSettings.vue b/frontend/src/pages/controller/StrengthSettings.vue new file mode 100644 index 0000000..cf943e8 --- /dev/null +++ b/frontend/src/pages/controller/StrengthSettings.vue @@ -0,0 +1,75 @@ + + + \ No newline at end of file diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 2e6d84a..7e36ad2 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -18,6 +18,7 @@ export default defineConfig({ output: { manualChunks: { 'chartRoutes': ['./src/charts/chartRoutes.ts'], + 'dg-pulse-helper': ['./src/lib/dg-pulse-helper/index.ts'], } } },