diff --git a/packages/opendesign/src/components/_shared/global.ts b/packages/opendesign/src/components/_shared/global.ts index 8e90de3356b3087e5485faa5f034a729f6b26e91..f86e3eca8fa2004c9c239a57eddaa55d21358f79 100644 --- a/packages/opendesign/src/components/_shared/global.ts +++ b/packages/opendesign/src/components/_shared/global.ts @@ -13,3 +13,7 @@ export function initSize(type: SizeT) { export type ShapeT = 'round' | 'normal' export const defaultShape = ref('normal'); + +export function initShape(type: ShapeT) { + defaultShape.value = type; +} diff --git a/packages/opendesign/src/components/_shared/icons.ts b/packages/opendesign/src/components/_shared/icons.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b46b1b1ffcd40e8f5130c79862dca018ea2b60b --- /dev/null +++ b/packages/opendesign/src/components/_shared/icons.ts @@ -0,0 +1,30 @@ +/** + * 定义全局图标,支持全局初始化自定义 + */ +import { IconLoading, IconLink, IconArrowRight } from '../icons'; +import type { Component } from 'vue'; + +let iLoading: Component = IconLoading; +export function setLoadingIcon(icon: Component) { + iLoading = icon; +} +export function getLoadingIcon() { + return iLoading; +} + + +let iLink: Component = IconLink; +export function setLinkIcon(icon: Component) { + iLink = icon; +} +export function getLinkIcon() { + return iLink; +} + +let iLinkArrow: Component = IconArrowRight; +export function setLinkArrowIcon(icon: Component) { + iLinkArrow = icon; +} +export function getLinkArrowIcon() { + return iLinkArrow; +} \ No newline at end of file diff --git a/packages/opendesign/src/components/button/OButton.vue b/packages/opendesign/src/components/button/OButton.vue index 9e4d53345c09c541cc4b0464e50daea5441ae396..c857ebc7f2c9b477b0ff567efb0dbffa420f0596 100644 --- a/packages/opendesign/src/components/button/OButton.vue +++ b/packages/opendesign/src/components/button/OButton.vue @@ -2,26 +2,32 @@ import { defaultSize, defaultShape } from '../_shared/global'; import type { SizeT, ShapeT } from '../_shared/global'; import { ButtonTypeT } from './types'; +import { getLoadingIcon } from '../_shared/icons'; interface ButtonPropT { /** - * 按钮类型:'primary' | 'outline' | 'text' | 'link' + * 按钮类型:"outline" | "primary" | "text" | "link" */ type?: ButtonTypeT; /** - * 按钮尺寸:'primary' | 'outline' | 'text' | 'link' + * 按钮尺寸:"normal" | "small" | "large" */ size?: SizeT; /** - * 按钮形状:'primary' | 'outline' | 'text' | 'link' + * 按钮形状:"normal" | "round" */ shape?: ShapeT; + /** + * 是否为loading状态 + */ + loading?: boolean; } const props = withDefaults(defineProps(), { type: 'outline', size: defaultSize.value, shape: defaultShape.value, }); +const IconLoading = getLoadingIcon();