Skip to content

Commit

Permalink
perf: remove unless code
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Feb 9, 2021
1 parent 2b466ea commit 2365754
Show file tree
Hide file tree
Showing 31 changed files with 107 additions and 169 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
"clean:lib": "npx rimraf node_modules",
"typecheck": "vuedx-typecheck .",
"lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" ",
"lint:eslint:fix": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:ls-lint": "ls-lint",
Expand Down
3 changes: 0 additions & 3 deletions src/components/Application/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
import AppLogo from './src/AppLogo.vue';
import AppProvider from './src/AppProvider.vue';
import { withInstall } from '../util';

export const AppLocalePicker = createAsyncComponent(() => import('./src/AppLocalePicker.vue'));
export const AppSearch = createAsyncComponent(() => import('./src/search/AppSearch.vue'), {
Expand All @@ -10,5 +9,3 @@ export const AppSearch = createAsyncComponent(() => import('./src/search/AppSear

export { useAppProviderContext } from './src/useAppContext';
export { AppLogo, AppProvider };

withInstall(AppLogo, AppProvider);
13 changes: 6 additions & 7 deletions src/components/Application/src/AppLocalePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
</Dropdown>
</template>
<script lang="ts">
import { defineComponent, ref, watchEffect, unref, computed } from 'vue';
import type { LocaleType } from '/@/locales/types';
import type { DropMenu } from '/@/components/Dropdown';

import { Dropdown, DropMenu } from '/@/components/Dropdown';
import { defineComponent, ref, watchEffect, unref, computed } from 'vue';
import { Dropdown } from '/@/components/Dropdown';
import Icon from '/@/components/Icon';

import { useLocale } from '/@/locales/useLocale';
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';

import { LocaleType } from '/@/locales/types';

import { propTypes } from '/@/utils/propTypes';
import { useDesign } from '/@/hooks/web/useDesign';
import { propTypes } from '/@/utils/propTypes';

import Icon from '/@/components/Icon';
export default defineComponent({
name: 'AppLocalPicker',
components: { Dropdown, Icon },
Expand Down
4 changes: 1 addition & 3 deletions src/components/Application/src/AppLogo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import { useGlobSetting } from '/@/hooks/setting';
import { useGo } from '/@/hooks/web/usePage';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { useDesign } from '/@/hooks/web/useDesign';

import { PageEnum } from '/@/enums/pageEnum';

import { propTypes } from '/@/utils/propTypes';

import { useDesign } from '/@/hooks/web/useDesign';

export default defineComponent({
name: 'AppLogo',
props: {
Expand Down
7 changes: 2 additions & 5 deletions src/components/Application/src/AppProvider.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<template>
<slot></slot>
</template>
<script lang="ts">
import type { PropType } from 'vue';
import { defineComponent, toRefs, ref } from 'vue';
Expand All @@ -19,7 +16,7 @@
default: designSetting.prefixCls,
},
},
setup(props) {
setup(props, { slots }) {
const isMobileRef = ref(false);
createBreakpointListen(({ screenMap, sizeEnum, width }) => {
Expand All @@ -31,7 +28,7 @@
const { prefixCls } = toRefs(props);
createAppProviderContext({ prefixCls, isMobile: isMobileRef });
return {};
return () => slots.default?.();
},
});
</script>
49 changes: 24 additions & 25 deletions src/components/Application/src/search/AppSearch.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
<template>
<div :class="prefixCls" v-if="getShowSearch" @click.stop="handleSearch">
<Tooltip>
<template #title>
{{ t('common.searchText') }}
</template>
<SearchOutlined />
</Tooltip>

<AppSearchModal @close="handleClose" :visible="showModal" />
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
<script lang="tsx">
import { defineComponent, ref, unref } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { SearchOutlined } from '@ant-design/icons-vue';
import AppSearchModal from './AppSearchModal.vue';
import { useDesign } from '/@/hooks/web/useDesign';
import AppSearchModal from './AppSearchModal.vue';
import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
import { SearchOutlined } from '@ant-design/icons-vue';
import { useI18n } from '/@/hooks/web/useI18n';
export default defineComponent({
Expand All @@ -32,15 +20,26 @@
function handleSearch() {
showModal.value = true;
}
return {
t,
prefixCls,
showModal,
getShowSearch,
handleClose: () => {
showModal.value = false;
},
handleSearch,
function handleClose() {
showModal.value = false;
}
return () => {
if (!getShowSearch.value) {
return null;
}
return (
<div class={prefixCls} onClick={handleSearch}>
<Tooltip>
{{
title: () => t('common.searchText'),
default: () => <SearchOutlined />,
}}
</Tooltip>
<AppSearchModal onClose={handleClose} visible={unref(showModal)} />
</div>
);
};
},
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/Application/src/search/AppSearchFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
<span>{{ t('common.closeText') }}</span>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import Icon from '/@/components/Icon';
import { useDesign } from '/@/hooks/web/useDesign';
import { useI18n } from '/@/hooks/web/useI18n';
import Icon from '/@/components/Icon';
export default defineComponent({
name: 'AppSearchFooter',
components: { Icon },
Expand Down
21 changes: 12 additions & 9 deletions src/components/Application/src/search/AppSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@
</template>
<script lang="ts">
import { defineComponent, computed, unref, ref } from 'vue';
import { SearchOutlined } from '@ant-design/icons-vue';
import { Input } from 'ant-design-vue';
import AppSearchFooter from './AppSearchFooter.vue';
import Icon from '/@/components/Icon';
import clickOutside from '/@/directives/clickOutside';
import { useDesign } from '/@/hooks/web/useDesign';
import { useRefs } from '/@/hooks/core/useRefs';
import { useMenuSearch } from './useMenuSearch';
import { SearchOutlined } from '@ant-design/icons-vue';
import AppSearchFooter from './AppSearchFooter.vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { useAppInject } from '/@/hooks/web/useAppInject';
import clickOutside from '/@/directives/clickOutside';
import { Input } from 'ant-design-vue';
import Icon from '/@/components/Icon';
export default defineComponent({
name: 'AppSearchModal',
Expand Down Expand Up @@ -108,6 +109,11 @@
];
});
function handleClose() {
searchResult.value = [];
emit('close');
}
return {
t,
prefixCls,
Expand All @@ -120,10 +126,7 @@
setRefs,
scrollWrap,
handleMouseenter,
handleClose: () => {
searchResult.value = [];
emit('close');
},
handleClose,
};
},
});
Expand Down
10 changes: 7 additions & 3 deletions src/components/Application/src/search/useMenuSearch.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { cloneDeep } from 'lodash-es';
import type { Menu } from '/@/router/types';

import { ref, onBeforeMount, unref, Ref, nextTick } from 'vue';
import { useI18n } from '/@/hooks/web/useI18n';

import { getMenus } from '/@/router/menus';
import type { Menu } from '/@/router/types';

import { cloneDeep } from 'lodash-es';
import { filter, forEach } from '/@/utils/helper/treeHelper';

import { useDebounce } from '/@/hooks/core/useDebounce';
import { useGo } from '/@/hooks/web/usePage';
import { useScrollTo } from '/@/hooks/event/useScrollTo';
import { useKeyPress } from '/@/hooks/event/useKeyPress';
import { useI18n } from '/@/hooks/web/useI18n';

export interface SearchResult {
name: string;
Expand Down
4 changes: 0 additions & 4 deletions src/components/Authority/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { withInstall } from '../util';

import Authority from './src/index.vue';

withInstall(Authority);

export { Authority };
4 changes: 3 additions & 1 deletion src/components/Basic/src/BasicArrow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
<script lang="ts">
import { defineComponent, computed } from 'vue';
import { RightOutlined } from '@ant-design/icons-vue';
import { propTypes } from '/@/utils/propTypes';

import { useDesign } from '/@/hooks/web/useDesign';

import { propTypes } from '/@/utils/propTypes';

export default defineComponent({
name: 'BasicArrow',
components: { RightOutlined },
Expand Down
60 changes: 27 additions & 33 deletions src/components/Basic/src/BasicHelp.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts">
<script lang="tsx">
import type { CSSProperties, PropType } from 'vue';
import { defineComponent, computed, unref, h } from 'vue';
Expand All @@ -9,7 +9,9 @@
import { isString, isArray } from '/@/utils/is';
import { getSlot } from '/@/utils/helper/tsxHelper';
import { propTypes } from '/@/utils/propTypes';
import { useDesign } from '/@/hooks/web/useDesign';
export default defineComponent({
name: 'BasicHelp',
components: { Tooltip },
Expand Down Expand Up @@ -40,15 +42,15 @@
setup(props, { slots }) {
const { prefixCls } = useDesign('basic-help');
const getOverlayStyleRef = computed(
const getOverlayStyle = computed(
(): CSSProperties => {
return {
maxWidth: props.maxWidth,
};
}
);
const getWrapStyleRef = computed(
const getWrapStyle = computed(
(): CSSProperties => {
return {
color: props.color,
Expand All @@ -65,47 +67,39 @@
const list = props.text;
if (isString(list)) {
return h('p', list);
return <p>{list}</p>;
}
if (isArray(list)) {
return list.map((item, index) => {
return h('p', { key: item }, [props.showIndex ? `${index + 1}. ` : '', item]);
return (
<p key={item}>
<>
{props.showIndex ? `${index + 1}. ` : ''}
{item}
</>
</p>
);
});
}
return null;
};
return () => {
return h(
// @ts-ignores
Tooltip,
{
title: h(
'div',
{
style: unref(getWrapStyleRef),
},
[renderTitle()]
),
overlayClassName: `${prefixCls}__wrap`,
autoAdjustOverflow: true,
overlayStyle: unref(getOverlayStyleRef),
placement: props.placement,
getPopupContainer: () => getPopupContainer(),
},
{
default: () =>
h(
'span',
{
class: prefixCls,
style: unref(getMainStyleRef),
},
getSlot(slots) || h(InfoCircleOutlined)
),
}
return (
<Tooltip
title={<div style={unref(getWrapStyle)}>{renderTitle()}</div>}
overlayClassName={`${prefixCls}__wrap`}
autoAdjustOverflow={true}
overlayStyle={unref(getOverlayStyle)}
placement={props.placement as 'left'}
getPopupContainer={() => getPopupContainer()}
>
<span class={prefixCls} style={unref(getMainStyleRef)}>
{getSlot(slots) || <InfoCircleOutlined />}
</span>
</Tooltip>
);
};
},
Expand Down
5 changes: 3 additions & 2 deletions src/components/Basic/src/BasicTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import type { PropType } from 'vue';
import { defineComponent } from 'vue';
import BasicHelp from './BasicHelp.vue';
import { propTypes } from '/@/utils/propTypes';
import { useDesign } from '/@/hooks/web/useDesign';
import { propTypes } from '/@/utils/propTypes';
export default defineComponent({
name: 'BasicTitle',
components: { BasicHelp },
Expand Down
2 changes: 0 additions & 2 deletions src/components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Button from './src/BasicButton.vue';
import PopConfirmButton from './src/PopConfirmButton.vue';
import { withInstall } from '../util';

withInstall(Button, PopConfirmButton);
export { Button, PopConfirmButton };
1 change: 1 addition & 0 deletions src/components/Button/src/BasicButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { Button } from 'ant-design-vue';
import Icon from '/@/components/Icon';
import { propTypes } from '/@/utils/propTypes';
export default defineComponent({
Expand Down
Loading

0 comments on commit 2365754

Please sign in to comment.