Skip to content

Commit

Permalink
feat(use-loading): add setTip method
Browse files Browse the repository at this point in the history
为useLoading添加setTip方法
  • Loading branch information
mynetfan committed Jul 30, 2021
1 parent ddd1893 commit 26d9476
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- **Preview** 添加新的属性及事件
- **Dark Theme** 新增对 tailwindcss 夜间模式的支持
- **其它** 为 useLoading 添加 setTip 方法

### 🐛 Bug Fixes

Expand Down
14 changes: 10 additions & 4 deletions src/components/Loading/src/useLoading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ interface Fn {
(): void;
}

export function useLoading(props: Partial<LoadingProps>): [Fn, Fn];
export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn];
export function useLoading(props: Partial<LoadingProps>): [Fn, Fn, (string) => void];
export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn, (string) => void];

export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOptions>): [Fn, Fn] {
export function useLoading(
opt: Partial<LoadingProps> | Partial<UseLoadingOptions>
): [Fn, Fn, (string) => void] {
let props: Partial<LoadingProps>;
let target: HTMLElement | Ref<ElRef> = document.body;

Expand All @@ -39,5 +41,9 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption
instance.close();
};

return [open, close];
const setTip = (tip: string) => {
instance.setTip(tip);
};

return [open, close, setTip];
}

0 comments on commit 26d9476

Please sign in to comment.