mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 08:55:53 +08:00
智慧宿舍系统小程序
This commit is contained in:
52
wechat/miniprogram/node_modules/@vant/weapp/dist/notify/notify.js
generated
vendored
Normal file
52
wechat/miniprogram/node_modules/@vant/weapp/dist/notify/notify.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { WHITE } from '../common/color';
|
||||
const defaultOptions = {
|
||||
selector: '#van-notify',
|
||||
type: 'danger',
|
||||
message: '',
|
||||
background: '',
|
||||
duration: 3000,
|
||||
zIndex: 110,
|
||||
top: 0,
|
||||
color: WHITE,
|
||||
safeAreaInsetTop: false,
|
||||
onClick: () => {},
|
||||
onOpened: () => {},
|
||||
onClose: () => {},
|
||||
};
|
||||
function parseOptions(message) {
|
||||
if (message == null) {
|
||||
return {};
|
||||
}
|
||||
return typeof message === 'string' ? { message } : message;
|
||||
}
|
||||
function getContext() {
|
||||
const pages = getCurrentPages();
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
export default function Notify(options) {
|
||||
options = Object.assign(
|
||||
Object.assign({}, defaultOptions),
|
||||
parseOptions(options)
|
||||
);
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
delete options.context;
|
||||
delete options.selector;
|
||||
if (notify) {
|
||||
notify.setData(options);
|
||||
notify.show();
|
||||
return notify;
|
||||
}
|
||||
console.warn('未找到 van-notify 节点,请确认 selector 及 context 是否正确');
|
||||
}
|
||||
Notify.clear = function (options) {
|
||||
options = Object.assign(
|
||||
Object.assign({}, defaultOptions),
|
||||
parseOptions(options)
|
||||
);
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
if (notify) {
|
||||
notify.hide();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user