From 4a434809e2e20b8b3c96efca2d22aa77cd46821f Mon Sep 17 00:00:00 2001 From: Treecat Date: Tue, 16 May 2023 09:59:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=97=A0jira=20fix:pixFormat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fineui/package.json | 2 +- packages/fineui/src/core/constant/var.js | 12 ++++++++++-- packages/fineui/typescript/core/var.ts | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/fineui/package.json b/packages/fineui/package.json index a10485cfc..4c3b25799 100644 --- a/packages/fineui/package.json +++ b/packages/fineui/package.json @@ -1,6 +1,6 @@ { "name": "@fui/core", - "version": "3.0.20230511185107", + "version": "3.0.20230511193354", "description": "fineui", "main": "dist/fineui.min.js", "module": "dist/lib/index.js", diff --git a/packages/fineui/src/core/constant/var.js b/packages/fineui/src/core/constant/var.js index 06bca51f6..3dd6f1247 100644 --- a/packages/fineui/src/core/constant/var.js +++ b/packages/fineui/src/core/constant/var.js @@ -142,7 +142,7 @@ export const StartOfWeek = 1; export const BlankSplitChar = "\u200b \u200b"; // 一定返回最终的单位 -export function pixFormat(pix, border) { +export let pixFormat = (pix, border) => { if (!isNumber(pix)) { return pix; } @@ -157,7 +157,11 @@ export function pixFormat(pix, border) { return length; } -export function toPix(pix, border) { +export function setPixFormat(func) { + pixFormat = func; +} + +export let toPix = (pix, border) => { if (!isNumber(pix)) { return pix; } @@ -171,4 +175,8 @@ export function toPix(pix, border) { return pix; } +export function setToPix(func) { + toPix = func; +} + export function emptyFn() {} diff --git a/packages/fineui/typescript/core/var.ts b/packages/fineui/typescript/core/var.ts index d3e956ccc..d4c4e05fd 100644 --- a/packages/fineui/typescript/core/var.ts +++ b/packages/fineui/typescript/core/var.ts @@ -129,3 +129,6 @@ export declare const VerticalAlign: { }; export declare const StartOfWeek: number; export declare const BlankSplitChar: string; + +export declare const setToPix: Function; +export declare const setPixFormat: Function; \ No newline at end of file From aac665e4c01148ec2e2bf371ec31a80a0c014238 Mon Sep 17 00:00:00 2001 From: Treecat Date: Wed, 17 May 2023 13:59:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?KERNEL-14316=20fix:=E7=BB=99=E6=AF=8F=20?= =?UTF-8?q?=E4=B8=AA=E5=8F=AF=E4=BF=AE=E6=94=B9=E5=B1=9E=E6=80=A7=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20Set=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fineui/src/core/constant/writable.var.js | 93 ++++++++++--------- packages/fineui/typescript/core/var.ts | 12 ++- 2 files changed, 60 insertions(+), 45 deletions(-) diff --git a/packages/fineui/src/core/constant/writable.var.js b/packages/fineui/src/core/constant/writable.var.js index 63c363507..1de6b3a79 100644 --- a/packages/fineui/src/core/constant/writable.var.js +++ b/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) { diff --git a/packages/fineui/typescript/core/var.ts b/packages/fineui/typescript/core/var.ts index d4c8f6077..580091fb2 100644 --- a/packages/fineui/typescript/core/var.ts +++ b/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; -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;