From a03b9f327bfe7df63e1eeabf83f443e2b437cf46 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Thu, 29 Oct 2020 11:10:58 +0100 Subject: [PATCH] make HMR work again + favicon + get route meta from parent if child has none --- zero.Core/Api/ApplicationContext.cs | 2 +- zero.Debug/wwwroot/Assets/zero-icon.png | Bin 0 -> 3935 bytes zero.Web.UI/App/config/router.config.js | 40 ++++++++++++++++------- zero.Web.UI/App/core/zero.js | 4 +-- zero.Web.UI/App/pages/settings/routes.js | 10 +++--- zero.Web.UI/vue.config.js | 5 +++ zero.Web/Views/Zero/Index.cshtml | 3 ++ 7 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 zero.Debug/wwwroot/Assets/zero-icon.png diff --git a/zero.Core/Api/ApplicationContext.cs b/zero.Core/Api/ApplicationContext.cs index e8ccb2e6..967f4f8b 100644 --- a/zero.Core/Api/ApplicationContext.cs +++ b/zero.Core/Api/ApplicationContext.cs @@ -66,7 +66,7 @@ namespace zero.Core.Api if (app == null) { - Logger.LogWarning($"Could not resolve application for host $host", context.Request.Host); + Logger.LogWarning("Could not resolve application for host {host}", context.Request.Host); IList apps = await GetApplications(); app = apps.FirstOrDefault(); } diff --git a/zero.Debug/wwwroot/Assets/zero-icon.png b/zero.Debug/wwwroot/Assets/zero-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..683dc9369769c023acf753169022e9c5ea6fb8b8 GIT binary patch literal 3935 zcmV-l51{agP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!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F_48Dwuv?C-4HW9k`=Sx$7G64e&njIq*+NVD1NA1fJ6b+X>AB9{~q|UqS%$81O3a zWDYrm9CFZ?z}vvFPJt-`yMWh$hXWgid}i%?q>I%Ul7j z>bVlIMtiYg%~!)7ZTzhMKJkI$3uZU4FC&zHH8~#B?si58Yd4K9zpTC7gg&x6fjcw8 zc};t*Y!Z>I$954pCFyldL=K9`(<0LE(O%=|*Lxh)d#2SX^_;1_tmd|e$dL@D&WXq# z5h*nRWaUxPd!EbSw7_roi-w$les)AZTgG^R0T22%mn8R!21P6WI(bV5BQX`RNH8O*TOMw0Yx-UaBKHKQJrRI=(k z7MMX`wQ>IUb}fE+YEeBVX|=}am3*zldl{$&45p?Ytpx0qd2uul zY8QZUdF=BY`QEm&z*HUIEp!%J zW6TU@4!CZdzt@_C1)#EeOwx60@@s*ab!7ENt+_@38dZ;0k2UK9W*WF;oWDn>?xAX% zdQ8$KjN)34W3F+=(fA(fd+9>cX7y(2j5XJDCEqDW0)7bC5g?cy>di{LQ@+V}QK#+~ z9VT9~CSx7Ypn9@&QDa;59r^x1eP@EDtA z(?(U)i?vO6Nn^Uu444}5HE`N--3ag|^*z0v(vW%>aa?y=W3o#oafvoA>gT?wAGd+T zjYDy(S?*wNo6U)FJ8RMsLfinIFPH|LxMki@e96L4d@aXNe32_ftu?;-XLPmkWziJn tfcSc`p{{x%y`5mXN^!SC1d~m-1^{b_#?)|G)$;%V002ovPDHLkV1i2bQmz01 literal 0 HcmV?d00001 diff --git a/zero.Web.UI/App/config/router.config.js b/zero.Web.UI/App/config/router.config.js index 260a099a..e6c330b3 100644 --- a/zero.Web.UI/App/config/router.config.js +++ b/zero.Web.UI/App/config/router.config.js @@ -1,8 +1,9 @@ import Localization from 'zero/services/localization'; +import { isArray as _isArray } from 'underscore'; // set meta title before routing -const beforeEach = () => (to, from, next) => +const beforeEach = (to, from, next) => { let isGuarded = false; @@ -10,24 +11,39 @@ const beforeEach = () => (to, from, next) => let callback = () => { let title = Localization.localize('@zero.name'); + let name = to.meta.name; - if (to.meta.name && to.meta.alias !== __zero.alias.sections.dashboard) + if (!name && to.matched.length > 1) { - let name = to.meta.name; - let nameParts = _isArray(name) ? name : [name]; - let translations = []; - - nameParts.forEach(part => + to.matched.forEach(route => { - if (part) + if (!name && route.meta.name) { - translations.push(Localization.localize(part)); + name = route.meta.name; } }); - - title += ': ' + translations.join(' - '); } + if (!name || to.meta.alias === __zero.alias.sections.dashboard) + { + document.title = title; + next(); + return; + } + + let nameParts = _isArray(name) ? name : [name]; + let translations = []; + + nameParts.forEach(part => + { + if (part) + { + translations.push(Localization.localize(part)); + } + }); + + title += ': ' + translations.join(' - '); + document.title = title; next(); @@ -67,7 +83,7 @@ export default { base: __zero.path, linkActiveClass: 'is-active', linkExactActiveClass: 'is-active-exact', - //beforeEach: beforeEach, + beforeEach: beforeEach, scrollBehavior(to, from, savedPosition) { return savedPosition ? savedPosition : { x: 0, y: 0 }; diff --git a/zero.Web.UI/App/core/zero.js b/zero.Web.UI/App/core/zero.js index 8ae0ee62..e53f59df 100644 --- a/zero.Web.UI/App/core/zero.js +++ b/zero.Web.UI/App/core/zero.js @@ -75,11 +75,11 @@ class Zero routes: this.#routes }); + this.#router.beforeEach(routerConfig.beforeEach); + //const result = await Axios.get('zerovue/config'); //this.config = { ...this.config, ...result.data }; - //console.info(this.#vue.router); - this.#setupDone = true; //EventHub.$emit('zero.setup'); } diff --git a/zero.Web.UI/App/pages/settings/routes.js b/zero.Web.UI/App/pages/settings/routes.js index b1a231e1..5425b851 100644 --- a/zero.Web.UI/App/pages/settings/routes.js +++ b/zero.Web.UI/App/pages/settings/routes.js @@ -33,7 +33,7 @@ const addArea = (areaAlias, component, detailComponent, hasCreate, postCreate) = path: area.url, component: component, meta: { - name: [area.name, section.name] + name: area.name } }); @@ -46,7 +46,7 @@ const addArea = (areaAlias, component, detailComponent, hasCreate, postCreate) = component: detailComponent, meta: { create: true, - name: [area.name, section.name] + name: area.name } }); } @@ -59,7 +59,7 @@ const addArea = (areaAlias, component, detailComponent, hasCreate, postCreate) = props: true, component: detailComponent, meta: { - name: [area.name, section.name] + name: area.name } }); } @@ -105,7 +105,7 @@ if (section) component: UserRole, meta: { create: true, - name: [area.name, section.name] + name: area.name } }); @@ -115,7 +115,7 @@ if (section) props: true, component: UserRole, meta: { - name: [area.name, section.name] + name: area.name } }); }); diff --git a/zero.Web.UI/vue.config.js b/zero.Web.UI/vue.config.js index 87edba85..41b54601 100644 --- a/zero.Web.UI/vue.config.js +++ b/zero.Web.UI/vue.config.js @@ -27,6 +27,11 @@ module.exports = { app: "app.js" }, + devServer: { + sockPath: '/zero/vue-cli/sockjs-node', + public: 'http://localhost:2310/zero/vue-cli' + }, + // webpack configuration chainWebpack: config => { diff --git a/zero.Web/Views/Zero/Index.cshtml b/zero.Web/Views/Zero/Index.cshtml index 3b79cdd0..addcf09b 100644 --- a/zero.Web/Views/Zero/Index.cshtml +++ b/zero.Web/Views/Zero/Index.cshtml @@ -10,6 +10,9 @@ + + +