Commit 2ee01fa6ea3200ec964d4e1b4765e48dfa7aeb3a
1 parent
b6e5c3f6
perf(import): perf components import
Showing
38 changed files
with
341 additions
and
430 deletions
src/components/Application/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
3 | import AppLogo from './src/AppLogo.vue'; | 2 | import AppLogo from './src/AppLogo.vue'; |
3 | +import AppProvider from './src/AppProvider.vue'; | ||
4 | +import { withInstall } from '../util'; | ||
4 | 5 | ||
5 | export const AppLocalePicker = createAsyncComponent(() => import('./src/AppLocalePicker.vue')); | 6 | export const AppLocalePicker = createAsyncComponent(() => import('./src/AppLocalePicker.vue')); |
6 | -export const AppProvider = createAsyncComponent(() => import('./src/AppProvider.vue')); | ||
7 | export const AppSearch = createAsyncComponent(() => import('./src/search/AppSearch.vue'), { | 7 | export const AppSearch = createAsyncComponent(() => import('./src/search/AppSearch.vue'), { |
8 | loading: true, | 8 | loading: true, |
9 | }); | 9 | }); |
10 | -// export const AppLogo = createAsyncComponent(() => import('./src/AppLogo.vue')); | ||
11 | - | ||
12 | -withInstall(AppLocalePicker, AppLogo, AppProvider, AppSearch); | ||
13 | 10 | ||
14 | export { useAppProviderContext } from './src/useAppContext'; | 11 | export { useAppProviderContext } from './src/useAppContext'; |
15 | -export { AppLogo }; | 12 | +export { AppLogo, AppProvider }; |
13 | + | ||
14 | +withInstall(AppLogo, AppProvider); |
src/components/Authority/index.ts
1 | import { withInstall } from '../util'; | 1 | import { withInstall } from '../util'; |
2 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
3 | 2 | ||
4 | -export const Authority = createAsyncComponent(() => import('./src/index.vue')); | 3 | +import Authority from './src/index.vue'; |
5 | 4 | ||
6 | withInstall(Authority); | 5 | withInstall(Authority); |
6 | + | ||
7 | +export { Authority }; |
src/components/Basic/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
3 | 2 | ||
4 | export const BasicArrow = createAsyncComponent(() => import('./src/BasicArrow.vue')); | 3 | export const BasicArrow = createAsyncComponent(() => import('./src/BasicArrow.vue')); |
5 | export const BasicHelp = createAsyncComponent(() => import('./src/BasicHelp.vue')); | 4 | export const BasicHelp = createAsyncComponent(() => import('./src/BasicHelp.vue')); |
6 | export const BasicTitle = createAsyncComponent(() => import('./src/BasicTitle.vue')); | 5 | export const BasicTitle = createAsyncComponent(() => import('./src/BasicTitle.vue')); |
7 | - | ||
8 | -withInstall(BasicArrow, BasicHelp, BasicTitle); |
src/components/Button/index.ts
@@ -2,5 +2,4 @@ import Button from './src/BasicButton.vue'; | @@ -2,5 +2,4 @@ import Button from './src/BasicButton.vue'; | ||
2 | import { withInstall } from '../util'; | 2 | import { withInstall } from '../util'; |
3 | 3 | ||
4 | withInstall(Button); | 4 | withInstall(Button); |
5 | - | ||
6 | export { Button }; | 5 | export { Button }; |
src/components/ClickOutSide/index.ts
1 | import { withInstall } from '../util'; | 1 | import { withInstall } from '../util'; |
2 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
3 | 2 | ||
4 | -export const ClickOutSide = createAsyncComponent(() => import('./src/index.vue')); | 3 | +import ClickOutSide from './src/index.vue'; |
5 | 4 | ||
6 | withInstall(ClickOutSide); | 5 | withInstall(ClickOutSide); |
6 | + | ||
7 | +export { ClickOutSide }; |
src/components/Container/index.ts
1 | import { withInstall } from '../util'; | 1 | import { withInstall } from '../util'; |
2 | import CollapseContainer from './src/collapse/CollapseContainer.vue'; | 2 | import CollapseContainer from './src/collapse/CollapseContainer.vue'; |
3 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
4 | -export const ScrollContainer = createAsyncComponent(() => import('./src/ScrollContainer.vue')); | ||
5 | - | ||
6 | -// export const CollapseContainer = createAsyncComponent( | ||
7 | -// () => import('./src/collapse/CollapseContainer.vue') | ||
8 | -// ); | ||
9 | -export const LazyContainer = createAsyncComponent(() => import('./src/LazyContainer.vue')); | 3 | +import ScrollContainer from './src/ScrollContainer.vue'; |
4 | +import LazyContainer from './src/LazyContainer.vue'; | ||
10 | 5 | ||
11 | withInstall(ScrollContainer, CollapseContainer, LazyContainer); | 6 | withInstall(ScrollContainer, CollapseContainer, LazyContainer); |
12 | - | ||
13 | -export { CollapseContainer }; | 7 | +export { CollapseContainer, ScrollContainer, LazyContainer }; |
14 | export * from './src/types'; | 8 | export * from './src/types'; |
src/components/CountTo/index.ts
1 | // Transform vue-count-to to support vue3 version | 1 | // Transform vue-count-to to support vue3 version |
2 | 2 | ||
3 | -import { withInstall } from '../util'; | ||
4 | - | ||
5 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
6 | export const CountTo = createAsyncComponent(() => import('./src/index.vue')); | 4 | export const CountTo = createAsyncComponent(() => import('./src/index.vue')); |
7 | - | ||
8 | -withInstall(CountTo); |
src/components/Description/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | export const Description = createAsyncComponent(() => import('./src/index')); | 2 | export const Description = createAsyncComponent(() => import('./src/index')); |
5 | 3 | ||
6 | -withInstall(Description); | ||
7 | - | ||
8 | export * from './src/types'; | 4 | export * from './src/types'; |
9 | export { useDescription } from './src/useDescription'; | 5 | export { useDescription } from './src/useDescription'; |
src/components/Drawer/index.ts
1 | import { withInstall } from '../util'; | 1 | import { withInstall } from '../util'; |
2 | 2 | ||
3 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
4 | -export const BasicDrawer = createAsyncComponent(() => import('./src/BasicDrawer')); | 3 | +import BasicDrawer from './src/BasicDrawer'; |
5 | 4 | ||
6 | -withInstall(BasicDrawer); | 5 | +export { BasicDrawer }; |
7 | export * from './src/types'; | 6 | export * from './src/types'; |
8 | export { useDrawer, useDrawerInner } from './src/useDrawer'; | 7 | export { useDrawer, useDrawerInner } from './src/useDrawer'; |
8 | + | ||
9 | +withInstall(BasicDrawer); |
src/components/Dropdown/index.ts
src/components/Dropdown/src/Dropdown.tsx deleted
100644 โ 0
1 | -import type { Trigger } from './types'; | ||
2 | - | ||
3 | -import { defineComponent, computed, unref } from 'vue'; | ||
4 | -import { Dropdown, Menu } from 'ant-design-vue'; | ||
5 | -import Icon from '/@/components/Icon/index'; | ||
6 | - | ||
7 | -import { basicDropdownProps } from './props'; | ||
8 | -import { getSlot } from '/@/utils/helper/tsxHelper'; | ||
9 | - | ||
10 | -export default defineComponent({ | ||
11 | - name: 'Dropdown', | ||
12 | - props: basicDropdownProps, | ||
13 | - emits: ['menuEvent'], | ||
14 | - setup(props, { slots, emit, attrs }) { | ||
15 | - const getMenuList = computed(() => props.dropMenuList); | ||
16 | - | ||
17 | - function handleClickMenu({ key }: any) { | ||
18 | - const menu = unref(getMenuList).find((item) => `${item.event}` === `${key}`); | ||
19 | - emit('menuEvent', menu); | ||
20 | - } | ||
21 | - | ||
22 | - function renderMenus() { | ||
23 | - return ( | ||
24 | - <Menu onClick={handleClickMenu} selectedKeys={props.selectedKeys}> | ||
25 | - {() => ( | ||
26 | - <> | ||
27 | - {unref(getMenuList).map((item) => { | ||
28 | - const { disabled, icon, text, divider, event } = item; | ||
29 | - return [ | ||
30 | - <Menu.Item key={`${event}`} disabled={disabled}> | ||
31 | - {() => ( | ||
32 | - <> | ||
33 | - {icon && <Icon icon={icon} />} | ||
34 | - <span class="ml-1">{text}</span> | ||
35 | - </> | ||
36 | - )} | ||
37 | - </Menu.Item>, | ||
38 | - // @ts-ignore | ||
39 | - divider && <Menu.Divider key={`d-${event}`} />, | ||
40 | - ]; | ||
41 | - })} | ||
42 | - </> | ||
43 | - )} | ||
44 | - </Menu> | ||
45 | - ); | ||
46 | - } | ||
47 | - | ||
48 | - return () => ( | ||
49 | - <Dropdown trigger={props.trigger as Trigger[]} {...attrs}> | ||
50 | - {{ | ||
51 | - default: () => <span>{getSlot(slots)}</span>, | ||
52 | - overlay: () => renderMenus(), | ||
53 | - }} | ||
54 | - </Dropdown> | ||
55 | - ); | ||
56 | - }, | ||
57 | -}); |
src/components/Dropdown/src/Dropdown.vue
0 โ 100644
1 | +<template> | ||
2 | + <a-dropdown :trigger="trigger" v-bind="$attrs"> | ||
3 | + <span> | ||
4 | + <slot /> | ||
5 | + </span> | ||
6 | + <template #overlay> | ||
7 | + <a-menu :selectedKeys="selectedKeys"> | ||
8 | + <template v-for="item in getMenuList" :key="`${item.event}`"> | ||
9 | + <a-menu-item @click="handleClickMenu({ key: item.event })" :disabled="item.disabled"> | ||
10 | + <Icon :icon="item.icon" v-if="item.icon" /> | ||
11 | + <span class="ml-1">{{ item.text }}</span> | ||
12 | + </a-menu-item> | ||
13 | + <a-menu-divider v-if="item.divider" :key="`d-${item.event}`" /> | ||
14 | + </template> | ||
15 | + </a-menu> | ||
16 | + </template> | ||
17 | + </a-dropdown> | ||
18 | +</template> | ||
19 | + | ||
20 | +<script lang="ts"> | ||
21 | + import type { PropType } from 'vue'; | ||
22 | + import type { DropMenu } from './types'; | ||
23 | + | ||
24 | + import { defineComponent, computed, unref } from 'vue'; | ||
25 | + import { Dropdown, Menu } from 'ant-design-vue'; | ||
26 | + import Icon from '/@/components/Icon/index'; | ||
27 | + | ||
28 | + export default defineComponent({ | ||
29 | + name: 'BasicDropdown', | ||
30 | + components: { | ||
31 | + [Dropdown.name]: Dropdown, | ||
32 | + [Menu.name]: Menu, | ||
33 | + [Menu.Item.name]: Menu.Item, | ||
34 | + [Menu.Divider.name]: Menu.Divider, | ||
35 | + Icon, | ||
36 | + }, | ||
37 | + props: { | ||
38 | + /** | ||
39 | + * the trigger mode which executes the drop-down action | ||
40 | + * @default ['hover'] | ||
41 | + * @type string[] | ||
42 | + */ | ||
43 | + trigger: { | ||
44 | + type: [Array] as PropType<string[]>, | ||
45 | + default: () => { | ||
46 | + return ['contextmenu']; | ||
47 | + }, | ||
48 | + }, | ||
49 | + dropMenuList: { | ||
50 | + type: Array as PropType<DropMenu[]>, | ||
51 | + default: () => [], | ||
52 | + }, | ||
53 | + selectedKeys: { | ||
54 | + type: Array as PropType<string[]>, | ||
55 | + default: () => [], | ||
56 | + }, | ||
57 | + }, | ||
58 | + emits: ['menuEvent'], | ||
59 | + setup(props, { emit }) { | ||
60 | + const getMenuList = computed(() => props.dropMenuList); | ||
61 | + | ||
62 | + function handleClickMenu({ key }: { key: string }) { | ||
63 | + const menu = unref(getMenuList).find((item) => `${item.event}` === `${key}`); | ||
64 | + emit('menuEvent', menu); | ||
65 | + } | ||
66 | + | ||
67 | + return { handleClickMenu, getMenuList }; | ||
68 | + }, | ||
69 | + }); | ||
70 | +</script> |
src/components/Dropdown/src/props.ts deleted
100644 โ 0
1 | -import type { PropType } from 'vue'; | ||
2 | -import type { DropMenu } from './types'; | ||
3 | - | ||
4 | -export const dropdownProps = { | ||
5 | - /** | ||
6 | - * the trigger mode which executes the drop-down action | ||
7 | - * @default ['hover'] | ||
8 | - * @type string[] | ||
9 | - */ | ||
10 | - trigger: { | ||
11 | - type: [Array] as PropType<string[]>, | ||
12 | - default: () => { | ||
13 | - return ['contextmenu']; | ||
14 | - }, | ||
15 | - }, | ||
16 | -}; | ||
17 | -export const basicDropdownProps = Object.assign({}, dropdownProps, { | ||
18 | - dropMenuList: { | ||
19 | - type: Array as PropType<DropMenu[]>, | ||
20 | - default: () => [], | ||
21 | - }, | ||
22 | - selectedKeys: { | ||
23 | - type: Array as PropType<string[]>, | ||
24 | - default: () => [], | ||
25 | - }, | ||
26 | -}); |
src/components/Dropdown/src/types.ts
src/components/Excel/index.ts
1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
2 | 2 | ||
3 | -import { withInstall } from '../util'; | ||
4 | - | ||
5 | export const ImpExcel = createAsyncComponent(() => import('./src/ImportExcel.vue')); | 3 | export const ImpExcel = createAsyncComponent(() => import('./src/ImportExcel.vue')); |
6 | export const ExpExcelModel = createAsyncComponent(() => import('./src/ExportExcelModel.vue')); | 4 | export const ExpExcelModel = createAsyncComponent(() => import('./src/ExportExcelModel.vue')); |
7 | 5 | ||
8 | -withInstall(ImpExcel, ExpExcelModel); | ||
9 | - | ||
10 | export * from './src/types'; | 6 | export * from './src/types'; |
11 | 7 | ||
12 | export { jsonToSheetXlsx, aoaToSheetXlsx } from './src/Export2Excel'; | 8 | export { jsonToSheetXlsx, aoaToSheetXlsx } from './src/Export2Excel'; |
src/components/Icon/index.less deleted
100644 โ 0
src/components/Icon/index.ts
0 โ 100644
src/components/Icon/index.tsx renamed to src/components/Icon/src/index.vue
1 | -import './index.less'; | ||
2 | - | ||
3 | -import type { PropType } from 'vue'; | ||
4 | -import { | ||
5 | - defineComponent, | ||
6 | - ref, | ||
7 | - watch, | ||
8 | - onMounted, | ||
9 | - nextTick, | ||
10 | - unref, | ||
11 | - computed, | ||
12 | - CSSProperties, | ||
13 | -} from 'vue'; | ||
14 | -import Iconify from '@purge-icons/generated'; | ||
15 | -import { isString } from '/@/utils/is'; | ||
16 | -import { propTypes } from '/@/utils/propTypes'; | ||
17 | -export default defineComponent({ | ||
18 | - name: 'GIcon', | ||
19 | - props: { | ||
20 | - // icon name | ||
21 | - icon: propTypes.string, | ||
22 | - // icon color | ||
23 | - color: propTypes.string, | ||
24 | - // icon size | ||
25 | - size: { | ||
26 | - type: [String, Number] as PropType<string | number>, | ||
27 | - default: 16, | 1 | +<template> |
2 | + <span ref="elRef" :class="[$attrs.class, 'app-iconify anticon']" :style="getWrapStyle" /> | ||
3 | +</template> | ||
4 | +<script lang="ts"> | ||
5 | + import type { PropType } from 'vue'; | ||
6 | + import { | ||
7 | + defineComponent, | ||
8 | + ref, | ||
9 | + watch, | ||
10 | + onMounted, | ||
11 | + nextTick, | ||
12 | + unref, | ||
13 | + computed, | ||
14 | + CSSProperties, | ||
15 | + } from 'vue'; | ||
16 | + import Iconify from '@purge-icons/generated'; | ||
17 | + import { isString } from '/@/utils/is'; | ||
18 | + import { propTypes } from '/@/utils/propTypes'; | ||
19 | + export default defineComponent({ | ||
20 | + name: 'GIcon', | ||
21 | + props: { | ||
22 | + // icon name | ||
23 | + icon: propTypes.string, | ||
24 | + // icon color | ||
25 | + color: propTypes.string, | ||
26 | + // icon size | ||
27 | + size: { | ||
28 | + type: [String, Number] as PropType<string | number>, | ||
29 | + default: 16, | ||
30 | + }, | ||
31 | + prefix: propTypes.string.def(''), | ||
28 | }, | 32 | }, |
29 | - prefix: propTypes.string.def(''), | ||
30 | - }, | ||
31 | - setup(props, { attrs }) { | ||
32 | - const elRef = ref<ElRef>(null); | 33 | + setup(props) { |
34 | + const elRef = ref<ElRef>(null); | ||
33 | 35 | ||
34 | - const getIconRef = computed(() => { | ||
35 | - const { icon, prefix } = props; | ||
36 | - return `${prefix ? prefix + ':' : ''}${icon}`; | ||
37 | - }); | 36 | + const getIconRef = computed(() => { |
37 | + const { icon, prefix } = props; | ||
38 | + return `${prefix ? prefix + ':' : ''}${icon}`; | ||
39 | + }); | ||
38 | 40 | ||
39 | - const update = async () => { | ||
40 | - const el = unref(elRef); | ||
41 | - if (el) { | ||
42 | - await nextTick(); | ||
43 | - const icon = unref(getIconRef); | 41 | + const update = async () => { |
42 | + const el = unref(elRef); | ||
43 | + if (el) { | ||
44 | + await nextTick(); | ||
45 | + const icon = unref(getIconRef); | ||
44 | 46 | ||
45 | - const svg = Iconify.renderSVG(icon, {}); | 47 | + const svg = Iconify.renderSVG(icon, {}); |
46 | 48 | ||
47 | - if (svg) { | ||
48 | - el.textContent = ''; | ||
49 | - el.appendChild(svg); | ||
50 | - } else { | ||
51 | - const span = document.createElement('span'); | ||
52 | - span.className = 'iconify'; | ||
53 | - span.dataset.icon = icon; | ||
54 | - el.textContent = ''; | ||
55 | - el.appendChild(span); | 49 | + if (svg) { |
50 | + el.textContent = ''; | ||
51 | + el.appendChild(svg); | ||
52 | + } else { | ||
53 | + const span = document.createElement('span'); | ||
54 | + span.className = 'iconify'; | ||
55 | + span.dataset.icon = icon; | ||
56 | + el.textContent = ''; | ||
57 | + el.appendChild(span); | ||
58 | + } | ||
56 | } | 59 | } |
57 | - } | ||
58 | - }; | 60 | + }; |
59 | 61 | ||
60 | - const wrapStyleRef = computed( | ||
61 | - (): CSSProperties => { | ||
62 | - const { size, color } = props; | ||
63 | - let fs = size; | ||
64 | - if (isString(size)) { | ||
65 | - fs = parseInt(size, 10); | 62 | + const getWrapStyle = computed( |
63 | + (): CSSProperties => { | ||
64 | + const { size, color } = props; | ||
65 | + let fs = size; | ||
66 | + if (isString(size)) { | ||
67 | + fs = parseInt(size, 10); | ||
68 | + } | ||
69 | + return { | ||
70 | + fontSize: `${fs}px`, | ||
71 | + color, | ||
72 | + display: 'inline-flex', | ||
73 | + }; | ||
66 | } | 74 | } |
67 | - return { | ||
68 | - fontSize: `${fs}px`, | ||
69 | - color, | ||
70 | - display: 'inline-flex', | ||
71 | - }; | ||
72 | - } | ||
73 | - ); | 75 | + ); |
76 | + | ||
77 | + watch(() => props.icon, update, { flush: 'post' }); | ||
74 | 78 | ||
75 | - watch(() => props.icon, update, { flush: 'post' }); | 79 | + onMounted(update); |
80 | + | ||
81 | + return { elRef, getWrapStyle }; | ||
82 | + }, | ||
83 | + }); | ||
84 | +</script> | ||
85 | +<style lang="less"> | ||
86 | + @import (reference) '../../../design/index.less'; | ||
76 | 87 | ||
77 | - onMounted(update); | 88 | + .app-iconify { |
89 | + display: inline-block; | ||
90 | + vertical-align: middle; | ||
91 | + } | ||
78 | 92 | ||
79 | - return () => ( | ||
80 | - <span ref={elRef} class={[attrs.class, 'app-iconify anticon']} style={unref(wrapStyleRef)} /> | ||
81 | - ); | ||
82 | - }, | ||
83 | -}); | 93 | + span.iconify { |
94 | + display: block; | ||
95 | + min-width: 1em; | ||
96 | + min-height: 1em; | ||
97 | + background: @iconify-bg-color; | ||
98 | + border-radius: 100%; | ||
99 | + } | ||
100 | +</style> |
src/components/Loading/index.ts
1 | -import './src/indicator'; | ||
2 | -import { withInstall } from '../util'; | ||
3 | - | ||
4 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
5 | export const Loading = createAsyncComponent(() => import('./src/index.vue')); | 2 | export const Loading = createAsyncComponent(() => import('./src/index.vue')); |
6 | 3 | ||
7 | -withInstall(Loading); | ||
8 | export { useLoading } from './src/useLoading'; | 4 | export { useLoading } from './src/useLoading'; |
9 | export { createLoading } from './src/createLoading'; | 5 | export { createLoading } from './src/createLoading'; |
src/components/Loading/src/indicator.tsx deleted
100644 โ 0
1 | -// If you need to modify the default icon, you can open the comment and modify it here | ||
2 | - | ||
3 | -// import { Spin } from 'ant-design-vue'; | ||
4 | -// import { LoadingOutlined } from '@ant-design/icons-vue'; | ||
5 | -// Spin.setDefaultIndicator({ | ||
6 | -// indicator: () => { | ||
7 | -// return <LoadingOutlined spin />; | ||
8 | -// }, | ||
9 | -// }); |
src/components/Loading/src/useLoading.ts
@@ -8,6 +8,10 @@ export interface UseLoadingOptions { | @@ -8,6 +8,10 @@ export interface UseLoadingOptions { | ||
8 | props?: Partial<LoadingProps>; | 8 | props?: Partial<LoadingProps>; |
9 | } | 9 | } |
10 | 10 | ||
11 | +interface Fn { | ||
12 | + (): void; | ||
13 | +} | ||
14 | + | ||
11 | export function useLoading(props: Partial<LoadingProps>): [Fn, Fn]; | 15 | export function useLoading(props: Partial<LoadingProps>): [Fn, Fn]; |
12 | export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn]; | 16 | export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn]; |
13 | 17 |
src/components/Markdown/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | export const MarkDown = createAsyncComponent(() => import('./src/index.vue')); | 2 | export const MarkDown = createAsyncComponent(() => import('./src/index.vue')); |
5 | 3 | ||
6 | -withInstall(MarkDown); | ||
7 | - | ||
8 | export * from './src/types'; | 4 | export * from './src/types'; |
src/components/Markdown/src/index.vue
1 | <template> | 1 | <template> |
2 | - <div class="markdown" ref="wrapRef" /> | 2 | + <div ref="wrapRef" /> |
3 | </template> | 3 | </template> |
4 | <script lang="ts"> | 4 | <script lang="ts"> |
5 | - import { | ||
6 | - defineComponent, | ||
7 | - ref, | ||
8 | - onMounted, | ||
9 | - unref, | ||
10 | - onUnmounted, | ||
11 | - nextTick, | ||
12 | - // watch, | ||
13 | - computed, | ||
14 | - } from 'vue'; | 5 | + import { defineComponent, ref, onMounted, unref, onUnmounted, nextTick, computed } from 'vue'; |
15 | import Vditor from 'vditor'; | 6 | import Vditor from 'vditor'; |
16 | import 'vditor/dist/index.css'; | 7 | import 'vditor/dist/index.css'; |
17 | 8 | ||
@@ -75,21 +66,6 @@ | @@ -75,21 +66,6 @@ | ||
75 | initedRef.value = true; | 66 | initedRef.value = true; |
76 | } | 67 | } |
77 | 68 | ||
78 | - // watch( | ||
79 | - // () => props.value, | ||
80 | - // () => { | ||
81 | - // nextTick(() => { | ||
82 | - // const vditor = unref(vditorRef); | ||
83 | - // if (unref(initedRef) && props.value && vditor) { | ||
84 | - // vditor.setValue(props.value); | ||
85 | - // } | ||
86 | - // }); | ||
87 | - // }, | ||
88 | - // { | ||
89 | - // immediate: true, | ||
90 | - // } | ||
91 | - // ); | ||
92 | - | ||
93 | onMounted(() => { | 69 | onMounted(() => { |
94 | nextTick(() => { | 70 | nextTick(() => { |
95 | init(); | 71 | init(); |
src/components/Menu/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | 2 | ||
5 | -export const BasicMenu = createAsyncComponent(() => import('./src/BasicMenu.vue'), { | ||
6 | - loading: false, | ||
7 | -}); | ||
8 | - | ||
9 | -export const MenuTag = createAsyncComponent(() => import('./src/components/MenuItemTag.vue'), { | ||
10 | - loading: false, | ||
11 | -}); | 3 | +export const BasicMenu = createAsyncComponent(() => import('./src/BasicMenu.vue')); |
12 | 4 | ||
13 | -withInstall(BasicMenu); | 5 | +export const MenuTag = createAsyncComponent(() => import('./src/components/MenuItemTag.vue')); |
src/components/Modal/index.ts
1 | import './src/index.less'; | 1 | import './src/index.less'; |
2 | import { withInstall } from '../util'; | 2 | import { withInstall } from '../util'; |
3 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
4 | - | ||
5 | -export const BasicModal = createAsyncComponent(() => import('./src/BasicModal')); | 3 | +import BasicModal from './src/BasicModal'; |
6 | 4 | ||
7 | withInstall(BasicModal); | 5 | withInstall(BasicModal); |
8 | 6 | ||
7 | +export { BasicModal }; | ||
9 | export { useModalContext } from './src/useModalContext'; | 8 | export { useModalContext } from './src/useModalContext'; |
10 | export { useModal, useModalInner } from './src/useModal'; | 9 | export { useModal, useModalInner } from './src/useModal'; |
11 | export * from './src/types'; | 10 | export * from './src/types'; |
src/components/Page/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | export const PageFooter = createAsyncComponent(() => import('./src/PageFooter.vue')); | 2 | export const PageFooter = createAsyncComponent(() => import('./src/PageFooter.vue')); |
5 | - | ||
6 | -withInstall(PageFooter); |
src/components/Qrcode/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | export const QrCode = createAsyncComponent(() => import('./src/index.vue')); | 2 | export const QrCode = createAsyncComponent(() => import('./src/index.vue')); |
5 | 3 | ||
6 | -withInstall(QrCode); | ||
7 | export * from './src/types'; | 4 | export * from './src/types'; |
src/components/Scrollbar/index.ts
@@ -3,10 +3,9 @@ | @@ -3,10 +3,9 @@ | ||
3 | */ | 3 | */ |
4 | 4 | ||
5 | import { withInstall } from '../util'; | 5 | import { withInstall } from '../util'; |
6 | - | ||
7 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
8 | -export const Scrollbar = createAsyncComponent(() => import('./src/index.vue')); | 6 | +import Scrollbar from './src/index.vue'; |
9 | 7 | ||
10 | withInstall(Scrollbar); | 8 | withInstall(Scrollbar); |
11 | 9 | ||
10 | +export { Scrollbar }; | ||
12 | export type { ScrollbarType } from './src/types'; | 11 | export type { ScrollbarType } from './src/types'; |
src/components/StrengthMeter/index.ts
0 โ 100644
src/components/StrengthMeter/index.tsx deleted
100644 โ 0
src/components/StrengthMeter/src/index.tsx deleted
100644 โ 0
1 | -import './index.less'; | ||
2 | - | ||
3 | -import { PropType } from 'vue'; | ||
4 | - | ||
5 | -import { defineComponent, computed, ref, watch, unref, watchEffect } from 'vue'; | ||
6 | - | ||
7 | -import { Input } from 'ant-design-vue'; | ||
8 | - | ||
9 | -import zxcvbn from 'zxcvbn'; | ||
10 | -import { extendSlots } from '/@/utils/helper/tsxHelper'; | ||
11 | -import { propTypes } from '/@/utils/propTypes'; | ||
12 | - | ||
13 | -const prefixCls = 'strength-meter'; | ||
14 | -export default defineComponent({ | ||
15 | - name: 'StrengthMeter', | ||
16 | - props: { | ||
17 | - value: propTypes.string, | ||
18 | - | ||
19 | - userInputs: { | ||
20 | - type: Array as PropType<string[]>, | ||
21 | - default: () => [], | ||
22 | - }, | ||
23 | - | ||
24 | - showInput: propTypes.bool.def(true), | ||
25 | - disabled: propTypes.bool, | ||
26 | - }, | ||
27 | - emits: ['score-change', 'change'], | ||
28 | - setup(props, { emit, attrs, slots }) { | ||
29 | - const innerValueRef = ref(''); | ||
30 | - const getPasswordStrength = computed(() => { | ||
31 | - const { userInputs, disabled } = props; | ||
32 | - if (disabled) return null; | ||
33 | - const innerValue = unref(innerValueRef); | ||
34 | - const score = innerValue | ||
35 | - ? zxcvbn(unref(innerValueRef), (userInputs as string[]) || null).score | ||
36 | - : null; | ||
37 | - emit('score-change', score); | ||
38 | - return score; | ||
39 | - }); | ||
40 | - | ||
41 | - function handleChange(e: ChangeEvent) { | ||
42 | - innerValueRef.value = e.target.value; | ||
43 | - } | ||
44 | - | ||
45 | - watchEffect(() => { | ||
46 | - innerValueRef.value = props.value || ''; | ||
47 | - }); | ||
48 | - watch( | ||
49 | - () => unref(innerValueRef), | ||
50 | - (val) => { | ||
51 | - emit('change', val); | ||
52 | - } | ||
53 | - ); | ||
54 | - | ||
55 | - return () => { | ||
56 | - const { showInput, disabled } = props; | ||
57 | - return ( | ||
58 | - <div class={prefixCls}> | ||
59 | - {showInput && ( | ||
60 | - <Input.Password | ||
61 | - {...attrs} | ||
62 | - allowClear={true} | ||
63 | - value={unref(innerValueRef)} | ||
64 | - onChange={handleChange} | ||
65 | - disabled={disabled} | ||
66 | - > | ||
67 | - {extendSlots(slots)} | ||
68 | - </Input.Password> | ||
69 | - )} | ||
70 | - <div class={`${prefixCls}-bar`}> | ||
71 | - <div class={`${prefixCls}-bar__fill`} data-score={unref(getPasswordStrength)}></div> | ||
72 | - </div> | ||
73 | - </div> | ||
74 | - ); | ||
75 | - }; | ||
76 | - }, | ||
77 | -}); |
src/components/StrengthMeter/src/index.less renamed to src/components/StrengthMeter/src/index.vue
1 | -@import (reference) '../../../design/index.less'; | 1 | +<template> |
2 | + <div :class="prefixCls"> | ||
3 | + <InputPassword | ||
4 | + v-if="showInput" | ||
5 | + v-bind="$attrs" | ||
6 | + allowClear | ||
7 | + :value="innerValueRef" | ||
8 | + @change="handleChange" | ||
9 | + :disabled="disabled" | ||
10 | + > | ||
11 | + <template #[item]="data" v-for="item in Object.keys($slots)"> | ||
12 | + <slot :name="item" v-bind="data" /> | ||
13 | + </template> | ||
14 | + </InputPassword> | ||
15 | + <div :class="`${prefixCls}-bar`"> | ||
16 | + <div :class="`${prefixCls}-bar--fill`" :data-score="getPasswordStrength"></div> | ||
17 | + </div> | ||
18 | + </div> | ||
19 | +</template> | ||
2 | 20 | ||
3 | -.strength-meter { | ||
4 | - position: relative; | 21 | +<script lang="ts"> |
22 | + import { PropType } from 'vue'; | ||
5 | 23 | ||
6 | - &-bar { | ||
7 | - position: relative; | ||
8 | - height: 4px; | ||
9 | - margin: 10px auto 6px; | ||
10 | - background: @disabled-color; | ||
11 | - border-radius: 3px; | ||
12 | - | ||
13 | - &::before, | ||
14 | - &::after { | ||
15 | - position: absolute; | ||
16 | - z-index: 10; | ||
17 | - display: block; | ||
18 | - width: 20%; | ||
19 | - height: inherit; | ||
20 | - background: transparent; | ||
21 | - border-color: @white; | ||
22 | - border-style: solid; | ||
23 | - border-width: 0 5px 0 5px; | ||
24 | - content: ''; | ||
25 | - } | 24 | + import { defineComponent, computed, ref, watch, unref, watchEffect } from 'vue'; |
26 | 25 | ||
27 | - &::before { | ||
28 | - left: 20%; | ||
29 | - } | 26 | + import { Input } from 'ant-design-vue'; |
30 | 27 | ||
31 | - &::after { | ||
32 | - right: 20%; | ||
33 | - } | 28 | + import zxcvbn from 'zxcvbn'; |
29 | + import { propTypes } from '/@/utils/propTypes'; | ||
30 | + import { useDesign } from '/@/hooks/web/useDesign'; | ||
34 | 31 | ||
35 | - &__fill { | ||
36 | - position: absolute; | ||
37 | - width: 0; | ||
38 | - height: inherit; | ||
39 | - background: transparent; | ||
40 | - border-radius: inherit; | ||
41 | - transition: width 0.5s ease-in-out, background 0.25s; | 32 | + export default defineComponent({ |
33 | + name: 'StrengthMeter', | ||
34 | + components: { InputPassword: Input.Password }, | ||
35 | + props: { | ||
36 | + value: propTypes.string, | ||
42 | 37 | ||
43 | - &[data-score='0'] { | ||
44 | - width: 20%; | ||
45 | - background: darken(@error-color, 10%); | 38 | + userInputs: { |
39 | + type: Array as PropType<string[]>, | ||
40 | + default: () => [], | ||
41 | + }, | ||
42 | + | ||
43 | + showInput: propTypes.bool.def(true), | ||
44 | + disabled: propTypes.bool, | ||
45 | + }, | ||
46 | + emits: ['score-change', 'change'], | ||
47 | + setup(props, { emit }) { | ||
48 | + const innerValueRef = ref(''); | ||
49 | + const { prefixCls } = useDesign('strength-meter'); | ||
50 | + | ||
51 | + const getPasswordStrength = computed(() => { | ||
52 | + const { userInputs, disabled } = props; | ||
53 | + if (disabled) return null; | ||
54 | + const innerValue = unref(innerValueRef); | ||
55 | + const score = innerValue | ||
56 | + ? zxcvbn(unref(innerValueRef), (userInputs as string[]) || null).score | ||
57 | + : null; | ||
58 | + emit('score-change', score); | ||
59 | + return score; | ||
60 | + }); | ||
61 | + | ||
62 | + function handleChange(e: ChangeEvent) { | ||
63 | + innerValueRef.value = e.target.value; | ||
46 | } | 64 | } |
47 | 65 | ||
48 | - &[data-score='1'] { | ||
49 | - width: 40%; | ||
50 | - background: @error-color; | 66 | + watchEffect(() => { |
67 | + innerValueRef.value = props.value || ''; | ||
68 | + }); | ||
69 | + watch( | ||
70 | + () => unref(innerValueRef), | ||
71 | + (val) => { | ||
72 | + emit('change', val); | ||
73 | + } | ||
74 | + ); | ||
75 | + | ||
76 | + return { | ||
77 | + getPasswordStrength, | ||
78 | + handleChange, | ||
79 | + prefixCls, | ||
80 | + innerValueRef, | ||
81 | + }; | ||
82 | + }, | ||
83 | + }); | ||
84 | +</script> | ||
85 | +<style lang="less" scoped> | ||
86 | + @import (reference) '../../../design/index.less'; | ||
87 | + @prefix-cls: ~'@{namespace}-strength-meter'; | ||
88 | + | ||
89 | + .@{prefix-cls} { | ||
90 | + position: relative; | ||
91 | + | ||
92 | + &-bar { | ||
93 | + position: relative; | ||
94 | + height: 4px; | ||
95 | + margin: 10px auto 6px; | ||
96 | + background: @disabled-color; | ||
97 | + border-radius: 3px; | ||
98 | + | ||
99 | + &::before, | ||
100 | + &::after { | ||
101 | + position: absolute; | ||
102 | + z-index: 10; | ||
103 | + display: block; | ||
104 | + width: 20%; | ||
105 | + height: inherit; | ||
106 | + background: transparent; | ||
107 | + border-color: @white; | ||
108 | + border-style: solid; | ||
109 | + border-width: 0 5px 0 5px; | ||
110 | + content: ''; | ||
51 | } | 111 | } |
52 | 112 | ||
53 | - &[data-score='2'] { | ||
54 | - width: 60%; | ||
55 | - background: @warning-color; | 113 | + &::before { |
114 | + left: 20%; | ||
56 | } | 115 | } |
57 | 116 | ||
58 | - &[data-score='3'] { | ||
59 | - width: 80%; | ||
60 | - background: fade(@success-color, 50%); | 117 | + &::after { |
118 | + right: 20%; | ||
61 | } | 119 | } |
62 | 120 | ||
63 | - &[data-score='4'] { | ||
64 | - width: 100%; | ||
65 | - background: @success-color; | 121 | + &--fill { |
122 | + position: absolute; | ||
123 | + width: 0; | ||
124 | + height: inherit; | ||
125 | + background: transparent; | ||
126 | + border-radius: inherit; | ||
127 | + transition: width 0.5s ease-in-out, background 0.25s; | ||
128 | + | ||
129 | + &[data-score='0'] { | ||
130 | + width: 20%; | ||
131 | + background: darken(@error-color, 10%); | ||
132 | + } | ||
133 | + | ||
134 | + &[data-score='1'] { | ||
135 | + width: 40%; | ||
136 | + background: @error-color; | ||
137 | + } | ||
138 | + | ||
139 | + &[data-score='2'] { | ||
140 | + width: 60%; | ||
141 | + background: @warning-color; | ||
142 | + } | ||
143 | + | ||
144 | + &[data-score='3'] { | ||
145 | + width: 80%; | ||
146 | + background: fade(@success-color, 50%); | ||
147 | + } | ||
148 | + | ||
149 | + &[data-score='4'] { | ||
150 | + width: 100%; | ||
151 | + background: @success-color; | ||
152 | + } | ||
66 | } | 153 | } |
67 | } | 154 | } |
68 | } | 155 | } |
69 | -} | 156 | +</style> |
src/components/Tinymce/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | export const Tinymce = createAsyncComponent(() => import('./src/Editor.vue')); | 2 | export const Tinymce = createAsyncComponent(() => import('./src/Editor.vue')); |
5 | - | ||
6 | -withInstall(Tinymce); |
src/components/Tree/index.ts
1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
2 | -import { withInstall } from '../util'; | ||
3 | 2 | ||
4 | export const BasicTree = createAsyncComponent(() => import('./src/BasicTree')); | 3 | export const BasicTree = createAsyncComponent(() => import('./src/BasicTree')); |
5 | 4 | ||
6 | -withInstall(BasicTree); | ||
7 | - | ||
8 | export type { ContextMenuItem } from '/@/hooks/web/useContextMenu'; | 5 | export type { ContextMenuItem } from '/@/hooks/web/useContextMenu'; |
9 | export * from './src/types'; | 6 | export * from './src/types'; |
src/components/Upload/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | export const BasicUpload = createAsyncComponent(() => import('./src/BasicUpload.vue')); | 2 | export const BasicUpload = createAsyncComponent(() => import('./src/BasicUpload.vue')); |
5 | - | ||
6 | -withInstall(BasicUpload); |
src/components/Verify/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | 2 | ||
5 | export const BasicDragVerify = createAsyncComponent(() => import('./src/DragVerify')); | 3 | export const BasicDragVerify = createAsyncComponent(() => import('./src/DragVerify')); |
6 | export const RotateDragVerify = createAsyncComponent(() => import('./src/ImgRotate')); | 4 | export const RotateDragVerify = createAsyncComponent(() => import('./src/ImgRotate')); |
7 | 5 | ||
8 | -withInstall(BasicDragVerify, RotateDragVerify); | ||
9 | - | ||
10 | export * from './src/types'; | 6 | export * from './src/types'; |
src/components/VirtualScroll/index.ts
1 | -import { withInstall } from '../util'; | ||
2 | - | ||
3 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | 1 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
4 | 2 | ||
5 | export const VScroll = createAsyncComponent(() => import('./src/index')); | 3 | export const VScroll = createAsyncComponent(() => import('./src/index')); |
6 | - | ||
7 | -withInstall(VScroll); |
src/layouts/default/header/index.vue
@@ -84,6 +84,7 @@ | @@ -84,6 +84,7 @@ | ||
84 | } from './components'; | 84 | } from './components'; |
85 | import { useAppInject } from '/@/hooks/web/useAppInject'; | 85 | import { useAppInject } from '/@/hooks/web/useAppInject'; |
86 | import { useDesign } from '/@/hooks/web/useDesign'; | 86 | import { useDesign } from '/@/hooks/web/useDesign'; |
87 | + import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | ||
87 | 88 | ||
88 | export default defineComponent({ | 89 | export default defineComponent({ |
89 | name: 'LayoutHeader', | 90 | name: 'LayoutHeader', |