diff --git a/dist/dialog/index.wxss b/dist/dialog/index.wxss index 571861ad..507a7895 100644 --- a/dist/dialog/index.wxss +++ b/dist/dialog/index.wxss @@ -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)} \ No newline at end of file +@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)} \ No newline at end of file diff --git a/dist/notify/notify.d.ts b/dist/notify/notify.d.ts index f6ee08f9..d5213cb0 100644 --- a/dist/notify/notify.d.ts +++ b/dist/notify/notify.d.ts @@ -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; diff --git a/dist/notify/notify.js b/dist/notify/notify.js index 59dc73e2..306d7fd4 100644 --- a/dist/notify/notify.js +++ b/dist/notify/notify.js @@ -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); +}; diff --git a/dist/toast/toast.d.ts b/dist/toast/toast.d.ts index 0c55025a..3c030ff3 100644 --- a/dist/toast/toast.d.ts +++ b/dist/toast/toast.d.ts @@ -1,12 +1,13 @@ /// /// 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; diff --git a/dist/toast/toast.js b/dist/toast/toast.js index 10775f31..51d14269 100644 --- a/dist/toast/toast.js +++ b/dist/toast/toast.js @@ -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 是否正确'); diff --git a/lib/calendar/components/month/index.wxs b/lib/calendar/components/month/index.wxs index 8c1e89b9..55e45a57 100644 --- a/lib/calendar/components/month/index.wxs +++ b/lib/calendar/components/month/index.wxs @@ -9,7 +9,7 @@ var ROW_HEIGHT = 64; function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) { var style = []; - var current = getDate(date).getUTCDay() || 7; + var current = getDate(date).getDay() || 7; var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) : current === 7 && firstDayOfWeek === 0 ? 0 : (current - firstDayOfWeek); diff --git a/lib/dialog/index.wxss b/lib/dialog/index.wxss index 571861ad..507a7895 100644 --- a/lib/dialog/index.wxss +++ b/lib/dialog/index.wxss @@ -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)} \ No newline at end of file +@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)} \ No newline at end of file diff --git a/lib/notify/notify.d.ts b/lib/notify/notify.d.ts index f6ee08f9..d5213cb0 100644 --- a/lib/notify/notify.d.ts +++ b/lib/notify/notify.d.ts @@ -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; diff --git a/lib/notify/notify.js b/lib/notify/notify.js index 1b57b1cf..d4704313 100644 --- a/lib/notify/notify.js +++ b/lib/notify/notify.js @@ -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); +}; diff --git a/lib/toast/toast.d.ts b/lib/toast/toast.d.ts index 0c55025a..3c030ff3 100644 --- a/lib/toast/toast.d.ts +++ b/lib/toast/toast.d.ts @@ -1,12 +1,13 @@ /// /// 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; diff --git a/lib/toast/toast.js b/lib/toast/toast.js index 4fdb2dab..f51a89ac 100644 --- a/lib/toast/toast.js +++ b/lib/toast/toast.js @@ -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 是否正确');