wms-antdvue/.svn/pristine/41/411dc991e643bc942ad389384d7fd7de2915d415.svn-base
2024-11-07 16:33:03 +08:00

56 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { BehaviorSubject, ReplaySubject } from 'rxjs';
// 处理LoadingBar状态只保留最后的状态
export const loadingSubject = new BehaviorSubject('start');
// 处理Message信息缓存最后两个
export const messageSubject = new ReplaySubject(2);
// 处理Modal信息缓存最后两个
export const modalSubject = new ReplaySubject(2);
export const $loading = {
start: () => loadingSubject.next('start'),
finish: () => loadingSubject.next('finish'),
error: () => loadingSubject.next('error'),
};
export const $message = {
success: (payload) =>
messageSubject.next({
type: 'success',
info: payload,
}),
info: (payload) =>
messageSubject.next({
type: 'info',
info: payload,
}),
warning: (payload) =>
messageSubject.next({
type: 'warning',
info: payload,
}),
error: (payload) =>
messageSubject.next({
type: 'error',
info: payload,
}),
loading: (payload) =>
messageSubject.next({
type: 'loading',
info: payload,
}),
};
export const $modal = {
info: (payload) =>
modalSubject.next({
type: 'info',
params: payload,
}),
warning: (payload) =>
modalSubject.next({
type: 'warning',
params: payload,
}),
};