From 5bcd8063ee1dbf0df5af6b4e19e7498ba69d3e58 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 20 Oct 2022 00:55:09 +0200 Subject: feat: add router config --- src-vue/src/main.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src-vue/src') diff --git a/src-vue/src/main.ts b/src-vue/src/main.ts index 0ac31a2d..623b175d 100644 --- a/src-vue/src/main.ts +++ b/src-vue/src/main.ts @@ -2,14 +2,21 @@ import { createApp } from 'vue' import App from './App.vue' import ElementPlus from "element-plus"; import * as ElementPlusIconsVue from '@element-plus/icons-vue' +import { store } from './plugins/store'; +import PlayView from "./views/PlayView.vue"; +import ChangelogView from "./views/ChangelogView.vue"; +import SettingsView from "./views/SettingsView.vue"; +import DeveloperView from "./views/DeveloperView.vue"; +import {createRouter, createWebHashHistory} from "vue-router"; + + +const app = createApp(App); // styles import 'element-plus/theme-chalk/index.css'; import './style.css' -import { store } from './plugins/store'; -const app = createApp(App); app.use(ElementPlus); // icons @@ -20,4 +27,19 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) { // style app.use( store, '$store' ); + +// routes +const routes = [ + { path: '/', name: 'Main', component: () => PlayView}, + { path: '/changelog', name: 'Changelog', component: () => ChangelogView}, + { path: '/settings', name: 'Settings', component: () => SettingsView}, + { path: '/dev', name: 'Dev', component: () => DeveloperView} +]; +const router = createRouter({ + history: createWebHashHistory(), + routes, // short for `routes: routes` +}); +app.use(router); + + app.mount('#app') -- cgit v1.2.3 From 8172bbcd9f0cdaf1b1cbb810617740183377b1ea Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 20 Oct 2022 01:17:14 +0200 Subject: feat: push PlayView as default view on launch --- src-vue/src/main.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'src-vue/src') diff --git a/src-vue/src/main.ts b/src-vue/src/main.ts index 623b175d..bbc99952 100644 --- a/src-vue/src/main.ts +++ b/src-vue/src/main.ts @@ -40,6 +40,7 @@ const router = createRouter({ routes, // short for `routes: routes` }); app.use(router); +router.push({path: '/'}); app.mount('#app') -- cgit v1.2.3 From 39db7afe31f845e3cc1a8c32a5216e672ba3c955 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 20 Oct 2022 01:17:41 +0200 Subject: fix: all routes must give a Future --- src-vue/src/main.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src-vue/src') diff --git a/src-vue/src/main.ts b/src-vue/src/main.ts index bbc99952..758fe747 100644 --- a/src-vue/src/main.ts +++ b/src-vue/src/main.ts @@ -30,10 +30,10 @@ app.use( store, '$store' ); // routes const routes = [ - { path: '/', name: 'Main', component: () => PlayView}, - { path: '/changelog', name: 'Changelog', component: () => ChangelogView}, - { path: '/settings', name: 'Settings', component: () => SettingsView}, - { path: '/dev', name: 'Dev', component: () => DeveloperView} + { path: '/', name: 'Main', component: async () => PlayView}, + { path: '/changelog', name: 'Changelog', component: async () => ChangelogView}, + { path: '/settings', name: 'Settings', component: async () => SettingsView}, + { path: '/dev', name: 'Dev', component: async () => DeveloperView} ]; const router = createRouter({ history: createWebHashHistory(), -- cgit v1.2.3 From 732cf68fe6fd2a9ed043b0795145039943351c1b Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 20 Oct 2022 01:21:55 +0200 Subject: refactor: replace tabs with app menu + router view --- src-vue/src/App.vue | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src-vue/src') diff --git a/src-vue/src/App.vue b/src-vue/src/App.vue index 2a2a176f..97a11539 100644 --- a/src-vue/src/App.vue +++ b/src-vue/src/App.vue @@ -23,7 +23,7 @@ export default { // Enable dragging entire app by dragging menu bar. // https://github.com/tauri-apps/tauri/issues/1656#issuecomment-1161495124 document.querySelector(".el-tabs__nav-scroll")!.addEventListener("mousedown", async e => { - if ((e.target as Element).closest(".el-tabs__item")) return; // Disable drag when clicking menu items. + if ((e.target as Element).closest(".el-menu-item")) return; // Disable drag when clicking menu items. await tauriWindow.appWindow.startDragging(); }); }, @@ -33,22 +33,31 @@ export default { }, close() { appWindow.close() - } + }, + handleSelect(key: string, keyPath: string[]) { + this.$router.push({path: key}); + } } }