From ac0f4b030013beab8b626771a8bb290e926d5336 Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Wed, 5 Oct 2022 20:33:30 -0400 Subject: [PATCH] reorganize initialization --- src/main.ts | 12 +++++------- src/router/index.ts | 5 +++++ src/stores/index.ts | 6 ++++++ 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 src/stores/index.ts diff --git a/src/main.ts b/src/main.ts index 59d0558..d53833b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,16 +1,14 @@ import Vue from "vue"; -import router from "./router"; -import vuetify from "./plugins/vuetify"; -import { createPinia, PiniaVuePlugin, mapStores } from "pinia"; -import { defineThemes } from "./monaco-editor"; + +import pinia from "@/stores"; +import router from "@/router"; +import vuetify from "@/plugins/vuetify"; +import { defineThemes } from "@/monaco-editor"; import App from "@/app/AppWLoadConfig.vue"; -Vue.use(PiniaVuePlugin); Vue.config.productionTip = false; -const pinia = createPinia(); - new Vue({ router, vuetify, diff --git a/src/router/index.ts b/src/router/index.ts index 1c1c673..309f309 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -4,6 +4,11 @@ import VueRouter, { RouteConfig } from "vue-router"; import HomeView from "../views/HomeView.vue"; import Runs from "@/views/Runs.vue"; +// Pinia must be plugged in before the router if a store is used in a route +// https://github.com/vuejs/pinia/discussions/723#discussioncomment-2110660 +// import { PiniaVuePlugin } from "pinia"; +// Vue.use(PiniaVuePlugin); + Vue.use(VueRouter); const routes: Array = [ diff --git a/src/stores/index.ts b/src/stores/index.ts new file mode 100644 index 0000000..24a55c6 --- /dev/null +++ b/src/stores/index.ts @@ -0,0 +1,6 @@ +import Vue from "vue"; +import { PiniaVuePlugin, createPinia } from "pinia"; +Vue.use(PiniaVuePlugin); +const pinia = createPinia(); + +export default pinia;