Browse Source

KERNEL-14316 fix:给每 个可修改属性添加 Set 方法

es6
Treecat 1 year ago
parent
commit
aac665e4c0
  1. 93
      packages/fineui/src/core/constant/writable.var.js
  2. 12
      packages/fineui/typescript/core/var.ts

93
packages/fineui/src/core/constant/writable.var.js

@ -8,74 +8,77 @@ import { Cache } from "../structure";
const PropertyDescriptors = {};
export let EVENT_RESPONSE_TIME = 200;
export const setEventResponseTime = v => {
EVENT_RESPONSE_TIME = v;
};
PropertyDescriptors["EVENT_RESPONSE_TIME"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return EVENT_RESPONSE_TIME;
},
set: function(newVal) {
EVENT_RESPONSE_TIME = newVal;
}
set: setEventResponseTime,
};
export let pixUnit = "px";
export const setPixUnit = v => {
pixUnit = v;
};
PropertyDescriptors["pixUnit"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return pixUnit;
},
set: function(newVal) {
pixUnit = newVal;
}
set: setPixUnit,
};
export let pixRatio = 1;
export const setPixRatio = v => {
pixRatio = v;
};
PropertyDescriptors["pixRatio"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return pixRatio;
},
set: function(newVal) {
pixRatio = newVal;
}
set: setPixRatio,
};
export let StartOfWeek = 1;
export const setStartOfWeek = v => {
StartOfWeek = v;
};
PropertyDescriptors["StartOfWeek"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return StartOfWeek;
},
set: function(newVal) {
StartOfWeek = newVal;
}
set: setStartOfWeek,
};
export let BlankSplitChar = "\u200b \u200b";
export const setBlankSplitChar = v => {
BlankSplitChar = v;
};
PropertyDescriptors["BlankSplitChar"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return BlankSplitChar;
},
set: function(newVal) {
BlankSplitChar = newVal;
}
set: setBlankSplitChar,
};
// 一定返回最终的单位
export function pixFormat(pix, border) {
export let pixFormat = (pix, border) => {
if (!isNumber(pix)) {
return pix;
}
if (pixUnit === "px") {
return (pix / pixRatio - (border || 0)) + pixUnit;
return pix / pixRatio - (border || 0) + pixUnit;
}
const length = pix / pixRatio + pixUnit;
if (border > 0) {
@ -83,20 +86,20 @@ export function pixFormat(pix, border) {
}
return length;
}
};
export const setPixFormat = v => {
pixFormat = v;
};
PropertyDescriptors["pixFormat"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return pixFormat;
},
set: function(newVal) {
pixFormat = newVal;
}
set: setPixFormat,
};
export function toPix(pix, border) {
export let toPix = (pix, border) => {
if (!isNumber(pix)) {
return pix;
}
@ -108,30 +111,34 @@ export function toPix(pix, border) {
}
return pix;
}
};
export let setToPix = v => {
toPix = v;
};
PropertyDescriptors["toPix"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return toPix;
},
set: function(newVal) {
toPix = newVal;
}
set: setToPix,
};
export let EVENT_BLUR = _global.localStorage ? Cache.getItem("event.blur", {typeConversion: true, defaultValue: true}) : true;
const getCacheItem = key => {
Cache.getItem(key, { typeConversion: true, defaultValue: true });
};
export let EVENT_BLUR = _global.localStorage ? getCacheItem("event.blur") : true;
export const setEventBlur = v => {
EVENT_BLUR = v;
Cache.setItem("event.blur", newVal);
};
PropertyDescriptors["EVENT_BLUR"] = {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return EVENT_BLUR;
},
set: function(newVal) {
EVENT_BLUR = newVal
Cache.setItem("event.blur", newVal)
}
set: setEventBlur,
};
export function _defineVarProperties(libName) {

12
packages/fineui/typescript/core/var.ts

@ -131,5 +131,13 @@ export declare const StartOfWeek: number;
export declare const BlankSplitChar: string;
export declare const Events: Record<string, string>;
export declare const setToPix: Function;
export declare const setPixFormat: Function;
type SetFunc = (value: any) => void;
export declare const setEventResponseTime: SetFunc;
export declare const setPixUnit: SetFunc;
export declare const setPixRatio: SetFunc;
export declare const setStartOfWeek: SetFunc;
export declare const setBlankSplitChar: SetFunc;
export declare const setPixFormat: SetFunc;
export declare const setToPix: SetFunc;
export declare const setEventBlur: SetFunc;

Loading…
Cancel
Save