fix: 解决 layout menu 空菜单问题 + env 环境覆盖问题

This commit is contained in:
winixt 2021-08-20 10:08:58 +08:00
parent c4793bf6b0
commit f0eefbbc76
14 changed files with 108 additions and 65 deletions

View File

@ -40,7 +40,7 @@
"@vuepress/plugin-docsearch": "^2.0.0-beta.22",
"@vuepress/plugin-pwa": "^2.0.0-beta.22",
"@vuepress/plugin-pwa-popup": "^2.0.0-beta.22",
"@webank/eslint-config-webank": "0.3.0",
"@webank/eslint-config-webank": "0.3.1",
"chalk": "^4.1.2",
"chokidar": "^3.5.2",
"commitizen": "^4.2.1",

View File

@ -40,7 +40,7 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.0",
"@webank/eslint-config-webank": "0.3.1",
"@ttou/postcss-px-to-viewport": "1.1.1"
},
"dependencies": {

View File

@ -43,7 +43,7 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.0"
"@webank/eslint-config-webank": "0.3.1"
},
"dependencies": {
"@fesjs/fes": "^2.0.0",

View File

@ -10,9 +10,7 @@ export default function loadDotEnv(envPath) {
const parsed = parse(readFileSync(envPath, 'utf-8')) || {};
Object.keys(parsed).forEach((key) => {
// eslint-disable-next-line no-prototype-builtins
if (!process.env.hasOwnProperty(key)) {
process.env[key] = parsed[key];
}
process.env[key] = parsed[key];
});
}
}

View File

@ -1,4 +1,5 @@
import { unref, computed } from 'vue';
// eslint-disable-next-line
import { useAccess } from '../../plugin-access/core';
if (!useAccess) {
@ -12,7 +13,10 @@ export const hasAccessByMenuItem = (item) => {
if (item.path && (!item.children || item.children.length === 0)) {
res = useAccess(item.path);
} else if (item.children && item.children.length > 0) {
res = computed(() => item.children.some(child => hasAccessByMenuItem(child)));
res = computed(() => item.children.some((child) => {
const rst = hasAccessByMenuItem(child);
return rst && rst.value;
}));
}
return res;
};
@ -31,5 +35,6 @@ const _addAccessTag = (arr) => {
export const transform = (menus) => {
const originData = unref(menus);
_addAccessTag(originData);
return originData;
};

View File

@ -43,7 +43,7 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.0"
"@webank/eslint-config-webank": "0.3.1"
},
"dependencies": {
"@fesjs/fes": "^2.0.0",

View File

@ -43,7 +43,7 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.0"
"@webank/eslint-config-webank": "0.3.1"
},
"dependencies": {
"@fesjs/fes": "^2.0.0",

View File

@ -40,7 +40,7 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.0",
"@webank/eslint-config-webank": "0.3.1",
"@ttou/postcss-px-to-viewport": "1.1.4"
},
"dependencies": {

View File

@ -1 +1 @@
FES_APP_PUBLISH_ERROR_PAGE=hello
FES_APP_PUBLISH_ERROR_PAGE=helloworld

View File

@ -0,0 +1 @@
FES_APP_PUBLISH_ERROR_PAGE=helloProduction

View File

@ -14,6 +14,7 @@ export default {
access: {
roles: {
admin: ["*"],
menuTest: ['/', '/onepiece', '/store'],
},
},
request: {
@ -45,7 +46,6 @@ export default {
path: "https://www.baidu.com",
},
{
// name: "abcd",
title: "abcd",
children: [
{

View File

@ -43,7 +43,7 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.0"
"@webank/eslint-config-webank": "0.3.1"
},
"dependencies": {
"@fesjs/fes": "^2.0.0",

View File

@ -5,6 +5,7 @@ import PageLoading from '@/components/PageLoading';
import UserCenter from '@/components/UserCenter';
console.log(store.getters[GETTER_TYPES.user.address]);
console.log(process.env.FES_APP_PUBLISH_ERROR_PAGE);
export const beforeRender = {
loading: <PageLoading />,
@ -12,7 +13,7 @@ export const beforeRender = {
const { setRole } = accessApi;
return new Promise((resolve) => {
setTimeout(() => {
setRole('admin');
setRole('menuTest');
resolve({
userName: 'harrywan'
});

140
yarn.lock
View File

@ -3319,10 +3319,10 @@
dependencies:
vue-demi "*"
"@webank/eslint-config-webank@0.3.0":
version "0.3.0"
resolved "http://127.0.0.1:8001/@webank/eslint-config-webank/download/@webank/eslint-config-webank-0.3.0.tgz#6a81c94501a80d85e1e9a3d49f8777aa082d524a"
integrity sha1-aoHJRQGoDYXh6aPUn4d3qggtUko=
"@webank/eslint-config-webank@0.3.1":
version "0.3.1"
resolved "https://registry.npmjs.org/@webank/eslint-config-webank/-/eslint-config-webank-0.3.1.tgz#71e803808ff239eb66ed04954edab144617467dd"
integrity sha512-DpfFEyzqM50+qU+rWJ8Leaa03vcPS0ddS1hlmdpNp3mcgpOWaBeVbWh9K7tKzH0rH+zUFGTg1HpCfyN+8bA8xA==
dependencies:
"@babel/eslint-parser" "^7.13.14"
"@babel/plugin-syntax-jsx" "^7.12.13"
@ -3330,7 +3330,7 @@
eslint "^7.26.0"
eslint-plugin-angular "^4.0.1"
eslint-plugin-html "^6.1.2"
eslint-plugin-import "^2.22.1"
eslint-plugin-import "2.22.1"
eslint-plugin-node "^11.1.0"
eslint-plugin-vue "^7.9.0"
vue-eslint-parser "^7.6.0"
@ -3798,10 +3798,10 @@ array-ify@^1.0.0:
resolved "http://127.0.0.1:8001/array-ify/download/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece"
integrity sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=
array-includes@^3.1.3:
array-includes@^3.1.1:
version "3.1.3"
resolved "http://127.0.0.1:8001/array-includes/download/array-includes-3.1.3.tgz#c7f619b382ad2afaf5326cddfdc0afc61af7690a"
integrity sha1-x/YZs4KtKvr1Mmzd/cCvxhr3aQo=
resolved "https://registry.npmjs.org/array-includes/-/array-includes-3.1.3.tgz#c7f619b382ad2afaf5326cddfdc0afc61af7690a"
integrity sha512-gcem1KlBU7c9rB+Rq8/3PPKsK2kjqeEBa3bD5kkQo4nYlOHQCJqIJFqBXDEfwaRuYTT4E+FxA9xez7Gf/e3Q7A==
dependencies:
call-bind "^1.0.2"
define-properties "^1.1.3"
@ -3836,10 +3836,10 @@ array-unique@^0.3.2:
resolved "http://127.0.0.1:8001/array-unique/download/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=
array.prototype.flat@^1.2.4:
array.prototype.flat@^1.2.3:
version "1.2.4"
resolved "http://127.0.0.1:8001/array.prototype.flat/download/array.prototype.flat-1.2.4.tgz#6ef638b43312bd401b4c6199fdec7e2dc9e9a123"
integrity sha1-bvY4tDMSvUAbTGGZ/ex+LcnpoSM=
resolved "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz#6ef638b43312bd401b4c6199fdec7e2dc9e9a123"
integrity sha512-4470Xi3GAPAjZqFcljX2xzckv1qeKPizoNkiS0+O4IoPR2ZNpcjE0pkhdihlDouK+x6QOast26B4Q/O9DJnwSg==
dependencies:
call-bind "^1.0.0"
define-properties "^1.1.3"
@ -4827,6 +4827,11 @@ consolidate@^0.16.0:
dependencies:
bluebird "^3.7.2"
contains-path@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a"
integrity sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=
content-disposition@0.5.3:
version "0.5.3"
resolved "http://127.0.0.1:8001/content-disposition/download/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd"
@ -5548,12 +5553,13 @@ dns-txt@^2.0.2:
dependencies:
buffer-indexof "^1.0.0"
doctrine@^2.1.0:
version "2.1.0"
resolved "http://127.0.0.1:8001/doctrine/download/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
integrity sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=
doctrine@1.5.0:
version "1.5.0"
resolved "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
integrity sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=
dependencies:
esutils "^2.0.2"
isarray "^1.0.0"
doctrine@^3.0.0:
version "3.0.0"
@ -5757,7 +5763,7 @@ errno@^0.1.1, errno@^0.1.3:
dependencies:
prr "~1.0.1"
error-ex@^1.3.1:
error-ex@^1.2.0, error-ex@^1.3.1:
version "1.3.2"
resolved "http://127.0.0.1:8001/error-ex/download/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
integrity sha1-tKxAZIEH/c3PriQvQovqihTU8b8=
@ -5863,18 +5869,18 @@ escodegen@^2.0.0:
optionalDependencies:
source-map "~0.6.1"
eslint-import-resolver-node@^0.3.5:
eslint-import-resolver-node@^0.3.4:
version "0.3.6"
resolved "http://127.0.0.1:8001/eslint-import-resolver-node/download/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd"
integrity sha1-QEi5WDldqJZoJSAB29nsprg7rL0=
resolved "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd"
integrity sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==
dependencies:
debug "^3.2.7"
resolve "^1.20.0"
eslint-module-utils@^2.6.2:
eslint-module-utils@^2.6.0:
version "2.6.2"
resolved "http://127.0.0.1:8001/eslint-module-utils/download/eslint-module-utils-2.6.2.tgz#94e5540dd15fe1522e8ffa3ec8db3b7fa7e7a534"
integrity sha1-lOVUDdFf4VIuj/o+yNs7f6fnpTQ=
resolved "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz#94e5540dd15fe1522e8ffa3ec8db3b7fa7e7a534"
integrity sha512-QG8pcgThYOuqxupd06oYTZoNOGaUdTY1PqK+oS6ElF6vs4pBdk/aYxFVQQXzcrAqp9m7cl7lb2ubazX+g16k2Q==
dependencies:
debug "^3.2.7"
pkg-dir "^2.0.0"
@ -5899,25 +5905,23 @@ eslint-plugin-html@^6.1.2:
dependencies:
htmlparser2 "^6.0.1"
eslint-plugin-import@^2.22.1:
version "2.24.0"
resolved "http://127.0.0.1:8001/eslint-plugin-import/download/eslint-plugin-import-2.24.0.tgz#697ffd263e24da5e84e03b282f5fb62251777177"
integrity sha1-aX/9Jj4k2l6E4DsoL1+2IlF3cXc=
eslint-plugin-import@2.22.1:
version "2.22.1"
resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz#0896c7e6a0cf44109a2d97b95903c2bb689d7702"
integrity sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==
dependencies:
array-includes "^3.1.3"
array.prototype.flat "^1.2.4"
array-includes "^3.1.1"
array.prototype.flat "^1.2.3"
contains-path "^0.1.0"
debug "^2.6.9"
doctrine "^2.1.0"
eslint-import-resolver-node "^0.3.5"
eslint-module-utils "^2.6.2"
find-up "^2.0.0"
doctrine "1.5.0"
eslint-import-resolver-node "^0.3.4"
eslint-module-utils "^2.6.0"
has "^1.0.3"
is-core-module "^2.4.0"
minimatch "^3.0.4"
object.values "^1.1.3"
pkg-up "^2.0.0"
read-pkg-up "^3.0.0"
resolve "^1.20.0"
object.values "^1.1.1"
read-pkg-up "^2.0.0"
resolve "^1.17.0"
tsconfig-paths "^3.9.0"
eslint-plugin-node@^11.1.0:
@ -7591,7 +7595,7 @@ is-color-stop@^1.1.0:
rgb-regex "^1.0.1"
rgba-regex "^1.0.0"
is-core-module@^2.2.0, is-core-module@^2.4.0:
is-core-module@^2.2.0:
version "2.5.0"
resolved "http://127.0.0.1:8001/is-core-module/download/is-core-module-2.5.0.tgz#f754843617c70bfd29b7bd87327400cda5c18491"
integrity sha1-91SENhfHC/0pt72HMnQAzaXBhJE=
@ -7900,7 +7904,7 @@ is-wsl@^2.2.0:
dependencies:
is-docker "^2.0.0"
isarray@1.0.0, isarray@~1.0.0:
isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "http://127.0.0.1:8001/isarray/download/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
@ -8760,6 +8764,16 @@ listr2@^3.2.2:
through "^2.3.8"
wrap-ansi "^7.0.0"
load-json-file@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
integrity sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=
dependencies:
graceful-fs "^4.1.2"
parse-json "^2.2.0"
pify "^2.0.0"
strip-bom "^3.0.0"
load-json-file@^4.0.0:
version "4.0.0"
resolved "http://127.0.0.1:8001/load-json-file/download/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b"
@ -9928,10 +9942,10 @@ object.pick@^1.3.0:
dependencies:
isobject "^3.0.1"
object.values@^1.1.3:
object.values@^1.1.1:
version "1.1.4"
resolved "http://127.0.0.1:8001/object.values/download/object.values-1.1.4.tgz#0d273762833e816b693a637d30073e7051535b30"
integrity sha1-DSc3YoM+gWtpOmN9MAc+cFFTWzA=
resolved "https://registry.npmjs.org/object.values/-/object.values-1.1.4.tgz#0d273762833e816b693a637d30073e7051535b30"
integrity sha512-TnGo7j4XSnKQoK3MfvkzqKCi0nVe/D9I9IjwTNYdb/fxYHpjrluHVOgw0AF6jrRFGMPHdfuidR09tIDiIvnaSg==
dependencies:
call-bind "^1.0.2"
define-properties "^1.1.3"
@ -10255,6 +10269,13 @@ parent-module@^1.0.0:
dependencies:
callsites "^3.0.0"
parse-json@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=
dependencies:
error-ex "^1.2.0"
parse-json@^4.0.0:
version "4.0.0"
resolved "http://127.0.0.1:8001/parse-json/download/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0"
@ -10378,6 +10399,13 @@ path-to-regexp@0.1.7:
resolved "http://127.0.0.1:8001/path-to-regexp/download/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=
path-type@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
integrity sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=
dependencies:
pify "^2.0.0"
path-type@^3.0.0:
version "3.0.0"
resolved "http://127.0.0.1:8001/path-type/download/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f"
@ -10472,13 +10500,6 @@ pkg-dir@^5.0.0:
dependencies:
find-up "^5.0.0"
pkg-up@^2.0.0:
version "2.0.0"
resolved "http://127.0.0.1:8001/pkg-up/download/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f"
integrity sha1-yBmscoBZpGHKscOImivjxJoATX8=
dependencies:
find-up "^2.1.0"
pkg-up@^3.1.0:
version "3.1.0"
resolved "http://127.0.0.1:8001/pkg-up/download/pkg-up-3.1.0.tgz#100ec235cc150e4fd42519412596a28512a0def5"
@ -11115,6 +11136,14 @@ read-package-tree@^5.3.1:
readdir-scoped-modules "^1.0.0"
util-promisify "^2.1.0"
read-pkg-up@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be"
integrity sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=
dependencies:
find-up "^2.0.0"
read-pkg "^2.0.0"
read-pkg-up@^3.0.0:
version "3.0.0"
resolved "http://127.0.0.1:8001/read-pkg-up/download/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07"
@ -11132,6 +11161,15 @@ read-pkg-up@^7.0.1:
read-pkg "^5.2.0"
type-fest "^0.8.1"
read-pkg@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8"
integrity sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=
dependencies:
load-json-file "^2.0.0"
normalize-package-data "^2.3.2"
path-type "^2.0.0"
read-pkg@^3.0.0:
version "3.0.0"
resolved "http://127.0.0.1:8001/read-pkg/download/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389"
@ -11424,7 +11462,7 @@ resolve-url@^0.2.1:
resolved "http://127.0.0.1:8001/resolve-url/download/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
resolve@^1.10.0, resolve@^1.10.1, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.20.0:
resolve@^1.10.0, resolve@^1.10.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0:
version "1.20.0"
resolved "http://127.0.0.1:8001/resolve/download/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha1-YpoBP7P3B1XW8LeTXMHCxTeLGXU=
@ -13184,7 +13222,7 @@ vue3-jest@^27.0.0-alpha.1:
source-map "0.5.6"
tsconfig "^7.0.0"
vue@^3.0.5, vue@^3.2.0, vue@^3.2.2:
vue@^3.0.5, vue@^3.2.2:
version "3.2.2"
resolved "http://127.0.0.1:8001/vue/download/vue-3.2.2.tgz#11715cb71a02baefd0f6e6552dc623680eb1bf32"
integrity sha1-EXFctxoCuu/Q9uZVLcYjaA6xvzI=