|
|
@ -1,51 +1,50 @@ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 可写的常量 |
|
|
|
* 可写的常量 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
import { isNumber } from "../2.base"; |
|
|
|
import { isNumber, nextTick, setNextTick } from "../2.base"; |
|
|
|
import { _global } from "../0.foundation"; |
|
|
|
import { _global } from "../0.foundation"; |
|
|
|
import { Cache } from "../structure"; |
|
|
|
import { Cache } from "../structure"; |
|
|
|
|
|
|
|
import { Element, setElement } from "../element/element"; |
|
|
|
import { setDom, DOM } from "../utils"; |
|
|
|
import { setDom, DOM } from "../utils"; |
|
|
|
|
|
|
|
|
|
|
|
const PropertyDescriptors = {}; |
|
|
|
const PropertyDescriptors = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function _defineVarProperties(libName) { |
|
|
|
|
|
|
|
Object.defineProperties(libName, PropertyDescriptors); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addDescriptor(key, options) { |
|
|
|
|
|
|
|
options.enumerable = options.enumerable === undefined ? true : options.enumerable; |
|
|
|
|
|
|
|
options.configurable = options.configurable === undefined ? true : options.configurable; |
|
|
|
|
|
|
|
PropertyDescriptors[key] = options; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export let EVENT_RESPONSE_TIME = 200; |
|
|
|
export let EVENT_RESPONSE_TIME = 200; |
|
|
|
export const setEventResponseTime = v => { |
|
|
|
export const setEventResponseTime = v => { |
|
|
|
EVENT_RESPONSE_TIME = v; |
|
|
|
EVENT_RESPONSE_TIME = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["EVENT_RESPONSE_TIME"] = { |
|
|
|
addDescriptor("EVENT_RESPONSE_TIME", { |
|
|
|
enumerable: true, |
|
|
|
get: () => EVENT_RESPONSE_TIME, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return EVENT_RESPONSE_TIME; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setEventResponseTime, |
|
|
|
set: setEventResponseTime, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export let pixUnit = "px"; |
|
|
|
export let pixUnit = "px"; |
|
|
|
export const setPixUnit = v => { |
|
|
|
export const setPixUnit = v => { |
|
|
|
pixUnit = v; |
|
|
|
pixUnit = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["pixUnit"] = { |
|
|
|
addDescriptor("pixUnit", { |
|
|
|
enumerable: true, |
|
|
|
get: () => pixUnit, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return pixUnit; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setPixUnit, |
|
|
|
set: setPixUnit, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export let pixRatio = 1; |
|
|
|
export let pixRatio = 1; |
|
|
|
export const setPixRatio = v => { |
|
|
|
export const setPixRatio = v => { |
|
|
|
pixRatio = v; |
|
|
|
pixRatio = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["pixRatio"] = { |
|
|
|
addDescriptor("pixRatio", { |
|
|
|
enumerable: true, |
|
|
|
get: () => pixRatio, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return pixRatio; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setPixRatio, |
|
|
|
set: setPixRatio, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export let StartOfWeek = 1; |
|
|
|
export let StartOfWeek = 1; |
|
|
|
export const setStartOfWeek = v => { |
|
|
|
export const setStartOfWeek = v => { |
|
|
@ -55,27 +54,19 @@ export const setStartOfWeek = v => { |
|
|
|
} |
|
|
|
} |
|
|
|
StartOfWeek = v; |
|
|
|
StartOfWeek = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["StartOfWeek"] = { |
|
|
|
addDescriptor("StartOfWeek", { |
|
|
|
enumerable: true, |
|
|
|
get: () => StartOfWeek, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return StartOfWeek; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setStartOfWeek, |
|
|
|
set: setStartOfWeek, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export let BlankSplitChar = "\u200b \u200b"; |
|
|
|
export let BlankSplitChar = "\u200b \u200b"; |
|
|
|
export const setBlankSplitChar = v => { |
|
|
|
export const setBlankSplitChar = v => { |
|
|
|
BlankSplitChar = v; |
|
|
|
BlankSplitChar = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["BlankSplitChar"] = { |
|
|
|
addDescriptor("BlankSplitChar", { |
|
|
|
enumerable: true, |
|
|
|
get: () => BlankSplitChar, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return BlankSplitChar; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setBlankSplitChar, |
|
|
|
set: setBlankSplitChar, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 一定返回最终的单位
|
|
|
|
// 一定返回最终的单位
|
|
|
|
export let pixFormat = (pix, border) => { |
|
|
|
export let pixFormat = (pix, border) => { |
|
|
@ -95,14 +86,10 @@ export let pixFormat = (pix, border) => { |
|
|
|
export const setPixFormat = v => { |
|
|
|
export const setPixFormat = v => { |
|
|
|
pixFormat = v; |
|
|
|
pixFormat = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["pixFormat"] = { |
|
|
|
addDescriptor("pixFormat", { |
|
|
|
enumerable: true, |
|
|
|
get: () => pixFormat, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return pixFormat; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setPixFormat, |
|
|
|
set: setPixFormat, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export let toPix = (pix, border) => { |
|
|
|
export let toPix = (pix, border) => { |
|
|
|
if (!isNumber(pix)) { |
|
|
|
if (!isNumber(pix)) { |
|
|
@ -120,14 +107,10 @@ export let toPix = (pix, border) => { |
|
|
|
export let setToPix = v => { |
|
|
|
export let setToPix = v => { |
|
|
|
toPix = v; |
|
|
|
toPix = v; |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["toPix"] = { |
|
|
|
addDescriptor("toPix", { |
|
|
|
enumerable: true, |
|
|
|
get: () => toPix, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return toPix; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setToPix, |
|
|
|
set: setToPix, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const getCacheItem = key => { |
|
|
|
const getCacheItem = key => { |
|
|
|
Cache.getItem(key, { typeConversion: true, defaultValue: true }); |
|
|
|
Cache.getItem(key, { typeConversion: true, defaultValue: true }); |
|
|
@ -137,24 +120,22 @@ export const setEventBlur = v => { |
|
|
|
EVENT_BLUR = v; |
|
|
|
EVENT_BLUR = v; |
|
|
|
Cache.setItem("event.blur", v); |
|
|
|
Cache.setItem("event.blur", v); |
|
|
|
}; |
|
|
|
}; |
|
|
|
PropertyDescriptors["EVENT_BLUR"] = { |
|
|
|
addDescriptor("EVENT_BLUR", { |
|
|
|
enumerable: true, |
|
|
|
get: () => EVENT_BLUR, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return EVENT_BLUR; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setEventBlur, |
|
|
|
set: setEventBlur, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addDescriptor("Element", { |
|
|
|
|
|
|
|
get: () => Element, |
|
|
|
|
|
|
|
set: setElement, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
PropertyDescriptors["DOM"] = { |
|
|
|
addDescriptor("DOM", { |
|
|
|
enumerable: true, |
|
|
|
get: () => DOM, |
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function() { |
|
|
|
|
|
|
|
return DOM; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: setDom, |
|
|
|
set: setDom, |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export function _defineVarProperties(libName) { |
|
|
|
addDescriptor("nextTick", { |
|
|
|
Object.defineProperties(libName, PropertyDescriptors); |
|
|
|
get: () => nextTick, |
|
|
|
} |
|
|
|
set: setNextTick, |
|
|
|
|
|
|
|
}); |