You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
3.0 KiB
170 lines
3.0 KiB
/** |
|
* 常量 |
|
*/ |
|
import { isNumber } from "../2.base"; |
|
|
|
export const MAX = 0xfffffffffffffff; |
|
export const MIN = -0xfffffffffffffff; |
|
export const EVENT_RESPONSE_TIME = 200; |
|
export const EVENT_BLUR = true; |
|
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", |
|
49: "1", |
|
50: "2", |
|
51: "3", |
|
52: "4", |
|
53: "5", |
|
54: "6", |
|
55: "7", |
|
56: "8", |
|
57: "9", |
|
65: "a", |
|
66: "b", |
|
67: "c", |
|
68: "d", |
|
69: "e", |
|
70: "f", |
|
71: "g", |
|
72: "h", |
|
73: "i", |
|
74: "j", |
|
75: "k", |
|
76: "l", |
|
77: "m", |
|
78: "n", |
|
79: "o", |
|
80: "p", |
|
81: "q", |
|
82: "r", |
|
83: "s", |
|
84: "t", |
|
85: "u", |
|
86: "v", |
|
87: "w", |
|
88: "x", |
|
89: "y", |
|
90: "z", |
|
96: "0", |
|
97: "1", |
|
98: "2", |
|
99: "3", |
|
100: "4", |
|
101: "5", |
|
102: "6", |
|
103: "7", |
|
104: "8", |
|
105: "9", |
|
106: "*", |
|
107: "+", |
|
109: "-", |
|
110: ".", |
|
111: "/", |
|
}; |
|
export const KeyCode = { |
|
BACKSPACE: 8, |
|
COMMA: 188, |
|
DELETE: 46, |
|
DOWN: 40, |
|
END: 35, |
|
ENTER: 13, |
|
ESCAPE: 27, |
|
HOME: 36, |
|
LEFT: 37, |
|
NUMPAD_ADD: 107, |
|
NUMPAD_DECIMAL: 110, |
|
NUMPAD_DIVIDE: 111, |
|
NUMPAD_ENTER: 108, |
|
NUMPAD_MULTIPLY: 106, |
|
NUMPAD_SUBTRACT: 109, |
|
PAGE_DOWN: 34, |
|
PAGE_UP: 33, |
|
PERIOD: 190, |
|
RIGHT: 39, |
|
SPACE: 32, |
|
TAB: 9, |
|
UP: 38, |
|
}; |
|
export const Status = { |
|
SUCCESS: 1, |
|
WRONG: 2, |
|
START: 3, |
|
END: 4, |
|
WAITING: 5, |
|
READY: 6, |
|
RUNNING: 7, |
|
OUTOFBOUNDS: 8, |
|
NULL: -1, |
|
}; |
|
export const Direction = { |
|
Top: "top", |
|
Bottom: "bottom", |
|
Left: "left", |
|
Right: "right", |
|
Custom: "custom", |
|
}; |
|
export const Axis = { |
|
Vertical: "vertical", |
|
Horizontal: "horizontal", |
|
}; |
|
export const Selection = { |
|
Default: -2, |
|
None: -1, |
|
Single: 0, |
|
Multi: 1, |
|
All: 2, |
|
}; |
|
export const HorizontalAlign = { |
|
Left: "left", |
|
Right: "right", |
|
Center: "center", |
|
Stretch: "stretch", |
|
}; |
|
export const VerticalAlign = { |
|
Middle: "middle", |
|
Top: "top", |
|
Bottom: "bottom", |
|
Stretch: "stretch", |
|
}; |
|
export const StartOfWeek = 1; |
|
export const BlankSplitChar = "\u200b \u200b"; |
|
|
|
// 一定返回最终的单位 |
|
export function pixFormat(pix, border) { |
|
if (!isNumber(pix)) { |
|
return pix; |
|
} |
|
if (BI.pixUnit === "px") { |
|
return (pix / BI.pixRatio - (border || 0)) + BI.pixUnit; |
|
} |
|
const length = pix / BI.pixRatio + BI.pixUnit; |
|
if (border > 0) { |
|
return `calc(${length} - ${`${border}px`})`; |
|
} |
|
|
|
return length; |
|
} |
|
|
|
export function toPix(pix, border) { |
|
if (!isNumber(pix)) { |
|
return pix; |
|
} |
|
if (BI.pixUnit === "px") { |
|
return pix - (border || 0) * BI.pixRatio; |
|
} |
|
if (border > 0) { |
|
return `calc(${pix / BI.pixRatio + BI.pixUnit} - ${`${border}px`})`; |
|
} |
|
|
|
return pix; |
|
} |
|
|
|
export function emptyFn() {}
|
|
|