Browse Source

Merge remote-tracking branch 'fineui/es6' into es6

# Conflicts:
#	packages/fineui/src/core/constant/var.js
es6
Treecat 2 years ago
parent
commit
2634e6de2b
  1. 6
      packages/fineui/src/bundle.js
  2. 1
      packages/fineui/src/core/constant/index.js
  3. 50
      packages/fineui/src/core/constant/var.js
  4. 139
      packages/fineui/src/core/constant/writable.var.js

6
packages/fineui/src/bundle.js

@ -1,6 +1,7 @@
import * as fuiExport from "./index";
import * as injectFn from "@/core/5.inject";
import { _global } from "@/core/0.foundation";
import {_defineVarProperties} from "@/core/constant/writable.var";
_global.BI = _global.BI || {};
@ -14,7 +15,4 @@ Object.assign(_global, {
Object.assign(_global.BI, fuiExport, injectFn);
Object.defineProperty(_global.BI, "EVENT_BLUR", {
set: fuiExport.setEventBlur,
get: () => fuiExport.EVENT_BLUR
});
_defineVarProperties(_global.BI)

1
packages/fineui/src/core/constant/index.js

@ -1,2 +1,3 @@
export { Events } from "./events";
export * from "./var";
export * from "./writable.var"

50
packages/fineui/src/core/constant/var.js

@ -1,24 +1,15 @@
/**
* 常量
*/
import { isNumber } from "../2.base";
import { Cache } from "../structure/cache";
import { _global } from "../0.foundation";
export let EVENT_BLUR = _global.localStorage ? Cache.getItem("event.blur", {typeConversion: true, defaultValue: true}) : true;
export const setEventBlur = (v) => { EVENT_BLUR = v, Cache.setItem("event.blur", v) };
export const MAX = 0xfffffffffffffff;
export const MIN = -0xfffffffffffffff;
export const EVENT_RESPONSE_TIME = 200;
export const zIndex_layer = 1e5;
export const zIndex_popover = 1e6;
export const zIndex_popup = 1e7;
export const zIndex_masker = 1e8;
export const zIndex_tip = 1e9;
export const emptyStr = "";
export const pixUnit = "px";
export const pixRatio = 1;
export const empty = null;
export const Key = {
48: "0",
@ -138,45 +129,4 @@ export const VerticalAlign = {
Bottom: "bottom",
Stretch: "stretch",
};
export const StartOfWeek = 1;
export const BlankSplitChar = "\u200b \u200b";
// 一定返回最终的单位
export let 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;
}
export function setPixFormat(func) {
pixFormat = func;
}
export let 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;
}
export function setToPix(func) {
toPix = func;
}
export function emptyFn() {}

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

@ -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…
Cancel
Save