From a4e2e5e75c9301ffb5ab9f31c1a6d43106f33db6 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 20 Oct 2022 00:40:58 +0200 Subject: build: add vue-router dependency --- src-vue/package-lock.json | 25 ++++++++++++++++++++++++- src-vue/package.json | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src-vue') diff --git a/src-vue/package-lock.json b/src-vue/package-lock.json index bcae0ab6..ace5d0db 100644 --- a/src-vue/package-lock.json +++ b/src-vue/package-lock.json @@ -12,6 +12,7 @@ "element-plus": "^2.2.17", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev", "vue": "^3.2.37", + "vue-router": "^4.1.5", "vuex": "^4.0.2" }, "devDependencies": { @@ -1131,6 +1132,20 @@ "@vue/shared": "3.2.39" } }, + "node_modules/vue-router": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.1.5.tgz", + "integrity": "sha512-IsvoF5D2GQ/EGTs/Th4NQms9gd2NSqV+yylxIyp/OYp8xOwxmU8Kj/74E9DTSYAyH5LX7idVUngN3JSj1X4xcQ==", + "dependencies": { + "@vue/devtools-api": "^6.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, "node_modules/vue-tsc": { "version": "0.40.13", "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.40.13.tgz", @@ -1840,7 +1855,7 @@ }, "tauri-plugin-store-api": { "version": "git+ssh://git@github.com/tauri-apps/tauri-plugin-store.git#4326f75446b8b9e0cb9904c65f258b81e23e544e", - "from": "tauri-plugin-store-api@https://github.com/tauri-apps/tauri-plugin-store#dev", + "from": "tauri-plugin-store-api@github:tauri-apps/tauri-plugin-store#dev", "requires": { "@tauri-apps/api": "1.1.0", "tslib": "2.4.0" @@ -1882,6 +1897,14 @@ "@vue/shared": "3.2.39" } }, + "vue-router": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.1.5.tgz", + "integrity": "sha512-IsvoF5D2GQ/EGTs/Th4NQms9gd2NSqV+yylxIyp/OYp8xOwxmU8Kj/74E9DTSYAyH5LX7idVUngN3JSj1X4xcQ==", + "requires": { + "@vue/devtools-api": "^6.1.4" + } + }, "vue-tsc": { "version": "0.40.13", "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.40.13.tgz", diff --git a/src-vue/package.json b/src-vue/package.json index 8f53ad27..186c44e0 100644 --- a/src-vue/package.json +++ b/src-vue/package.json @@ -13,6 +13,7 @@ "element-plus": "^2.2.17", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev", "vue": "^3.2.37", + "vue-router": "^4.1.5", "vuex": "^4.0.2" }, "devDependencies": { -- cgit v1.2.3 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') 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') 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') 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') 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}); + } } }