Skip to content

Commit 35c24e6

Browse files
author
DCloud_LXH
committed
chore: build uni-h5
1 parent b47ff13 commit 35c24e6

File tree

2 files changed

+54
-17
lines changed

2 files changed

+54
-17
lines changed

packages/uni-h5/dist-x/uni-h5.cjs.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9294,12 +9294,18 @@ const index$d = /* @__PURE__ */ defineBuiltInComponent({
92949294
};
92959295
}
92969296
});
9297+
class UniVueElement extends HTMLElement {
9298+
}
9299+
class UniLoadingElement extends UniVueElement {
9300+
}
92979301
function useLoadingStyle(targetElement, bold) {
92989302
const loadingSize = vue.ref("16px");
9299-
const loadingBorderWidth = vue.ref("0px");
9303+
const loadingBorderWidth = vue.ref("1px");
9304+
const loadingBorderRadius = vue.ref("8px");
93009305
return {
93019306
size: loadingSize,
9302-
borderWidth: loadingBorderWidth
9307+
borderWidth: loadingBorderWidth,
9308+
borderRadius: loadingBorderRadius
93039309
};
93049310
}
93059311
var __defProp = Object.defineProperty;
@@ -9322,7 +9328,12 @@ var __spreadValues = (a, b) => {
93229328
};
93239329
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
93249330
const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
9325-
name: "Loading",
9331+
name: "loading",
9332+
// @ts-ignore
9333+
rootElement: {
9334+
name: "uni-loading-element",
9335+
class: UniLoadingElement
9336+
},
93269337
__reserved: true,
93279338
compatConfig: {
93289339
MODE: 3

packages/uni-h5/dist-x/uni-h5.es.js

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18865,33 +18865,54 @@ const index$e = /* @__PURE__ */ defineBuiltInComponent({
1886518865
};
1886618866
}
1886718867
});
18868-
const coefficientMap = {
18869-
medium: 1,
18870-
thick: 2
18871-
};
18868+
class UniVueElement extends HTMLElement {
18869+
}
18870+
class UniLoadingElement extends UniVueElement {
18871+
}
1887218872
function useLoadingStyle(targetElement, bold) {
1887318873
const loadingSize = ref("16px");
18874-
const loadingBorderWidth = ref("0px");
18874+
const loadingBorderWidth = ref("1px");
18875+
const loadingBorderRadius = ref("8px");
18876+
let observer = null;
1887518877
const calculateLoadingWidth = (element, bold2) => {
18876-
if (!element)
18877-
return;
18878-
const computedStyle = window.getComputedStyle(element);
18879-
const width = parseFloat(computedStyle.width);
18880-
const height = parseFloat(computedStyle.height);
18881-
const coefficient = coefficientMap[bold2 ? "thick" : "medium"];
18878+
const { width, height } = element.getBoundingClientRect();
18879+
const coefficient = bold2 ? 2 : 1;
1888218880
const minSide = Math.min(width, height);
1888318881
const calculatedWidth = minSide / 16 * coefficient;
1888418882
loadingSize.value = `${minSide}px`;
1888518883
loadingBorderWidth.value = `${calculatedWidth}px`;
18884+
loadingBorderRadius.value = `${minSide / 2}px`;
18885+
};
18886+
const setupObserver = (cb) => {
18887+
const el = targetElement.value;
18888+
if (!el)
18889+
return;
18890+
observer = new ResizeObserver((entries2) => {
18891+
cb(el);
18892+
});
18893+
observer.observe(el);
1888618894
};
1888718895
onMounted(() => {
18896+
setupObserver((el) => {
18897+
calculateLoadingWidth(el, bold.value);
18898+
});
1888818899
watchEffect(() => {
18889-
calculateLoadingWidth(targetElement.value, bold.value);
18900+
const _bold = bold.value;
18901+
const el = targetElement.value;
18902+
if (el !== null) {
18903+
calculateLoadingWidth(el, _bold);
18904+
}
1889018905
});
1889118906
});
18907+
onUnmounted(() => {
18908+
if (observer) {
18909+
observer.disconnect();
18910+
}
18911+
});
1889218912
return {
1889318913
size: loadingSize,
18894-
borderWidth: loadingBorderWidth
18914+
borderWidth: loadingBorderWidth,
18915+
borderRadius: loadingBorderRadius
1889518916
};
1889618917
}
1889718918
var __defProp2 = Object.defineProperty;
@@ -18914,7 +18935,12 @@ var __spreadValues = (a2, b) => {
1891418935
};
1891518936
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
1891618937
const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
18917-
name: "Loading",
18938+
name: "loading",
18939+
// @ts-ignore
18940+
rootElement: {
18941+
name: "uni-loading-element",
18942+
class: UniLoadingElement
18943+
},
1891818944
__reserved: true,
1891918945
compatConfig: {
1892018946
MODE: 3

0 commit comments

Comments
 (0)