forked from fanruan/fineui
Browse Source
Merge in VISUAL/fineui from ~DAILER/fineui:es6 to es6 * commit 'cffd97f4508f7b6fcc2add0e0f7ed94b457ed412': BI-126203 fix: 【6.0.10冒烟】设置周开始于周日,日期面板仍然以周一开始es6
Dailer-刘荣歆
2 years ago
4 changed files with 142 additions and 46 deletions
@ -1,2 +1,3 @@
|
||||
export { Events } from "./events"; |
||||
export * from "./var"; |
||||
export * from "./writable.var" |
||||
|
@ -0,0 +1,139 @@
|
||||
/** |
||||
* 可写的常量 |
||||
*/ |
||||
import { isNumber } from "../2.base"; |
||||
import { _global } from "../0.foundation"; |
||||
import { Cache } from "../structure"; |
||||
|
||||
const PropertyDescriptors = {}; |
||||
|
||||
export let EVENT_RESPONSE_TIME = 200; |
||||
PropertyDescriptors["EVENT_RESPONSE_TIME"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return EVENT_RESPONSE_TIME; |
||||
}, |
||||
set: function(newVal) { |
||||
EVENT_RESPONSE_TIME = newVal; |
||||
} |
||||
}; |
||||
|
||||
|
||||
export let pixUnit = "px"; |
||||
PropertyDescriptors["pixUnit"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return pixUnit; |
||||
}, |
||||
set: function(newVal) { |
||||
pixUnit = newVal; |
||||
} |
||||
}; |
||||
|
||||
export let pixRatio = 1; |
||||
PropertyDescriptors["pixRatio"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return pixRatio; |
||||
}, |
||||
set: function(newVal) { |
||||
pixRatio = newVal; |
||||
} |
||||
}; |
||||
|
||||
export let StartOfWeek = 1; |
||||
PropertyDescriptors["StartOfWeek"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return StartOfWeek; |
||||
}, |
||||
set: function(newVal) { |
||||
StartOfWeek = newVal; |
||||
} |
||||
}; |
||||
|
||||
export let BlankSplitChar = "\u200b \u200b"; |
||||
PropertyDescriptors["BlankSplitChar"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return BlankSplitChar; |
||||
}, |
||||
set: function(newVal) { |
||||
BlankSplitChar = newVal; |
||||
} |
||||
}; |
||||
|
||||
|
||||
// 一定返回最终的单位
|
||||
export function pixFormat(pix, border) { |
||||
if (!isNumber(pix)) { |
||||
return pix; |
||||
} |
||||
if (pixUnit === "px") { |
||||
return (pix / pixRatio - (border || 0)) + pixUnit; |
||||
} |
||||
const length = pix / pixRatio + pixUnit; |
||||
if (border > 0) { |
||||
return `calc(${length} - ${`${border}px`})`; |
||||
} |
||||
|
||||
return length; |
||||
} |
||||
PropertyDescriptors["pixFormat"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return pixFormat; |
||||
}, |
||||
set: function(newVal) { |
||||
pixFormat = newVal; |
||||
} |
||||
}; |
||||
|
||||
|
||||
export function toPix(pix, border) { |
||||
if (!isNumber(pix)) { |
||||
return pix; |
||||
} |
||||
if (pixUnit === "px") { |
||||
return pix - (border || 0) * pixRatio; |
||||
} |
||||
if (border > 0) { |
||||
return `calc(${pix / pixRatio + pixUnit} - ${`${border}px`})`; |
||||
} |
||||
|
||||
return pix; |
||||
} |
||||
PropertyDescriptors["toPix"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return toPix; |
||||
}, |
||||
set: function(newVal) { |
||||
toPix = newVal; |
||||
} |
||||
}; |
||||
|
||||
|
||||
export let EVENT_BLUR = _global.localStorage ? Cache.getItem("event.blur", {typeConversion: true, defaultValue: true}) : true; |
||||
PropertyDescriptors["EVENT_BLUR"] = { |
||||
enumerable: true, |
||||
configurable: true, |
||||
get: function() { |
||||
return EVENT_BLUR; |
||||
}, |
||||
set: function(newVal) { |
||||
EVENT_BLUR = newVal |
||||
Cache.setItem("event.blur", newVal) |
||||
} |
||||
}; |
||||
|
||||
export function _defineVarProperties(libName) { |
||||
Object.defineProperties(libName, PropertyDescriptors); |
||||
} |
Loading…
Reference in new issue