From 4fc62a940dffa05511b524865bf50e9cab2eaaf6 Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Mon, 13 Dec 2021 11:36:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20rootadmin=20=E5=81=87=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95,=E9=81=BF=E5=85=8D=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E4=BA=BA=E8=A2=AB=E8=BF=AB=E4=B8=8B=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 - package.json | 3 + src/api/account/model.d.ts | 1 + src/components/dynamic-table/hooks/index.ts | 1 - .../dynamic-table/hooks/useCalculate.ts | 86 ------ src/layout/header/components.ts | 33 --- src/layout/header/index.vue | 264 +++++++++--------- src/layout/menu/menu-item.vue | 2 +- src/router/router-guards.ts | 2 +- src/router/staticModules/error.ts | 2 +- src/router/staticModules/redirect.ts | 4 +- src/store/modules/user.ts | 3 + src/utils/common.ts | 4 +- src/views/shared/dashboard/welcome/index.vue | 4 +- .../demos/form/basic-form/form-schema.ts | 2 +- .../demos/form/rule-form/form-schema.ts | 2 +- src/views/shared/login/index.vue | 5 +- tsconfig.json | 47 ++-- types/modules.d.ts | 8 +- types/vue-router.d.ts | 26 +- types/vuex.d.ts | 8 +- vue.config.js | 22 +- 22 files changed, 211 insertions(+), 326 deletions(-) delete mode 100644 src/components/dynamic-table/hooks/useCalculate.ts delete mode 100644 src/layout/header/components.ts diff --git a/README.md b/README.md index c260de5c7..158c2a3e3 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,6 @@ > 使用了 Vue3.0 全家桶、ant-design-vue2.0 和 typescript4.0,实践 vue3.0 的新特性以及玩法,不得不说 vue3.0 的 Composition API 相比于 vue2.0 的 Options API 灵活很多,让我们可以灵活地组合组件逻辑,我们可以很轻松的使用 hooks 的形式去代替以前 mixins 等的写法。更多 hooks 可以参考[vueuse](https://vueuse.org/functions.html) -## 克隆项目 - -```bash -git clone --single-branch https://github.com/buqiyuan/vite-vue3-lowcode.git -or -git clone --depth=1 https://github.com/buqiyuan/vite-vue3-lowcode.git -``` - ## Project setup ```shell diff --git a/package.json b/package.json index 28d76b981..c3922a1e0 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,9 @@ "typescript" ], "license": "MIT", + "engines": { + "node": "^12 || >=14" + }, "lint-staged": { "*.{js,jsx,ts,tsx}": [ "eslint --fix", diff --git a/src/api/account/model.d.ts b/src/api/account/model.d.ts index 439cac29a..cf790a24f 100644 --- a/src/api/account/model.d.ts +++ b/src/api/account/model.d.ts @@ -31,6 +31,7 @@ declare namespace API { psalt: string; nickName: string; headImg: string; + loginIp: string; email: string; phone: string; remark: string; diff --git a/src/components/dynamic-table/hooks/index.ts b/src/components/dynamic-table/hooks/index.ts index 2975b518e..397ae13b7 100644 --- a/src/components/dynamic-table/hooks/index.ts +++ b/src/components/dynamic-table/hooks/index.ts @@ -1,3 +1,2 @@ export { useDragCol } from './useDragCol'; export { useExpandLoading } from './useExpandLoading'; -export { useCalculate } from './useCalculate'; diff --git a/src/components/dynamic-table/hooks/useCalculate.ts b/src/components/dynamic-table/hooks/useCalculate.ts deleted file mode 100644 index 31d092ce8..000000000 --- a/src/components/dynamic-table/hooks/useCalculate.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { nextTick } from 'vue'; -import { isFunction } from '@/utils/is'; - -interface CalculateParams { - /** 表格实例 */ - tableRef: any; - /** 数据源 */ - dataSource: any[]; - /** 表格列的配置描述 */ - columns: any[]; - /** 合计显示文本 */ - sumText: string; - /** 合计行计算方法 */ - summaryFunc?: (params: { dataSource: any[]; columns: any[] }) => string[]; -} - -/** - * 表格尾部合计行 - */ -export const useCalculate = () => { - let tr: HTMLTableRowElement; - - const setCalculateRow = async (params: CalculateParams) => { - await nextTick(); - const { tableRef, dataSource = [], columns = [], sumText, summaryFunc } = params; - if (!dataSource.length) return; - const tbody = tableRef.value.$el.querySelector('.ant-table-tbody') as HTMLTableSectionElement; - if (!tr) { - tr = tbody.lastElementChild?.cloneNode(true) as HTMLTableRowElement; - tr.style.backgroundColor = '#f8f8f9'; - tr.style.position = 'sticky'; - tr.style.zIndex = '999'; - tr.style.bottom = '0'; - tr.setAttribute('data-row-key', String(Math.random())); - } - // 渲染单元格 - const renderCol = (colEls?: HTMLTableCellElement[]) => { - // 如果有传进自定义合计行渲染方法 - if (isFunction(summaryFunc)) { - const result = summaryFunc({ dataSource, columns }); - [...tr.children].forEach((item: HTMLTableCellElement, index) => { - item.textContent = result[index]; - item.style.backgroundColor = 'inherit'; - }); - } else { - // 没有自定义合计行方法就默认渲染囖 - const lastData = Object.keys(dataSource[0]).reduce((prev, key) => { - const count = dataSource.map((n) => n[key]).reduce((p, c) => c + p, 0); - prev[key] = isNaN(Number(count)) ? 'N/A' : count; - return prev; - }, {}); - const columnKeys = columns.map((item) => item.dataIndex ?? item.key); - [...tr.children].forEach((item: HTMLTableCellElement, index) => { - if (index == 0) { - item.textContent = sumText; - } else { - item.textContent = lastData[columnKeys[index]]; - } - item.style.backgroundColor = 'inherit'; - }); - } - if (colEls?.length) { - [...tr.children].forEach((item: HTMLTableCellElement, index) => { - Object.keys(colEls[index].style || []).forEach((key) => { - const styleKey = colEls[index].style[key]; - item.style[styleKey] = colEls[index].style[styleKey]; - item.className = colEls[index].className; - }); - }); - } - }; - - renderCol(); - - if (!tbody.contains(tr)) { - tbody.appendChild(tr); - setTimeout(() => { - const colEls = - tableRef.value.$el.querySelector('.ant-table-tbody')?.firstElementChild?.children; - colEls && renderCol([...colEls] as HTMLTableCellElement[]); - }, 100); - } - }; - - return { setCalculateRow }; -}; diff --git a/src/layout/header/components.ts b/src/layout/header/components.ts deleted file mode 100644 index 92f3717a3..000000000 --- a/src/layout/header/components.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Layout, Avatar, Menu, Dropdown, Breadcrumb, Tooltip } from 'ant-design-vue'; - -import { - SettingOutlined, - SearchOutlined, - MenuFoldOutlined, - MenuUnfoldOutlined, - FullscreenOutlined, - FullscreenExitOutlined, - PoweroffOutlined, - GithubOutlined, - LockOutlined, -} from '@ant-design/icons-vue'; - -export default { - [Layout.Header.name]: Layout.Header, - [Avatar.name]: Avatar, - [Menu.name]: Menu, - [Tooltip.name]: Tooltip, - [Menu.Divider.name]: Menu.Divider, - SettingOutlined, - Dropdown, - LockOutlined, - GithubOutlined, - SearchOutlined, - [Breadcrumb.name]: Breadcrumb, - [Breadcrumb.Item.name]: Breadcrumb.Item, - MenuFoldOutlined, - MenuUnfoldOutlined, - FullscreenOutlined, - FullscreenExitOutlined, - PoweroffOutlined, -}; diff --git a/src/layout/header/index.vue b/src/layout/header/index.vue index 9d9c685d1..d0da1cea9 100644 --- a/src/layout/header/index.vue +++ b/src/layout/header/index.vue @@ -1,176 +1,180 @@ -