【升级】升级uView前端UI框架到2.0.36版本。

This commit is contained in:
jianweie
2023-05-16 16:01:08 +08:00
parent 9624e09b65
commit 614bfde50f
7 changed files with 76 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020 www.uviewui.com Copyright (c) 2023 www.uviewui.com
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,3 +1,8 @@
## 2.0.362023-03-27
# uView2.0重磅发布,利剑出鞘,一统江湖
1. 重构`deepClone` & `deepMerge`方法
2. 其他优化
## 2.0.342022-09-24 ## 2.0.342022-09-24
# uView2.0重磅发布,利剑出鞘,一统江湖 # uView2.0重磅发布,利剑出鞘,一统江湖

View File

@@ -114,7 +114,7 @@
* @event {Function} confirm 点击确认按钮时触发 * @event {Function} confirm 点击确认按钮时触发
* @event {Function} cancel 点击取消按钮时触发 * @event {Function} cancel 点击取消按钮时触发
* @event {Function} close 点击遮罩关闭出发closeOnClickOverlay为true有效 * @event {Function} close 点击遮罩关闭出发closeOnClickOverlay为true有效
* @example <u-loadmore :status="status" icon-type="iconType" load-text="loadText" /> * @example <u-modal :show="true" title="title" content="content"></u-modal>
*/ */
export default { export default {
name: 'u-modal', name: 'u-modal',

View File

@@ -83,7 +83,7 @@ export default {
}, },
// 文字装饰,下划线,中划线等,可选值 none|underline|line-through // 文字装饰,下划线,中划线等,可选值 none|underline|line-through
decoration: { decoration: {
tepe: String, type: String,
default: uni.$u.props.text.decoration default: uni.$u.props.text.decoration
}, },
// 外边距,对象、字符串,数值形式均可 // 外边距,对象、字符串,数值形式均可

View File

@@ -1,5 +1,5 @@
// 此版本发布于2022-00-24 // 此版本发布于2023-03-27
const version = '2.0.34' const version = '2.0.36'
// 开发环境才提示,生产环境不会提示 // 开发环境才提示,生产环境不会提示
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {

View File

@@ -179,22 +179,34 @@ function addUnit(value = 'auto', unit = uni?.$u?.config?.unit ?? 'px') {
/** /**
* @description 深度克隆 * @description 深度克隆
* @param {object} obj 需要深度克隆的对象 * @param {object} obj 需要深度克隆的对象
* @param cache 缓存
* @returns {*} 克隆后的对象或者原值(不是对象) * @returns {*} 克隆后的对象或者原值(不是对象)
*/ */
function deepClone(obj) { function deepClone(obj, cache = new WeakMap()) {
// 对常见的“非”值,直接返回原来值 if (obj === null || typeof obj !== 'object') return obj;
if ([null, undefined, NaN, false].includes(obj)) return obj if (cache.has(obj)) return cache.get(obj);
if (typeof obj !== 'object' && typeof obj !== 'function') { let clone;
// 原始类型直接返回 if (obj instanceof Date) {
return obj clone = new Date(obj.getTime());
} else if (obj instanceof RegExp) {
clone = new RegExp(obj);
} else if (obj instanceof Map) {
clone = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)]));
} else if (obj instanceof Set) {
clone = new Set(Array.from(obj, value => deepClone(value, cache)));
} else if (Array.isArray(obj)) {
clone = obj.map(value => deepClone(value, cache));
} else if (Object.prototype.toString.call(obj) === '[object Object]') {
clone = Object.create(Object.getPrototypeOf(obj));
cache.set(obj, clone);
for (const [key, value] of Object.entries(obj)) {
clone[key] = deepClone(value, cache);
} }
const o = test.array(obj) ? [] : {} } else {
for (const i in obj) { clone = Object.assign({}, obj);
if (obj.hasOwnProperty(i)) {
o[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i]
} }
} cache.set(obj, clone);
return o return clone;
} }
/** /**
@@ -205,24 +217,27 @@ function deepClone(obj) {
*/ */
function deepMerge(target = {}, source = {}) { function deepMerge(target = {}, source = {}) {
target = deepClone(target) target = deepClone(target)
if (typeof target !== 'object' || typeof source !== 'object') return false if (typeof target !== 'object' || target === null || typeof source !== 'object' || source === null) return target;
const merged = Array.isArray(target) ? target.slice() : Object.assign({}, target);
for (const prop in source) { for (const prop in source) {
if (!source.hasOwnProperty(prop)) continue if (!source.hasOwnProperty(prop)) continue;
if (prop in target) { const sourceValue = source[prop];
if (typeof target[prop] !== 'object') { const targetValue = merged[prop];
target[prop] = source[prop] if (sourceValue instanceof Date) {
} else if (typeof source[prop] !== 'object') { merged[prop] = new Date(sourceValue);
target[prop] = source[prop] } else if (sourceValue instanceof RegExp) {
} else if (target[prop].concat && source[prop].concat) { merged[prop] = new RegExp(sourceValue);
target[prop] = target[prop].concat(source[prop]) } else if (sourceValue instanceof Map) {
merged[prop] = new Map(sourceValue);
} else if (sourceValue instanceof Set) {
merged[prop] = new Set(sourceValue);
} else if (typeof sourceValue === 'object' && sourceValue !== null) {
merged[prop] = deepMerge(targetValue, sourceValue);
} else { } else {
target[prop] = deepMerge(target[prop], source[prop]) merged[prop] = sourceValue;
}
} else {
target[prop] = source[prop]
} }
} }
return target return merged;
} }
/** /**
@@ -650,6 +665,16 @@ function pages() {
return pages return pages
} }
/**
* 获取页面历史栈指定层实例
* @param back {number} [0] - 0或者负数表示获取历史栈的哪一层0表示获取当前页面实例-1 表示获取上一个页面实例。默认0。
*/
function getHistoryPage(back = 0) {
const pages = getCurrentPages()
const len = pages.length
return pages[len - 1 + back]
}
/** /**
* @description 修改uView内置属性值 * @description 修改uView内置属性值
* @param {object} props 修改内置props属性 * @param {object} props 修改内置props属性
@@ -701,5 +726,6 @@ export default {
setProperty, setProperty,
page, page,
pages, pages,
getHistoryPage,
setConfig setConfig
} }

View File

@@ -2,7 +2,7 @@
"id": "uview-ui", "id": "uview-ui",
"name": "uview-ui", "name": "uview-ui",
"displayName": "uView2.0重磅发布,利剑出鞘,一统江湖", "displayName": "uView2.0重磅发布,利剑出鞘,一统江湖",
"version": "2.0.35", "version": "2.0.36",
"description": "uView UI已完美兼容nvue全面的组件和便捷的工具会让您信手拈来如鱼得水", "description": "uView UI已完美兼容nvue全面的组件和便捷的工具会让您信手拈来如鱼得水",
"keywords": [ "keywords": [
"uview", "uview",
@@ -18,10 +18,6 @@
"HBuilderX": "^3.1.0" "HBuilderX": "^3.1.0"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/uview-ui" "npmurl": "https://www.npmjs.com/package/uview-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [], "dependencies": [],