This commit is contained in:
2026-03-25 14:54:15 +08:00
commit ab4646b43a
827 changed files with 123812 additions and 0 deletions
@@ -0,0 +1,6 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_config_themeTokens = require("./theme-tokens.js");
const color = common_vendor.reactive({ ...uni_modules_uviewPro_libs_config_themeTokens.lightPalette });
exports.color = color;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/config/color.js.map
@@ -0,0 +1,17 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const version = "0.5.9";
const config = common_vendor.reactive({
v: version,
version,
// 主题名称
type: ["primary", "success", "info", "error", "warning"],
// 默认为官方主题名称
defaultTheme: "uviewpro",
// 默认为亮色模式
defaultDarkMode: "light",
// 默认为中文
defaultLocale: "zh-CN"
});
exports.config = config;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/config/config.js.map
@@ -0,0 +1,100 @@
"use strict";
const uni_modules_uviewPro_libs_config_config = require("./config.js");
const lightPalette = {
primary: "#2979ff",
primaryDark: "#2b85e4",
primaryDisabled: "#a0cfff",
primaryLight: "#ecf5ff",
success: "#19be6b",
successDark: "#18b566",
successDisabled: "#71d5a1",
successLight: "#dbf1e1",
warning: "#ff9900",
warningDark: "#f29100",
warningDisabled: "#fcbd71",
warningLight: "#fdf6ec",
error: "#fa3534",
errorDark: "#dd6161",
errorDisabled: "#fab6b6",
errorLight: "#fef0f0",
info: "#909399",
infoDark: "#82848a",
infoDisabled: "#c8c9cc",
infoLight: "#f4f4f5",
whiteColor: "#ffffff",
blackColor: "#000000",
mainColor: "#303133",
contentColor: "#606266",
tipsColor: "#909399",
lightColor: "#c0c4cc",
borderColor: "#dcdfe6",
dividerColor: "#e4e7ed",
maskColor: "rgba(0, 0, 0, 0.4)",
shadowColor: "rgba(0, 0, 0, 0.1)",
bgColor: "#f3f4f6",
bgWhite: "#ffffff",
bgGrayLight: "#f1f1f1",
bgGrayDark: "#2f343c",
bgBlack: "#000000"
};
const darkPalette = {
primary: "#8ab4ff",
primaryDark: "#5f8dff",
primaryDisabled: "#3d4f74",
primaryLight: "#1d273f",
success: "#4ade80",
successDark: "#1f9d57",
successDisabled: "#2f4d3d",
successLight: "#10291f",
warning: "#fbbf24",
warningDark: "#c88f00",
warningDisabled: "#4a3b17",
warningLight: "#2b1f05",
error: "#ff6b6b",
errorDark: "#d83a3a",
errorDisabled: "#4f2323",
errorLight: "#2d1414",
info: "#a0a7b8",
infoDark: "#7c8394",
infoDisabled: "#3b3f4c",
infoLight: "#1d2029",
whiteColor: "#f5f6f7",
blackColor: "#f5f6f7",
mainColor: "#f5f6f7",
contentColor: "#cfd3dc",
tipsColor: "#9aa1af",
lightColor: "#6b7082",
borderColor: "#3a4251",
dividerColor: "#3a4251",
maskColor: "rgba(0, 0, 0, 0.6)",
shadowColor: "rgba(0, 0, 0, 0.3)",
bgColor: "#111827",
bgWhite: "#000000",
bgGrayLight: "#1a1a1a",
bgGrayDark: "#f5f7fa",
bgBlack: "#ffffff"
};
const lightCss = {
"--u-background": "#ffffff",
"--u-surface": "#f7f8fa",
"--u-text": "#303133"
};
const darkCss = {
"--u-background": "#0f1115",
"--u-surface": "#1c2233",
"--u-text": "#f5f6f7"
};
const defaultThemes = [
{
name: uni_modules_uviewPro_libs_config_config.config.defaultTheme,
label: "默认蓝",
description: "uView Pro 默认主题,支持亮色与暗黑模式",
color: lightPalette,
darkColor: darkPalette,
css: lightCss,
darkCss
}
];
exports.defaultThemes = defaultThemes;
exports.lightPalette = lightPalette;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/config/theme-tokens.js.map
@@ -0,0 +1,15 @@
"use strict";
const zIndex = {
toast: 10090,
noNetwork: 10080,
// popup包含popupactionSheetkeyboardpicker的值
popup: 10075,
mask: 10070,
navbar: 980,
topTips: 975,
sticky: 970,
indexListSticky: 965,
tabbar: 998
};
exports.zIndex = zIndex;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/config/zIndex.js.map
@@ -0,0 +1,19 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
function $parent(componentName, _instance = null) {
var _a;
const instance = _instance || common_vendor.getCurrentInstance();
let parent = instance && instance.parent;
if (!componentName)
return parent;
while (parent) {
const name = (_a = parent.type) == null ? void 0 : _a.name;
if (name === componentName) {
return parent;
}
parent = parent.parent;
}
return null;
}
exports.$parent = $parent;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/_parent.js.map
@@ -0,0 +1,21 @@
"use strict";
const uni_modules_uviewPro_libs_function_test = require("./test.js");
function addUnit(value = "auto", unit = "rpx") {
const strValue = String(value);
if (!strValue)
return "";
if (strValue === "auto")
return strValue;
if (strValue.includes(" ")) {
return strValue.split(" ").map((s) => {
if (s === "auto" || /^-?\d*\.?\d+(%|px|rpx|em|rem|vh|vw)$/.test(s))
return s;
return uni_modules_uviewPro_libs_function_test.test.number(s) ? `${s}${unit}` : s;
}).join(" ");
}
if (/^-?\d*\.?\d+(%|px|rpx|em|rem|vh|vw)$/.test(strValue))
return strValue;
return uni_modules_uviewPro_libs_function_test.test.number(strValue) ? `${strValue}${unit}` : strValue;
}
exports.addUnit = addUnit;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/addUnit.js.map
@@ -0,0 +1,22 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
function UniCopy(text, config) {
const opt = Object.assign({ data: text }, config);
common_vendor.index.setClipboardData(opt);
}
function clipboard(content, options) {
const text = String(content);
const defaultOpt = {
showToast: true,
success: () => {
},
fail: () => {
},
complete: () => {
}
};
const config = Object.assign(defaultOpt, options);
UniCopy(text, config);
}
exports.clipboard = clipboard;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/clipboard.js.map
@@ -0,0 +1,18 @@
"use strict";
const uni_modules_uviewPro_libs_config_color = require("../config/color.js");
const uni_modules_uviewPro_libs_config_themeTokens = require("../config/theme-tokens.js");
const uni_modules_uviewPro_libs_util_configProvider = require("../util/config-provider.js");
function getColor(name) {
if (uni_modules_uviewPro_libs_config_color.color[name]) {
return uni_modules_uviewPro_libs_config_color.color[name];
}
return uni_modules_uviewPro_libs_config_themeTokens.lightPalette[name] || "";
}
function setColor(theme) {
if (theme) {
uni_modules_uviewPro_libs_util_configProvider.configProvider.setThemeColor(theme);
}
}
exports.getColor = getColor;
exports.setColor = setColor;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/color.js.map
@@ -0,0 +1,106 @@
"use strict";
function colorGradient(startColor = "rgb(0, 0, 0)", endColor = "rgb(255, 255, 255)", step = 10) {
const startRGB = hexToRgb(startColor, false);
const [startR, startG, startB] = startRGB;
const endRGB = hexToRgb(endColor, false);
const [endR, endG, endB] = endRGB;
const sR = (endR - startR) / step;
const sG = (endG - startG) / step;
const sB = (endB - startB) / step;
const colorArr = [];
for (let i = 0; i < step; i++) {
const hex = rgbToHex(
`rgb(${Math.round(sR * i + startR)},${Math.round(sG * i + startG)},${Math.round(sB * i + startB)})`
);
colorArr.push(hex);
}
return colorArr;
}
function hexToRgb(sColor, str = true) {
const reg = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
sColor = sColor.toLowerCase();
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
let sColorNew = "#";
for (let i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
}
sColor = sColorNew;
}
const sColorChange = [
parseInt("0x" + sColor.slice(1, 3)),
parseInt("0x" + sColor.slice(3, 5)),
parseInt("0x" + sColor.slice(5, 7))
];
if (!str) {
return sColorChange;
} else {
return `rgb(${sColorChange[0]},${sColorChange[1]},${sColorChange[2]})`;
}
} else if (/^(rgb|RGB)/.test(sColor)) {
const arr = sColor.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
return arr.map((val) => Number(val));
} else {
return sColor;
}
}
function rgbToHex(rgb) {
const reg = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
if (/^(rgb|RGB)/.test(rgb)) {
const aColor = rgb.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
let strHex = "#";
for (let i = 0; i < aColor.length; i++) {
let hex = Number(aColor[i]).toString(16);
hex = hex.length == 1 ? "0" + hex : hex;
strHex += hex;
}
if (strHex.length !== 7) {
strHex = rgb;
}
return strHex;
} else if (reg.test(rgb)) {
const aNum = rgb.replace(/#/, "").split("");
if (aNum.length === 6) {
return rgb;
} else if (aNum.length === 3) {
let numHex = "#";
for (let i = 0; i < aNum.length; i += 1) {
numHex += aNum[i] + aNum[i];
}
return numHex;
}
} else {
return rgb;
}
return rgb;
}
function colorToRgba(color, alpha = 0.3) {
color = rgbToHex(color);
const reg = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
let sColor = color.toLowerCase();
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
let sColorNew = "#";
for (let i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
}
sColor = sColorNew;
}
const sColorChange = [
parseInt("0x" + sColor.slice(1, 3)),
parseInt("0x" + sColor.slice(3, 5)),
parseInt("0x" + sColor.slice(5, 7))
];
return `rgba(${sColorChange.join(",")},${alpha})`;
} else {
return sColor;
}
}
const colorGradients = {
colorGradient,
hexToRgb,
rgbToHex,
colorToRgba
};
exports.colorGradients = colorGradients;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/colorGradient.js.map
@@ -0,0 +1,20 @@
"use strict";
let timeout = null;
function debounce(func, wait = 500, immediate = false) {
if (timeout !== null)
clearTimeout(timeout);
if (immediate) {
const callNow = !timeout;
timeout = setTimeout(() => {
timeout = null;
}, wait);
if (callNow)
typeof func === "function" && func();
} else {
timeout = setTimeout(() => {
typeof func === "function" && func();
}, wait);
}
}
exports.debounce = debounce;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/debounce.js.map
@@ -0,0 +1,31 @@
"use strict";
function deepClone(obj, cache = /* @__PURE__ */ new WeakMap()) {
if (obj === null || typeof obj !== "object")
return obj;
if (cache.has(obj))
return cache.get(obj);
let clone;
if (obj instanceof Date) {
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);
}
} else {
clone = Object.assign({}, obj);
}
cache.set(obj, clone);
return clone;
}
exports.deepClone = deepClone;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/deepClone.js.map
@@ -0,0 +1,30 @@
"use strict";
const uni_modules_uviewPro_libs_function_deepClone = require("./deepClone.js");
function deepMerge(target = {}, source = {}) {
target = uni_modules_uviewPro_libs_function_deepClone.deepClone(target);
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) {
if (!Object.prototype.hasOwnProperty.call(source, prop))
continue;
const sourceValue = source[prop];
const targetValue = merged[prop];
if (sourceValue instanceof Date) {
merged[prop] = new Date(sourceValue);
} else if (sourceValue instanceof RegExp) {
merged[prop] = new RegExp(sourceValue);
} 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 {
merged[prop] = sourceValue;
}
}
return merged;
}
exports.deepMerge = deepMerge;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/deepMerge.js.map
@@ -0,0 +1,39 @@
"use strict";
function getParent(name, keys) {
var _a;
let parent = this.$parent;
while (parent) {
if (((_a = parent.$options) == null ? void 0 : _a.name) !== name) {
parent = parent.$parent;
} else {
const data = {};
if (Array.isArray(keys)) {
keys.forEach((val) => {
data[val] = (parent == null ? void 0 : parent[val]) ? parent[val] : "";
});
} else {
for (const i in keys) {
if (Array.isArray(keys[i])) {
if (keys[i].length) {
data[i] = keys[i];
} else {
data[i] = parent[i];
}
} else if (keys[i] && keys[i].constructor === Object) {
if (Object.keys(keys[i]).length) {
data[i] = keys[i];
} else {
data[i] = parent[i];
}
} else {
data[i] = keys[i] || keys[i] === false ? keys[i] : parent[i];
}
}
}
return data;
}
}
return {};
}
exports.getParent = getParent;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/getParent.js.map
@@ -0,0 +1,17 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
function getRect(selector, _instance = null, all = false) {
const instance = _instance || common_vendor.getCurrentInstance();
return new Promise((resolve) => {
common_vendor.index.createSelectorQuery().in(instance == null ? void 0 : instance.proxy)[all ? "selectAll" : "select"](selector).boundingClientRect((rect) => {
if (all && Array.isArray(rect) && rect.length) {
resolve(rect);
}
if (!all && rect) {
resolve(rect);
}
}).exec();
});
}
exports.getRect = getRect;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/getRect.js.map
@@ -0,0 +1,28 @@
"use strict";
function guid(len = 32, firstU = true, radix) {
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
const uuid = [];
const base = radix || chars.length;
if (len) {
for (let i = 0; i < len; i++)
uuid[i] = chars[0 | Math.random() * base];
} else {
let r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
uuid[14] = "4";
for (let i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[i == 19 ? r & 3 | 8 : r];
}
}
}
if (firstU) {
uuid.shift();
return "u" + uuid.join("");
} else {
return uuid.join("");
}
}
exports.guid = guid;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/guid.js.map
@@ -0,0 +1,48 @@
"use strict";
function queryParams(data = {}, isPrefix = true, arrayFormat = "brackets") {
const prefix = isPrefix ? "?" : "";
const _result = [];
if (!["indices", "brackets", "repeat", "comma"].includes(arrayFormat))
arrayFormat = "brackets";
for (const key in data) {
const value = data[key];
if (["", void 0, null].includes(value)) {
continue;
}
if (Array.isArray(value)) {
switch (arrayFormat) {
case "indices":
for (let i = 0; i < value.length; i++) {
_result.push(`${key}[${i}]=${value[i]}`);
}
break;
case "brackets":
value.forEach((_value) => {
_result.push(`${key}[]=${_value}`);
});
break;
case "repeat":
value.forEach((_value) => {
_result.push(`${key}=${_value}`);
});
break;
case "comma":
let commaStr = "";
value.forEach((_value) => {
commaStr += (commaStr ? "," : "") + _value;
});
_result.push(`${key}=${commaStr}`);
break;
default:
value.forEach((_value) => {
_result.push(`${key}[]=${_value}`);
});
}
} else {
_result.push(`${key}=${value}`);
}
}
return _result.length ? prefix + _result.join("&") : "";
}
exports.queryParams = queryParams;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/queryParams.js.map
@@ -0,0 +1,11 @@
"use strict";
function random(min, max) {
if (min >= 0 && max > 0 && max >= min) {
const gab = max - min + 1;
return Math.floor(Math.random() * gab + min);
} else {
return 0;
}
}
exports.random = random;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/random.js.map
@@ -0,0 +1,6 @@
"use strict";
function randomArray(array = []) {
return array.sort(() => Math.random() - 0.5);
}
exports.randomArray = randomArray;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/randomArray.js.map
@@ -0,0 +1,88 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
class Router {
// route: (options?: string | RouterConfig, params?: Record<string, any>) => Promise<void>;
constructor() {
this.config = {
type: "navigateTo",
url: "",
delta: 1,
// navigateBack页面后退时,回退的层数
params: {},
// 传递的参数
animationType: "pop-in",
// 窗口动画,只在APP有效
animationDuration: 300,
// 窗口动画持续时间,单位毫秒,只在APP有效
intercept: false
// 是否需要拦截
};
this.route = this.route.bind(this);
}
// 判断url前面是否有"/",如果没有则加上,否则无法跳转
addRootPath(url) {
return url[0] === "/" ? url : `/${url}`;
}
// 整合路由参数
mixinParam(url, params) {
url = url && this.addRootPath(url);
let query = "";
if (/.*\/.*\?.*=.*/.test(url)) {
query = common_vendor.index.$u.queryParams(params, false);
return url + "&" + query;
} else {
query = common_vendor.index.$u.queryParams(params);
return url + query;
}
}
/**
* 路由跳转主方法
* @param options 跳转配置或url字符串
* @param params 跳转参数
*/
async route(options = {}, params = {}) {
let mergeConfig = {};
if (typeof options === "string") {
mergeConfig.url = this.mixinParam(options, params);
mergeConfig.type = "navigateTo";
} else {
mergeConfig = common_vendor.index.$u.deepMerge(this.config, options);
mergeConfig.url = this.mixinParam(options.url || "", options.params || {});
}
if (params.intercept) {
this.config.intercept = params.intercept;
}
mergeConfig.params = params;
mergeConfig = common_vendor.index.$u.deepMerge(this.config, mergeConfig);
if (common_vendor.index.$u.routeIntercept && typeof common_vendor.index.$u.routeIntercept === "function") {
const isNext = await new Promise((resolve) => {
common_vendor.index.$u.routeIntercept(mergeConfig, resolve);
});
isNext && this.openPage(mergeConfig);
} else {
this.openPage(mergeConfig);
}
}
// 执行路由跳转
openPage(config) {
const { url = "", type = "", delta = 1, animationDuration = 300 } = config;
if (type == "navigateTo" || type == "to") {
common_vendor.index.navigateTo({ url, animationDuration });
}
if (type == "redirectTo" || type == "redirect") {
common_vendor.index.redirectTo({ url });
}
if (type == "switchTab" || type == "tab") {
common_vendor.index.switchTab({ url });
}
if (type == "reLaunch" || type == "launch") {
common_vendor.index.reLaunch({ url });
}
if (type == "navigateBack" || type == "back") {
common_vendor.index.navigateBack({ delta });
}
}
}
const route = new Router().route;
exports.route = route;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/route.js.map
@@ -0,0 +1,11 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
function os() {
return common_vendor.index.getSystemInfoSync().platform;
}
function sys() {
return common_vendor.index.getSystemInfoSync();
}
exports.os = os;
exports.sys = sys;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/sys.js.map
@@ -0,0 +1,173 @@
"use strict";
function email(value) {
return /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/.test(
value
);
}
function mobile(value) {
return /^1[3-9]\d{9}$/.test(value);
}
function url(value) {
return /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.test(value);
}
function date(value) {
return !/Invalid|NaN/.test(new Date(value).toString());
}
function dateISO(value) {
return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value);
}
function number(value) {
return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value);
}
function digits(value) {
return /^\d+$/.test(value);
}
function idCard(value) {
return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value);
}
function carNo(value) {
const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
if (value.length === 7) {
return creg.test(value);
} else if (value.length === 8) {
return xreg.test(value);
} else {
return false;
}
}
function amount(value) {
return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value);
}
function chinese(value) {
let reg = /^[\u4e00-\u9fa5]+$/gi;
return reg.test(value);
}
function letter(value) {
return /^[a-zA-Z]*$/.test(value);
}
function enOrNum(value) {
let reg = /^[0-9a-zA-Z]*$/g;
return reg.test(value);
}
function contains(value, param) {
return value.indexOf(param) >= 0;
}
function range(value, param) {
return value >= param[0] && value <= param[1];
}
function rangeLength(value, param) {
return value.length >= param[0] && value.length <= param[1];
}
function landline(value) {
let reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/;
return reg.test(value);
}
function empty(value) {
switch (typeof value) {
case "undefined":
return true;
case "string":
if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, "").length == 0)
return true;
break;
case "boolean":
if (!value)
return true;
break;
case "number":
if (0 === value || isNaN(value))
return true;
break;
case "object":
if (null === value || value.length === 0)
return true;
for (var i in value) {
return false;
}
return true;
}
return false;
}
function jsonString(value) {
if (typeof value == "string") {
try {
var obj = JSON.parse(value);
if (typeof obj == "object" && obj) {
return true;
} else {
return false;
}
} catch (e) {
return false;
}
}
return false;
}
function array(value) {
if (typeof Array.isArray === "function") {
return Array.isArray(value);
} else {
return Object.prototype.toString.call(value) === "[object Array]";
}
}
function object(value) {
return Object.prototype.toString.call(value) === "[object Object]";
}
function code(value, len = 6) {
return new RegExp(`^\\d{${len}}$`).test(value);
}
function func(value) {
return typeof value === "function";
}
function promise(value) {
return object(value) && func(value.then) && func(value.catch);
}
function image(value) {
const newValue = value.split("?")[0];
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
return IMAGE_REGEXP.test(newValue);
}
function video(value) {
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i;
return VIDEO_REGEXP.test(value);
}
function regExp(o) {
return o && Object.prototype.toString.call(o) === "[object RegExp]";
}
function string(value) {
return typeof value === "string";
}
const test = {
email,
mobile,
url,
date,
dateISO,
number,
digits,
idCard,
carNo,
amount,
chinese,
letter,
enOrNum,
contains,
range,
rangeLength,
empty,
isEmpty: empty,
jsonString,
landline,
object,
array,
code,
func,
promise,
video,
image,
regExp,
string
};
exports.test = test;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/test.js.map
@@ -0,0 +1,23 @@
"use strict";
let flag;
function throttle(func, wait = 500, immediate = true) {
if (immediate) {
if (!flag) {
flag = true;
typeof func === "function" && func();
setTimeout(() => {
flag = false;
}, wait);
}
} else {
if (!flag) {
flag = true;
setTimeout(() => {
flag = false;
typeof func === "function" && func();
}, wait);
}
}
}
exports.throttle = throttle;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/throttle.js.map
@@ -0,0 +1,52 @@
"use strict";
if (!String.prototype.padStart) {
String.prototype.padStart = function(maxLength, fillString = " ") {
if (Object.prototype.toString.call(fillString) !== "[object String]")
throw new TypeError("fillString must be String");
let str = this;
if (str.length >= maxLength)
return String(str);
let fillLength = maxLength - str.length, times = Math.ceil(fillLength / fillString.length);
while (times >>= 1) {
fillString += fillString;
if (times === 1) {
fillString += fillString;
}
}
return fillString.slice(0, fillLength) + str;
};
}
function timeFormat(dateTime = null, fmt = "yyyy-mm-dd") {
if (!dateTime)
dateTime = Number(/* @__PURE__ */ new Date());
if (typeof dateTime === "number" || typeof dateTime === "string") {
if (dateTime.toString().length == 10)
dateTime = Number(dateTime) * 1e3;
}
const date = new Date(dateTime);
let ret;
const opt = {
"y+": date.getFullYear().toString(),
// 年
"m+": (date.getMonth() + 1).toString(),
// 月
"d+": date.getDate().toString(),
// 日
"h+": date.getHours().toString(),
// 时
"M+": date.getMinutes().toString(),
// 分
"s+": date.getSeconds().toString()
// 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (const k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0"));
}
}
return fmt;
}
exports.timeFormat = timeFormat;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/timeFormat.js.map
@@ -0,0 +1,40 @@
"use strict";
const uni_modules_uviewPro_libs_function_timeFormat = require("./timeFormat.js");
function timeFrom(dateTime = null, format = "yyyy-mm-dd") {
if (!dateTime)
dateTime = Number(/* @__PURE__ */ new Date());
if (typeof dateTime === "number" || typeof dateTime === "string") {
if (dateTime.toString().length == 10)
dateTime = Number(dateTime) * 1e3;
}
const timestamp = +new Date(Number(dateTime));
const timer = (Number(/* @__PURE__ */ new Date()) - timestamp) / 1e3;
let tips = "";
switch (true) {
case timer < 300:
tips = "刚刚";
break;
case (timer >= 300 && timer < 3600):
tips = parseInt(String(timer / 60)) + "分钟前";
break;
case (timer >= 3600 && timer < 86400):
tips = parseInt(String(timer / 3600)) + "小时前";
break;
case (timer >= 86400 && timer < 2592e3):
tips = parseInt(String(timer / 86400)) + "天前";
break;
default:
if (format === false) {
if (timer >= 2592e3 && timer < 365 * 86400) {
tips = parseInt(String(timer / (86400 * 30))) + "个月前";
} else {
tips = parseInt(String(timer / (86400 * 365))) + "年前";
}
} else {
tips = uni_modules_uviewPro_libs_function_timeFormat.timeFormat(timestamp, format);
}
}
return tips;
}
exports.timeFrom = timeFrom;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/timeFrom.js.map
@@ -0,0 +1,11 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
function toast(title, option = 1500) {
common_vendor.index.showToast({
title,
icon: typeof option === "string" ? option : typeof option === "object" ? option.icon || "none" : "none",
duration: typeof option === "number" ? option : typeof option === "object" ? option.duration || "1500" : 1500
});
}
exports.toast = toast;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/toast.js.map
@@ -0,0 +1,16 @@
"use strict";
function trim(str, pos = "both") {
if (pos === "both") {
return str.replace(/^\s+|\s+$/g, "");
} else if (pos === "left") {
return str.replace(/^\s*/, "");
} else if (pos === "right") {
return str.replace(/(\s*$)/g, "");
} else if (pos === "all") {
return str.replace(/\s+/g, "");
} else {
return str;
}
}
exports.trim = trim;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/trim.js.map
@@ -0,0 +1,30 @@
"use strict";
function type2icon(type = "success", fill = false) {
if (!["primary", "info", "error", "warning", "success"].includes(type))
type = "success";
let iconName = "";
switch (type) {
case "primary":
iconName = "info-circle";
break;
case "info":
iconName = "info-circle";
break;
case "error":
iconName = "close-circle";
break;
case "warning":
iconName = "error-circle";
break;
case "success":
iconName = "checkmark-circle";
break;
default:
iconName = "checkmark-circle";
}
if (fill)
iconName += "-fill";
return iconName;
}
exports.type2icon = type2icon;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/function/type2icon.js.map
@@ -0,0 +1,6 @@
"use strict";
require("../../../../common/vendor.js");
require("../util/logger.js");
require("./useTheme.js");
require("../util/config-provider.js");
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/index.js.map
@@ -0,0 +1,4 @@
"use strict";
require("../../../../common/vendor.js");
require("../util/config-provider.js");
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useColor.js.map
@@ -0,0 +1,290 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_util_logger = require("../util/logger.js");
const PARENT_CONTEXT_SYMBOL = Symbol("parent_context");
function generateInstanceId(componentName) {
return `${componentName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
}
function findParentInstance(name, instance) {
var _a, _b;
if (!instance)
return null;
let parent = instance.parent;
while (parent) {
const parentName = ((_a = parent.type) == null ? void 0 : _a.name) || ((_b = parent.type) == null ? void 0 : _b.__name);
if (parentName === name) {
return parent;
}
parent = parent.parent;
}
return null;
}
function getParentContext(name, instance) {
var _a;
const parentInstance = findParentInstance(name, instance);
return ((_a = parentInstance == null ? void 0 : parentInstance.proxy) == null ? void 0 : _a[PARENT_CONTEXT_SYMBOL]) || null;
}
function findAllChildComponents(componentName, instance) {
const components = [];
function traverse(currentInstance) {
var _a;
if (!(currentInstance == null ? void 0 : currentInstance.subTree))
return;
const subTree = ((_a = currentInstance.subTree) == null ? void 0 : _a.children) || [];
const children = Array.isArray(subTree) ? subTree : [subTree];
children.forEach((vnode) => {
var _a2, _b;
const child = vnode.component;
if (!child)
return;
const name = ((_a2 = child.type) == null ? void 0 : _a2.name) || ((_b = child.type) == null ? void 0 : _b.__name);
if (name === componentName) {
components.push(child);
}
traverse(child);
});
}
traverse(instance);
uni_modules_uviewPro_libs_util_logger.logger.log(`Found ${components.length} ${componentName} components`);
return components;
}
function useParent(componentName) {
const instance = common_vendor.getCurrentInstance();
if (!instance) {
throw new Error("useParent must be called within setup function");
}
const name = componentName || instance.type.name || instance.type.__name;
if (!name) {
throw new Error("Component name is required for useParent");
}
const children = common_vendor.reactive([]);
const childrenMap = /* @__PURE__ */ new Map();
const broadcast = (event, data, childIds) => {
const targetChildren = childIds ? (Array.isArray(childIds) ? childIds : [childIds]).map((id) => childrenMap.get(id)).filter(Boolean) : Array.from(childrenMap.values());
uni_modules_uviewPro_libs_util_logger.logger.log(`Parent ${name} broadcasting event: ${event} to ${targetChildren.length} children`);
targetChildren.forEach((child) => {
const exposed = child.getExposed();
if (exposed && typeof exposed[event] === "function") {
try {
exposed[event](data);
} catch (error) {
uni_modules_uviewPro_libs_util_logger.logger.warn(`Error calling child method ${event}:`, error);
}
}
});
};
const broadcastToChildren = (componentName2, event, data) => {
uni_modules_uviewPro_libs_util_logger.logger.log(`Parent ${name} broadcasting event: ${event} to all ${componentName2} components`);
const childComponents = findAllChildComponents(componentName2, instance);
let successCount = 0;
childComponents.forEach((childComponent) => {
const exposed = childComponent.exposed || childComponent.proxy;
if (exposed && typeof exposed[event] === "function") {
try {
exposed[event](data);
successCount++;
} catch (error) {
uni_modules_uviewPro_libs_util_logger.logger.warn(`Error calling ${componentName2} method ${event}:`, error);
}
}
});
uni_modules_uviewPro_libs_util_logger.logger.log(
`Parent ${name} successfully called ${successCount} of ${childComponents.length} ${componentName2} components`
);
};
const parentContext = {
name,
addChild(child) {
if (!childrenMap.has(child.id)) {
childrenMap.set(child.id, child);
children.push(child);
uni_modules_uviewPro_libs_util_logger.logger.log(`Parent ${name} added child: ${child.name}`);
}
},
removeChild(childId) {
if (childrenMap.has(childId)) {
childrenMap.get(childId);
childrenMap.delete(childId);
const index = children.findIndex((c) => c.id === childId);
if (index > -1)
children.splice(index, 1);
uni_modules_uviewPro_libs_util_logger.logger.log(`Parent ${name} removed child: ${childId}`);
}
},
broadcast,
broadcastToChildren,
getChildren: () => Array.from(childrenMap.values()),
getExposed: () => instance.exposed || {},
getChildExposed(childId) {
var _a;
const child = childrenMap.get(childId);
return ((_a = child == null ? void 0 : child.getExposed) == null ? void 0 : _a.call(child)) || {};
},
getChildrenExposed() {
return Array.from(childrenMap.values()).filter((child) => child.getExposed).map((child) => ({
id: child.id,
name: child.name,
exposed: child.getExposed()
})).filter((item) => Object.keys(item.exposed).length > 0);
},
getInstance: () => instance
};
if (instance.proxy) {
instance.proxy[PARENT_CONTEXT_SYMBOL] = parentContext;
}
common_vendor.onUnmounted(() => {
childrenMap.forEach((_, childId) => parentContext.removeChild(childId));
if (instance.proxy) {
delete instance.proxy[PARENT_CONTEXT_SYMBOL];
}
uni_modules_uviewPro_libs_util_logger.logger.log(`Parent ${name} unmounted and cleaned up`);
});
return {
parentName: name,
children,
broadcast,
broadcastToChildren,
getChildren: parentContext.getChildren,
getChildExposed: parentContext.getChildExposed,
getChildrenExposed: parentContext.getChildrenExposed,
getExposed: parentContext.getExposed,
getInstance: parentContext.getInstance
};
}
function useChildren(componentName, parentName) {
const instance = common_vendor.getCurrentInstance();
if (!instance) {
throw new Error("useChildren must be called within setup function");
}
const name = componentName || instance.type.name || instance.type.__name;
const instanceId = generateInstanceId(name || "anonymous");
const parentRef = common_vendor.ref(null);
const parentExposed = common_vendor.ref({});
const createSimulatedParentContext = (parentInstance) => {
var _a, _b;
return {
name: ((_a = parentInstance == null ? void 0 : parentInstance.type) == null ? void 0 : _a.name) || ((_b = parentInstance == null ? void 0 : parentInstance.type) == null ? void 0 : _b.__name) || "unknown",
addChild: () => uni_modules_uviewPro_libs_util_logger.logger.log("Simulated parent added child"),
removeChild: () => uni_modules_uviewPro_libs_util_logger.logger.log("Simulated parent removed child"),
broadcast: () => uni_modules_uviewPro_libs_util_logger.logger.log("Simulated parent broadcasting"),
broadcastToChildren: () => uni_modules_uviewPro_libs_util_logger.logger.log("Simulated parent broadcasting to children"),
getChildren: () => [],
getExposed: () => (parentInstance == null ? void 0 : parentInstance.exposed) || {},
getChildExposed: () => ({}),
getChildrenExposed: () => [],
getInstance: () => parentInstance
};
};
const getParentExposed = () => {
if (parentRef.value) {
const exposed = parentRef.value.getExposed();
parentExposed.value = exposed;
return exposed;
}
return {};
};
const getExposed = () => instance.exposed || {};
const findParent = () => {
var _a;
if (parentName) {
const parentContext = getParentContext(parentName, instance);
if (parentContext) {
if (!parentContext.getInstance) {
parentContext.getInstance = () => findParentInstance(parentName, instance);
}
return parentContext;
}
const parentInstance = findParentInstance(parentName, instance);
if (parentInstance) {
return createSimulatedParentContext(parentInstance);
}
}
let current = instance.parent;
while (current) {
const context = (_a = current.proxy) == null ? void 0 : _a[PARENT_CONTEXT_SYMBOL];
if (context) {
if (!context.getInstance) {
context.getInstance = () => current;
}
return context;
}
current = current.parent;
}
return instance.parent ? createSimulatedParentContext(instance.parent) : null;
};
const linkParent = () => {
const parent = findParent();
if (parent) {
parentRef.value = parent;
if (parent.addChild && childContext) {
parent.addChild(childContext);
}
getParentExposed();
uni_modules_uviewPro_libs_util_logger.logger.log(`Child ${name || "anonymous"} linked to parent ${parent.name}`);
return true;
}
uni_modules_uviewPro_libs_util_logger.logger.log(`Child ${name || "anonymous"} no parent found, working in standalone mode`);
return false;
};
const emitToParent = (event, data) => {
if (parentRef.value) {
const exposed = getParentExposed();
if (exposed && typeof exposed[event] === "function") {
try {
exposed[event](data, instanceId, name);
} catch (error) {
uni_modules_uviewPro_libs_util_logger.logger.warn(`Error calling parent method ${event}:`, error);
}
}
}
};
const getChildIndex = () => {
if (!parentRef.value)
return -1;
try {
const children = parentRef.value.getChildren();
return children.findIndex((child) => child.id === instanceId);
} catch (error) {
return -1;
}
};
const childContext = {
id: instanceId,
name: name || "anonymous",
getChildIndex,
emitToParent,
getParentExposed,
getInstance: () => instance,
getExposed
};
uni_modules_uviewPro_libs_util_logger.logger.log(`Child ${name || "anonymous"} registered, looking for parent`);
common_vendor.onMounted(() => {
let connected = linkParent();
common_vendor.nextTick$1(() => {
connected = linkParent();
if (!connected) {
setTimeout(linkParent, 500);
}
});
});
common_vendor.onUnmounted(() => {
var _a;
if ((_a = parentRef.value) == null ? void 0 : _a.removeChild) {
parentRef.value.removeChild(instanceId);
}
uni_modules_uviewPro_libs_util_logger.logger.log(`Child ${name || "anonymous"} unmounted`);
});
return {
childId: instanceId,
childName: name || "anonymous",
childIndex: common_vendor.computed(getChildIndex),
parent: parentRef,
emitToParent,
getParentExposed,
parentExposed: common_vendor.computed(() => parentExposed.value),
getExposed
};
}
exports.useChildren = useChildren;
exports.useParent = useParent;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useCompRelation.js.map
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useDebounce.js.map
@@ -0,0 +1,3 @@
"use strict";
require("../../../../common/vendor.js");
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useEmitter.js.map
@@ -0,0 +1,23 @@
"use strict";
const uni_modules_uviewPro_libs_util_configProvider = require("../util/config-provider.js");
function useLocale(namespace) {
const createTranslateFunction = (ns) => {
return (key, replacements, localeName) => {
const fullKey = ns ? `${ns}.${key}` : key;
return uni_modules_uviewPro_libs_util_configProvider.configProvider.t(fullKey, replacements, localeName);
};
};
return {
// 响应式引用
currentLocale: uni_modules_uviewPro_libs_util_configProvider.configProvider.currentLocaleRef,
locales: uni_modules_uviewPro_libs_util_configProvider.configProvider.localesRef,
// 方法
t: createTranslateFunction(namespace),
setLocale: (name) => uni_modules_uviewPro_libs_util_configProvider.configProvider.setLocale(name),
getLocales: () => uni_modules_uviewPro_libs_util_configProvider.configProvider.getLocales(),
getCurrentLocale: () => uni_modules_uviewPro_libs_util_configProvider.configProvider.getCurrentLocale(),
initLocales: (locales, defaultLocaleName, isForce) => uni_modules_uviewPro_libs_util_configProvider.configProvider.initLocales(locales, defaultLocaleName, isForce)
};
}
exports.useLocale = useLocale;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useLocale.js.map
@@ -0,0 +1,3 @@
"use strict";
require("../../../../common/vendor.js");
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useModal.js.map
@@ -0,0 +1,3 @@
"use strict";
require("../../../../common/vendor.js");
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useRect.js.map
@@ -0,0 +1,16 @@
"use strict";
require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_util_configProvider = require("../util/config-provider.js");
const uni_modules_uviewPro_libs_config_themeTokens = require("../config/theme-tokens.js");
uni_modules_uviewPro_libs_util_configProvider.configProvider.themesRef;
uni_modules_uviewPro_libs_util_configProvider.configProvider.currentThemeRef;
uni_modules_uviewPro_libs_util_configProvider.configProvider.darkModeRef;
function initTheme(themes, defaultConfig, isForce) {
if (Array.isArray(themes) && themes.length > 0) {
uni_modules_uviewPro_libs_util_configProvider.configProvider.initTheme(themes, defaultConfig, isForce);
return;
}
uni_modules_uviewPro_libs_util_configProvider.configProvider.initTheme(uni_modules_uviewPro_libs_config_themeTokens.defaultThemes, defaultConfig);
}
exports.initTheme = initTheme;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useTheme.js.map
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useThrottle.js.map
@@ -0,0 +1,3 @@
"use strict";
require("../../../../common/vendor.js");
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/hooks/useToast.js.map
@@ -0,0 +1,208 @@
"use strict";
const uni_modules_uviewPro_libs_function_queryParams = require("./function/queryParams.js");
const uni_modules_uviewPro_libs_function_route = require("./function/route.js");
const uni_modules_uviewPro_libs_function_timeFormat = require("./function/timeFormat.js");
const uni_modules_uviewPro_libs_function_timeFrom = require("./function/timeFrom.js");
const uni_modules_uviewPro_libs_function_colorGradient = require("./function/colorGradient.js");
const uni_modules_uviewPro_libs_function_guid = require("./function/guid.js");
const uni_modules_uviewPro_libs_config_color = require("./config/color.js");
const uni_modules_uviewPro_libs_function_color = require("./function/color.js");
const uni_modules_uviewPro_libs_function_type2icon = require("./function/type2icon.js");
const uni_modules_uviewPro_libs_function_randomArray = require("./function/randomArray.js");
const uni_modules_uviewPro_libs_function_deepClone = require("./function/deepClone.js");
const uni_modules_uviewPro_libs_function_deepMerge = require("./function/deepMerge.js");
const uni_modules_uviewPro_libs_function_addUnit = require("./function/addUnit.js");
const uni_modules_uviewPro_libs_function_test = require("./function/test.js");
const uni_modules_uviewPro_libs_function_random = require("./function/random.js");
const uni_modules_uviewPro_libs_function_trim = require("./function/trim.js");
const uni_modules_uviewPro_libs_function_toast = require("./function/toast.js");
const uni_modules_uviewPro_libs_function_getParent = require("./function/getParent.js");
const uni_modules_uviewPro_libs_function_$parent = require("./function/_parent.js");
const uni_modules_uviewPro_libs_function_sys = require("./function/sys.js");
const uni_modules_uviewPro_libs_function_debounce = require("./function/debounce.js");
const uni_modules_uviewPro_libs_function_throttle = require("./function/throttle.js");
const uni_modules_uviewPro_libs_function_getRect = require("./function/getRect.js");
const uni_modules_uviewPro_libs_function_clipboard = require("./function/clipboard.js");
const uni_modules_uviewPro_libs_config_config = require("./config/config.js");
const uni_modules_uviewPro_libs_config_zIndex = require("./config/zIndex.js");
const uni_modules_uviewPro_libs_util_mitt = require("./util/mitt.js");
const uni_modules_uviewPro_libs_request_index = require("./request/index.js");
require("../../../common/vendor.js");
require("./util/logger.js");
require("./hooks/useTheme.js");
require("./util/config-provider.js");
function formatPrice(number, decimals = 0, decimalPoint = ".", thousandsSeparator = ",") {
function round(num, precision) {
const factor = Math.pow(10, precision);
return (Math.round(num * factor) / factor).toFixed(precision);
}
let numStr = String(number).replace(/[^0-9+\-Ee.]/g, "");
const n = !isFinite(+numStr) ? 0 : +numStr;
const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals);
const sep = thousandsSeparator ?? ",";
const dec = decimalPoint ?? ".";
let s = [];
s = (prec ? round(n, prec) : Math.round(n).toString()).split(".");
const re = /(-?\d+)(\d{3})/;
while (re.test(s[0])) {
s[0] = s[0].replace(re, `$1${sep}$2`);
}
if ((s[1] || "").length < prec) {
s[1] = s[1] || "";
s[1] += "0".repeat(prec - s[1].length);
}
return s.join(dec);
}
function formatName(name) {
if (name.length === 2) {
return name.charAt(0) + "*";
} else if (name.length > 2) {
const masked = "*".repeat(name.length - 2);
return name.charAt(0) + masked + name.charAt(name.length - 1);
} else {
return name;
}
}
function addStyle(customStyle, target = "object") {
if (uni_modules_uviewPro_libs_function_test.test.empty(customStyle) || typeof customStyle === "object" && target === "object" || target === "string" && typeof customStyle === "string") {
return customStyle;
}
if (target === "object") {
const trimmedStyle = uni_modules_uviewPro_libs_function_trim.trim(customStyle);
const styleArray = trimmedStyle.split(";");
const style = {};
for (let i = 0; i < styleArray.length; i++) {
if (styleArray[i]) {
const item = styleArray[i].split(":");
if (item.length === 2) {
style[uni_modules_uviewPro_libs_function_trim.trim(item[0])] = uni_modules_uviewPro_libs_function_trim.trim(item[1]);
}
}
}
return style;
}
let string = "";
for (const i in customStyle) {
if (Object.prototype.hasOwnProperty.call(customStyle, i)) {
const key = i.replace(/([A-Z])/g, "-$1").toLowerCase();
string += `${key}:${customStyle[i]};`;
}
}
return uni_modules_uviewPro_libs_function_trim.trim(string);
}
function toStyle(...styles) {
if (styles.length === 1 && Array.isArray(styles[0])) {
styles = styles[0].slice();
}
const map = /* @__PURE__ */ new Map();
const processString = (str) => {
if (!str)
return;
const parts = str.split(";");
for (let part of parts) {
part = part.trim();
if (!part)
continue;
const idx = part.indexOf(":");
if (idx === -1)
continue;
const key = uni_modules_uviewPro_libs_function_trim.trim(part.slice(0, idx));
const val = uni_modules_uviewPro_libs_function_trim.trim(part.slice(idx + 1));
if (key === "" || val === "")
continue;
const k = kebabCase(key);
map.set(k, val);
}
};
const processObject = (obj) => {
if (!obj)
return;
Object.keys(obj).forEach((key) => {
const val = obj[key];
if (val == null || val === "")
return;
const k = kebabCase(key);
map.set(k, val);
});
};
for (const item of styles) {
if (item == null || item === "")
continue;
if (uni_modules_uviewPro_libs_function_test.test.string(item)) {
processString(item);
} else if (uni_modules_uviewPro_libs_function_test.test.array(item)) {
item.forEach((el) => {
if (uni_modules_uviewPro_libs_function_test.test.string(el))
processString(el);
else if (uni_modules_uviewPro_libs_function_test.test.object(el))
processObject(el);
});
} else if (uni_modules_uviewPro_libs_function_test.test.object(item)) {
processObject(item);
}
}
if (map.size === 0)
return "";
const result = Array.from(map.entries()).map(([k, v]) => `${k}:${String(v)}`).join(";");
return result ? result.endsWith(";") ? result : result + ";" : "";
}
function kebabCase(word) {
const newWord = word.replace(/[A-Z]/g, function(match) {
return "-" + match;
}).toLowerCase();
return newWord;
}
function sleep(value = 30) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, value);
});
}
const $u = {
queryParams: uni_modules_uviewPro_libs_function_queryParams.queryParams,
route: uni_modules_uviewPro_libs_function_route.route,
timeFormat: uni_modules_uviewPro_libs_function_timeFormat.timeFormat,
date: uni_modules_uviewPro_libs_function_timeFormat.timeFormat,
// 另名date
timeFrom: uni_modules_uviewPro_libs_function_timeFrom.timeFrom,
colorGradient: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.colorGradient,
colorToRgba: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.colorToRgba,
guid: uni_modules_uviewPro_libs_function_guid.guid,
color: uni_modules_uviewPro_libs_config_color.color,
getColor: uni_modules_uviewPro_libs_function_color.getColor,
setColor: uni_modules_uviewPro_libs_function_color.setColor,
sys: uni_modules_uviewPro_libs_function_sys.sys,
os: uni_modules_uviewPro_libs_function_sys.os,
type2icon: uni_modules_uviewPro_libs_function_type2icon.type2icon,
randomArray: uni_modules_uviewPro_libs_function_randomArray.randomArray,
hexToRgb: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.hexToRgb,
rgbToHex: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.rgbToHex,
test: uni_modules_uviewPro_libs_function_test.test,
random: uni_modules_uviewPro_libs_function_random.random,
deepClone: uni_modules_uviewPro_libs_function_deepClone.deepClone,
deepMerge: uni_modules_uviewPro_libs_function_deepMerge.deepMerge,
getParent: uni_modules_uviewPro_libs_function_getParent.getParent,
$parent: uni_modules_uviewPro_libs_function_$parent.$parent,
clipboard: uni_modules_uviewPro_libs_function_clipboard.clipboard,
addUnit: uni_modules_uviewPro_libs_function_addUnit.addUnit,
trim: uni_modules_uviewPro_libs_function_trim.trim,
type: ["primary", "success", "error", "warning", "info"],
http: uni_modules_uviewPro_libs_request_index.httpInstance,
toast: uni_modules_uviewPro_libs_function_toast.toast,
config: uni_modules_uviewPro_libs_config_config.config,
// uView配置信息相关,比如版本号
zIndex: uni_modules_uviewPro_libs_config_zIndex.zIndex,
debounce: uni_modules_uviewPro_libs_function_debounce.debounce,
throttle: uni_modules_uviewPro_libs_function_throttle.throttle,
mitt: uni_modules_uviewPro_libs_util_mitt.mitt(),
getRect: uni_modules_uviewPro_libs_function_getRect.getRect,
formatPrice,
formatName,
addStyle,
toStyle,
kebabCase,
sleep
};
exports.$u = $u;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/index.js.map
@@ -0,0 +1,178 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_function_deepMerge = require("../function/deepMerge.js");
const IGNORE_REQUEST_KEYS = ["baseUrl", "meta"];
class Request {
constructor() {
this.config = {
baseUrl: "",
// 请求的根域名
header: {},
// 默认的请求头
method: "POST",
// 请求方式
dataType: "json",
// 设置为json,返回后uni.request会对数据进行一次JSON.parse
responseType: "text",
// 此参数无需处理,因为5+和支付宝小程序不支持,默认为text即可
timeout: 6e4,
meta: {
originalData: true,
// 是否在拦截器中返回服务端的原始数据,见文档说明
toast: false,
// 是否在请求出错时,弹出toast
loading: false
// 是否显示加载中
}
};
this.interceptor = {
request: null,
response: null
};
}
/**
* 将全局配置合并到本次请求的 options 中
* - 忽略 IGNORE_REQUEST_KEYS 中的字段(如 meta
* - 对 header 使用深合并(全局 header 为默认,options.header 优先)
* - 对对象类型的字段尝试深合并,基础类型以 options 值优先
* - 处理 baseUrl:若存在全局 baseUrl 且 options.url 非完整 url(非 http 开头),则合并成完整 URL
*/
mergeGlobalConfigToOptions(options) {
const mergedOptions = { ...options };
for (const key of Object.keys(this.config)) {
if (IGNORE_REQUEST_KEYS.includes(key)) {
continue;
}
const cfgVal = this.config[key];
const optVal = options[key];
if (cfgVal === void 0)
continue;
if (key === "header") {
mergedOptions.header = uni_modules_uviewPro_libs_function_deepMerge.deepMerge(cfgVal || {}, optVal || {});
continue;
}
if (typeof cfgVal === "string" || typeof cfgVal === "number" || typeof cfgVal === "boolean") {
mergedOptions[key] = optVal !== void 0 ? optVal : cfgVal;
continue;
}
if (typeof cfgVal === "object" && !Array.isArray(cfgVal)) {
mergedOptions[key] = uni_modules_uviewPro_libs_function_deepMerge.deepMerge(cfgVal || {}, optVal || {});
continue;
}
if (optVal === void 0) {
mergedOptions[key] = cfgVal;
}
}
const baseUrl = this.config.baseUrl;
if (baseUrl && mergedOptions.url && typeof mergedOptions.url === "string" && mergedOptions.url.indexOf("http") !== 0) {
mergedOptions.url = baseUrl + (mergedOptions.url.indexOf("/") === 0 ? mergedOptions.url : `/${mergedOptions.url}`);
}
if (!mergedOptions.url) {
mergedOptions.url = "";
}
return mergedOptions;
}
/**
* 设置全局默认配置
* @param customConfig 自定义配置
*/
setConfig(customConfig) {
this.config = uni_modules_uviewPro_libs_function_deepMerge.deepMerge(this.config, customConfig);
}
/**
* 主要请求部分
* @param options 请求参数
*/
request(options) {
const mergedMeta = {
...this.config.meta,
...options.meta || {}
};
options.meta = mergedMeta;
options.url = options.url || "";
options.params = options.params || {};
options = this.mergeGlobalConfigToOptions(options);
if (this.interceptor.request && typeof this.interceptor.request === "function") {
const interceptorRequest = this.interceptor.request(options);
if (!interceptorRequest) {
return new Promise(() => {
});
}
this.options = interceptorRequest;
}
return new Promise((resolve, reject) => {
options.complete = (response) => {
const meta = options.meta || this.config.meta || {};
const originalData = meta.originalData ?? false;
response.config = options;
if (originalData) {
if (this.interceptor.response && typeof this.interceptor.response === "function") {
const resInterceptors = this.interceptor.response(response);
if (resInterceptors !== false) {
resolve(resInterceptors);
} else {
reject(response);
}
} else {
resolve(response);
}
} else {
if (response.statusCode === 200) {
if (this.interceptor.response && typeof this.interceptor.response === "function") {
const resInterceptors = this.interceptor.response(response.data);
if (resInterceptors !== false) {
resolve(resInterceptors);
} else {
reject(response.data);
}
} else {
resolve(response.data);
}
} else {
reject(response);
}
}
};
common_vendor.index.request(options);
});
}
get(url, data = {}, options = {}) {
return this.request({
method: "GET",
url,
data,
header: options.header || {},
meta: options.meta
});
}
post(url, data = {}, options = {}) {
return this.request({
url,
method: "POST",
data,
header: options.header || {},
meta: options.meta
});
}
put(url, data = {}, options = {}) {
return this.request({
url,
method: "PUT",
data,
header: options.header || {},
meta: options.meta
});
}
delete(url, data = {}, options = {}) {
return this.request({
url,
method: "DELETE",
data,
header: options.header || {},
meta: options.meta
});
}
}
const httpInstance = new Request();
exports.httpInstance = httpInstance;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/request/index.js.map
@@ -0,0 +1,687 @@
"use strict";
var _a, _b;
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_config_config = require("../config/config.js");
const uni_modules_uviewPro_libs_config_themeTokens = require("../config/theme-tokens.js");
const uni_modules_uviewPro_libs_config_color = require("../config/color.js");
const uni_modules_uviewPro_libs_util_systemTheme = require("./system-theme.js");
const uni_modules_uviewPro_locale_index = require("../../locale/index.js");
const THEME_STORAGE_KEY = "uview-pro-theme";
const DARK_MODE_STORAGE_KEY = "uview-pro-dark-mode";
const LOCALE_STORAGE_KEY = "uview-pro-locale";
const DEFAULT_LIGHT_TOKENS = ((_a = uni_modules_uviewPro_libs_config_themeTokens.defaultThemes[0]) == null ? void 0 : _a.color) || {};
const DEFAULT_DARK_TOKENS = ((_b = uni_modules_uviewPro_libs_config_themeTokens.defaultThemes[0]) == null ? void 0 : _b.darkColor) || {};
const STRUCTURAL_TOKENS = /* @__PURE__ */ new Set([
"bgColor",
"bgWhite",
"bgGrayLight",
"bgGrayDark",
"bgBlack",
"borderColor",
"lightColor",
"mainColor",
"contentColor",
"tipsColor",
"whiteColor",
"blackColor",
"dividerColor",
"maskColor",
"shadowColor"
]);
class ConfigProvider {
constructor() {
this.themesRef = common_vendor.ref([]);
this.currentThemeRef = common_vendor.ref(null);
this.darkModeRef = common_vendor.ref(uni_modules_uviewPro_libs_config_config.config.defaultDarkMode);
this.cssVarsRef = common_vendor.ref({});
this.localesRef = common_vendor.ref([]);
this.currentLocaleRef = common_vendor.ref(null);
this.baseColorTokens = DEFAULT_LIGHT_TOKENS;
this.baseDarkColorTokens = DEFAULT_DARK_TOKENS;
this.debug = false;
this.systemDarkModeMediaQuery = null;
this.lastAppliedCssKeys = [];
this.interval = 0;
this.initSystemDarkModeListener();
}
/**
* 初始化系统暗黑模式监听器
* 支持 H5、App、小程序等平台
*/
initSystemDarkModeListener() {
try {
if (typeof window !== "undefined" && window.matchMedia) {
this.systemDarkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
const listener = () => {
if (this.darkModeRef.value === "auto") {
this.applyTheme(this.currentThemeRef.value);
}
};
if (this.systemDarkModeMediaQuery.addEventListener) {
this.systemDarkModeMediaQuery.addEventListener("change", listener);
} else if (this.systemDarkModeMediaQuery.addListener) {
this.systemDarkModeMediaQuery.addListener(listener);
}
}
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:98", "[ConfigProvider] H5 system dark mode listener failed", e);
}
try {
if (typeof common_vendor.index !== "undefined" && typeof common_vendor.index.onThemeChange === "function") {
common_vendor.index.onThemeChange((res) => {
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:105", "[ConfigProvider] system theme changed", res);
if (this.darkModeRef.value === "auto") {
this.applyTheme(this.currentThemeRef.value);
}
});
}
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:113", "[ConfigProvider] uni-app system dark mode listener failed", e);
}
this.initAppEvent();
}
/**
* App 平台事件监听
* 经测试 uni.onThemeChange 在 App 平台目前没生效,暂时只能通过定时检查
*/
initAppEvent() {
}
/**
* 检测当前是否应该使用暗黑模式
*/
isSystemDarkMode() {
try {
if (this.systemDarkModeMediaQuery) {
return this.systemDarkModeMediaQuery.matches;
}
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:147", "[ConfigProvider] matchMedia check failed", e);
}
try {
return uni_modules_uviewPro_libs_util_systemTheme.getSystemDarkMode() === "dark";
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:152", "[ConfigProvider] native system theme check failed", e);
return false;
}
}
/**
* 初始化主题系统
* @param themes 可用主题数组
* @param defaultTheme 可选默认主题名
*/
initTheme(themes, defaultConfig, isForce) {
const normalizedThemes = this.normalizeThemes(themes);
if (!normalizedThemes.length) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:165", "[ConfigProvider] init called with empty themes");
return;
}
if (defaultConfig) {
if (typeof defaultConfig === "string") {
uni_modules_uviewPro_libs_config_config.config.defaultTheme = defaultConfig || uni_modules_uviewPro_libs_config_config.config.defaultTheme;
} else if (typeof defaultConfig === "object") {
const { defaultTheme, defaultDarkMode } = defaultConfig;
uni_modules_uviewPro_libs_config_config.config.defaultTheme = defaultTheme || uni_modules_uviewPro_libs_config_config.config.defaultTheme;
uni_modules_uviewPro_libs_config_config.config.defaultDarkMode = defaultDarkMode || uni_modules_uviewPro_libs_config_config.config.defaultDarkMode;
}
}
this.themesRef.value = normalizedThemes.slice();
const saved = this.readStorage(THEME_STORAGE_KEY);
let initialName = saved || uni_modules_uviewPro_libs_config_config.config.defaultTheme || this.themesRef.value[0].name;
if (isForce && uni_modules_uviewPro_libs_config_config.config.defaultTheme)
initialName = uni_modules_uviewPro_libs_config_config.config.defaultTheme;
let found = this.themesRef.value.find((t) => t.name === initialName);
if (!found)
found = this.themesRef.value.find((t) => t.name === uni_modules_uviewPro_libs_config_config.config.defaultTheme);
if (!found)
found = this.themesRef.value[0];
this.currentThemeRef.value = found;
this.initDarkMode(uni_modules_uviewPro_libs_config_config.config.defaultDarkMode, isForce);
this.applyTheme(found);
if (this.debug)
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:201", "[ConfigProvider] initialized, theme=", found.name, "darkMode=", this.darkModeRef.value);
return this;
}
/**
* 初始化暗黑模式设置
* @param darkMode
*/
initDarkMode(darkMode, isForce) {
const savedDarkMode = this.readStorage(DARK_MODE_STORAGE_KEY);
let darkModeValue = savedDarkMode || darkMode || uni_modules_uviewPro_libs_config_config.config.defaultDarkMode;
if (isForce && darkMode)
darkModeValue = darkMode;
this.darkModeRef.value = darkModeValue;
}
/**
* 初始化国际化数据
* @param locales 可选的 locale 列表(对象数组,包含 name 字段)
* @param defaultLocaleName 可选默认 locale 名称
*/
initLocales(locales, defaultLocaleName, isForce) {
const normalized = this.normalizeLocales(locales);
if (!normalized.length) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:226", "[ConfigProvider] initLocales called with empty locales");
return;
}
this.localesRef.value = normalized.slice();
const saved = this.readStorage(LOCALE_STORAGE_KEY);
let initialName = saved || defaultLocaleName || uni_modules_uviewPro_libs_config_config.config.defaultLocale;
if (isForce && defaultLocaleName)
initialName = defaultLocaleName;
let found = this.localesRef.value.find((l) => l.name === initialName);
if (!found)
found = this.localesRef.value.find((l) => l.name === uni_modules_uviewPro_libs_config_config.config.defaultLocale);
if (!found)
found = this.localesRef.value[0];
this.currentLocaleRef.value = found;
if (this.debug)
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:244", "[ConfigProvider] locales initialized, locale=", found == null ? void 0 : found.name);
return this;
}
/**
* 归一化 locale 配置,保证始终至少有一个默认 locale
*/
normalizeLocales(locales) {
let builtinList = [];
try {
builtinList = Object.values(uni_modules_uviewPro_locale_index.localePack || {}).filter((v) => v && typeof v === "object");
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:258", "[ConfigProvider] normalizeLocales read builtin failed", e);
}
if (!Array.isArray(locales) || !locales.length) {
return builtinList.slice();
}
const map = /* @__PURE__ */ new Map();
builtinList.forEach((item) => {
if (item && item.name) {
map.set(item.name, { ...item || {} });
}
});
locales.forEach((loc) => {
if (!loc || !loc.name)
return;
const existing = map.get(loc.name);
if (!existing) {
map.set(loc.name, { ...loc || {} });
return;
}
const merged = { ...existing };
Object.keys(loc).forEach((k) => {
const v = loc[k];
if (v != null && typeof v === "object" && !Array.isArray(v) && typeof merged[k] === "object") {
merged[k] = { ...merged[k] || {}, ...v || {} };
} else {
merged[k] = v;
}
});
map.set(loc.name, merged);
});
return Array.from(map.values());
}
/**
* 获取所有可用 locale
*/
getLocales() {
return this.localesRef.value.slice();
}
/**
* 获取当前 locale 对象
*/
getCurrentLocale() {
return this.currentLocaleRef.value;
}
/**
* 切换 locale 并持久化
*/
setLocale(localeName) {
if (!this.localesRef.value || this.localesRef.value.length === 0) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:318", "[ConfigProvider] setLocale called but locales list empty");
return;
}
const locale = this.localesRef.value.find((l) => l.name === localeName);
if (!locale) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:323", "[ConfigProvider] locale not found:", localeName);
return;
}
this.currentLocaleRef.value = locale;
this.writeStorage(LOCALE_STORAGE_KEY, localeName);
if (this.debug)
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:328", "[ConfigProvider] setLocale ->", localeName);
}
/**
* 翻译函数
* 支持 key 路径,例如 'calendar.placeholder'
* replacements 支持数组或对象替换占位符 {0} 或 {name}
*/
t(key, replacements, localeName) {
try {
if (!Array.isArray(this.localesRef.value) || this.localesRef.value.length === 0) {
this.initLocales();
}
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:343", "[ConfigProvider] lazy initLocales failed", e);
}
const localeObj = localeName && this.localesRef.value.find((l) => l.name === localeName) || this.currentLocaleRef.value;
if (!localeObj)
return key;
const parts = key.split(".");
let cur = localeObj;
for (let i = 0; i < parts.length; i++) {
if (cur == null)
break;
cur = cur[parts[i]];
}
let text = typeof cur === "string" ? cur : key;
if (replacements != null) {
if (Array.isArray(replacements)) {
replacements.forEach((val, idx) => {
text = text.split(`{${idx}}`).join(String(val));
});
} else if (typeof replacements === "object") {
Object.keys(replacements).forEach((k) => {
text = text.split(`{${k}}`).join(String(replacements[k]));
});
}
}
return text;
}
/**
* 获取所有可用主题
*/
getThemes() {
return this.themesRef.value.slice();
}
/**
* 获取当前主题
*/
getCurrentTheme() {
return this.currentThemeRef.value;
}
/**
* 切换主题并持久化
*/
setTheme(themeName) {
if (!this.themesRef.value || this.themesRef.value.length === 0) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:389", "[ConfigProvider] setTheme called but themes list empty");
return;
}
const theme = this.themesRef.value.find((t) => t.name === themeName);
if (!theme) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:395", "[ConfigProvider] theme not found:", themeName);
return;
}
this.currentThemeRef.value = theme;
this.applyTheme(theme);
this.writeStorage(THEME_STORAGE_KEY, themeName);
if (this.debug)
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:407", "[ConfigProvider] setTheme ->", themeName);
}
/**
* 运行时更新当前主题颜色并应用(不持久化)
* @param colors 主题颜色键值,支持部分更新
*/
setThemeColor(colors) {
if (!colors || Object.keys(colors).length === 0)
return;
if (!this.currentThemeRef.value) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:417", "[ConfigProvider] setThemeColor called but no current theme");
return;
}
const mode = this.getActiveMode();
if (mode === "dark") {
const existing = this.currentThemeRef.value.darkColor || {};
this.currentThemeRef.value.darkColor = {
...existing,
...colors
};
} else {
const existing = this.currentThemeRef.value.color || {};
this.currentThemeRef.value.color = {
...existing,
...colors
};
}
this.applyTheme(this.currentThemeRef.value);
if (this.debug)
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:440", "[ConfigProvider] setThemeColor ->", colors);
}
/**
* 获取当前暗黑模式设置
*/
getDarkMode() {
return this.darkModeRef.value;
}
/**
* 设置暗黑模式
* @param mode 'auto' (跟随系统) | 'light' (强制亮色) | 'dark' (强制暗黑)
*/
setDarkMode(mode) {
this.darkModeRef.value = mode;
this.writeStorage(DARK_MODE_STORAGE_KEY, mode);
this.applyTheme(this.currentThemeRef.value);
if (this.debug)
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/config-provider.ts:462", "[ConfigProvider] setDarkMode ->", mode);
}
/**
* 检查当前是否处于暗黑模式
*/
isInDarkMode() {
const mode = this.darkModeRef.value;
if (mode === "dark")
return true;
if (mode === "light")
return false;
return this.isSystemDarkMode();
}
/**
* 归一化主题配置,保证始终至少有一个默认主题
*/
normalizeThemes(themes) {
if (Array.isArray(themes) && themes.length) {
return this.mergeThemes(uni_modules_uviewPro_libs_config_themeTokens.defaultThemes, themes);
}
return uni_modules_uviewPro_libs_config_themeTokens.defaultThemes.slice();
}
mergeThemes(...lists) {
const map = /* @__PURE__ */ new Map();
lists.filter((list) => Array.isArray(list) && list.length > 0).forEach((list) => {
list.forEach((theme) => {
const normalized = this.ensureDarkVariant({
...theme,
color: this.applyColorFallbacks(theme.color),
darkColor: theme.darkColor ? { ...theme.darkColor } : void 0,
css: theme.css ? { ...theme.css } : void 0,
darkCss: theme.darkCss ? { ...theme.darkCss } : void 0
});
map.set(normalized.name, normalized);
});
});
return Array.from(map.values());
}
ensureDarkVariant(theme) {
const finalDark = this.buildDarkPalette(theme);
return {
...theme,
darkColor: this.applyDarkFallbacks(finalDark)
};
}
buildDarkPalette(theme) {
const provided = theme.darkColor || {};
const generated = this.generateDarkFromLight(theme.color || {}, provided);
return {
...generated,
...provided
};
}
/**
* 应用亮色主题
*/
applyColorFallbacks(color) {
return {
...this.baseColorTokens || {},
...color || {}
};
}
/**
* 应用暗黑主题
*/
applyDarkFallbacks(color) {
return {
...this.baseDarkColorTokens || {},
...color || {}
};
}
filterNonStructuralTokens(palette) {
const result = {};
Object.entries(palette || {}).forEach(([key, value]) => {
if (!this.isStructuralToken(key)) {
result[key] = value;
}
});
return result;
}
generateDarkFromLight(palette, provided) {
const result = {};
const nonStructural = this.filterNonStructuralTokens(palette);
Object.entries(nonStructural).forEach(([key, value]) => {
var _a2;
if (typeof value !== "string")
return;
if (provided && Object.prototype.hasOwnProperty.call(provided, key)) {
return;
}
const fallback = (_a2 = this.baseDarkColorTokens) == null ? void 0 : _a2[key];
result[key] = this.createDarkVariantFromLight(value, fallback);
});
return result;
}
createDarkVariantFromLight(color, fallback) {
const normalized = this.normalizeHex(color);
const fallbackHex = fallback ? this.normalizeHex(fallback) : null;
if (normalized && fallbackHex) {
return this.mixHex(normalized, fallbackHex, 0.6);
}
if (fallbackHex)
return fallbackHex;
return normalized || color;
}
normalizeHex(color) {
if (!color)
return null;
const hex = color.trim();
if (/^#([0-9a-fA-F]{6})$/.test(hex))
return hex.toLowerCase();
return null;
}
mixHex(fromHex, toHex, ratio) {
const from = this.hexToRgb(fromHex);
const to = this.hexToRgb(toHex);
if (!from || !to)
return toHex;
const clamp = (val) => Math.min(255, Math.max(0, Math.round(val)));
const r = clamp(from.r * (1 - ratio) + to.r * ratio);
const g = clamp(from.g * (1 - ratio) + to.g * ratio);
const b = clamp(from.b * (1 - ratio) + to.b * ratio);
return this.rgbToHex(r, g, b);
}
hexToRgb(hex) {
const match = /^#([0-9a-fA-F]{6})$/.exec(hex);
if (!match)
return null;
return {
r: parseInt(match[1].slice(0, 2), 16),
g: parseInt(match[1].slice(2, 4), 16),
b: parseInt(match[1].slice(4, 6), 16)
};
}
rgbToHex(r, g, b) {
const toHex = (val) => val.toString(16).padStart(2, "0");
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
}
isStructuralToken(token) {
return STRUCTURAL_TOKENS.has(token);
}
/**
* 运行时同步主题颜色($u.color)
* 更新响应式 color 对象,确保所有使用 $u.color 的地方都能响应式更新
*/
syncRuntimeTheme(palette) {
var _a2, _b2;
try {
const defaultPalette = this.getActiveMode() === "dark" ? this.baseDarkColorTokens : this.baseColorTokens;
const mergedPalette = {
...defaultPalette,
...palette
};
Object.keys(mergedPalette).forEach((key) => {
const value = mergedPalette[key];
if (value != null) {
uni_modules_uviewPro_libs_config_color.color[key] = value;
}
});
if (typeof common_vendor.index !== "undefined" && ((_b2 = (_a2 = common_vendor.index) == null ? void 0 : _a2.$u) == null ? void 0 : _b2.color)) {
common_vendor.index.$u.color = uni_modules_uviewPro_libs_config_color.color;
}
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:640", "[ConfigProvider] sync runtime theme failed", e);
}
}
/**
* 获取当前激活的模式
*/
getActiveMode() {
return this.isInDarkMode() ? "dark" : "light";
}
/**
* 获取当前主题的配色方案
*/
getPaletteForMode(theme, mode) {
if (mode === "dark") {
return theme.darkColor && Object.keys(theme.darkColor).length ? theme.darkColor : theme.color || {};
}
return theme.color || {};
}
/**
* 获取当前主题的CSS变量覆盖
*/
getCssOverrides(theme, mode) {
if (mode === "dark") {
return (theme.darkCss && Object.keys(theme.darkCss).length ? theme.darkCss : theme.css) || {};
}
return theme.css || {};
}
/**
* 读取Storage key
*/
readStorage(key) {
try {
if (typeof common_vendor.index === "undefined" || typeof common_vendor.index.getStorageSync !== "function")
return null;
const value = common_vendor.index.getStorageSync(key);
return value ?? null;
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:680", "[ConfigProvider] failed to read storage", e);
return null;
}
}
/**
* 写入Storage key value
*/
writeStorage(key, value) {
try {
if (typeof common_vendor.index === "undefined" || typeof common_vendor.index.setStorageSync !== "function")
return;
common_vendor.index.setStorageSync(key, value);
} catch (e) {
if (this.debug)
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/config-provider.ts:693", "[ConfigProvider] failed to write storage", e);
}
}
/**
* 更新文档主题模式 H5
*/
updateDocumentMode(mode) {
if (typeof document === "undefined" || !document.documentElement)
return;
const root = document.documentElement;
root.dataset.uThemeMode = mode;
root.classList.remove("u-theme-light", "u-theme-dark");
root.classList.add(`u-theme-${mode}`);
}
/**
* 转换为 CSS 变量名称
*/
toCssVarName(key, prefix = "--u") {
const types = uni_modules_uviewPro_libs_config_config.config.type;
if (types.some((type) => key.startsWith(type))) {
prefix += "-type";
}
const kebab = key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
return `${prefix}-${kebab}`;
}
/**
* 添加 RGB 值
*/
attachRgbVar(target, varName, value) {
if (typeof value !== "string")
return;
const hex = value.startsWith("#") ? value.slice(1) : "";
if (!/^[0-9a-fA-F]{6}$/.test(hex))
return;
const r = parseInt(hex.slice(0, 2), 16);
const g = parseInt(hex.slice(2, 4), 16);
const b = parseInt(hex.slice(4, 6), 16);
target[`${varName}-rgb`] = `${r}, ${g}, ${b}`;
}
/**
* 构建 CSS 变量映射表
* 生成格式:
*/
buildCssVarMap(theme, mode) {
const map = {
"--u-theme-mode": mode
};
const palette = this.getPaletteForMode(theme, mode);
const cssOverrides = this.getCssOverrides(theme, mode);
const applyEntry = (key, value) => {
if (value == null)
return;
const strValue = String(value);
if (key.startsWith("--")) {
map[key] = strValue;
this.attachRgbVar(map, key, strValue);
return;
}
const cssVarName = this.toCssVarName(key);
map[cssVarName] = strValue;
this.attachRgbVar(map, cssVarName, strValue);
};
Object.entries(palette || {}).forEach(([key, value]) => applyEntry(key, value));
Object.entries(cssOverrides || {}).forEach(([key, value]) => applyEntry(key, value));
return map;
}
/**
* 刷新 CSS 变量 H5
*/
flushCssVars(vars) {
if (typeof document === "undefined" || !document.documentElement)
return;
const root = document.documentElement;
this.lastAppliedCssKeys.forEach((key) => {
root.style.removeProperty(key);
});
Object.entries(vars).forEach(([key, value]) => {
root.style.setProperty(key, value);
});
this.lastAppliedCssKeys = Object.keys(vars);
}
/**
* 将主题应用到运行时:
* - 1) 调用 uni.$u.setColor(theme.color) 如果存在
* - 2) 在 H5 环境中,将 css map 注入到 document.documentElement 的 CSS 变量中
* - 3) 支持暗黑模式:根据 darkColor 或 color 应用相应的颜色
*/
applyTheme(theme) {
if (!theme)
return;
const mode = this.getActiveMode();
const palette = this.getPaletteForMode(theme, mode);
this.syncRuntimeTheme(palette);
const cssVarMap = this.buildCssVarMap(theme, mode);
this.cssVarsRef.value = cssVarMap;
this.flushCssVars(cssVarMap);
this.updateDocumentMode(mode);
}
}
const configProvider = new ConfigProvider();
exports.configProvider = configProvider;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/util/config-provider.js.map
@@ -0,0 +1,306 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const originalConsole = {
log: console.log,
info: console.info,
warn: console.warn,
error: console.error,
debug: console.debug,
trace: console.trace,
table: console.table,
time: console.time,
timeEnd: console.timeEnd,
group: console.group,
groupEnd: console.groupEnd,
groupCollapsed: console.groupCollapsed,
assert: console.assert,
clear: console.clear,
count: console.count,
countReset: console.countReset
};
Object.keys(originalConsole).forEach((key) => {
const methodKey = key;
if (!originalConsole[methodKey]) {
originalConsole[methodKey] = () => {
};
}
});
class Logger {
constructor() {
this.debugMode = false;
this.prefix = "[uViewPro]";
this.showCallerInfo = true;
}
/**
* 设置调试模式
* @param enabled 是否启用调试模式
*/
setDebugMode(enabled) {
this.debugMode = !!enabled;
if (this.debugMode) {
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/logger.ts:64", "[uViewPro] Debug mode enabled");
} else {
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/logger.ts:66", "[uViewPro] Debug mode disabled");
}
return this;
}
/**
* 设置是否显示调用者信息(文件名和行号)
* @param show 是否显示调用者信息
*/
setShowCallerInfo(show) {
this.showCallerInfo = !!show;
return this;
}
/**
* 设置日志前缀
* @param prefix 日志前缀
*/
setPrefix(prefix) {
if (prefix)
this.prefix = prefix;
return this;
}
/**
* 获取当前调试模式状态
* @returns 当前调试模式状态
*/
getDebugMode() {
return this.debugMode;
}
/**
* 从文件路径中提取纯净的文件名(去除查询参数和路径)
* @param filePath 文件路径
* @returns 纯净的文件名
*/
extractFileName(filePath) {
if (!filePath)
return "";
const withoutQuery = filePath.split("?")[0];
const parts = withoutQuery.split(/[/\\]/);
const fileNameWithExt = parts.pop() || "";
return fileNameWithExt;
}
/**
* 获取调用者信息(文件名和行号)
* @returns 调用者信息字符串
*/
getCallerInfo() {
if (!this.showCallerInfo)
return "";
try {
const error = new Error();
const stack = error.stack;
if (!stack)
return "";
const stackLines = stack.split("\n");
for (let i = 3; i < stackLines.length; i++) {
const line = stackLines[i].trim();
if (line && !line.includes("logger.ts") && !line.includes("Logger.") && !line.includes("at Object.")) {
const match = line.match(/\(?(.*):(\d+):(\d+)\)?/);
if (match) {
const filePath = match[1];
const lineNumber = match[2];
const fileName = this.extractFileName(filePath);
return `[${fileName}:${lineNumber}]`;
}
break;
}
}
} catch (e) {
}
return "";
}
/**
* 通用日志输出方法
* @param level 日志级别
* @param args 日志参数
*/
output(level, ...args) {
if (!this.debugMode || !originalConsole[level])
return;
const method = originalConsole[level];
const callerInfo = this.getCallerInfo();
if (this.prefix) {
if (callerInfo) {
method(`${this.prefix}${callerInfo}`, ...args);
} else {
method(this.prefix, ...args);
}
} else {
if (callerInfo) {
method(callerInfo, ...args);
} else {
method(...args);
}
}
}
/**
* 普通日志
* @param args 日志参数
*/
log(...args) {
this.output("log", ...args);
}
/**
* 信息日志
* @param args 日志参数
*/
info(...args) {
this.output("info", ...args);
}
/**
* 警告日志
* @param args 日志参数
*/
warn(...args) {
this.output("warn", ...args);
}
/**
* 错误日志
* @param args 日志参数
*/
error(...args) {
this.output("error", ...args);
}
/**
* 调试日志
* @param args 日志参数
*/
debug(...args) {
if (!originalConsole.debug)
return;
this.output("debug", ...args);
}
/**
* 堆栈跟踪
* @param args 日志参数
*/
trace(...args) {
if (!originalConsole.trace)
return;
this.output("trace", ...args);
}
/**
* 表格输出
* @param data 表格数据
* @param columns 列名(可选)
*/
table(data, columns) {
if (!this.debugMode || !originalConsole.table)
return;
if (this.prefix) {
originalConsole.log(this.prefix);
}
originalConsole.table(data, columns);
}
/**
* 开始计时
* @param label 计时器标签
*/
time(label) {
if (!this.debugMode || !originalConsole.time)
return;
const fullLabel = this.prefix ? `${this.prefix} ${label}` : label;
originalConsole.time(fullLabel);
}
/**
* 结束计时
* @param label 计时器标签
*/
timeEnd(label) {
if (!this.debugMode || !originalConsole.timeEnd)
return;
const fullLabel = this.prefix ? `${this.prefix} ${label}` : label;
originalConsole.timeEnd(fullLabel);
}
/**
* 分组日志
* @param label 分组标签
*/
group(label) {
if (!this.debugMode || !originalConsole.group)
return;
const fullLabel = this.prefix ? `${this.prefix} ${label}` : label;
originalConsole.group(fullLabel);
}
/**
* 结束分组
*/
groupEnd() {
if (!this.debugMode || !originalConsole.groupEnd)
return;
originalConsole.groupEnd();
}
/**
* 分组日志(默认折叠)
* @param label 分组标签
*/
groupCollapsed(label) {
if (!this.debugMode || !originalConsole.groupCollapsed)
return;
const fullLabel = this.prefix ? `${this.prefix} ${label}` : label;
originalConsole.groupCollapsed(fullLabel);
}
/**
* 断言
* @param condition 条件
* @param message 错误消息
*/
assert(condition, ...message) {
if (!this.debugMode || !originalConsole.assert)
return;
if (this.prefix) {
originalConsole.assert(condition, this.prefix, ...message);
} else {
originalConsole.assert(condition, ...message);
}
}
/**
* 清空控制台
*/
clear() {
if (!this.debugMode || !originalConsole.clear)
return;
originalConsole.clear();
}
/**
* 计数器
* @param label 计数器标签
*/
count(label) {
if (!this.debugMode || !originalConsole.count)
return;
const fullLabel = this.prefix && label ? `${this.prefix} ${label}` : label || this.prefix;
originalConsole.count(fullLabel);
}
/**
* 重置计数器
* @param label 计数器标签
*/
countReset(label) {
if (!this.debugMode || !originalConsole.countReset)
return;
const fullLabel = this.prefix && label ? `${this.prefix} ${label}` : label || this.prefix;
originalConsole.countReset(fullLabel);
}
/**
* 带样式的日志
* @param style CSS样式
* @param message 消息内容
*/
styled(style, message) {
if (!this.debugMode)
return;
const callerInfo = this.getCallerInfo();
const fullMessage = callerInfo ? `${message} ${callerInfo}` : message;
if (this.prefix) {
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/logger.ts:353", `%c${this.prefix} ${fullMessage}`, style);
} else {
common_vendor.index.__f__("log", "at uni_modules/uview-pro/libs/util/logger.ts:355", `%c${fullMessage}`, style);
}
}
}
const logger = new Logger();
exports.logger = logger;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/util/logger.js.map
@@ -0,0 +1,73 @@
"use strict";
function mitt(all) {
all = all || /* @__PURE__ */ new Map();
return {
/**
* A Map of event names to registered handler functions.
*/
all,
/**
* Register an event handler for the given type.
* @param {string|symbol} type Type of event to listen for, or `'*'` for all events
* @param {Function} handler Function to call in response to given event
* @memberOf mitt
*/
on(type, handler) {
const handlers = all.get(type);
if (handlers) {
handlers.push(handler);
} else {
all.set(type, [handler]);
}
},
/**
* Remove an event handler for the given type.
* If `handler` is omitted, all handlers of the given type are removed.
* @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
* @param {Function} [handler] Handler function to remove
* @memberOf mitt
*/
off(type, handler) {
const handlers = all.get(type);
if (handlers) {
if (handler) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
} else {
all.set(type, []);
}
}
},
/**
* Invoke all handlers for the given type.
* If present, `'*'` handlers are invoked after type-matched handlers.
*
* Note: Manually firing '*' handlers is not supported.
*
* @param {string|symbol} type The event type to invoke
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
* @memberOf mitt
*/
emit(type, evt) {
let handlers = all.get(type);
if (handlers) {
[...handlers].forEach((handler) => {
handler(evt);
});
}
handlers = all.get("*");
if (handlers) {
[...handlers].forEach((handler) => {
handler(type, evt);
});
}
},
/**
* Clear all
*/
clear() {
this.all.clear();
}
};
}
exports.mitt = mitt;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/util/mitt.js.map
@@ -0,0 +1,21 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
function getSystemDarkMode() {
try {
if (typeof common_vendor.index !== "undefined" && typeof common_vendor.index.getSystemInfoSync === "function") {
const systemInfo = common_vendor.index.getSystemInfoSync();
const theme = systemInfo.osTheme || systemInfo.theme || "light";
if (theme === "dark") {
return "dark";
}
if (theme === "light") {
return "light";
}
}
} catch (e) {
common_vendor.index.__f__("warn", "at uni_modules/uview-pro/libs/util/system-theme.ts:22", "[system-theme] getSystemDarkMode failed", e);
}
return "light";
}
exports.getSystemDarkMode = getSystemDarkMode;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/util/system-theme.js.map