Skip to content

Commit

Permalink
perf: compatible vue
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jul 11, 2020
1 parent ed51b20 commit 24cea92
Show file tree
Hide file tree
Showing 124 changed files with 145 additions and 148 deletions.
1 change: 1 addition & 0 deletions config/vue/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const baseAlias = {
'@': 'src',
'@ant-design/icons/lib/dist$': 'src/assets/icons/setupIcon.ts',
'@design': 'src/design/index.less',
'compatible-vue': 'src/setup/vue/index.ts',
};

function configAlias(config) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"postinstall": "node ./build/npm-hook/postinstall.js && npm run clean:cache"
},
"dependencies": {
"@vue/composition-api": "^1.0.0-beta.2",
"@vue/composition-api": "^1.0.0-beta.3",
"ant-design-vue": "^1.6.3",
"axios": "^0.19.2",
"core-js": "^3.6.5",
Expand Down
7 changes: 2 additions & 5 deletions src/common/factory/AsyncComponentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ export type AsyncComponent = AsyncComponentPromise;
/**
* @description: 异步组件工厂
*/
export function createAsyncComponent(
options: AsyncComponentPromise | AsyncComponentFactoryOptions | Promise<typeof import('*.vue')>
): Promise<FunctionalComponentOptions> {
// !只能写内部方法,否则死循环
function asyncHandler(): AsyncComponentFactoryOptions {
export function createAsyncComponent(options: any): Promise<FunctionalComponentOptions> {
function asyncHandler(): any {
const defOptions = {
loading: LOADING_PAGE,
delay: DELAY,
Expand Down
4 changes: 2 additions & 2 deletions src/common/factory/getAsyncComponent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* 获取动态组件
*/
import Vue, { VueConstructor } from 'vue';
import { VueConstructor, Vue } from 'compatible-vue';

export function getAsyncComponent(importComp: () => Promise<typeof import('*.vue')>) {
export function getAsyncComponent(importComp: any) {
return (importComp as unknown) as VueConstructor<Vue>;
}
2 changes: 1 addition & 1 deletion src/common/plugins/watermark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCurrentInstance, onBeforeUnmount } from '@/setup/vue';
import { getCurrentInstance, onBeforeUnmount } from 'compatible-vue';
const watermark: {
set?: (str: string) => void;
} = {};
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/src/Arrow.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
import { Icon } from '@/components/icon/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/src/Help.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Tooltip } from 'ant-design-vue';
import { Icon } from '@/components/icon/index';
import { defineComponent, computed, unref, PropOptions } from '@/setup/vue';
import { defineComponent, computed, unref, PropOptions } from 'compatible-vue';
// hook
import { useDesign } from '@/hooks/core/useDesign';
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/src/Title.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="tsx">
import BaseHelp from './Help.vue';
import { defineComponent } from '@/setup/vue';
import { defineComponent } from 'compatible-vue';
// hook
import { useDesign } from '@/hooks/core/useDesign';
Expand Down
2 changes: 1 addition & 1 deletion src/components/container/src/CollapseContainer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, ref, unref } from '@/setup/vue';
import { defineComponent, ref, unref } from 'compatible-vue';
// component
import { CollapseTransition } from '@/components/transition/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/container/src/ScrollContainer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="tsx">
// component
import { defineComponent } from '@/setup/vue';
import { defineComponent } from 'compatible-vue';
// hook
import { useDesign } from '@/hooks/core/useDesign';
Expand Down
2 changes: 1 addition & 1 deletion src/components/countdown/src/CodeCountdown.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, ref, unref } from '@/setup/vue';
import { defineComponent, ref, unref } from 'compatible-vue';
import { useDesign } from '@/hooks/core/useDesign';
import { Button } from 'ant-design-vue';
import { useCountdown } from '@/hooks/event/useCountdown';
Expand Down
2 changes: 1 addition & 1 deletion src/components/description/src/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, computed, ref, unref } from '@/setup/vue';
import { defineComponent, computed, ref, unref } from 'compatible-vue';
import { Descriptions } from 'ant-design-vue';
import { CollapseContainer, CollapseContainerOptions } from '@/components/container/index';
import { DescOptions, DescInstance } from './type';
Expand Down
2 changes: 1 addition & 1 deletion src/components/description/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropOptions } from '@/setup/vue';
import { PropOptions } from 'compatible-vue';
import { DescItem } from './type';
// import { CollapseContainerOptions } from '@/components/container/index';

Expand Down
2 changes: 1 addition & 1 deletion src/components/description/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode } from 'vue';
import { VNode } from 'compatible-vue';
import { CollapseContainerOptions } from '@/components/container/index';

export interface DescItem {
Expand Down
2 changes: 1 addition & 1 deletion src/components/description/src/useDescription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, getCurrentInstance, unref } from '@/setup/vue';
import { ref, getCurrentInstance, unref } from 'compatible-vue';
import { isProdMode } from '@/utils/envUtil';

import { DescOptions, DescInstance, UseDescReturnType } from './type';
Expand Down
2 changes: 1 addition & 1 deletion src/components/drawer/src/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="tsx">
import { Drawer, Button } from 'ant-design-vue';
import { defineComponent, ref, computed, watch, unref } from '@/setup/vue';
import { defineComponent, ref, computed, watch, unref } from 'compatible-vue';
// import { BaseTitle } from '@/components/base/index';
import { Icon } from '@/components/icon/index';
import { BaseTitle } from '@/components/base/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/drawer/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropOptions } from '@/setup/vue';
import { PropOptions } from 'compatible-vue';
import { DrawerType } from './types';
// import {DrawerProps} from './types'

Expand Down
2 changes: 1 addition & 1 deletion src/components/drawer/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Drawer } from 'ant-design-vue/types/drawer';
import { Ref } from '@/setup/vue';
import { Ref } from 'compatible-vue';
import { ScrollContainerOptions } from '@/components/container/index';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/drawer/src/useDrawer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UseDrawerReturnType, DrawerInstance, ReturnMethods, DrawerProps } from './types';
import { ref, Ref, getCurrentInstance, onUnmounted, unref } from '@/setup/vue';
import { ref, Ref, getCurrentInstance, onUnmounted, unref } from 'compatible-vue';

import { isProdMode } from '@/utils/envUtil';

Expand Down
2 changes: 1 addition & 1 deletion src/components/dropdown/src/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
import { Dropdown, Menu } from 'ant-design-vue';
import { Icon } from '@/components/icon/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/dropdown/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropOptions } from '@/setup/vue';
import { PropOptions } from 'compatible-vue';
/**
* @description: 基础表格参数配置
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/empty/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, PropOptions } from '@/setup/vue';
import { defineComponent, PropOptions } from 'compatible-vue';
import { Empty } from 'ant-design-vue';

import emptySrc from '@/assets/images/page_null.png';
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/src/BasicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
computed,
unref,
// PropOptions
} from '@/setup/vue';
} from 'compatible-vue';
import { formProps } from './props/form';
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/src/componentMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'vue';
import { Component } from 'compatible-vue';
/**
* 组件列表,在这里注册才可以在表单使用
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/src/renderAction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode } from 'vue';
import { VNode } from 'compatible-vue';
import { Form, Button, Col } from 'ant-design-vue';
import { FormProps, ActionButtonOption } from './types/form';
import { ColEx } from './types/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/src/renderItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode } from 'vue';
import { VNode } from 'compatible-vue';
import { Form, Col } from 'ant-design-vue';

// import { FormModelItem } from './types/formModelItem';
Expand Down
3 changes: 1 addition & 2 deletions src/components/form/src/types/form.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ColEx, ComponentType } from './index';
import { VNode } from 'vue';
import { VNode, Ref } from 'compatible-vue';
import { Button } from 'ant-design-vue';
import { Ref } from '@/setup/vue';
import {
WrappedFormUtils,
FieldDecoratorOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode } from 'vue';
import { VNode } from 'compatible-vue';
import { Col } from 'ant-design-vue';

export interface ColEx extends Col {
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/src/useForm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, getCurrentInstance, Ref, onUnmounted, unref } from '@/setup/vue';
import { ref, getCurrentInstance, Ref, onUnmounted, unref } from 'compatible-vue';
import { isProdMode } from '@/utils/envUtil';
// import { isFunction } from '@/utils/is/index';

Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import Vue, { VueConstructor } from 'vue';
// import Vue, { VueConstructor } from 'compatible-vue';
import { getAsyncComponent } from '@/common/factory/getAsyncComponent';

// export { default as Icon } from './src/index.vue';
Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/src/SvgIcon.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
export default defineComponent({
name: 'SvgIcon',
Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Icon } from 'ant-design-vue';
import { SvgIcon } from '@/components/icon/index';
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
export default defineComponent({
name: 'Icon',
Expand Down
2 changes: 1 addition & 1 deletion src/components/loading/src/BasicLoading.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="tsx">
// components
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
// hook
import { useDesign } from '@/hooks/core/useDesign';
Expand Down
2 changes: 1 addition & 1 deletion src/components/loading/src/FullLoading.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="tsx">
// components
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
import BasicLoading from './BasicLoading.vue';
import { useDesign } from '@/hooks/core/useDesign';
Expand Down
10 changes: 9 additions & 1 deletion src/components/menu/src/BasicMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
import { Icon } from '@/components/icon/index';
import SearchInput from './SearchInput.vue';
import { ScrollContainer, TypeEnum } from '@/components/container/index';
import { defineComponent, reactive, computed, watch, Ref, unref, PropOptions } from '@/setup/vue';
import {
defineComponent,
reactive,
computed,
watch,
Ref,
unref,
PropOptions,
} from 'compatible-vue';
// import projectSetting from '@/settings/projectSetting';
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/src/SearchInput.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="tsx">
import { Input } from 'ant-design-vue';
// import { Icon } from '@/components/icon/index';
import { defineComponent, computed, unref } from '@/setup/vue';
import { defineComponent, computed, unref } from 'compatible-vue';
// import { unwrap } from '@/utils/composition/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComputedRef } from '@/setup/vue';
import { ComputedRef } from 'compatible-vue';

import { MenuModeEnum, MenuThemeEnum, MenuTypeEnum } from '@/enums/menuEnum';
// import { BuildMenuModuleResult } from '@/router/menus/_type';
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/src/useMenu.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// type
import { Ref, computed, unref, watch } from '@/setup/vue';
import { Ref, computed, unref, watch } from 'compatible-vue';
import { MenuData, MenuProps, MenuState, MenuTreeItem } from './type';
import { MenuTypeEnum, MenuModeEnum } from '@/enums/menuEnum';
import { Route } from 'vue-router/types/index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/src/BasicModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Button } from 'ant-design-vue';
import ModalWrapper from './ModalWrapper.vue';
import { BaseTitle } from '@/components/base/index';
import { defineComponent, computed, ref, watch, unref } from '@/setup/vue';
import { defineComponent, computed, ref, watch, unref } from 'compatible-vue';
import { ModalProps, ModalInstance } from './types';
import { basicProps } from './props';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/src/Modal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="tsx">
import { Modal } from 'ant-design-vue';
import { defineComponent, watch } from '@/setup/vue';
import { defineComponent, watch } from 'compatible-vue';
import { ModalProps } from './types';
import { modalProps } from './props';
export default defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/src/ModalWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
unref,
// watch,
PropOptions,
} from '@/setup/vue';
} from 'compatible-vue';
import { Spin } from 'ant-design-vue';
import { ScrollContainer, TypeEnum } from '@/components/container/index';
Expand Down
4 changes: 2 additions & 2 deletions src/components/modal/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PropOptions } from '@/setup/vue';
// import {PropType} from 'vue'
import { PropOptions } from 'compatible-vue';
// import {PropType} from 'compatible-vue'
export const modalProps = {
// 是否开启拖拽事件
draggable: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ref } from '@/setup/vue';
import { Ref } from 'compatible-vue';
import { Modal } from 'ant-design-vue/types/modal';
/**
* @description: 弹窗对外暴露的方法
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/src/useModal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UseModalReturnType, ModalInstance, ModalProps, ReturnMethods } from './types';
import { ref, Ref, getCurrentInstance, onUnmounted, unref } from '@/setup/vue';
import { ref, Ref, getCurrentInstance, onUnmounted, unref } from 'compatible-vue';

import { isProdMode } from '@/utils/envUtil';

Expand Down
2 changes: 1 addition & 1 deletion src/components/pagination/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Pagination } from 'ant-design-vue';
import { Icon } from '@/components/icon/index';
import { defineComponent, ref, watch, unref } from '@/setup/vue';
import { defineComponent, ref, watch, unref } from 'compatible-vue';
//
import { useDesign } from '@/hooks/core/useDesign';
Expand Down
2 changes: 1 addition & 1 deletion src/components/pagination/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode } from 'vue';
import { VNode } from 'compatible-vue';
export interface PaginationProps {
/**
* total number of data items
Expand Down
2 changes: 1 addition & 1 deletion src/components/scrollbar/src/bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { renderThumbStyle, BAR_MAP, on, off } from './util';
import { defineComponent } from '@/setup/vue';
import { defineComponent } from 'compatible-vue';
/* istanbul ignore next */
export default defineComponent({
name: 'Bar',
Expand Down
2 changes: 1 addition & 1 deletion src/components/scrollbar/src/scrollbar-width.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue from 'vue';
import { Vue } from 'compatible-vue';

let scrollBarWidth;

Expand Down
2 changes: 1 addition & 1 deletion src/components/transition/src/Collapse.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="tsx">
// collapse 展开折叠
import CollapseTransitionComponent from './collapse-transition';
import { defineComponent } from '@/setup/vue';
import { defineComponent } from 'compatible-vue';
export default defineComponent({
name: 'CollapseTransition',
Expand Down
2 changes: 1 addition & 1 deletion src/components/transition/src/collapse-transition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addClass, removeClass } from '@/utils/domUtils';
import { VueConstructor } from 'vue';
import { VueConstructor } from 'compatible-vue';

const ZERO = '0px';
class Transition {
Expand Down
2 changes: 1 addition & 1 deletion src/components/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue, { VueConstructor } from 'vue';
import { VueConstructor } from 'compatible-vue';

export function getAsyncComponent(importComp: () => Promise<typeof import('*.vue')>) {
return (importComp as unknown) as VueConstructor<Vue>;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue, { VNode } from 'vue';
import { Ref } from '@/setup/vue';
import { VNode, Vue } from 'compatible-vue';
import { Ref } from 'compatible-vue';
import { ModalOptions } from 'ant-design-vue/types/modal';

export type Fn<T> = () => T;
Expand Down
Loading

0 comments on commit 24cea92

Please sign in to comment.