Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ding #810

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
interface Window {
gUid: string;
CNPilot?: any;
dataLayer?: any;
aes?: any;
AESPluginEvent?: any;
}
interface PerformanceEntry {
type?: any;
}

// 或者
interface GlobalThis {
gUid: string;
}
2 changes: 1 addition & 1 deletion src/components/common/Header/CommunityMenu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const posts = await getEntries(simplifiedPosts as any);
<div class="mr-16 hoverable relative">
<img
class="tooltip hidden w-40 absolute bottom-9"
src="https://img.alicdn.com/imgextra/i4/O1CN01ivNLl61l6i93SDfcz_!!6000000004770-0-tps-854-1102.jpg"
src="https://img.alicdn.com/imgextra/i4/O1CN01jbIvii1i7Dp8PoPB7_!!6000000004365-0-tps-1242-1549.jpg"
alt=""
/>
<span class="text-gray-02 flex items-center">
Expand Down
25 changes: 19 additions & 6 deletions src/components/common/Header/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ let height,
</script>

<script>
//cnpilot
function addCopilot() {
//cnpilot
const copilotJSScript = document.createElement("script");
copilotJSScript.type = "text/javascript";
copilotJSScript.src = "https://g.alicdn.com/cm-design/copilot-booter/0.0.26/copilot-booter.js";
Expand Down Expand Up @@ -166,11 +164,26 @@ let height,
});
document.body.append(copilotJSScript);
}
addCopilot();
document.addEventListener("astro:page-load", function () {
if (window.CNPilot) window.CNPilot.unmounted();

let htmlWidthInRem = 100;
try {
const htmlElement = document.documentElement;
const computedStyle = window.getComputedStyle(htmlElement);
const rootFontSize = parseFloat(computedStyle.fontSize);
const htmlWidthInPixels = htmlElement.clientWidth;
htmlWidthInRem = htmlWidthInPixels / rootFontSize;
} catch(err) {
console.info('err', err);
};
// 30rem
if(htmlWidthInRem > 30) {
addCopilot();
});

document.addEventListener("astro:page-load", function () {
if (window.CNPilot) window.CNPilot.unmounted();
addCopilot();
});
};
</script>

<script>
Expand Down
Loading