diff --git a/component/bi/bi.js b/component/bi/bi.js index 1e692fe..0701493 100644 --- a/component/bi/bi.js +++ b/component/bi/bi.js @@ -139,6 +139,10 @@ class BiCard extends HTMLElement { coinSubmit() { const num = Number(this.input.value || this.defaultcoinnum) || 0; + if (num <= 0) { + creationAlertBox("error", "投币数量必须大于0"); + return; + } this.fetchData(`https://api.gter.net/v2/api/forum/postTopicCoin`, { token: this.token, num, diff --git a/component/item-bottom/item-bottom.js b/component/item-bottom/item-bottom.js index afe7bdc..50476e2 100644 --- a/component/item-bottom/item-bottom.js +++ b/component/item-bottom/item-bottom.js @@ -114,17 +114,36 @@ export const itemBottom = defineComponent({ }); }; + let isright = ref(false); + const share = () => { const token = item.value.token || ""; - ajax(`/v2/api/forum/postTopicShare`, {token}); + ajax(`/v2/api/forum/postTopicShare`, { token }); + + if (!shareBoxRef.value) return + + // 1. 获取元素相对于可视窗口的位置信息 + const rect = shareBoxRef.value.getBoundingClientRect(); + + // 2. 获取可视窗口宽度(不包含滚动条,更准确) + const clientWidth = document.documentElement.clientWidth; + + // 3. 计算距离:可视窗口宽度 - 元素右边缘到左边缘的距离 + const distance = clientWidth - rect.right; + console.log('distance', distance); + + if (distance < 140) isright.value = true; + else isright.value = false; }; - return { share, QRcode, showQRcode, copyLinkClick, collectClick, item, likeClick, isLogin, isLikeGif }; + const shareBoxRef = ref(null); + + return { isright, shareBoxRef, share, QRcode, showQRcode, copyLinkClick, collectClick, item, likeClick, isLogin, isLikeGif }; }, components: { like, }, - template: `
{{ item?.commentreviews?.content || "[图]" }}
{{ item.likes || "赞" }}
{{ item.collections || "收藏" }}
{{ item.comments || "讨论" }}
{{ item.coins || "投币" }}
{{ item.shares || '转发'}}
`, + template: `
{{ item?.commentreviews?.content || "[图]" }}
{{ item.likes || "赞" }}
{{ item.collections || "收藏" }}
{{ item.comments || "讨论" }}
{{ item.coins || "投币" }}
{{ item.shares || '转发'}}
`, }); diff --git a/component/item-bottom/item-bottom.txt b/component/item-bottom/item-bottom.txt index 08b5cb2..0f7cd53 100644 --- a/component/item-bottom/item-bottom.txt +++ b/component/item-bottom/item-bottom.txt @@ -35,7 +35,7 @@
{{ item.shares || '转发'}}
-
+