mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
build(tsconfig): use strict mode (#3712)
This commit is contained in:
parent
31aacedd5b
commit
225484aeae
@ -12,6 +12,8 @@ Page({
|
||||
color: '#ad0000',
|
||||
background: '#ffe1e1'
|
||||
});
|
||||
|
||||
Notify.clear();
|
||||
},
|
||||
|
||||
showCustomDuration() {
|
||||
|
@ -1,398 +1,402 @@
|
||||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"scopeDataCheck": false,
|
||||
"coverView": true,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"compileHotReLoad": false,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"autoAudits": false,
|
||||
"newFeature": true,
|
||||
"uglifyFileName": false,
|
||||
"uploadWithSourceMap": true,
|
||||
"useIsolateContext": true,
|
||||
"nodeModules": true,
|
||||
"enhance": false,
|
||||
"useCompilerModule": false,
|
||||
"userConfirmedUseCompilerModuleSwitch": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"bundle": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"cloudfunctionRoot": "functions/",
|
||||
"libVersion": "2.3.0",
|
||||
"appid": "wx1c01b35002d3ba14",
|
||||
"projectname": "vant-weapp",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"scripts": {},
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"plugin": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"list": []
|
||||
},
|
||||
"gamePlugin": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": 42,
|
||||
"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": "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": "switch-cell",
|
||||
"pathName": "pages/switch-cell/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": "",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"enhance": false,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"nodeModules": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"uglifyFileName": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"useMultiFrameRuntime": false,
|
||||
"useApiHook": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"bundle": false,
|
||||
"useIsolateContext": true,
|
||||
"useCompilerModule": true,
|
||||
"userConfirmedUseCompilerModuleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": []
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"cloudfunctionRoot": "functions/",
|
||||
"libVersion": "2.3.0",
|
||||
"appid": "wx1c01b35002d3ba14",
|
||||
"projectname": "vant-weapp",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"scripts": {},
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"plugin": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"list": []
|
||||
},
|
||||
"gamePlugin": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": 42,
|
||||
"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": "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": "switch-cell",
|
||||
"pathName": "pages/switch-cell/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": "",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { Weapp } from 'definitions/weapp';
|
||||
import { button } from '../mixins/button';
|
||||
import { openType } from '../mixins/open-type';
|
||||
|
||||
@ -41,7 +40,7 @@ VantComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSelect(event: Weapp.Event) {
|
||||
onSelect(event: WechatMiniprogram.TapEvent) {
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const item = this.data.actions[index];
|
||||
if (item && !item.disabled && !item.loading) {
|
||||
|
@ -122,7 +122,7 @@ VantComponent({
|
||||
|
||||
getList(type: string, code?: string): AreaItem[] {
|
||||
const { typeToColumnsPlaceholder } = this.data;
|
||||
let result = [];
|
||||
let result: { code: string; name: string }[] = [];
|
||||
if (type !== 'province' && !code) {
|
||||
return result;
|
||||
}
|
||||
@ -133,13 +133,15 @@ VantComponent({
|
||||
name: list[code],
|
||||
}));
|
||||
|
||||
if (code) {
|
||||
if (code != null) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
|
||||
result = result.filter((item) => item.code.indexOf(code) === 0);
|
||||
result = result.filter(
|
||||
(item) => item.code.indexOf(code as string) === 0
|
||||
);
|
||||
}
|
||||
|
||||
if (typeToColumnsPlaceholder[type] && result.length) {
|
||||
@ -159,7 +161,7 @@ VantComponent({
|
||||
return result;
|
||||
},
|
||||
|
||||
getIndex(type: string, code: string): number {
|
||||
getIndex(type: string, code: string) {
|
||||
let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
|
||||
const list = this.getList(type, code.slice(0, compareNum - 2));
|
||||
|
||||
@ -201,8 +203,8 @@ VantComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
const stack = [];
|
||||
const indexes = [];
|
||||
const stack: Promise<void>[] = [];
|
||||
const indexes: number[] = [];
|
||||
const { columnsNum } = this.data;
|
||||
|
||||
if (columnsNum >= 1) {
|
||||
|
@ -6,6 +6,13 @@ import {
|
||||
getNextDay,
|
||||
} from '../../utils';
|
||||
|
||||
interface Day {
|
||||
date: Date;
|
||||
type: string;
|
||||
text: number;
|
||||
bottomInfo: string;
|
||||
}
|
||||
|
||||
VantComponent({
|
||||
props: {
|
||||
date: {
|
||||
@ -48,14 +55,14 @@ VantComponent({
|
||||
methods: {
|
||||
onClick(event) {
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const item = this.data.days[index];
|
||||
const item: Day = this.data.days[index];
|
||||
if (item.type !== 'disabled') {
|
||||
this.$emit('click', item);
|
||||
}
|
||||
},
|
||||
|
||||
setDays() {
|
||||
const days = [];
|
||||
const days: Day[] = [];
|
||||
const startDate = new Date(this.data.date);
|
||||
const year = startDate.getFullYear();
|
||||
const month = startDate.getMonth();
|
||||
@ -69,7 +76,7 @@ VantComponent({
|
||||
const date = new Date(year, month, day);
|
||||
const type = this.getDayType(date);
|
||||
|
||||
let config = {
|
||||
let config: Day = {
|
||||
date,
|
||||
type,
|
||||
text: day,
|
||||
|
@ -182,6 +182,7 @@ VantComponent({
|
||||
minDate,
|
||||
maxDate,
|
||||
} = this.data;
|
||||
// @ts-ignore
|
||||
const targetDate = type === 'single' ? currentDate : currentDate[0];
|
||||
const displayed = show || !poppable;
|
||||
if (!targetDate || !displayed) {
|
||||
@ -222,6 +223,7 @@ VantComponent({
|
||||
const { type, currentDate, allowSameDay } = this.data;
|
||||
|
||||
if (type === 'range') {
|
||||
// @ts-ignore
|
||||
const [startDay, endDay] = currentDate;
|
||||
|
||||
if (startDay && !endDay) {
|
||||
@ -240,6 +242,7 @@ VantComponent({
|
||||
} else if (type === 'multiple') {
|
||||
let selectedIndex: number;
|
||||
|
||||
// @ts-ignore
|
||||
const selected = currentDate.some((dateItem: number, index: number) => {
|
||||
const equal = compareDay(dateItem, date) === 0;
|
||||
if (equal) {
|
||||
@ -249,10 +252,12 @@ VantComponent({
|
||||
});
|
||||
|
||||
if (selected) {
|
||||
// @ts-ignore
|
||||
const cancelDate = currentDate.splice(selectedIndex, 1);
|
||||
this.setData({ currentDate });
|
||||
this.unselect(cancelDate);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
this.select([...currentDate, date]);
|
||||
}
|
||||
} else {
|
||||
@ -324,6 +329,7 @@ VantComponent({
|
||||
return;
|
||||
}
|
||||
wx.nextTick(() => {
|
||||
// @ts-ignore
|
||||
this.$emit('confirm', copyDates(this.data.currentDate));
|
||||
});
|
||||
},
|
||||
|
@ -89,7 +89,7 @@ export function getMonthEndDay(year: number, month: number): number {
|
||||
}
|
||||
|
||||
export function getMonths(minDate: number, maxDate: number) {
|
||||
const months = [];
|
||||
const months: number[] = [];
|
||||
const cursor = new Date(minDate);
|
||||
|
||||
cursor.setDate(1);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { link } from '../mixins/link';
|
||||
import { VantComponent } from '../common/component';
|
||||
import { Weapp } from 'definitions/weapp';
|
||||
|
||||
VantComponent({
|
||||
classes: [
|
||||
@ -35,7 +34,7 @@ VantComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick(event: Weapp.Event) {
|
||||
onClick(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('click', event.detail);
|
||||
this.jumpLink();
|
||||
},
|
||||
|
@ -7,18 +7,23 @@ import {
|
||||
const relationFunctions = {
|
||||
ancestor: {
|
||||
linked(parent) {
|
||||
// @ts-ignore
|
||||
this.parent = parent;
|
||||
},
|
||||
unlinked() {
|
||||
// @ts-ignore
|
||||
this.parent = null;
|
||||
},
|
||||
},
|
||||
descendant: {
|
||||
linked(child) {
|
||||
// @ts-ignore
|
||||
this.children = this.children || [];
|
||||
// @ts-ignore
|
||||
this.children.push(child);
|
||||
},
|
||||
unlinked(child) {
|
||||
// @ts-ignore
|
||||
this.children = (this.children || []).filter((it) => it !== child);
|
||||
},
|
||||
},
|
||||
|
@ -70,25 +70,29 @@ export function pickExclude(obj: unknown, keys: string[]) {
|
||||
export function getRect(
|
||||
this: WechatMiniprogram.Component.TrivialInstance,
|
||||
selector: string
|
||||
): Promise<WechatMiniprogram.BoundingClientRectCallbackResult> {
|
||||
return new Promise((resolve) => {
|
||||
wx.createSelectorQuery()
|
||||
.in(this)
|
||||
.select(selector)
|
||||
.boundingClientRect()
|
||||
.exec((rect = []) => resolve(rect[0]));
|
||||
});
|
||||
) {
|
||||
return new Promise<WechatMiniprogram.BoundingClientRectCallbackResult>(
|
||||
(resolve) => {
|
||||
wx.createSelectorQuery()
|
||||
.in(this)
|
||||
.select(selector)
|
||||
.boundingClientRect()
|
||||
.exec((rect = []) => resolve(rect[0]));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getAllRect(
|
||||
this: WechatMiniprogram.Component.TrivialInstance,
|
||||
selector: string
|
||||
): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]> {
|
||||
return new Promise((resolve) => {
|
||||
wx.createSelectorQuery()
|
||||
.in(this)
|
||||
.selectAll(selector)
|
||||
.boundingClientRect()
|
||||
.exec((rect = []) => resolve(rect[0]));
|
||||
});
|
||||
) {
|
||||
return new Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>(
|
||||
(resolve) => {
|
||||
wx.createSelectorQuery()
|
||||
.in(this)
|
||||
.selectAll(selector)
|
||||
.boundingClientRect()
|
||||
.exec((rect = []) => resolve(rect[0]));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ function range(num: number, min: number, max: number) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
|
||||
function padZero(val: string | number): string {
|
||||
function padZero(val: string | number) {
|
||||
return `00${val}`.slice(-2);
|
||||
}
|
||||
|
||||
@ -26,8 +26,7 @@ function times(n: number, iteratee: (index: number) => string): string[] {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getTrueValue(formattedValue: string): number {
|
||||
if (!formattedValue) return;
|
||||
function getTrueValue(formattedValue: string) {
|
||||
while (isNaN(parseInt(formattedValue, 10))) {
|
||||
formattedValue = formattedValue.slice(1);
|
||||
}
|
||||
@ -38,7 +37,10 @@ function getMonthEndDay(year: number, month: number): number {
|
||||
return 32 - new Date(year, month - 1, 32).getDate();
|
||||
}
|
||||
|
||||
const defaultFormatter = (_, value) => value;
|
||||
const defaultFormatter = (
|
||||
type: 'year' | 'month' | 'day' | 'hour' | 'minute',
|
||||
value: string
|
||||
) => value;
|
||||
|
||||
VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
@ -327,7 +329,7 @@ VantComponent({
|
||||
},
|
||||
|
||||
updateColumnValue(value) {
|
||||
let values = [];
|
||||
let values: string[] = [];
|
||||
const { type } = this.data;
|
||||
const formatter = this.data.formatter || defaultFormatter;
|
||||
const picker = this.getPicker();
|
||||
|
@ -1,10 +1,10 @@
|
||||
let queue = [];
|
||||
let queue: WechatMiniprogram.Component.TrivialInstance[] = [];
|
||||
|
||||
type DialogOptions = {
|
||||
interface DialogOptions {
|
||||
lang?: string;
|
||||
show?: boolean;
|
||||
title?: string;
|
||||
width?: string | number;
|
||||
width?: string | number | null;
|
||||
zIndex?: number;
|
||||
theme?: string;
|
||||
context?:
|
||||
@ -33,7 +33,7 @@ type DialogOptions = {
|
||||
showCancelButton?: boolean;
|
||||
closeOnClickOverlay?: boolean;
|
||||
confirmButtonOpenType?: string;
|
||||
};
|
||||
}
|
||||
|
||||
const defaultOptions: DialogOptions = {
|
||||
show: false,
|
||||
@ -65,39 +65,39 @@ function getContext() {
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
|
||||
const Dialog = (
|
||||
options: DialogOptions
|
||||
): Promise<WechatMiniprogram.Component.TrivialInstance> => {
|
||||
const Dialog = (options: DialogOptions) => {
|
||||
options = {
|
||||
...currentOptions,
|
||||
...options,
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const context = options.context || getContext();
|
||||
const dialog = context.selectComponent(options.selector);
|
||||
return new Promise<WechatMiniprogram.Component.TrivialInstance>(
|
||||
(resolve, reject) => {
|
||||
const context = options.context || getContext();
|
||||
const dialog = context.selectComponent(options.selector as string);
|
||||
|
||||
delete options.context;
|
||||
delete options.selector;
|
||||
delete options.context;
|
||||
delete options.selector;
|
||||
|
||||
if (dialog) {
|
||||
dialog.setData({
|
||||
onCancel: reject,
|
||||
onConfirm: resolve,
|
||||
...options,
|
||||
});
|
||||
if (dialog) {
|
||||
dialog.setData({
|
||||
onCancel: reject,
|
||||
onConfirm: resolve,
|
||||
...options,
|
||||
});
|
||||
|
||||
wx.nextTick(() => {
|
||||
dialog.setData({ show: true });
|
||||
});
|
||||
wx.nextTick(() => {
|
||||
dialog.setData({ show: true });
|
||||
});
|
||||
|
||||
queue.push(dialog);
|
||||
} else {
|
||||
console.warn(
|
||||
'未找到 van-dialog 节点,请确认 selector 及 context 是否正确'
|
||||
);
|
||||
queue.push(dialog);
|
||||
} else {
|
||||
console.warn(
|
||||
'未找到 van-dialog 节点,请确认 selector 及 context 是否正确'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
};
|
||||
|
||||
Dialog.alert = (options: DialogOptions) => Dialog(options);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { Weapp } from 'definitions/weapp';
|
||||
import { Option } from './shared';
|
||||
|
||||
VantComponent({
|
||||
field: true,
|
||||
@ -58,6 +58,7 @@ VantComponent({
|
||||
closeOnClickOverlay,
|
||||
direction,
|
||||
} = this.parent.data;
|
||||
|
||||
this.setData({
|
||||
overlay,
|
||||
duration,
|
||||
@ -85,9 +86,9 @@ VantComponent({
|
||||
this.setData({ showWrapper: false });
|
||||
},
|
||||
|
||||
onOptionTap(event: Weapp.Event) {
|
||||
onOptionTap(event: WechatMiniprogram.TapEvent) {
|
||||
const { option } = event.currentTarget.dataset;
|
||||
const { value } = option;
|
||||
const { value } = (option as unknown) as Option;
|
||||
|
||||
const shouldEmitChange = this.data.value !== value;
|
||||
this.setData({ showPopup: false, value });
|
||||
@ -100,7 +101,7 @@ VantComponent({
|
||||
}
|
||||
},
|
||||
|
||||
toggle(show, options = {}) {
|
||||
toggle(show?: boolean, options: { immediate?: boolean } = {}) {
|
||||
const { showPopup } = this.data;
|
||||
|
||||
if (typeof show !== 'boolean') {
|
||||
|
5
packages/dropdown-item/shared.ts
Normal file
5
packages/dropdown-item/shared.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface Option {
|
||||
text: string;
|
||||
value: string | number;
|
||||
icon: string;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
export const commonProps = {
|
||||
value: {
|
||||
type: String,
|
||||
observer(value: string) {
|
||||
observer(this: WechatMiniprogram.Component.TrivialInstance, value: string) {
|
||||
if (value !== this.value) {
|
||||
this.setData({ innerValue: value });
|
||||
this.value = value;
|
||||
|
@ -50,7 +50,7 @@ VantComponent({
|
||||
} = data;
|
||||
const width = `${100 / columnNum}%`;
|
||||
|
||||
const styleWrapper = [];
|
||||
const styleWrapper: string[] = [];
|
||||
styleWrapper.push(`width: ${width}`);
|
||||
|
||||
if (square) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { GREEN } from '../common/color';
|
||||
import { VantComponent } from '../common/component';
|
||||
import { getRect } from '../common/utils';
|
||||
import { pageScrollMixin } from '../mixins/page-scroll';
|
||||
|
||||
const indexList = () => {
|
||||
const indexList = [];
|
||||
const indexList: string[] = [];
|
||||
const charCodeOfA = 'A'.charCodeAt(0);
|
||||
|
||||
for (let i = 0; i < 26; i++) {
|
||||
@ -51,7 +52,7 @@ VantComponent({
|
||||
|
||||
mixins: [
|
||||
pageScrollMixin(function (event) {
|
||||
this.scrollTop = event.scrollTop || 0;
|
||||
this.scrollTop = event?.scrollTop || 0;
|
||||
this.onScroll();
|
||||
}),
|
||||
],
|
||||
@ -94,34 +95,29 @@ VantComponent({
|
||||
|
||||
setAnchorsRect() {
|
||||
return Promise.all(
|
||||
this.children.map((anchor) =>
|
||||
anchor
|
||||
.getRect('.van-index-anchor-wrapper')
|
||||
.then(
|
||||
(rect: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
||||
Object.assign(anchor, {
|
||||
height: rect.height,
|
||||
top: rect.top + this.scrollTop,
|
||||
});
|
||||
}
|
||||
)
|
||||
this.children.map(
|
||||
(anchor: WechatMiniprogram.Component.TrivialInstance) =>
|
||||
getRect.call(anchor, '.van-index-anchor-wrapper').then((rect) => {
|
||||
Object.assign(anchor, {
|
||||
height: rect.height,
|
||||
top: rect.top + this.scrollTop,
|
||||
});
|
||||
})
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
setListRect() {
|
||||
return this.getRect('.van-index-bar').then(
|
||||
(rect: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
||||
Object.assign(this, {
|
||||
height: rect.height,
|
||||
top: rect.top + this.scrollTop,
|
||||
});
|
||||
}
|
||||
);
|
||||
return getRect.call(this, '.van-index-bar').then((rect) => {
|
||||
Object.assign(this, {
|
||||
height: rect.height,
|
||||
top: rect.top + this.scrollTop,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
setSiderbarRect() {
|
||||
return this.getRect('.van-index-bar__sidebar').then((res) => {
|
||||
return getRect.call(this, '.van-index-bar__sidebar').then((res) => {
|
||||
this.sidebar = {
|
||||
height: res.height,
|
||||
top: res.top,
|
||||
@ -144,12 +140,10 @@ VantComponent({
|
||||
},
|
||||
|
||||
getAnchorRect(anchor) {
|
||||
return anchor
|
||||
.getRect('.van-index-anchor-wrapper')
|
||||
.then((rect: WechatMiniprogram.BoundingClientRectCallbackResult) => ({
|
||||
height: rect.height,
|
||||
top: rect.top,
|
||||
}));
|
||||
return getRect.call(anchor, '.van-index-anchor-wrapper').then((rect) => ({
|
||||
height: rect.height,
|
||||
top: rect.top,
|
||||
}));
|
||||
},
|
||||
|
||||
getActiveAnchorIndex() {
|
||||
|
@ -1,10 +1,14 @@
|
||||
export const basic = Behavior({
|
||||
methods: {
|
||||
$emit(...args) {
|
||||
this.triggerEvent(...args);
|
||||
$emit(
|
||||
name: string,
|
||||
detail?: Record<string, unknown>,
|
||||
options?: Record<string, unknown>
|
||||
) {
|
||||
this.triggerEvent(name, detail, options);
|
||||
},
|
||||
|
||||
set(data: object, callback: Function) {
|
||||
set(data: object, callback: () => void) {
|
||||
this.setData(data, callback);
|
||||
|
||||
return new Promise((resolve) => wx.nextTick(resolve));
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Weapp } from 'definitions/weapp';
|
||||
// @ts-nocheck
|
||||
|
||||
export const openType = Behavior({
|
||||
properties: {
|
||||
@ -6,27 +6,27 @@ export const openType = Behavior({
|
||||
},
|
||||
|
||||
methods: {
|
||||
bindGetUserInfo(event: Partial<Weapp.Event>) {
|
||||
bindGetUserInfo(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('getuserinfo', event.detail);
|
||||
},
|
||||
|
||||
bindContact(event: Partial<Weapp.Event>) {
|
||||
bindContact(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('contact', event.detail);
|
||||
},
|
||||
|
||||
bindGetPhoneNumber(event: Partial<Weapp.Event>) {
|
||||
bindGetPhoneNumber(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('getphonenumber', event.detail);
|
||||
},
|
||||
|
||||
bindError(event: Partial<Weapp.Event>) {
|
||||
bindError(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('error', event.detail);
|
||||
},
|
||||
|
||||
bindLaunchApp(event: Partial<Weapp.Event>) {
|
||||
bindLaunchApp(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('launchapp', event.detail);
|
||||
},
|
||||
|
||||
bindOpenSetting(event: Partial<Weapp.Event>) {
|
||||
bindOpenSetting(event: WechatMiniprogram.TapEvent) {
|
||||
this.$emit('opensetting', event.detail);
|
||||
},
|
||||
},
|
||||
|
@ -1,5 +1,8 @@
|
||||
type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
|
||||
type Scroller = (event: IPageScrollOption) => void;
|
||||
type Scroller = (
|
||||
this: WechatMiniprogram.Component.TrivialInstance,
|
||||
event?: IPageScrollOption
|
||||
) => void;
|
||||
type TrivialInstance = WechatMiniprogram.Page.TrivialInstance & {
|
||||
vanPageScroller?: Scroller[];
|
||||
};
|
||||
@ -9,11 +12,12 @@ function getCurrentPage(): TrivialInstance {
|
||||
return pages[pages.length - 1] || ({} as TrivialInstance);
|
||||
}
|
||||
|
||||
function onPageScroll(event: IPageScrollOption) {
|
||||
function onPageScroll(event?: IPageScrollOption) {
|
||||
const { vanPageScroller = [] } = getCurrentPage();
|
||||
|
||||
vanPageScroller.forEach((scroller: Scroller) => {
|
||||
if (typeof scroller === 'function') {
|
||||
// @ts-ignore
|
||||
scroller(event);
|
||||
}
|
||||
});
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { Weapp } from 'definitions/weapp';
|
||||
|
||||
const MIN_DISTANCE = 10;
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { isObj, requestAnimationFrame } from '../common/utils';
|
||||
|
||||
const getClassNames = (name: string) => ({
|
||||
@ -7,7 +8,7 @@ const getClassNames = (name: string) => ({
|
||||
'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`,
|
||||
});
|
||||
|
||||
export const transition = function (showDefaultValue: boolean) {
|
||||
export function transition(showDefaultValue: boolean) {
|
||||
return Behavior({
|
||||
properties: {
|
||||
customStyle: String,
|
||||
@ -123,4 +124,4 @@ export const transition = function (showDefaultValue: boolean) {
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { Weapp } from 'definitions/weapp';
|
||||
import { requestAnimationFrame } from '../common/utils';
|
||||
import { getRect, requestAnimationFrame } from '../common/utils';
|
||||
|
||||
VantComponent({
|
||||
props: {
|
||||
@ -70,9 +70,9 @@ VantComponent({
|
||||
methods: {
|
||||
init() {
|
||||
Promise.all([
|
||||
this.getRect('.van-notice-bar__content'),
|
||||
this.getRect('.van-notice-bar__wrap'),
|
||||
]).then((rects: WechatMiniprogram.BoundingClientRectCallbackResult[]) => {
|
||||
getRect.call(this, '.van-notice-bar__content'),
|
||||
getRect.call(this, '.van-notice-bar__wrap'),
|
||||
]).then((rects) => {
|
||||
const [contentRect, wrapRect] = rects;
|
||||
if (
|
||||
contentRect == null ||
|
||||
|
@ -16,7 +16,7 @@ interface NotifyOptions {
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
const defaultOptions = {
|
||||
const defaultOptions: NotifyOptions = {
|
||||
selector: '#van-notify',
|
||||
type: 'danger',
|
||||
message: '',
|
||||
@ -31,7 +31,13 @@ const defaultOptions = {
|
||||
onClose: () => {},
|
||||
};
|
||||
|
||||
function parseOptions(message: NotifyOptions | string): NotifyOptions {
|
||||
function parseOptions(
|
||||
message?: NotifyOptions | string
|
||||
): Partial<NotifyOptions> {
|
||||
if (message == null) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return typeof message === 'string' ? { message } : message;
|
||||
}
|
||||
|
||||
@ -41,7 +47,7 @@ function getContext() {
|
||||
}
|
||||
|
||||
export default function Notify(options: NotifyOptions | string) {
|
||||
options = { ...defaultOptions, ...parseOptions(options) } as NotifyOptions;
|
||||
options = { ...defaultOptions, ...parseOptions(options) };
|
||||
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
@ -59,7 +65,7 @@ export default function Notify(options: NotifyOptions | string) {
|
||||
}
|
||||
|
||||
Notify.clear = function (options?: NotifyOptions) {
|
||||
options = { ...defaultOptions, ...parseOptions(options) } as NotifyOptions;
|
||||
options = { ...defaultOptions, ...parseOptions(options) };
|
||||
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
|
@ -32,7 +32,7 @@ const defaultOptions = {
|
||||
selector: '#van-toast',
|
||||
};
|
||||
|
||||
let queue = [];
|
||||
let queue: WechatMiniprogram.Component.TrivialInstance[] = [];
|
||||
let currentOptions: ToastOptions = { ...defaultOptions };
|
||||
|
||||
function parseOptions(message): ToastOptions {
|
||||
@ -44,16 +44,14 @@ function getContext() {
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
|
||||
function Toast(
|
||||
toastOptions: ToastOptions | ToastMessage
|
||||
): WechatMiniprogram.Component.TrivialInstance {
|
||||
function Toast(toastOptions: ToastOptions | ToastMessage) {
|
||||
const options = {
|
||||
...currentOptions,
|
||||
...parseOptions(toastOptions),
|
||||
} as ToastOptions;
|
||||
|
||||
const context = options.context || getContext();
|
||||
const toast = context.selectComponent(options.selector);
|
||||
const toast = context.selectComponent(options.selector as string);
|
||||
|
||||
if (!toast) {
|
||||
console.warn('未找到 van-toast 节点,请确认 selector 及 context 是否正确');
|
||||
@ -75,7 +73,7 @@ function Toast(
|
||||
toast.setData(options);
|
||||
clearTimeout(toast.timer);
|
||||
|
||||
if (options.duration > 0) {
|
||||
if (options.duration != null && options.duration > 0) {
|
||||
toast.timer = setTimeout(() => {
|
||||
toast.clear();
|
||||
queue = queue.filter((item) => item !== toast);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { isImageFile, chooseFile, isVideoFile } from './utils';
|
||||
import { isImageFile, chooseFile, isVideoFile, File } from './utils';
|
||||
import { chooseImageProps, chooseVideoProps } from './shared';
|
||||
import { isBoolean, isPromise } from '../common/validator';
|
||||
|
||||
@ -79,8 +79,6 @@ VantComponent({
|
||||
deletable: isBoolean(item.deletable) ? item.deletable : true,
|
||||
}));
|
||||
|
||||
console.log(lists);
|
||||
|
||||
this.setData({ lists, isInCount: lists.length < maxCount });
|
||||
},
|
||||
|
||||
@ -92,7 +90,7 @@ VantComponent({
|
||||
},
|
||||
|
||||
startUpload() {
|
||||
const { maxCount, multiple, accept, lists, disabled } = this.data;
|
||||
const { maxCount, multiple, lists, disabled } = this.data;
|
||||
|
||||
if (disabled) return;
|
||||
|
||||
@ -101,8 +99,6 @@ VantComponent({
|
||||
maxCount: maxCount - lists.length,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
|
||||
this.onBeforeRead(multiple ? res : res[0]);
|
||||
})
|
||||
.catch((error) => {
|
||||
@ -110,7 +106,7 @@ VantComponent({
|
||||
});
|
||||
},
|
||||
|
||||
onBeforeRead(file) {
|
||||
onBeforeRead(file: File) {
|
||||
const { beforeRead, useBeforeRead } = this.data;
|
||||
let res: boolean | Promise<void> = true;
|
||||
|
||||
@ -172,7 +168,7 @@ VantComponent({
|
||||
if (!this.data.previewFullImage) return;
|
||||
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const { lists } = this.data;
|
||||
const { lists } = this.data as { lists: File[] };
|
||||
const item = lists[index];
|
||||
|
||||
wx.previewImage({
|
||||
@ -187,7 +183,7 @@ VantComponent({
|
||||
onPreviewVideo(event) {
|
||||
if (!this.data.previewFullImage) return;
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const { lists } = this.data;
|
||||
const { lists } = this.data as { lists: File[] };
|
||||
|
||||
wx.previewMedia({
|
||||
sources: lists
|
||||
@ -205,7 +201,7 @@ VantComponent({
|
||||
|
||||
onClickPreview(event) {
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const item = this.data.lists[index];
|
||||
const item: File = this.data.lists[index];
|
||||
|
||||
this.$emit('click-preview', {
|
||||
...item,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { pickExclude } from '../common/utils';
|
||||
import { isImageUrl, isVideoUrl } from '../common/validator';
|
||||
|
||||
interface File {
|
||||
export interface File {
|
||||
url: string; // 上传临时地址
|
||||
size?: number; // 上传大小
|
||||
name?: string;
|
||||
@ -83,7 +83,7 @@ function formatFile(
|
||||
return res.tempFiles.map((item) => ({
|
||||
...pickExclude(item, ['path']),
|
||||
url: item.path,
|
||||
}));
|
||||
})) as File[];
|
||||
}
|
||||
|
||||
export function chooseFile({
|
||||
@ -96,7 +96,7 @@ export function chooseFile({
|
||||
camera,
|
||||
maxCount,
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise<File | File[]>((resolve, reject) => {
|
||||
switch (accept) {
|
||||
case 'image':
|
||||
wx.chooseImage({
|
||||
|
@ -7,7 +7,7 @@
|
||||
"noImplicitAny": false,
|
||||
"outDir": "dist",
|
||||
"baseUrl": ".",
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"paths": {
|
||||
"definitions/*": ["./packages/definitions/*"],
|
||||
"packages/*": ["./packages/*"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user