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