From dddafef3a1e9d9354f916c67106bb392a2ed7046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 13 Oct 2020 11:27:27 +0200 Subject: [PATCH] Fixed Error und Warnings --- package-lock.json | 30 ++----- package.json | 2 +- quasar.conf.js | 6 -- src/boot/composition-api.ts | 3 +- src/boot/plugins.ts | 42 +++++---- ...nLinksHome.vue => PluginChildrenLinks.vue} | 0 .../navigation/PluginLinksAbout.vue | 28 ------ src/layouts/MainLayout.vue | 90 +++++++++++++++++-- src/layouts/OutLayout.vue | 18 ++-- src/pages/Login.vue | 4 +- src/pages/home/Home.vue | 2 +- src/plugins/plugin-example-2/pages/Plugin.vue | 2 +- src/plugins/plugin-example-2/plugin.ts | 24 ++++- src/plugins/plugin-example/pages/Plugin.vue | 2 +- src/plugins/plugin-example/plugin.ts | 24 ++++- src/router/routes.ts | 12 +-- tsconfig.json | 2 +- 17 files changed, 172 insertions(+), 119 deletions(-) rename src/components/navigation/{PluginLinksHome.vue => PluginChildrenLinks.vue} (100%) delete mode 100644 src/components/navigation/PluginLinksAbout.vue diff --git a/package-lock.json b/package-lock.json index 8cd8737..dd37519 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1376,6 +1376,12 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true + }, + "typescript": { + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz", + "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==", + "dev": true } } }, @@ -8645,15 +8651,6 @@ "lower-case": "1.1.4" } }, - "node-dir": { - "version": "0.1.17", - "resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.1.17.tgz", - "integrity": "sha1-X1Zl2TNRM1yqvvjxxVRRbPXx5OU=", - "dev": true, - "requires": { - "minimatch": "3.0.4" - } - }, "node-forge": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", @@ -10912,15 +10909,6 @@ } } }, - "require-context": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/require-context/-/require-context-1.1.0.tgz", - "integrity": "sha512-nfYSy3Q9W3W1fCo0nief19bDq216IGY9+wOUsmCWAJ5jssyak0r110rvqIj4KJYoUYDxLDaeA66ONOYy4PJEUw==", - "dev": true, - "requires": { - "node-dir": "0.1.17" - } - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -12947,9 +12935,9 @@ "dev": true }, "typescript": { - "version": "3.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz", - "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.3.tgz", + "integrity": "sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index b3d9381..7b12e13 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "eslint-config-prettier": "^6.9.0", "eslint-loader": "^3.0.3", "eslint-plugin-vue": "^6.1.2", - "require-context": "^1.1.0" + "typescript": "^4.0.3" }, "browserslist": [ "last 10 Chrome versions", diff --git a/quasar.conf.js b/quasar.conf.js index 08ce14e..73977b8 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -8,7 +8,6 @@ /* eslint-env node */ /* eslint-disable @typescript-eslint/no-var-requires */ const { configure } = require('quasar/wrappers'); -const { path } = require('path'); module.exports = configure(function(ctx) { return { @@ -75,11 +74,6 @@ module.exports = configure(function(ctx) { exclude: /node_modules/ }); } - cfg.resolve.alias = { - ...cfg.resolve.alias - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access - //flaschngeist_plugin: path.resolve(__dirname, './src/plugins') - }; } }, diff --git a/src/boot/composition-api.ts b/src/boot/composition-api.ts index 0880600..cac99ea 100644 --- a/src/boot/composition-api.ts +++ b/src/boot/composition-api.ts @@ -1,6 +1,7 @@ import VueCompositionApi from '@vue/composition-api'; +import { VueConstructor } from 'vue'; import { boot } from 'quasar/wrappers'; -export default boot(({ Vue }) => { +export default boot(({ Vue }: { Vue: VueConstructor }) => { Vue.use(VueCompositionApi); }); diff --git a/src/boot/plugins.ts b/src/boot/plugins.ts index 0d368e9..cdddfdd 100644 --- a/src/boot/plugins.ts +++ b/src/boot/plugins.ts @@ -1,7 +1,6 @@ import { boot } from 'quasar/wrappers'; import { RouteConfig } from 'vue-router'; import { Module } from 'vuex'; -import {} from 'webpack'; interface PluginRouteConfig extends RouteConfig { example?: unknown; @@ -15,30 +14,35 @@ interface EssentialLink { interface Plugin { router: PluginRouteConfig[]; - store?: Module; - mainLink: EssentialLink; + store?: Module; + mainLink: PluginMainLink; } -export { PluginRouteConfig, Plugin }; +interface PluginMainLink extends PluginChildLink { + children: PluginChildLink[] | []; +} + +interface PluginChildLink { + name: string; + title: string; + link: string; + icon: string; +} + +export { PluginRouteConfig, Plugin, PluginChildLink, PluginMainLink }; // "async" is optional; // more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore -export default boot(({ Vue, router, store }) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access - const plugins: any = require.context('src/plugins', true, /.+\/plugin.ts$/); - // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access - let mop = []; - // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access - plugins.keys().forEach((fileName: any) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call - - // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access +export default boot(({ Vue, router }) => { + const plugins = require.context('src/plugins', true, /.+\/plugin.ts$/); + const pluginMainLinks: PluginMainLink[] = []; + plugins.keys().forEach((fileName: string) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access router.addRoutes(plugins(fileName).default.router); - // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access - mop.push(plugins(fileName).default.mainLink); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + pluginMainLinks.push(plugins(fileName).default.mainLink); }); - Vue.prototype.$flaschengeist_plugins = mop; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + Vue.prototype.$flaschengeist_plugins = pluginMainLinks; console.log(plugins); }); diff --git a/src/components/navigation/PluginLinksHome.vue b/src/components/navigation/PluginChildrenLinks.vue similarity index 100% rename from src/components/navigation/PluginLinksHome.vue rename to src/components/navigation/PluginChildrenLinks.vue diff --git a/src/components/navigation/PluginLinksAbout.vue b/src/components/navigation/PluginLinksAbout.vue deleted file mode 100644 index 7e12254..0000000 --- a/src/components/navigation/PluginLinksAbout.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index cd868fb..c24dc45 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -48,14 +48,14 @@ - + + + + + +
import EssentialLink from 'components/navigation/EssentialLink.vue'; -import { event, Screen } from 'quasar'; -import { defineComponent, ref, reactive, computed } from '@vue/composition-api'; +import { Screen } from 'quasar'; +import { PluginMainLink } from 'boot/plugins'; +import { defineComponent, ref, computed } from '@vue/composition-api'; const links = [ - { title: 'home', icon: 'mdi-home' }, - { title: 'about', link: 'about', icon: 'mdi-information' } + { + name: 'home', + title: 'home', + icon: 'mdi-home', + children: [ + { title: 'Neues Home', link: 'newHome', icon: 'mdi-google-home' }, + { title: 'Altes Home', link: 'oldHome', icon: 'mdi-home-modern' } + ] + }, + { + name: 'about', + title: 'about', + link: 'about', + icon: 'mdi-information', + children: [ + { + title: 'Neues About', + link: 'newAbout', + icon: 'mdi-information-outline' + }, + { + title: 'Altes About', + link: 'oldAbout', + icon: 'mdi-information-variant' + } + ] + } ]; +declare module 'vue/types/vue' { + interface Vue { + $flaschengeist_plugins: PluginMainLink[]; + } +} + export default defineComponent({ name: 'MainLayout', components: { EssentialLink }, - setup() { + setup(_, ctx) { const leftDrawer = ref(false); const leftDrawerOpen = ref( @@ -114,7 +157,36 @@ export default defineComponent({ } } - return { leftDrawerOpen, leftDrawerMini, leftDrawerClicker, links }; + const pluginChildLinks = computed(() => { + const test: + | PluginMainLink + | undefined = ctx.root.$flaschengeist_plugins.find( + (plugin: PluginMainLink) => { + return plugin.name == ctx.root.$route.matched[1].name; + } + ); + console.log(test); + if (typeof test == undefined) { + return []; + } else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + //@ts-ignore + return test.children; + } + }); + + function showRoute() { + console.log(ctx.root.$route); + } + + return { + leftDrawerOpen, + leftDrawerMini, + leftDrawerClicker, + links, + pluginChildLinks, + showRoute + }; } }); diff --git a/src/layouts/OutLayout.vue b/src/layouts/OutLayout.vue index 400ea93..1857789 100644 --- a/src/layouts/OutLayout.vue +++ b/src/layouts/OutLayout.vue @@ -1,12 +1,13 @@ diff --git a/src/pages/Login.vue b/src/pages/Login.vue index e492340..3716c18 100644 --- a/src/pages/Login.vue +++ b/src/pages/Login.vue @@ -38,7 +38,7 @@ import { defineComponent, ref } from '@vue/composition-api'; export default defineComponent({ // name: 'PageName' - setup() { + setup(_, ctx) { const username = ref(''); const password = ref(''); const rules = [ @@ -47,7 +47,7 @@ export default defineComponent({ function doLogin() { console.log(username.value, password.value); - this.$router.push({ name: 'home' }); + void ctx.root.$router.push({ name: 'home' }); } return { username, password, doLogin, rules }; diff --git a/src/pages/home/Home.vue b/src/pages/home/Home.vue index 0f28c92..57ba773 100644 --- a/src/pages/home/Home.vue +++ b/src/pages/home/Home.vue @@ -13,7 +13,7 @@