Skip to content

Commit

Permalink
fix(simple-menu): collapse openmenus error #204
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 19, 2021
1 parent 025ee92 commit ca4f1a8
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 99 deletions.
7 changes: 6 additions & 1 deletion build/vite/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean, mode: stri

// rollup-plugin-visualizer
if (isReportMode()) {
vitePlugins.push(visualizer({ filename: './build/.cache/stats.html', open: true }) as Plugin);
vitePlugins.push(
visualizer({
filename: './build/.cache/stats.html',
open: true,
}) as Plugin
);
}

return vitePlugins;
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"path-to-regexp": "^6.2.0",
"qrcode": "^1.4.4",
"sortablejs": "^1.13.0",
"vditor": "^3.7.6",
"vditor": "^3.7.7",
"vue": "^3.0.5",
"vue-i18n": "^9.0.0-rc.2",
"vue-router": "^4.0.3",
Expand All @@ -46,9 +46,9 @@
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@iconify/json": "^1.1.287",
"@iconify/json": "^1.1.288",
"@ls-lint/ls-lint": "^1.9.2",
"@purge-icons/generated": "^0.5.1",
"@purge-icons/generated": "^0.5.2",
"@types/echarts": "^4.9.3",
"@types/fs-extra": "^9.0.6",
"@types/http-proxy": "^1.17.5",
Expand All @@ -61,8 +61,8 @@
"@types/sortablejs": "^1.10.6",
"@types/yargs": "^15.0.12",
"@types/zxcvbn": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"@vitejs/plugin-legacy": "^1.2.1",
"@vitejs/plugin-vue": "^1.0.6",
"@vitejs/plugin-vue-jsx": "^1.0.2",
Expand All @@ -76,7 +76,7 @@
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.1.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.4.1",
"esno": "^0.4.0",
Expand All @@ -91,17 +91,17 @@
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"rollup-plugin-gzip": "^2.5.0",
"rollup-plugin-visualizer": "^4.1.2",
"rollup-plugin-visualizer": "^4.2.0",
"stylelint": "^13.8.0",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^20.0.0",
"stylelint-order": "^4.1.0",
"ts-node": "^9.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"vite": "^2.0.0-beta.31",
"vite-plugin-html": "^2.0.0-beta.5",
"vite-plugin-mock": "^2.0.0-beta.3",
"vite-plugin-purge-icons": "^0.5.1",
"vite-plugin-purge-icons": "^0.5.2",
"vite-plugin-pwa": "^0.3.8",
"vite-plugin-style-import": "^0.4.3",
"vue-eslint-parser": "^7.3.0",
Expand Down
3 changes: 1 addition & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
name: 'App',
components: { ConfigProvider, AppProvider },
setup() {
// support Multi-language
const { antConfigLocale, setLocale } = useLocale();
setLocale();
Expand All @@ -30,8 +31,6 @@
// Create a lock screen monitor
const lockEvent = useLockPage();
// support Multi-language
return {
antConfigLocale,
lockEvent,
Expand Down
9 changes: 5 additions & 4 deletions src/components/Form/src/hooks/useFormValues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
import { isArray, isFunction, isObject, isString, isNullOrUnDef } from '/@/utils/is';
import { dateUtil } from '/@/utils/dateUtil';

import { unref, nextTick } from 'vue';
Expand Down Expand Up @@ -78,9 +78,10 @@ export function useFormValues({
const schemas = unref(getSchema);
const obj: Recordable = {};
schemas.forEach((item) => {
if (item.defaultValue) {
obj[item.field] = item.defaultValue;
formModel[item.field] = item.defaultValue;
const { defaultValue } = item;
if (!isNullOrUnDef(defaultValue)) {
obj[item.field] = defaultValue;
formModel[item.field] = defaultValue;
}
});
defaultValueRef.value = obj;
Expand Down
13 changes: 10 additions & 3 deletions src/components/SimpleMenu/src/SimpleMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-bind="getBindValues"
@select="handleSelect"
:activeName="activeName"
:openNames="openNames"
:openNames="getOpenKeys"
:class="prefixCls"
:activeSubMenuNames="activeSubMenuNames"
>
Expand Down Expand Up @@ -67,8 +67,14 @@
const { currentRoute } = useRouter();
const { prefixCls } = useDesign('simple-menu');
const { items, accordion, mixSider } = toRefs(props);
const { setOpenKeys } = useOpenKeys(menuState, items, accordion, mixSider);
const { items, accordion, mixSider, collapse } = toRefs(props);
const { setOpenKeys, getOpenKeys } = useOpenKeys(
menuState,
items,
accordion,
mixSider,
collapse
);
const getBindValues = computed(() => ({ ...attrs, ...props }));
Expand Down Expand Up @@ -125,6 +131,7 @@
prefixCls,
getBindValues,
handleSelect,
getOpenKeys,
...toRefs(menuState),
};
},
Expand Down
11 changes: 8 additions & 3 deletions src/components/SimpleMenu/src/useOpenKeys.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Menu as MenuType } from '/@/router/types';
import type { MenuState } from './types';

import { Ref, toRaw } from 'vue';
import { computed, Ref, toRaw } from 'vue';

import { unref } from 'vue';
import { es6Unique } from '/@/utils';
Expand All @@ -12,7 +12,8 @@ export function useOpenKeys(
menuState: MenuState,
menus: Ref<MenuType[]>,
accordion: Ref<boolean>,
mixSider: Ref<boolean>
mixSider: Ref<boolean>,
collapse: Ref<boolean>
// mode: Ref<MenuModeEnum>,
) {
async function setOpenKeys(path: string) {
Expand Down Expand Up @@ -41,5 +42,9 @@ export function useOpenKeys(
);
}

return { setOpenKeys };
const getOpenKeys = computed(() => {
return unref(collapse) ? [] : menuState.openNames;
});

return { setOpenKeys, getOpenKeys };
}
2 changes: 1 addition & 1 deletion src/locales/lang/zh_CN/sys/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
timeoutMessage: '登录超时,请重新登录!',
apiTimeoutMessage: '接口请求超时,请刷新页面重试!',
networkException: '网络异常',
networkExceptionMsg: '网请检查您的网络连接是否正常!络异常',
networkExceptionMsg: '请检查您的网络连接是否正常!',

errMsg401: '用户没有权限(令牌、用户名、密码错误)!',
errMsg403: '用户得到授权,但是访问是被禁止的。!',
Expand Down
4 changes: 4 additions & 0 deletions src/utils/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export function isNullAndUnDef(val: unknown): val is null | undefined {
return isUnDef(val) && isNull(val);
}

export function isNullOrUnDef(val: unknown): val is null | undefined {
return isUnDef(val) || isNull(val);
}

export function isNumber(val: unknown): val is number {
return is(val, 'Number');
}
Expand Down
Loading

0 comments on commit ca4f1a8

Please sign in to comment.