Skip to content

Commit

Permalink
feat: support for nested routes
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Apr 27, 2022
1 parent 9c9ec46 commit 79b2093
Show file tree
Hide file tree
Showing 20 changed files with 619 additions and 396 deletions.
91 changes: 0 additions & 91 deletions .cz-config.js

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dist
/bin
/src/mock
Dockerfile
commitlint.config.js
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/dist/*
.local
.output.js
commitlint.config.js
/node_modules/**

**/*.svg
Expand Down
80 changes: 59 additions & 21 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const { execSync } = require('child_process');

// @tip: git branch name = feature/issue_33 => auto get defaultIssues = #33
const issue = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim()
.split("_")[1]

/** @type {import('cz-git').UserConfig} */
module.exports = {
ignores: [(commit) => commit.includes('init')],
extends: ['@commitlint/config-conventional'],
Expand All @@ -8,26 +17,55 @@ module.exports = {
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'subject-case': [0],
'type-enum': [
2,
'always',
[
'feat',
'fix',
'perf',
'style',
'docs',
'test',
'refactor',
'build',
'ci',
'chore',
'revert',
'wip',
'workflow',
'types',
'release',
],
],
'type-enum': [2, 'always', [ 'feat', 'fix', 'perf', 'style', 'docs', 'test', 'refactor', 'build', 'ci', 'chore', 'revert', 'wip', 'workflow', 'types', 'release']],
},
prompt: {
messages: {
type: '确保本次提交遵循 Angular 规范!\n选择你要提交的类型:',
scope: '选择一个提交范围(可选):',
customScope: '请输入自定义的提交范围: ',
subject: '填写简短精炼的变更描述:\n',
body: '填写更加详细的变更描述(可选)。使用 "|" 换行:\n',
breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行:\n',
footerPrefixsSelect: "选择关联issue前缀(可选):",
customFooterPrefixs: "输入自定义issue前缀 :",
footer: "列举关联issue (可选) 例如: #31, #I3244 :",
confirmCommit: "是否提交或修改 commit ?",
},
types: [
{value: 'feat', name: 'feat: 新增功能'},
{value: 'fix', name: 'fix: 修复缺陷'},
{value: 'types', name: 'types: 类型修改'},
{value: 'docs', name: 'docs: 文档变更'},
{value: 'perf', name: 'perf: 性能优化'},
{value: 'style', name: 'style: 代码格式(不影响功能,例如空格、分号等格式修正)'},
{value: 'refactor', name: 'refactor: 代码重构(不包括 bug 修复、功能新增)'},
{value: 'test', name: 'test: 添加、修改测试用例'},
{value: 'build', name: 'build: 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)'},
{value: 'ci', name: 'ci: 修改 CI 配置、脚本'},
{value: 'revert', name: 'revert: 回滚 commit'},
{value: 'wip', name: 'wip: 功能开发中'},
{value: 'workflow', name: 'workflow: 工作流程变更'},
{value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)'},
],
scopes: [
{value: 'components', name: 'components: 组件相关'},
{value: 'hooks', name: 'hooks: 组件相关'},
{value: 'utils', name: 'utils: utils 相关'},
{value: 'element-ui', name: 'element-ui: 对 element-ui 的调整'},
{value: 'styles', name: 'styles: 对样式的调整'},
{value: 'deps', name: 'deps: 项目依赖'},
{value: 'auth', name: 'auth: 对 auth 修改'},
{value: 'other', name: 'other: 其他修改'},
],
customScopesAlign: "top-bottom",
customScopesAlias: "custom: 以上都不是?我要自定义",
allowBreakingChanges: ['feat', 'fix'],
issuePrefixs: [
{ value: "link", name: "link: 链接 ISSUES 进行中" },
{ value: "closed", name: "closed: 标记 ISSUES 已完成" },
],
customIssuePrefixsAlign: !issue ? "top" : "bottom",
defaultIssues: !issue ? "" : `#${issue}`
}
};
42 changes: 23 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:report": "vue-cli-service build --report && npx live-server --open=dist/report.html",
"clean:lib": "npx rimraf node_modules",
"deploy": "npm run build && npx gh-pages -d dist",
"dev:debug": "cross-env DEBUG_ANTDV=true npm run serve",
"lint": "vue-cli-service lint",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
Expand All @@ -26,25 +27,26 @@
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run dev",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
"test:gzip": "npx http-server dist --cors --gzip -c-1",
"test:br": "npx http-server dist --cors --brotli -c-1"
"test:br": "npx http-server dist --cors --brotli -c-1",
"commit": "git cz"
},
"dependencies": {
"@ant-design/icons-vue": "^6.1.0",
"@vueuse/core": "^8.2.5",
"ant-design-vue": "3.1.1",
"axios": "^0.26.1",
"core-js": "^3.21.1",
"dayjs": "^1.11.0",
"@vueuse/core": "^8.3.1",
"ant-design-vue": "3.2.2",
"axios": "^0.27.1",
"core-js": "^3.22.2",
"dayjs": "^1.11.1",
"file-saver": "^2.0.5",
"lodash-es": "^4.17.21",
"mitt": "^3.0.0",
"mockjs": "^1.1.0",
"nprogress": "^1.0.0-1",
"pinia": "2.0.13",
"qs": "^6.10.3",
"socket.io-client": "4.4.1",
"socket.io-client": "4.5.0",
"sortablejs": "^1.15.0",
"vue": "^3.2.32",
"vue": "3.2.33",
"vue-i18n": "9.2.0-beta.30",
"vue-router": "^4.0.14",
"vue-types": "^4.1.1",
Expand All @@ -54,35 +56,37 @@
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@types/lodash-es": "^4.17.6",
"@types/node": "^17.0.23",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"@types/node": "^17.0.29",
"@types/webpack-env": "^1.16.4",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"@vue/cli-plugin-babel": "^5.0.4",
"@vue/cli-plugin-eslint": "^5.0.4",
"@vue/cli-plugin-router": "^5.0.4",
"@vue/cli-plugin-typescript": "^5.0.4",
"@vue/cli-service": "^5.0.4",
"@vue/eslint-config-typescript": "^10.0.0",
"babel-plugin-import": "^1.13.3",
"babel-plugin-import": "^1.13.5",
"commitizen": "^4.2.4",
"conventional-changelog-cli": "^2.2.2",
"eslint": "^8.13.0",
"cross-env": "^7.0.3",
"cz-git": "^1.2.3",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.6.0",
"eslint-plugin-vue": "^8.7.1",
"husky": "^7.0.4",
"less": "^4.1.2",
"less-loader": "10.2.0",
"lint-staged": "^12.3.7",
"lint-staged": "^12.4.1",
"path-browserify": "^1.0.1",
"postcss-html": "^1.3.1",
"postcss-html": "^1.4.1",
"postcss-less": "^6.0.0",
"prettier": "^2.6.2",
"regenerator-runtime": "^0.13.9",
"speed-measure-webpack-plugin": "^1.5.0",
"stylelint": "^14.6.1",
"stylelint": "^14.8.0",
"stylelint-config-html": "^1.0.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-recommended": "^7.0.0",
Expand All @@ -91,7 +95,7 @@
"stylelint-order": "^5.0.0",
"svg-sprite-loader": "^6.0.11",
"typescript": "^4.6.3",
"unplugin-vue-define-options": "^0.6.0",
"unplugin-vue-define-options": "^0.6.1",
"vue-cli-plugin-windicss": "^1.1.4",
"vue-eslint-parser": "^8.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<ConfigProvider :locale="getAntdLocale">
<router-view v-slot="{ Component }">
<router-view #="{ Component }">
<component :is="Component" />
</router-view>
<LockScreen />
Expand Down
13 changes: 10 additions & 3 deletions src/components/core/dynamic-table/src/dynamic-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
v-bind="getFormProps"
:table-instance="tableAction"
@toggle-advanced="(e) => $emit('toggle-advanced', e)"
@submit="queryTable"
@submit="handleSubmit"
>
<template v-for="item in getFormSlotKeys" #[replaceFormSlotKey(item)]="data">
<slot :name="item" v-bind="data || {}"></slot>
Expand Down Expand Up @@ -104,8 +104,15 @@
const { tableData, queryFormRef, getBindValues } = tableState;
// 表格内部方法
const tableMethods = useTableMethods({ state: tableState, props, emit });
const { getColumnKey, setProps, fetchData, queryTable, reload, handleTableChange, getComponent } =
tableMethods;
const {
getColumnKey,
setProps,
fetchData,
handleSubmit,
reload,
handleTableChange,
getComponent,
} = tableMethods;
// 搜索表单
const { getFormProps, replaceFormSlotKey, getFormSlotKeys } = useTableForm({
Expand Down
17 changes: 10 additions & 7 deletions src/components/core/dynamic-table/src/hooks/useTableMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const useTableMethods = ({ state, props, emit }: UseTableMethodsContext)
/**
* @description 表格查询
*/
const queryTable = (params) => {
params.page = 1;
const handleSubmit = (params, page = 1) => {
params.page = page;
fetchData(params);
};

Expand Down Expand Up @@ -103,13 +103,16 @@ export const useTableMethods = ({ state, props, emit }: UseTableMethodsContext)
/**
* @description 分页改变
*/
const handleTableChange = (...rest: OnChangeCallbackParams) => {
const handleTableChange = async (...rest: OnChangeCallbackParams) => {
// const [pagination, filters, sorter] = rest;
const [pagination] = rest;
if (Object.keys(pagination).length) {
Object.assign(unref(paginationRef), pagination);
let params = {};
if (queryFormRef.value) {
const values = await queryFormRef.value.validate();
params = queryFormRef.value.handleFormValues(values);
}
fetchData(pagination, rest);
Object.assign(unref(paginationRef), pagination || {});
fetchData(params, rest);
emit('change', ...rest);
};

Expand All @@ -129,7 +132,7 @@ export const useTableMethods = ({ state, props, emit }: UseTableMethodsContext)
return {
setProps,
getComponent,
queryTable,
handleSubmit,
handleTableChange,
getColumnKey,
fetchData,
Expand Down
10 changes: 9 additions & 1 deletion src/layout/menu/menu-item.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<!-- 目录 -->
<template v-if="props.menuInfo?.meta?.type === 0 || props.menuInfo?.children?.length">
<template v-if="isShowSubMenu">
<Menu.SubMenu :key="props.menuInfo?.name" v-bind="$attrs">
<template #title>
<span>
Expand Down Expand Up @@ -45,6 +45,14 @@
.filter((n) => !n.meta?.hideInMenu)
.sort((a, b) => (a?.meta?.orderNum || 0) - (b?.meta?.orderNum || 0));
});
const isShowSubMenu = computed(() => {
const menuInfo = props.menuInfo;
return (
menuInfo?.meta?.type === 0 ||
(!Object.is(menuInfo?.meta?.hideChildrenInMenu, true) && menuInfo?.children?.length)
);
});
</script>
<style scoped></style>

0 comments on commit 79b2093

Please sign in to comment.