stellar-ui-v2 1.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
package/utils/Color.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const rgbReg = /^rgb\(\s?(\d{1,3})\s?\,\s?(\d{1,3})\s?\,\s?(\d{1,3})\s?\)/;
|
|
2
|
+
const rgbaReg = /^rgba\(\s?(\d{1,3}\s?\,\s?\d{1,3}\s?\,\s?\d{1,3})\s?\,\s?([\d\.]+)\s?\)/;
|
|
3
|
+
const hexReg = /^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
4
|
+
const hexaReg = /^\#([0-9a-fA-F]{4}|[0-9a-fA-F]{8})$/;
|
|
5
|
+
|
|
6
|
+
class Color {
|
|
7
|
+
static hex2rgba(hex, a = 1) {
|
|
8
|
+
const str = hex.toLowerCase()
|
|
9
|
+
const result = [];
|
|
10
|
+
let sColor = str.replace(hexReg, "$1");
|
|
11
|
+
if (sColor.length === 3) {
|
|
12
|
+
sColor = sColor.split("").map(s => s + s).join("");
|
|
13
|
+
}
|
|
14
|
+
for (let i = 0; i < 6; i += 2) {
|
|
15
|
+
result.push(parseInt(sColor.slice(i, i + 2), 16))
|
|
16
|
+
}
|
|
17
|
+
return `rgba(${result.join(",")},${a})`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static hexa2rgba(hexa, a) {
|
|
21
|
+
const str = hexa.toLowerCase();
|
|
22
|
+
const result = []
|
|
23
|
+
|
|
24
|
+
let sColor = str.replace(hexaReg, "$1");
|
|
25
|
+
if (sColor.length === 4) {
|
|
26
|
+
sColor = sColor.split("").map(s => s + s).join("");
|
|
27
|
+
}
|
|
28
|
+
for (let i = 0; i < 6; i += 2) {
|
|
29
|
+
result.push(parseInt(sColor.slice(i, i + 2), 16))
|
|
30
|
+
}
|
|
31
|
+
const _a = a ? a : Number(parseInt(sColor.slice(6, 8), 16) / 255).toFixed(2)
|
|
32
|
+
return `rgba(${result.join(",")},${ _a})`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static rgb2rgba(rgb, a = 1) {
|
|
36
|
+
const result = [];
|
|
37
|
+
for (let i = 1; i <= 3; i++) {
|
|
38
|
+
result.push(rgb.replace(rgbReg, `$${i}`))
|
|
39
|
+
}
|
|
40
|
+
return `rgba(${result.join(",")},${a})`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static setRgbaDiaphaneity(rgba, a) {
|
|
44
|
+
const _rgb = rgba.replace(rgbaReg, "$1")
|
|
45
|
+
const _a = a ? a : rgba.replace(rgbaReg, "$2")
|
|
46
|
+
return `rgba(${_rgb},${_a})`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static formatColor(color, a) {
|
|
50
|
+
if (hexReg.test(color)) {
|
|
51
|
+
return Color.hex2rgba(color, a);
|
|
52
|
+
}
|
|
53
|
+
if (hexaReg.test(color)) {
|
|
54
|
+
return Color.hexa2rgba(color, a)
|
|
55
|
+
}
|
|
56
|
+
if (rgbReg.test(color)) {
|
|
57
|
+
return Color.rgb2rgba(color, a)
|
|
58
|
+
}
|
|
59
|
+
if (rgbaReg.test(color) && a) {
|
|
60
|
+
return Color.setRgbaDiaphaneity(color, a)
|
|
61
|
+
}
|
|
62
|
+
return color;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default Color;
|
package/utils/System.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export default class System {
|
|
2
|
+
/**
|
|
3
|
+
* 获取设备设置
|
|
4
|
+
*/
|
|
5
|
+
static getSystemSetting() {
|
|
6
|
+
// #ifdef MP-WEIXIN
|
|
7
|
+
return wx.getSystemSetting();
|
|
8
|
+
// #endif
|
|
9
|
+
|
|
10
|
+
// #ifndef MP-WEIXIN
|
|
11
|
+
return uni.getSystemInfoSync();
|
|
12
|
+
// #endif
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 获取微信APP授权设置
|
|
16
|
+
*/
|
|
17
|
+
static getAppAuthorizeSetting() {
|
|
18
|
+
// #ifdef MP-WEIXIN
|
|
19
|
+
return wx.getAppAuthorizeSetting();
|
|
20
|
+
// #endif
|
|
21
|
+
|
|
22
|
+
// #ifndef MP-WEIXIN
|
|
23
|
+
return uni.getSystemInfoSync();
|
|
24
|
+
// #endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 获取设备基础信息
|
|
29
|
+
*/
|
|
30
|
+
static getDeviceInfo() {
|
|
31
|
+
// #ifdef MP-WEIXIN
|
|
32
|
+
return wx.getDeviceInfo();
|
|
33
|
+
// #endif
|
|
34
|
+
|
|
35
|
+
// #ifndef MP-WEIXIN
|
|
36
|
+
return uni.getSystemInfoSync();
|
|
37
|
+
// #endif
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 获取窗口信息
|
|
42
|
+
*/
|
|
43
|
+
static getWindowInfo() {
|
|
44
|
+
// #ifdef MP-WEIXIN
|
|
45
|
+
let windowInfo = wx.getWindowInfo();
|
|
46
|
+
windowInfo.safeAreaInsets = {
|
|
47
|
+
bottom: windowInfo.screenHeight - windowInfo.safeArea.bottom,
|
|
48
|
+
};
|
|
49
|
+
return windowInfo;
|
|
50
|
+
// #endif
|
|
51
|
+
|
|
52
|
+
// #ifndef MP-WEIXIN
|
|
53
|
+
return uni.getSystemInfoSync();
|
|
54
|
+
// #endif
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 获取微信APP基础信息
|
|
59
|
+
*/
|
|
60
|
+
static getAppBaseInfo() {
|
|
61
|
+
// #ifdef MP-WEIXIN
|
|
62
|
+
return wx.getAppBaseInfo();
|
|
63
|
+
// #endif
|
|
64
|
+
|
|
65
|
+
// #ifndef MP-WEIXIN
|
|
66
|
+
return uni.getSystemInfoSync();
|
|
67
|
+
// #endif
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 获取屏幕宽度
|
|
72
|
+
*/
|
|
73
|
+
static getWindowWidth() {
|
|
74
|
+
return System.getWindowInfo().windowWidth;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 获取屏幕高度
|
|
79
|
+
*/
|
|
80
|
+
static getWindowHeight() {
|
|
81
|
+
return System.getWindowInfo().windowHeight;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 获取手机顶部安全区域距离顶部的距离(状态栏高度)
|
|
86
|
+
*/
|
|
87
|
+
static getStatusBarHeight() {
|
|
88
|
+
return System.getWindowInfo().statusBarHeight;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 获取导航栏底部安全区域距离底部的距离(底部安全区距离状态栏的距离)
|
|
93
|
+
*/
|
|
94
|
+
static getNavbarBottom() {
|
|
95
|
+
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
|
96
|
+
return menuButtonInfo.bottom + 8;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static getElementBoundary(el) {
|
|
100
|
+
const vw = System.getWindowWidth(); // 计算vw单位
|
|
101
|
+
const vh = System.getWindowHeight(); // 计算vh单位
|
|
102
|
+
const { top = 0, left = 0, bottom = 0, right = 0 } = el;
|
|
103
|
+
return {
|
|
104
|
+
top: top,
|
|
105
|
+
left: left,
|
|
106
|
+
bottom: vh - bottom,
|
|
107
|
+
right: vw - right,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
package/utils/mixin.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 父组件混入对象
|
|
3
|
+
* @param {String} name 父组件名称
|
|
4
|
+
*/
|
|
5
|
+
export function parentMixin(name) {
|
|
6
|
+
return {
|
|
7
|
+
provide() {
|
|
8
|
+
return {
|
|
9
|
+
[name]: {
|
|
10
|
+
getParent: () => this
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
data() {
|
|
15
|
+
return {
|
|
16
|
+
children: [],
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 子组件混入对象
|
|
24
|
+
* @param {String} parentName 父组件名称
|
|
25
|
+
*/
|
|
26
|
+
export function childMixin(parentName) {
|
|
27
|
+
return {
|
|
28
|
+
options: {
|
|
29
|
+
virtualHost: true,
|
|
30
|
+
},
|
|
31
|
+
inject: {
|
|
32
|
+
[parentName]: {
|
|
33
|
+
value: parentName,
|
|
34
|
+
default: null
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
parent: {},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
created() {
|
|
43
|
+
this.parent = this[parentName]?.getParent();
|
|
44
|
+
this.getParentData();
|
|
45
|
+
},
|
|
46
|
+
beforeDestroy() {
|
|
47
|
+
// 判断当前页面是否存在parent和chldren,一般在checkbox和checkbox-group父子联动的场景会有此情况
|
|
48
|
+
// 组件销毁时,移除子组件在父组件children数组中的实例,释放资源,避免数据混乱
|
|
49
|
+
if (this.parent && Array.isArray(this.parent.children)) {
|
|
50
|
+
// 组件销毁时,移除父组件中的children数组中对应的实例
|
|
51
|
+
this.parent.children.map((child, index) => {
|
|
52
|
+
// 如果相等,则移除
|
|
53
|
+
if (child === this) {
|
|
54
|
+
this.parent.children.splice(index, 1);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
getParentData() {
|
|
61
|
+
if (this.parent?.children && this.parent.children.indexOf(this) === -1) {
|
|
62
|
+
this.parent.children.push(this);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|