Skip to content

Commit

Permalink
releases 3.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Mar 6, 2025
1 parent 38cb1b9 commit d40b407
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
20 changes: 16 additions & 4 deletions func/ctor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ import SetupDefaults from './setupDefaults'
/**
* 版本信息
*/
export const VERSION: string;
export const version: string

/**
* 设置全局参数
* 设置全局配置
* @param options 全局参数
*/
export function setConfig(options: SetupDefaults): SetupDefaults;

/**
* 获取全局配置
*/
export function getConfig(): SetupDefaults;

export const VERSION: string
export function setup(options: SetupDefaults): SetupDefaults;

/**
Expand All @@ -18,16 +26,20 @@ export function setup(options: SetupDefaults): SetupDefaults;
export function mixin(...methods: {[key: string]: any}[]): void;

export interface XEUtilsMethods {
version: typeof version;
setConfig: typeof setConfig;
getConfig: typeof getConfig;
mixin: typeof mixin;

VERSION: typeof VERSION;
setup: typeof setup;
mixin: typeof mixin;

[propertys: string]: any;
}

/**
* JavaScript 函数库、工具类
*/
declare var XEUtils: XEUtilsMethods
declare let XEUtils: XEUtilsMethods

export default XEUtils
15 changes: 12 additions & 3 deletions func/ctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ function mixin () {
})
}

function setup (options) {
function setConfig (options) {
return assign(setupDefaults, options)
}

XEUtils.VERSION = '@VERSION'
function getConfig () {
return setupDefaults
}

var version = '@VERSION'

XEUtils.VERSION = version
XEUtils.version = version
XEUtils.mixin = mixin
XEUtils.setup = setup
XEUtils.setup = setConfig
XEUtils.setConfig = setConfig
XEUtils.getConfig = getConfig

module.exports = XEUtils
14 changes: 9 additions & 5 deletions func/setupDefaults.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { ToDateStringFormats } from "./toDateString"

export interface SetupDefaults {
/**
* 默认树的转换配置
* 全局唯一标识
*/
keyId?: number
/**
* 默认树的转换配置
* 用于 toArrayTree()、toTreeArray()
*/
treeOptions?: {
Expand All @@ -16,22 +20,22 @@ export interface SetupDefaults {
[key: string]: any;
};
/**
* 默认解析的日期格式
* 默认解析的日期格式
* 用于 toDateString()
*/
parseDateFormat?: string;
/**
* 默认格式化日期的规则
* 默认格式化日期的规则
* 用于 toDateString()
*/
parseDateRules?: ToDateStringFormats;
/**
* 默认周视图的起始天
* 默认周视图的起始天
* 用于 getWhatWeek()、getYearWeek()、toDateString()
*/
firstDayOfWeek?: FirstDayOfWeek;
/**
* 分隔函数配置
* 分隔函数配置
* 用于 commafy()
*/
commafyOptions?: CommafyOptions;
Expand Down
1 change: 1 addition & 0 deletions func/setupDefaults.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

var setupDefaults = {
keyId: 1,
cookies: {
path: '/'
},
Expand Down
5 changes: 3 additions & 2 deletions func/uniqueId.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var setupDefaults = require('./setupDefaults')

var eqNull = require('./eqNull')

/**
Expand All @@ -6,9 +8,8 @@ var eqNull = require('./eqNull')
* @param {String} prefix 前缀
* @return {Number}
*/
let __uniqueId = 1
function uniqueId (prefix) {
return '' + (eqNull(prefix) ? '' : prefix) + __uniqueId++
return '' + (eqNull(prefix) ? '' : prefix) + (setupDefaults.keyId++)
}

module.exports = uniqueId
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xe-utils",
"version": "3.7.3",
"version": "3.7.4",
"description": "JavaScript 函数库、工具类",
"main": "index.js",
"unpkg": "dist/xe-utils.umd.min.js",
Expand Down

0 comments on commit d40b407

Please sign in to comment.