Commit e15b4f14db51812effd55670b3d2da7b082e00a7

Authored by vben
1 parent a5ff5923

fix: fix all types of errors, compatible with volar plugin

Showing 35 changed files with 69 additions and 61 deletions
src/components/Application/src/search/AppSearchModal.vue
... ... @@ -62,6 +62,7 @@
62 62 import { SearchOutlined } from '@ant-design/icons-vue';
63 63 import AppSearchFooter from './AppSearchFooter.vue';
64 64 import Icon from '/@/components/Icon';
  65 + // @ts-ignore
65 66 import vClickOutside from '/@/directives/clickOutside';
66 67 import { useDesign } from '/@/hooks/web/useDesign';
67 68 import { useRefs } from '/@/hooks/core/useRefs';
... ...
src/components/Button/src/BasicButton.vue
... ... @@ -9,10 +9,11 @@
9 9 </template>
10 10  
11 11 <script lang="ts">
12   - export default {
  12 + import { defineComponent } from 'vue';
  13 + export default defineComponent({
13 14 name: 'AButton',
14 15 inheritAttrs: false,
15   - };
  16 + });
16 17 </script>
17 18 <script lang="ts" setup>
18 19 import { computed, unref } from 'vue';
... ...
src/components/Container/src/ScrollContainer.vue
... ... @@ -54,7 +54,7 @@
54 54 return;
55 55 }
56 56 nextTick(() => {
57   - const wrap = unref(scrollbar.wrap);
  57 + const wrap = unref(scrollbar.wrap) as any;
58 58 if (!wrap) {
59 59 return;
60 60 }
... ...
src/components/ContextMenu/src/ContextMenu.vue
... ... @@ -46,7 +46,7 @@
46 46 name: 'ContextMenu',
47 47 props,
48 48 setup(props) {
49   - const wrapRef = ref<ElRef>(null);
  49 + const wrapRef = ref(null);
50 50 const showRef = ref(false);
51 51  
52 52 const getStyle = computed((): CSSProperties => {
... ...
src/components/Cropper/src/CropperAvatar.vue
... ... @@ -103,7 +103,7 @@
103 103 t,
104 104 prefixCls,
105 105 register,
106   - openModal,
  106 + openModal: openModal as any,
107 107 getIconWidth,
108 108 sourceValue,
109 109 getClass,
... ...
src/components/Drawer/src/BasicDrawer.vue
... ... @@ -181,9 +181,9 @@
181 181 onClose,
182 182 t,
183 183 prefixCls,
184   - getMergeProps,
  184 + getMergeProps: getMergeProps as any,
185 185 getScrollContentStyle,
186   - getProps,
  186 + getProps: getProps as any,
187 187 getLoading,
188 188 getBindValues,
189 189 getFooterHeight,
... ...
src/components/Form/src/BasicForm.vue
... ... @@ -24,7 +24,7 @@
24 24 </FormItem>
25 25 </template>
26 26  
27   - <FormAction v-bind="{ ...getProps, ...advanceState }" @toggle-advanced="handleToggleAdvanced">
  27 + <FormAction v-bind="getFormActionBindProps" @toggle-advanced="handleToggleAdvanced">
28 28 <template
29 29 #[item]="data"
30 30 v-for="item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']"
... ... @@ -62,8 +62,6 @@
62 62 import { basicProps } from './props';
63 63 import { useDesign } from '/@/hooks/web/useDesign';
64 64  
65   - import type { RowProps } from 'ant-design-vue/lib/grid/Row';
66   -
67 65 export default defineComponent({
68 66 name: 'BasicForm',
69 67 components: { FormItem, Form, Row, FormAction },
... ... @@ -103,7 +101,7 @@
103 101 });
104 102  
105 103 // Get uniform row style and Row configuration for the entire form
106   - const getRow = computed((): RowProps => {
  104 + const getRow = computed((): Recordable => {
107 105 const { baseRowStyle = {}, rowProps } = unref(getProps);
108 106 return {
109 107 style: baseRowStyle,
... ... @@ -282,10 +280,12 @@
282 280 getProps,
283 281 formElRef,
284 282 getSchema,
285   - formActionType,
  283 + formActionType: formActionType as any,
286 284 setFormModel,
287   - prefixCls,
288 285 getFormClass,
  286 + getFormActionBindProps: computed(
  287 + (): Recordable => ({ ...getProps.value, ...advanceState })
  288 + ),
289 289 ...formActionType,
290 290 };
291 291 },
... ...
src/components/Form/src/components/FormItem.vue
... ... @@ -83,7 +83,7 @@
83 83 plain: true,
84 84 });
85 85 }
86   - return componentProps;
  86 + return componentProps as Recordable;
87 87 });
88 88  
89 89 const getDisable = computed(() => {
... ...
src/components/Loading/src/useLoading.ts
... ... @@ -4,7 +4,7 @@ import type { LoadingProps } from &#39;./typing&#39;;
4 4 import type { Ref } from 'vue';
5 5  
6 6 export interface UseLoadingOptions {
7   - target?: HTMLElement | Ref<ElRef>;
  7 + target?: any;
8 8 props?: Partial<LoadingProps>;
9 9 }
10 10  
... ...
src/components/Markdown/src/Markdown.vue
... ... @@ -2,6 +2,7 @@
2 2 <div ref="wrapRef"></div>
3 3 </template>
4 4 <script lang="ts">
  5 + import type { Ref } from 'vue';
5 6 import {
6 7 defineComponent,
7 8 ref,
... ... @@ -30,7 +31,7 @@
30 31 emits: ['change', 'get', 'update:value'],
31 32 setup(props, { attrs, emit }) {
32 33 const wrapRef = ref<ElRef>(null);
33   - const vditorRef = ref<Nullable<Vditor>>(null);
  34 + const vditorRef = ref(null) as Ref<Nullable<Vditor>>;
34 35 const initedRef = ref(false);
35 36  
36 37 const modalFn = useModalContext();
... ...
src/components/Menu/src/BasicMenu.vue
... ... @@ -56,14 +56,14 @@
56 56 const { prefixCls } = useDesign('basic-menu');
57 57 const { items, mode, accordion } = toRefs(props);
58 58  
59   - const { getCollapsed, getIsHorizontal, getTopMenuAlign, getSplit } = useMenuSetting();
  59 + const { getCollapsed, getTopMenuAlign, getSplit } = useMenuSetting();
60 60  
61 61 const { currentRoute } = useRouter();
62 62  
63 63 const { handleOpenChange, setOpenKeys, getOpenKeys } = useOpenKeys(
64 64 menuState,
65 65 items,
66   - mode,
  66 + mode as any,
67 67 accordion
68 68 );
69 69  
... ... @@ -150,8 +150,6 @@
150 150 }
151 151  
152 152 return {
153   - prefixCls,
154   - getIsHorizontal,
155 153 handleMenuClick,
156 154 getInlineCollapseOptions,
157 155 getMenuClass,
... ...
src/components/Menu/src/props.ts
... ... @@ -4,6 +4,8 @@ import type { PropType } from &#39;vue&#39;;
4 4 import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
5 5 import { ThemeEnum } from '/@/enums/appEnum';
6 6 import { propTypes } from '/@/utils/propTypes';
  7 +import type { MenuTheme } from 'ant-design-vue';
  8 +import type { MenuMode } from 'ant-design-vue/lib/menu/src/interface';
7 9 export const basicProps = {
8 10 items: {
9 11 type: Array as PropType<Menu[]>,
... ... @@ -14,7 +16,7 @@ export const basicProps = {
14 16 inlineIndent: propTypes.number.def(20),
15 17 // 菜单组件的mode属性
16 18 mode: {
17   - type: String as PropType<MenuModeEnum>,
  19 + type: String as PropType<MenuMode>,
18 20 default: MenuModeEnum.INLINE,
19 21 },
20 22  
... ... @@ -22,7 +24,10 @@ export const basicProps = {
22 24 type: String as PropType<MenuTypeEnum>,
23 25 default: MenuTypeEnum.MIX,
24 26 },
25   - theme: propTypes.string.def(ThemeEnum.DARK),
  27 + theme: {
  28 + type: String as PropType<MenuTheme>,
  29 + default: ThemeEnum.DARK,
  30 + },
26 31 inlineCollapsed: propTypes.bool,
27 32 mixSider: propTypes.bool,
28 33  
... ...
src/components/Modal/src/BasicModal.vue
... ... @@ -104,7 +104,7 @@
104 104 }
105 105  
106 106 // Custom title component: get title
107   - const getMergeProps = computed((): ModalProps => {
  107 + const getMergeProps = computed((): Recordable => {
108 108 return {
109 109 ...props,
110 110 ...(unref(propsRef) as any),
... ... @@ -118,7 +118,7 @@
118 118 });
119 119  
120 120 // modal component does not need title and origin buttons
121   - const getProps = computed((): ModalProps => {
  121 + const getProps = computed((): Recordable => {
122 122 const opt = {
123 123 ...unref(getMergeProps),
124 124 visible: unref(visibleRef),
... ... @@ -212,7 +212,7 @@
212 212 extHeightRef.value = height;
213 213 }
214 214  
215   - function handleTitleDbClick(e: ChangeEvent) {
  215 + function handleTitleDbClick(e) {
216 216 if (!props.canFullscreen) return;
217 217 e.stopPropagation();
218 218 handleFullScreen(e);
... ...
src/components/Modal/src/components/ModalWrapper.vue
... ... @@ -125,7 +125,7 @@
125 125 const modalDom = bodyDom.parentElement && bodyDom.parentElement.parentElement;
126 126 if (!modalDom) return;
127 127  
128   - const modalRect = getComputedStyle(modalDom).top;
  128 + const modalRect = getComputedStyle(modalDom as Element).top;
129 129 const modalTop = Number.parseInt(modalRect);
130 130 let maxHeight =
131 131 window.innerHeight -
... ...
src/components/Preview/src/Preview.vue
... ... @@ -56,7 +56,7 @@
56 56 setup(props) {
57 57 const { prefixCls } = useDesign('image-preview');
58 58  
59   - const getImageList = computed(() => {
  59 + const getImageList = computed((): any[] => {
60 60 const { imageList } = props;
61 61 if (!imageList) {
62 62 return [];
... ...
src/components/SimpleMenu/src/components/Menu.vue
... ... @@ -124,7 +124,7 @@
124 124 isRemoveAllPopup,
125 125 sliceIndex,
126 126 level: 0,
127   - props,
  127 + props: props as any,
128 128 });
129 129  
130 130 onMounted(() => {
... ...
src/components/SimpleMenu/src/components/useSimpleMenuContext.ts
1 1 import type { InjectionKey, Ref } from 'vue';
  2 +import type { Emitter } from '/@/utils/mitt';
2 3 import { createContext, useContext } from '/@/hooks/core/useContext';
3   -import mitt from '/@/utils/mitt';
4 4  
5 5 export interface SimpleRootMenuContextProps {
6   - rootMenuEmitter: typeof mitt;
  6 + rootMenuEmitter: Emitter;
7 7 activeName: Ref<string | number>;
8 8 }
9 9  
... ...
src/components/Table/src/BasicTable.vue
... ... @@ -320,7 +320,7 @@
320 320 wrapRef,
321 321 tableAction,
322 322 redoHeight,
323   - getFormProps,
  323 + getFormProps: getFormProps as any,
324 324 replaceFormSlotKey,
325 325 getFormSlotKeys,
326 326 getWrapperClass,
... ...
src/components/Table/src/components/TableAction.vue
... ... @@ -95,7 +95,7 @@
95 95 .map((action) => {
96 96 const { popConfirm } = action;
97 97 return {
98   - getPopupContainer: () => unref(table?.wrapRef.value) ?? document.body,
  98 + getPopupContainer: () => unref((table as any)?.wrapRef.value) ?? document.body,
99 99 type: 'link',
100 100 size: 'small',
101 101 ...action,
... ... @@ -107,7 +107,7 @@
107 107 });
108 108 });
109 109  
110   - const getDropdownList = computed(() => {
  110 + const getDropdownList = computed((): any[] => {
111 111 return (toRaw(props.dropDownActions) || [])
112 112 .filter((action) => {
113 113 return hasPermission(action.auth) && isIfShow(action);
... ... @@ -133,7 +133,7 @@
133 133  
134 134 function getTooltip(data: string | TooltipProps): TooltipProps {
135 135 return {
136   - getPopupContainer: () => unref(table?.wrapRef.value) ?? document.body,
  136 + getPopupContainer: () => unref((table as any)?.wrapRef.value) ?? document.body,
137 137 placement: 'bottom',
138 138 ...(isString(data) ? { title: data } : data),
139 139 };
... ...
src/components/Table/src/components/TableImg.vue
... ... @@ -24,7 +24,7 @@
24 24 <template v-for="(img, index) in imgList" :key="img">
25 25 <Image
26 26 :width="size"
27   - :style="{ 'margin-left': index === 0 ? 0 : margin }"
  27 + :style="{ marginLeft: index === 0 ? 0 : margin }"
28 28 :src="srcPrefix + img"
29 29 />
30 30 </template>
... ...
src/components/Upload/src/UploadModal.vue
... ... @@ -276,8 +276,8 @@
276 276 }
277 277  
278 278 return {
279   - columns: createTableColumns(),
280   - actionColumn: createActionColumn(handleRemove),
  279 + columns: createTableColumns() as any[],
  280 + actionColumn: createActionColumn(handleRemove) as any,
281 281 register,
282 282 closeModal,
283 283 getHelpText,
... ...
src/components/Upload/src/UploadPreviewModal.vue
... ... @@ -80,8 +80,8 @@
80 80 register,
81 81 closeModal,
82 82 fileListRef,
83   - columns: createPreviewColumns(),
84   - actionColumn: createPreviewActionColumn({ handleRemove, handleDownload }),
  83 + columns: createPreviewColumns() as any[],
  84 + actionColumn: createPreviewActionColumn({ handleRemove, handleDownload }) as any,
85 85 };
86 86 },
87 87 });
... ...
src/components/Verify/src/DragVerify.vue
1 1 <script lang="tsx">
  2 + import type { Ref } from 'vue';
2 3 import { defineComponent, ref, computed, unref, reactive, watch, watchEffect } from 'vue';
3 4 import { useTimeoutFn } from '/@/hooks/core/useTimeout';
4 5 import { useEventListener } from '/@/hooks/event/useEventListener';
... ... @@ -23,7 +24,7 @@
23 24 const wrapElRef = ref<HTMLDivElement | null>(null);
24 25 const barElRef = ref<HTMLDivElement | null>(null);
25 26 const contentElRef = ref<HTMLDivElement | null>(null);
26   - const actionElRef = ref<HTMLDivElement | null>(null);
  27 + const actionElRef = ref(null) as Ref<HTMLDivElement | null>;
27 28  
28 29 useEventListener({
29 30 el: document,
... ... @@ -324,13 +325,8 @@
324 325 color-stop(1, #333)
325 326 );
326 327 animation: slidetounlock 3s infinite;
327   - -webkit-background-clip: text;
328   - -moz-user-select: none;
329   - -webkit-user-select: none;
330   - -o-user-select: none;
331   - -ms-user-select: none;
  328 + background-clip: text;
332 329 user-select: none;
333   - -webkit-text-fill-color: transparent;
334 330  
335 331 &.success {
336 332 -webkit-text-fill-color: @white;
... ... @@ -363,7 +359,7 @@
363 359 }
364 360 }
365 361  
366   - @-webkit-keyframes slidetounlock {
  362 + @keyframes slidetounlock {
367 363 0% {
368 364 background-position: -120px 0;
369 365 }
... ...
src/hooks/event/useIntersectionObserver.ts
... ... @@ -2,7 +2,7 @@ import { Ref, watchEffect, ref } from &#39;vue&#39;;
2 2  
3 3 interface IntersectionObserverProps {
4 4 target: Ref<Element | null | undefined>;
5   - root?: Ref<Element | null | undefined>;
  5 + root?: Ref<any>;
6 6 onIntersect: IntersectionObserverCallback;
7 7 rootMargin?: string;
8 8 threshold?: number;
... ...
src/hooks/event/useScrollTo.ts
... ... @@ -2,7 +2,7 @@ import { isFunction, isUnDef } from &#39;/@/utils/is&#39;;
2 2 import { ref, unref } from 'vue';
3 3  
4 4 export interface ScrollToParams {
5   - el: HTMLElement;
  5 + el: any;
6 6 to: number;
7 7 duration?: number;
8 8 callback?: () => any;
... ...
src/layouts/default/menu/index.vue
... ... @@ -146,11 +146,11 @@
146 146 <SimpleMenu {...menuProps} isSplitMenu={unref(getSplit)} items={menus} />
147 147 ) : (
148 148 <BasicMenu
149   - {...menuProps}
  149 + {...(menuProps as any)}
150 150 isHorizontal={props.isHorizontal}
151 151 type={unref(getMenuType)}
152 152 showLogo={unref(getIsShowLogo)}
153   - mode={unref(getComputedMenuMode)}
  153 + mode={unref(getComputedMenuMode as any)}
154 154 items={menus}
155 155 />
156 156 );
... ...
src/layouts/default/setting/components/InputNumberItem.vue
... ... @@ -31,7 +31,7 @@
31 31 setup(props) {
32 32 const { prefixCls } = useDesign('setting-input-number-item');
33 33  
34   - function handleChange(e: ChangeEvent) {
  34 + function handleChange(e) {
35 35 props.event && baseHandler(props.event, e);
36 36 }
37 37 return {
... ...
src/layouts/default/tabs/index.vue
... ... @@ -27,7 +27,7 @@
27 27 </div>
28 28 </template>
29 29 <script lang="ts">
30   - import type { RouteLocationNormalized } from 'vue-router';
  30 + import type { RouteLocationNormalized, RouteMeta } from 'vue-router';
31 31  
32 32 import { defineComponent, computed, unref, ref } from 'vue';
33 33  
... ... @@ -94,7 +94,7 @@
94 94 }
95 95  
96 96 const { path, fullPath, meta = {} } = route;
97   - const { currentActiveMenu, hideTab } = meta;
  97 + const { currentActiveMenu, hideTab } = meta as RouteMeta;
98 98 const isHide = !hideTab ? null : currentActiveMenu;
99 99 const p = isHide || fullPath || path;
100 100 if (activeKeyRef.value !== p) {
... ...
src/views/dashboard/analysis/components/GrowCard.vue
... ... @@ -3,7 +3,7 @@
3 3 <template v-for="(item, index) in growCardList" :key="item.title">
4 4 <Card
5 5 size="small"
6   - :loading="$attrs.loading"
  6 + :loading="loading"
7 7 :title="item.title"
8 8 class="md:w-1/4 w-full !md:mt-0 !mt-4"
9 9 :class="[index + 1 < 4 && '!md:mr-4']"
... ... @@ -31,4 +31,10 @@
31 31 import { Icon } from '/@/components/Icon';
32 32 import { Tag, Card } from 'ant-design-vue';
33 33 import { growCardList } from '../data';
  34 +
  35 + defineProps({
  36 + loading: {
  37 + type: Boolean,
  38 + },
  39 + });
34 40 </script>
... ...
src/views/demo/comp/cropper/index.vue
... ... @@ -73,7 +73,7 @@
73 73 handleCropend,
74 74 handleCircleCropend,
75 75 avatar,
76   - uploadApi,
  76 + uploadApi: uploadApi as any,
77 77 };
78 78 },
79 79 });
... ...
src/views/demo/comp/qrcode/index.vue
... ... @@ -98,7 +98,7 @@
98 98 qrEl.download('Qrcode');
99 99 }
100 100  
101   - function onQrcodeDone({ ctx }) {
  101 + function onQrcodeDone({ ctx }: any) {
102 102 if (ctx instanceof CanvasRenderingContext2D) {
103 103 // 额外绘制
104 104 ctx.fillStyle = 'black';
... ...
src/views/demo/page/account/setting/BaseSetting.vue
... ... @@ -74,7 +74,7 @@
74 74 return {
75 75 avatar,
76 76 register,
77   - uploadApi,
  77 + uploadApi: uploadApi as any,
78 78 updateAvatar,
79 79 handleSubmit: () => {
80 80 createMessage.success('更新成功!');
... ...
src/views/demo/page/list/search/index.vue
... ... @@ -19,7 +19,7 @@
19 19 {{ item.content }}
20 20 </div>
21 21 <div :class="`${prefixCls}__action`">
22   - <template v-for="(action, index) in actions" :key="index">
  22 + <template v-for="action in actions" :key="action.icon">
23 23 <div :class="`${prefixCls}__action-item`">
24 24 <Icon
25 25 v-if="action.icon"
... ...
src/views/demo/system/account/DeptTree.vue
... ... @@ -29,9 +29,8 @@
29 29 treeData.value = (await getDeptList()) as unknown as TreeItem[];
30 30 }
31 31  
32   - function handleSelect(keys: string, e) {
  32 + function handleSelect(keys) {
33 33 emit('select', keys[0]);
34   - console.log(keys, e);
35 34 }
36 35  
37 36 onMounted(() => {
... ...
src/views/demo/tree/EditTree.vue
... ... @@ -88,6 +88,7 @@
88 88 if (level === 3) {
89 89 return 'ion:airplane';
90 90 }
  91 + return '';
91 92 }
92 93 return { treeData, actionList, getRightMenuList, createIcon };
93 94 },
... ...