mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2026-07-11 00:41:06 +08:00
Compare commits
8 Commits
d965fa6934
...
ba064e5a71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba064e5a71 | ||
|
|
9789f68d71 | ||
|
|
0d71d8068d | ||
|
|
842e88f115 | ||
|
|
9a708747a8 | ||
|
|
8220552f66 | ||
|
|
06c2457513 | ||
|
|
0d3694c9d7 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ example/dist
|
||||
changelog.generated.md
|
||||
package-lock.json
|
||||
build/private.wx1c01b35002d3ba14.key
|
||||
project.private.config.json
|
||||
|
||||
2
dist/dialog/index.wxss
vendored
2
dist/dialog/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-dialog{background-color:var(--dialog-background-color,#fff);border-radius:var(--dialog-border-radius,16px);font-size:var(--dialog-font-size,16px);overflow:hidden;top:45%!important;width:var(--dialog-width,320px)}@media (max-width:321px){.van-dialog{width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{font-weight:var(--dialog-header-font-weight,500);line-height:var(--dialog-header-line-height,24px);padding-top:var(--dialog-header-padding-top,24px);text-align:center}.van-dialog__header--isolated{padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{-webkit-overflow-scrolling:touch;font-size:var(--dialog-message-font-size,14px);line-height:var(--dialog-message-line-height,20px);max-height:var(--dialog-message-max-height,60vh);overflow-y:auto;padding:var(--dialog-message-padding,24px);text-align:center}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{color:var(--dialog-has-title-message-text-color,#646566);padding-top:var(--dialog-has-title-message-padding-top,8px)}.van-dialog__message--round-button{color:#323233;padding-bottom:16px}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:flex}.van-dialog__footer--round-button{padding:8px 24px 16px!important;position:relative!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;transform:translate3d(-50%,-50%,0) scale(.9)}
|
||||
@import '../common/index.wxss';.van-dialog{background-color:var(--dialog-background-color,#fff);border-radius:var(--dialog-border-radius,16px);font-size:var(--dialog-font-size,16px);overflow:hidden;top:45%!important;width:var(--dialog-width,320px)}@media (max-width:321px){.van-dialog{width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{font-weight:var(--dialog-header-font-weight,500);line-height:var(--dialog-header-line-height,24px);padding-top:var(--dialog-header-padding-top,24px);text-align:center}.van-dialog__header--isolated{padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{-webkit-overflow-scrolling:touch;font-size:var(--dialog-message-font-size,14px);line-height:var(--dialog-message-line-height,20px);max-height:var(--dialog-message-max-height,60vh);overflow-y:auto;padding:var(--dialog-message-padding,24px);text-align:center}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{color:var(--dialog-has-title-message-text-color,#646566);padding-top:var(--dialog-has-title-message-padding-top,8px)}.van-dialog__message--round-button{color:#323233;padding-bottom:16px}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__message--justify{text-align:justify}.van-dialog__footer{display:flex}.van-dialog__footer--round-button{padding:8px 24px 16px!important;position:relative!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;transform:translate3d(-50%,-50%,0) scale(.9)}
|
||||
2
dist/notify/notify.d.ts
vendored
2
dist/notify/notify.d.ts
vendored
@ -16,5 +16,7 @@ interface NotifyOptions {
|
||||
declare function Notify(options: NotifyOptions | string): any;
|
||||
declare namespace Notify {
|
||||
var clear: (options?: NotifyOptions | undefined) => void;
|
||||
var setDefaultOptions: (options: NotifyOptions) => void;
|
||||
var resetDefaultOptions: () => void;
|
||||
}
|
||||
export default Notify;
|
||||
|
||||
9
dist/notify/notify.js
vendored
9
dist/notify/notify.js
vendored
@ -13,6 +13,7 @@ const defaultOptions = {
|
||||
onOpened: () => { },
|
||||
onClose: () => { },
|
||||
};
|
||||
let currentOptions = Object.assign({}, defaultOptions);
|
||||
function parseOptions(message) {
|
||||
if (message == null) {
|
||||
return {};
|
||||
@ -24,7 +25,7 @@ function getContext() {
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
export default function Notify(options) {
|
||||
options = Object.assign(Object.assign({}, defaultOptions), parseOptions(options));
|
||||
options = Object.assign(Object.assign({}, currentOptions), parseOptions(options));
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
delete options.context;
|
||||
@ -44,3 +45,9 @@ Notify.clear = function (options) {
|
||||
notify.hide();
|
||||
}
|
||||
};
|
||||
Notify.setDefaultOptions = (options) => {
|
||||
Object.assign(currentOptions, options);
|
||||
};
|
||||
Notify.resetDefaultOptions = () => {
|
||||
currentOptions = Object.assign({}, defaultOptions);
|
||||
};
|
||||
|
||||
3
dist/toast/toast.d.ts
vendored
3
dist/toast/toast.d.ts
vendored
@ -1,12 +1,13 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
declare type ToastMessage = string | number;
|
||||
declare type ToastContext = WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance;
|
||||
interface ToastOptions {
|
||||
show?: boolean;
|
||||
type?: string;
|
||||
mask?: boolean;
|
||||
zIndex?: number;
|
||||
context?: WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance;
|
||||
context?: (() => ToastContext) | ToastContext;
|
||||
position?: string;
|
||||
duration?: number;
|
||||
selector?: string;
|
||||
|
||||
4
dist/toast/toast.js
vendored
4
dist/toast/toast.js
vendored
@ -22,7 +22,9 @@ function getContext() {
|
||||
}
|
||||
function Toast(toastOptions) {
|
||||
const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions));
|
||||
const context = options.context || getContext();
|
||||
const context = (typeof options.context === 'function'
|
||||
? options.context()
|
||||
: options.context) || getContext();
|
||||
const toast = context.selectComponent(options.selector);
|
||||
if (!toast) {
|
||||
console.warn('未找到 van-toast 节点,请确认 selector 及 context 是否正确');
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
# 更新日志
|
||||
|
||||
### [v1.10.5](https://github.com/vant-ui/vant-weapp/compare/v1.10.4...v1.10.5)
|
||||
|
||||
`2022-09-07`
|
||||
|
||||
**Feature**
|
||||
|
||||
- Dialog: messageAlign 属性支持传 justify [#5034](https://github.com/vant-ui/vant-weapp/issues/5034)
|
||||
- Notify: 支持 setDefaultOptions 和 resetDefaultOptions 方法 [#5028](https://github.com/vant-ui/vant-weapp/issues/5028)
|
||||
- toast: context 选项支持传入函数 [#5022](https://github.com/vant-ui/vant-weapp/issues/5022)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Calendar: 修复 getDay 和 getUTCDay 有时间差,导致星期错位的问题 [#4883](https://github.com/vant-ui/vant-weapp/issues/4883)
|
||||
|
||||
### [v1.10.4](https://github.com/vant-ui/vant-weapp/compare/v1.10.3...v1.10.4)
|
||||
|
||||
`2022-07-23`
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
@ -42,355 +43,279 @@
|
||||
"libVersion": "2.6.5",
|
||||
"appid": "wx1c01b35002d3ba14",
|
||||
"projectname": "vant-weapp",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"scripts": {},
|
||||
"staticServerOptions": {
|
||||
"baseURL": "",
|
||||
"servePath": ""
|
||||
},
|
||||
"isGameTourist": false,
|
||||
"condition": {
|
||||
"search": {
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"list": []
|
||||
},
|
||||
"plugin": {
|
||||
"list": []
|
||||
},
|
||||
"gamePlugin": {
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"id": -1,
|
||||
"name": "button",
|
||||
"pathName": "pages/button/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "loading",
|
||||
"pathName": "pages/loading/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "icon",
|
||||
"pathName": "pages/icon/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "layout",
|
||||
"pathName": "pages/col/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "cell",
|
||||
"pathName": "pages/cell/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "config-provider",
|
||||
"pathName": "pages/config-provider/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "card",
|
||||
"pathName": "pages/card/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "stepper",
|
||||
"pathName": "pages/stepper/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "switch",
|
||||
"pathName": "pages/switch/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "tag",
|
||||
"pathName": "pages/tag/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "notice-bar",
|
||||
"pathName": "pages/notice-bar/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "tree-select",
|
||||
"pathName": "pages/tree-select/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "select",
|
||||
"pathName": "pages/select/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "field",
|
||||
"pathName": "pages/field/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "sidebar",
|
||||
"pathName": "pages/sidebar/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "panel",
|
||||
"pathName": "pages/panel/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "popup",
|
||||
"pathName": "pages/popup/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name": "action-sheet",
|
||||
"pathName": "pages/action-sheet/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "steps",
|
||||
"pathName": "pages/steps/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "search",
|
||||
"pathName": "pages/search/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "nav-bar",
|
||||
"pathName": "pages/nav-bar/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "notify",
|
||||
"pathName": "pages/notify/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "toast",
|
||||
"pathName": "pages/toast/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "tabbar",
|
||||
"pathName": "pages/tabbar/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "transition",
|
||||
"pathName": "pages/transition/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "slider",
|
||||
"pathName": "pages/slider/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "progress",
|
||||
"pathName": "pages/progress/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "area",
|
||||
"pathName": "pages/area/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "tab",
|
||||
"pathName": "pages/tab/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "dialog",
|
||||
"pathName": "pages/dialog/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "submit-bar",
|
||||
"pathName": "pages/submit-bar/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "checkbox",
|
||||
"pathName": "pages/checkbox/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "goods-action",
|
||||
"pathName": "pages/goods-action/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "radio",
|
||||
"pathName": "pages/radio/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "swipe-cell",
|
||||
"pathName": "pages/swipe-cell/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "rate",
|
||||
"pathName": "pages/rate/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "collapse",
|
||||
"pathName": "pages/collapse/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "datetime-picker",
|
||||
"pathName": "pages/datetime-picker/index",
|
||||
"query": ""
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "sticky",
|
||||
"pathName": "pages/sticky/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "picker",
|
||||
"pathName": "pages/picker/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "overlay",
|
||||
"pathName": "pages/overlay/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "circle",
|
||||
"pathName": "pages/circle/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "grid",
|
||||
"pathName": "pages/grid/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "count-down",
|
||||
"pathName": "pages/count-down/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "image",
|
||||
"pathName": "pages/image/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": 45,
|
||||
"name": "skeleton",
|
||||
"pathName": "pages/skeleton/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "uploader",
|
||||
"pathName": "pages/uploader/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "dropdown-menu",
|
||||
"pathName": "pages/dropdown-menu/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "calendar",
|
||||
"pathName": "pages/calendar/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "index-bar",
|
||||
"pathName": "pages/index-bar/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": -1,
|
||||
"name": "empty",
|
||||
"pathName": "pages/empty/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"id": 51,
|
||||
"name": "share-sheet",
|
||||
"pathName": "pages/share-sheet/index",
|
||||
"query": "",
|
||||
@ -405,9 +330,14 @@
|
||||
{
|
||||
"name": "divider",
|
||||
"pathName": "pages/divider/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
}
|
||||
}
|
||||
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-dialog{background-color:var(--dialog-background-color,#fff);border-radius:var(--dialog-border-radius,16px);font-size:var(--dialog-font-size,16px);overflow:hidden;top:45%!important;width:var(--dialog-width,320px)}@media (max-width:321px){.van-dialog{width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{font-weight:var(--dialog-header-font-weight,500);line-height:var(--dialog-header-line-height,24px);padding-top:var(--dialog-header-padding-top,24px);text-align:center}.van-dialog__header--isolated{padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{-webkit-overflow-scrolling:touch;font-size:var(--dialog-message-font-size,14px);line-height:var(--dialog-message-line-height,20px);max-height:var(--dialog-message-max-height,60vh);overflow-y:auto;padding:var(--dialog-message-padding,24px);text-align:center}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{color:var(--dialog-has-title-message-text-color,#646566);padding-top:var(--dialog-has-title-message-padding-top,8px)}.van-dialog__message--round-button{color:#323233;padding-bottom:16px}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:flex}.van-dialog__footer--round-button{padding:8px 24px 16px!important;position:relative!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;transform:translate3d(-50%,-50%,0) scale(.9)}
|
||||
@import '../common/index.wxss';.van-dialog{background-color:var(--dialog-background-color,#fff);border-radius:var(--dialog-border-radius,16px);font-size:var(--dialog-font-size,16px);overflow:hidden;top:45%!important;width:var(--dialog-width,320px)}@media (max-width:321px){.van-dialog{width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{font-weight:var(--dialog-header-font-weight,500);line-height:var(--dialog-header-line-height,24px);padding-top:var(--dialog-header-padding-top,24px);text-align:center}.van-dialog__header--isolated{padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{-webkit-overflow-scrolling:touch;font-size:var(--dialog-message-font-size,14px);line-height:var(--dialog-message-line-height,20px);max-height:var(--dialog-message-max-height,60vh);overflow-y:auto;padding:var(--dialog-message-padding,24px);text-align:center}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{color:var(--dialog-has-title-message-text-color,#646566);padding-top:var(--dialog-has-title-message-padding-top,8px)}.van-dialog__message--round-button{color:#323233;padding-bottom:16px}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__message--justify{text-align:justify}.van-dialog__footer{display:flex}.van-dialog__footer--round-button{padding:8px 24px 16px!important;position:relative!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;transform:translate3d(-50%,-50%,0) scale(.9)}
|
||||
2
lib/notify/notify.d.ts
vendored
2
lib/notify/notify.d.ts
vendored
@ -16,5 +16,7 @@ interface NotifyOptions {
|
||||
declare function Notify(options: NotifyOptions | string): any;
|
||||
declare namespace Notify {
|
||||
var clear: (options?: NotifyOptions | undefined) => void;
|
||||
var setDefaultOptions: (options: NotifyOptions) => void;
|
||||
var resetDefaultOptions: () => void;
|
||||
}
|
||||
export default Notify;
|
||||
|
||||
@ -26,6 +26,7 @@ var defaultOptions = {
|
||||
onOpened: function () { },
|
||||
onClose: function () { },
|
||||
};
|
||||
var currentOptions = __assign({}, defaultOptions);
|
||||
function parseOptions(message) {
|
||||
if (message == null) {
|
||||
return {};
|
||||
@ -37,7 +38,7 @@ function getContext() {
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
function Notify(options) {
|
||||
options = __assign(__assign({}, defaultOptions), parseOptions(options));
|
||||
options = __assign(__assign({}, currentOptions), parseOptions(options));
|
||||
var context = options.context || getContext();
|
||||
var notify = context.selectComponent(options.selector);
|
||||
delete options.context;
|
||||
@ -58,3 +59,9 @@ Notify.clear = function (options) {
|
||||
notify.hide();
|
||||
}
|
||||
};
|
||||
Notify.setDefaultOptions = function (options) {
|
||||
Object.assign(currentOptions, options);
|
||||
};
|
||||
Notify.resetDefaultOptions = function () {
|
||||
currentOptions = __assign({}, defaultOptions);
|
||||
};
|
||||
|
||||
3
lib/toast/toast.d.ts
vendored
3
lib/toast/toast.d.ts
vendored
@ -1,12 +1,13 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
declare type ToastMessage = string | number;
|
||||
declare type ToastContext = WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance;
|
||||
interface ToastOptions {
|
||||
show?: boolean;
|
||||
type?: string;
|
||||
mask?: boolean;
|
||||
zIndex?: number;
|
||||
context?: WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance;
|
||||
context?: (() => ToastContext) | ToastContext;
|
||||
position?: string;
|
||||
duration?: number;
|
||||
selector?: string;
|
||||
|
||||
@ -35,7 +35,9 @@ function getContext() {
|
||||
}
|
||||
function Toast(toastOptions) {
|
||||
var options = __assign(__assign({}, currentOptions), parseOptions(toastOptions));
|
||||
var context = options.context || getContext();
|
||||
var context = (typeof options.context === 'function'
|
||||
? options.context()
|
||||
: options.context) || getContext();
|
||||
var toast = context.selectComponent(options.selector);
|
||||
if (!toast) {
|
||||
console.warn('未找到 van-toast 节点,请确认 selector 及 context 是否正确');
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/weapp",
|
||||
"version": "1.10.4",
|
||||
"version": "1.10.5",
|
||||
"author": "vant-ui",
|
||||
"license": "MIT",
|
||||
"miniprogram": "lib",
|
||||
|
||||
@ -62,6 +62,10 @@
|
||||
&--right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&--justify {
|
||||
text-align: justify;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
|
||||
@ -31,6 +31,8 @@ const defaultOptions: NotifyOptions = {
|
||||
onClose: () => {},
|
||||
};
|
||||
|
||||
let currentOptions: NotifyOptions = { ...defaultOptions };
|
||||
|
||||
function parseOptions(
|
||||
message?: NotifyOptions | string
|
||||
): Partial<NotifyOptions> {
|
||||
@ -47,7 +49,7 @@ function getContext() {
|
||||
}
|
||||
|
||||
export default function Notify(options: NotifyOptions | string) {
|
||||
options = { ...defaultOptions, ...parseOptions(options) };
|
||||
options = { ...currentOptions, ...parseOptions(options) };
|
||||
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
@ -74,3 +76,11 @@ Notify.clear = function (options?: NotifyOptions) {
|
||||
notify.hide();
|
||||
}
|
||||
};
|
||||
|
||||
Notify.setDefaultOptions = (options: NotifyOptions) => {
|
||||
Object.assign(currentOptions, options);
|
||||
};
|
||||
|
||||
Notify.resetDefaultOptions = () => {
|
||||
currentOptions = { ...defaultOptions };
|
||||
};
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
import { isObj } from '../common/validator';
|
||||
|
||||
type ToastMessage = string | number;
|
||||
type ToastContext =
|
||||
| WechatMiniprogram.Component.TrivialInstance
|
||||
| WechatMiniprogram.Page.TrivialInstance;
|
||||
|
||||
interface ToastOptions {
|
||||
show?: boolean;
|
||||
type?: string;
|
||||
mask?: boolean;
|
||||
zIndex?: number;
|
||||
context?:
|
||||
| WechatMiniprogram.Component.TrivialInstance
|
||||
| WechatMiniprogram.Page.TrivialInstance;
|
||||
context?: (() => ToastContext) | ToastContext;
|
||||
position?: string;
|
||||
duration?: number;
|
||||
selector?: string;
|
||||
@ -50,7 +51,10 @@ function Toast(toastOptions: ToastOptions | ToastMessage) {
|
||||
...parseOptions(toastOptions),
|
||||
} as ToastOptions;
|
||||
|
||||
const context = options.context || getContext();
|
||||
const context =
|
||||
(typeof options.context === 'function'
|
||||
? options.context()
|
||||
: options.context) || getContext();
|
||||
const toast = context.selectComponent(options.selector as string);
|
||||
|
||||
if (!toast) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user