Commit 2f268ca8f43d98687ffd809e2c1d140d29033bd6

Authored by 陈文彬
1 parent 351f60a8

fix: fix form,transition,build bug

Too many changes to show.

To preserve performance only 19 of 20 files are displayed.

src/App.vue
... ... @@ -30,7 +30,6 @@
30 30 createBreakpointListen();
31 31 const { renderEmpty, transformCellText } = useConfigProvider();
32 32 const { on: lockOn } = useLockPage();
33   -
34 33 return {
35 34 renderEmpty,
36 35 transformCellText,
... ...
src/components/Form/src/BasicForm.vue
... ... @@ -48,7 +48,7 @@
48 48 import { isArray, isBoolean, isFunction, isNumber, isObject, isString } from '/@/utils/is';
49 49 import { cloneDeep } from 'lodash-es';
50 50 import { useBreakpoint } from '/@/hooks/event/useBreakpoint';
51   - import { useThrottle } from '/@/hooks/core/useThrottle';
  51 + // import { useThrottle } from '/@/hooks/core/useThrottle';
52 52 import { useFormValues } from './hooks/useFormValues';
53 53 import type { ColEx } from './types';
54 54 import { NamePath } from 'ant-design-vue/types/form/form-item';
... ... @@ -163,13 +163,13 @@
163 163 });
164 164  
165 165 const { realWidthRef, screenEnum, screenRef } = useBreakpoint();
166   - const [throttleUpdateAdvanced] = useThrottle(updateAdvanced, 30, { immediate: true });
  166 + // const [throttleUpdateAdvanced] = useThrottle(updateAdvanced, 30, { immediate: true });
167 167 watch(
168 168 [() => unref(getSchema), () => advanceState.isAdvanced, () => unref(realWidthRef)],
169 169 () => {
170 170 const { showAdvancedButton } = unref(getProps);
171 171 if (showAdvancedButton) {
172   - throttleUpdateAdvanced();
  172 + updateAdvanced();
173 173 }
174 174 },
175 175 { immediate: true }
... ...
src/components/Form/src/FormItem.tsx
... ... @@ -189,14 +189,13 @@ export default defineComponent({
189 189 const bindValue = {
190 190 [isCheck ? 'checked' : 'value']: (props.formModel as any)[field],
191 191 };
  192 + if (!renderComponentContent) {
  193 + return <Comp {...propsData} {...on} {...bindValue} />;
  194 + }
192 195 return (
193 196 <Comp {...propsData} {...on} {...bindValue}>
194 197 {{
195   - ...(renderComponentContent
196   - ? renderComponentContent(unref(getValuesRef))
197   - : {
198   - default: () => '',
199   - }),
  198 + ...renderComponentContent(unref(getValuesRef)),
200 199 }}
201 200 </Comp>
202 201 );
... ...
src/components/Tree/src/BasicTree.tsx
... ... @@ -161,6 +161,7 @@ export default defineComponent({
161 161 const treeData: any = cloneDeep(unref(treeDataRef));
162 162 if (!parentKey) {
163 163 treeData[push](node);
  164 + treeDataRef.value = treeData;
164 165 return;
165 166 }
166 167 const { key: keyField, children: childrenField } = unref(getReplaceFields);
... ...
src/enums/eventBusEnum.ts 0 → 100644
  1 +export const MENU_DRAG_STATE = 'MENU_DRAG_STATE';
... ...
src/hooks/event/useEventHub.ts 0 → 100644
  1 +import { tryOnUnmounted } from '/@/utils/helper/vueHelper';
  2 +import {} from 'vue';
  3 +import EventHub from '/@/utils/eventHub';
  4 +const eventHub = new EventHub();
  5 +export function useEventHub(): EventHub {
  6 + tryOnUnmounted(() => {
  7 + eventHub.clear();
  8 + });
  9 +
  10 + return eventHub;
  11 +}
... ...
src/layouts/default/LayoutBreadcrumb.tsx
... ... @@ -65,7 +65,7 @@ export default defineComponent({
65 65  
66 66 return () => (
67 67 <>
68   - <Breadcrumb class="layout-breadcrumb">
  68 + <Breadcrumb class="layout-breadcrumb flex-grow">
69 69 {() => (
70 70 <>
71 71 <TransitionGroup name="breadcrumb">
... ...
src/layouts/default/LayoutHeader.tsx
... ... @@ -68,7 +68,7 @@ export default defineComponent({
68 68 {showLogo && !isSidebarType && <Logo class={`layout-header__logo`} />}
69 69  
70 70 {mode !== MenuModeEnum.HORIZONTAL && showBreadCrumb && !splitMenu && (
71   - <LayoutBreadcrumb class="flex-grow " />
  71 + <LayoutBreadcrumb />
72 72 )}
73 73 {(mode === MenuModeEnum.HORIZONTAL || splitMenu) && (
74 74 <div class={[`layout-header__menu flex-grow `, `justify-${topMenuAlign}`]}>
... ...
src/router/guard/pageLoadingGuard.ts
... ... @@ -28,12 +28,15 @@ export function createPageLoadingGuard(router: Router) {
28 28 }
29 29 return true;
30 30 });
31   - router.afterEach(async () => {
  31 + router.afterEach(async (to) => {
32 32 const { openRouterTransition, openPageLoading } = appStore.getProjectConfig;
33   - if ((!openRouterTransition && openPageLoading) || isFirstLoad) {
34   - appStore.commitPageLoadingState(false);
  33 + if ((!openRouterTransition && openPageLoading) || isFirstLoad || to.meta.afterCloseLoading) {
  34 + setTimeout(() => {
  35 + appStore.commitPageLoadingState(false);
  36 + }, 110);
35 37 isFirstLoad = false;
36 38 }
  39 +
37 40 return true;
38 41 });
39 42 }
... ...
src/router/routes/modules/demo/exception.ts
... ... @@ -27,6 +27,7 @@ export default {
27 27 },
28 28 meta: {
29 29 title: '404',
  30 + afterCloseLoading: true,
30 31 },
31 32 },
32 33 {
... ... @@ -38,6 +39,7 @@ export default {
38 39 },
39 40 meta: {
40 41 title: '500',
  42 + afterCloseLoading: true,
41 43 },
42 44 },
43 45 {
... ... @@ -49,6 +51,7 @@ export default {
49 51 },
50 52 meta: {
51 53 title: '网络错误',
  54 + afterCloseLoading: true,
52 55 },
53 56 },
54 57 {
... ... @@ -60,6 +63,7 @@ export default {
60 63 },
61 64 meta: {
62 65 title: '页面超时',
  66 + afterCloseLoading: true,
63 67 },
64 68 },
65 69 {
... ... @@ -71,6 +75,7 @@ export default {
71 75 },
72 76 meta: {
73 77 title: '无数据',
  78 + afterCloseLoading: true,
74 79 },
75 80 },
76 81 ],
... ...
src/router/types.d.ts
... ... @@ -26,6 +26,9 @@ export interface RouteMeta {
26 26  
27 27 // disabled redirect
28 28 disabledRedirect?: boolean;
  29 +
  30 + // close loading
  31 + afterCloseLoading?: boolean;
29 32 }
30 33  
31 34 export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
... ...
src/store/modules/permission.ts
1   -import { REDIRECT_ROUTE } from './../../router/constant';
  1 +import { REDIRECT_ROUTE } from '/@/router/constant';
2 2 import type { AppRouteRecordRaw, Menu } from '/@/router/types';
3 3 import store from '/@/store/index';
4 4 import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
... ... @@ -19,7 +19,7 @@ import { genRouteModule, transformObjToRoute } from &#39;/@/utils/helper/routeHelper
19 19 import { transformRouteToMenu } from '/@/utils/helper/menuHelper';
20 20  
21 21 import { useMessage } from '/@/hooks/web/useMessage';
22   -
  22 +import { warn } from 'vue';
23 23 const { createMessage } = useMessage();
24 24 const NAME = 'permission';
25 25 hotModuleUnregisterModule(NAME);
... ... @@ -107,7 +107,7 @@ class Permission extends VuexModule {
107 107 });
108 108 // this.commitRoutesState(routes);
109 109 // Background permissions
110   - console.warn(
  110 + warn(
111 111 `当前权限模式为:${PermissionModeEnum.ROLE},请将src/store/modules/permission.ts内的后台菜单获取函数注释,如果已注释可以忽略此信息!`
112 112 );
113 113 // 如果确定不需要做后台动态权限,请将下面整个判断注释
... ...
src/utils/eventHub.ts 0 → 100644
  1 +class EventHub {
  2 + private cache: { [key: string]: Array<(data: any) => void> } = {};
  3 + on(eventName: string, fn: (data: any) => void) {
  4 + this.cache[eventName] = this.cache[eventName] || [];
  5 + this.cache[eventName].push(fn);
  6 + }
  7 +
  8 + once(eventName: string, fn: (data: any) => void) {
  9 + const decor = (...args: any[]) => {
  10 + fn && fn.apply(this, args);
  11 + this.off(eventName, decor);
  12 + };
  13 + this.on(eventName, decor);
  14 + return this;
  15 + }
  16 +
  17 + emit(eventName: string, data?: any) {
  18 + if (this.cache[eventName] === undefined) return;
  19 + console.log('======================');
  20 + console.log(this.cache, eventName);
  21 + console.log('======================');
  22 + this.cache[eventName].forEach((fn) => fn(data));
  23 + }
  24 + off(eventName: string, fn: (data: any) => void) {
  25 + if (this.cache[eventName] === undefined || this.cache[eventName].length === 0) return;
  26 + const i = this.cache[eventName].indexOf(fn);
  27 + if (i === -1) return;
  28 + this.cache[eventName].splice(i, 1);
  29 + }
  30 +
  31 + clear() {
  32 + this.cache = {};
  33 + }
  34 +}
  35 +
  36 +export default EventHub;
... ...
src/views/demo/form/RefForm.vue
... ... @@ -58,6 +58,7 @@
58 58 <BasicForm
59 59 :schemas="schemas"
60 60 ref="formElRef"
  61 + :labelWidth="100"
61 62 @submit="handleSubmit"
62 63 :actionColOptions="{ span: 24 }"
63 64 />
... ...
src/views/sys/error-log/DetailModal.vue deleted 100644 → 0
1   -<script lang="tsx">
2   - import { defineComponent, PropOptions } from 'compatible-vue';
3   - import { BasicModal } from '@/components/modal/index';
4   - import { ErrorInfo } from '@/store/modules/error';
5   - import { Description, useDescription } from '@/components/description/index';
6   - import { getDescSchema } from './data';
7   -
8   - export default defineComponent({
9   - name: 'ErrorLogDetailModal',
10   - props: {
11   - info: {
12   - type: Object,
13   - default: null,
14   - } as PropOptions<ErrorInfo>,
15   - },
16   - setup(props, { listeners }) {
17   - const [register] = useDescription({
18   - column: 2,
19   - schema: getDescSchema(),
20   - });
21   - return () => {
22   - return (
23   - <BasicModal width={800} title="错误详情" on={listeners}>
24   - <Description data={props.info} onRegister={register} />
25   - </BasicModal>
26   - );
27   - };
28   - },
29   - });
30   -</script>
src/views/sys/error-log/data.tsx deleted 100644 → 0
1   -import { Tag } from 'ant-design-vue';
2   -import { BasicColumn } from '@/components/table/index';
3   -import { ErrorTypeEnum } from '@/store/modules/error';
4   -import { DescItem } from '@/components/description/index';
5   -
6   -export function getColumns(): BasicColumn[] {
7   - return [
8   - {
9   - dataIndex: 'type',
10   - title: '类型',
11   - width: 80,
12   - customRender: (text: string) => {
13   - const color =
14   - text === ErrorTypeEnum.VUE
15   - ? 'green'
16   - : text === ErrorTypeEnum.RESOURCE
17   - ? 'cyan'
18   - : text === ErrorTypeEnum.PROMISE
19   - ? 'blue'
20   - : ErrorTypeEnum.AJAX
21   - ? 'red'
22   - : 'purple';
23   - return <Tag color={color}>{text}</Tag>;
24   - },
25   - },
26   - {
27   - dataIndex: 'url',
28   - title: '地址',
29   - width: 200,
30   - },
31   - {
32   - dataIndex: 'time',
33   - title: '时间',
34   - width: 160,
35   - },
36   - {
37   - dataIndex: 'file',
38   - title: '文件',
39   - width: 200,
40   - },
41   - {
42   - dataIndex: 'name',
43   - title: 'Name',
44   - width: 200,
45   - },
46   - {
47   - dataIndex: 'message',
48   - title: '错误信息',
49   - width: 300,
50   - },
51   - {
52   - dataIndex: 'stack',
53   - title: 'stack信息',
54   - width: 300,
55   - },
56   - ];
57   -}
58   -
59   -export function getDescSchema(): DescItem[] {
60   - return getColumns().map((column) => {
61   - return {
62   - field: column.dataIndex!,
63   - label: column.title,
64   - };
65   - });
66   -}
src/views/sys/error-log/index.vue deleted 100644 → 0
1   -<script lang="tsx">
2   - import { defineComponent, watch, ref, unref } from 'compatible-vue';
3   -
4   - import DetailModal from './DetailModal.vue';
5   - import { useModal } from '@/components/modal/index';
6   -
7   - import { useDesign } from '@/hooks/core/useDesign';
8   -
9   - import { BasicTable, useTable } from '@/components/table/index';
10   -
11   - import { errorStore, ErrorInfo } from '@/store/modules/error';
12   -
13   - import { fireErrorApi } from '@/api/demo/error';
14   -
15   - import { getColumns } from './data';
16   -
17   - const { prefixCls } = useDesign('error-handle');
18   -
19   - export default defineComponent({
20   - name: 'ErrorHandler',
21   - setup() {
22   - const rowInfoRef = ref<ErrorInfo>();
23   - const imgListRef = ref<string[]>([]);
24   - const [register, { setTableData }] = useTable({
25   - titleHelpMessage: '只在`/src/settings/projectSetting.ts` 内的useErrorHandle=true时生效!',
26   - title: '错误日志列表',
27   - columns: getColumns(),
28   - actionColumn: {
29   - width: 80,
30   - title: '操作',
31   - dataIndex: 'action',
32   - customRender: (text: string, recoed: ErrorInfo) => {
33   - return (
34   - <a-button type="link" size="small" onClick={handleDetail.bind(null, recoed)}>
35   - 详情
36   - </a-button>
37   - );
38   - },
39   - },
40   - });
41   -
42   - const [registerModal, { openModal }] = useModal();
43   - watch(
44   - () => errorStore.getErrorInfoState,
45   - (list: any[]) => {
46   - setTableData(list);
47   - },
48   - {
49   - immediate: true,
50   - }
51   - );
52   -
53   - // 查看详情
54   - function handleDetail(row: ErrorInfo) {
55   - rowInfoRef.value = row;
56   - openModal({
57   - visible: true,
58   - });
59   - }
60   -
61   - function fireVueError() {
62   - throw new Error('fire vue error!');
63   - }
64   -
65   - function fireResourceError() {
66   - imgListRef.value.push(`${new Date().getTime()}.png`);
67   - }
68   -
69   - async function fireAjaxError() {
70   - await fireErrorApi();
71   - }
72   -
73   - return () => (
74   - <div class={[prefixCls, 'p-4']}>
75   - {unref(imgListRef).map((src) => {
76   - return <img src={src} key={src} class="hidden" />;
77   - })}
78   -
79   - <DetailModal info={unref(rowInfoRef)} onRegister={registerModal} />
80   -
81   - <BasicTable onRegister={register} class={`${prefixCls}-table`}>
82   - <template slot="toolbar">
83   - <a-button onClick={fireVueError} type="primary">
84   - 点击触发vue错误
85   - </a-button>
86   - <a-button onClick={fireResourceError} type="primary">
87   - 点击触发resource错误
88   - </a-button>
89   - <a-button onClick={fireAjaxError} type="primary">
90   - 点击触发ajax错误
91   - </a-button>
92   - </template>
93   - </BasicTable>
94   - </div>
95   - );
96   - },
97   - });
98   -</script>
99   -<style scoped lang="less">
100   - @import (reference) '~@design';
101   - @prefix-cls: ~'@{namespace}-error-handle';
102   -
103   - .@{prefix-cls} {
104   - &-table {
105   - background: #fff;
106   - }
107   - }
108   -</style>
src/views/sys/iframe/index.vue
1 1 <template>
2 2 <div class="iframe-page" :style="getWrapStyle">
3 3 <Spin :spinning="loading" size="large" :style="getWrapStyle">
4   - <div class="iframe-page__mask" v-show="menuStore.getDragStartState" />
5 4 <iframe :src="frameSrc" class="iframe-page__main" ref="frameRef" />
6 5 </Spin>
7 6 </div>
... ... @@ -12,7 +11,7 @@
12 11  
13 12 import { getViewportOffset } from '/@/utils/domUtils';
14 13 import { useWindowSizeFn } from '/@/hooks/event/useWindowSize';
15   - import { menuStore } from '/@/store/modules/menu';
  14 +
16 15 export default defineComponent({
17 16 name: 'IFrame',
18 17 components: { Spin },
... ... @@ -76,7 +75,6 @@
76 75 }),
77 76 loading: loadingRef,
78 77 frameRef,
79   - menuStore,
80 78 };
81 79 },
82 80 });
... ...
vite.config.ts
... ... @@ -51,7 +51,7 @@ const viteConfig: UserConfig = {
51 51 */
52 52 port: 3100,
53 53 /**
54   - * 运行自动打开浏览器
  54 + * 运行自动打开浏览器·
55 55 * @default 'false'
56 56 */
57 57 open: false,
... ... @@ -88,9 +88,9 @@ const viteConfig: UserConfig = {
88 88 assetsInlineLimit: 4096,
89 89 /**
90 90 * esbuild转换目标。
91   - * @default 'es2020'
  91 + * @default 'es2019'
92 92 */
93   - esbuildTarget: 'es2020',
  93 + esbuildTarget: 'es2019',
94 94  
95 95 // 别名
96 96 alias: {
... ...