Skip to content

Commit 40905d8

Browse files
committed
fix: docs deploy cleanup and ssr guards
1 parent 6897c11 commit 40905d8

20 files changed

Lines changed: 186 additions & 76 deletions

File tree

.github/workflows/docs-deploy-bt.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ jobs:
142142
run: |
143143
PORT="${DOCS_DEPLOY_PORT:-22}"
144144
TARGET_DIR="${{ steps.target_path.outputs.TARGET_DIR }}"
145-
ssh -p "$PORT" "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST" "rm -rf '$TARGET_DIR' && mkdir -p '$TARGET_DIR'"
145+
ssh -p "$PORT" "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST" "\
146+
mkdir -p '$TARGET_DIR' && \
147+
find '$TARGET_DIR' -mindepth 1 -maxdepth 1 ! -name '.user.ini' -exec rm -rf {} +"
146148
147149
- name: Upload dist
148150
env:
@@ -152,7 +154,7 @@ jobs:
152154
run: |
153155
PORT="${DOCS_DEPLOY_PORT:-22}"
154156
TARGET_DIR="${{ steps.target_path.outputs.TARGET_DIR }}"
155-
rsync -az --delete --timeout=120 --info=progress2 -e "ssh -p $PORT" apps/docs/.vitepress/dist/ "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST:$TARGET_DIR/"
157+
rsync -az --delete --exclude='.user.ini' --timeout=120 --info=progress2 -e "ssh -p $PORT" apps/docs/.vitepress/dist/ "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST:$TARGET_DIR/"
156158
157159
- name: Print remote dist summary
158160
env:

apps/docs/en/components/bubble/demos/with-markdown.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ Supports formulas, code blocks, task lists, and streaming rendering.
77
</docs>
88

99
<script setup lang="ts">
10-
import { MarkdownRenderer } from 'x-markdown-vue';
11-
import 'x-markdown-vue/style';
1210
import 'katex/dist/katex.min.css';
1311
1412
import 'shiki';
1513
import 'shiki-stream';
1614
15+
const MarkdownRenderer = shallowRef();
16+
onMounted(async () => {
17+
if (typeof window === 'undefined') return;
18+
await import('x-markdown-vue/style');
19+
const mod = await import('x-markdown-vue');
20+
MarkdownRenderer.value = mod.MarkdownRenderer ?? mod.default ?? mod;
21+
});
22+
1723
const avatar = 'https://avatars.githubusercontent.com/u/76239030?s=40&v=4';
1824
1925
const staticContent = ref(`### Inline Formulas
@@ -117,7 +123,11 @@ onUnmounted(() => {
117123
<Bubble :avatar="avatar" placement="start">
118124
<template #content>
119125
<div class="markdown-content-wrapper">
120-
<MarkdownRenderer :markdown="staticContent" />
126+
<component
127+
:is="MarkdownRenderer"
128+
v-if="MarkdownRenderer"
129+
:markdown="staticContent"
130+
/>
121131
</div>
122132
</template>
123133
</Bubble>
@@ -139,7 +149,9 @@ onUnmounted(() => {
139149
<Bubble :avatar="avatar" placement="start">
140150
<template #content>
141151
<div class="markdown-content-wrapper">
142-
<MarkdownRenderer
152+
<component
153+
:is="MarkdownRenderer"
154+
v-if="MarkdownRenderer"
143155
:markdown="streamingContent"
144156
:enable-animate="true"
145157
/>

apps/docs/en/components/bubbleList/demos/with-markdown.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ Supports formulas, code blocks, and task lists in list rendering.
77
</docs>
88

99
<script setup lang="ts">
10-
import { MarkdownRenderer } from 'x-markdown-vue';
11-
import 'x-markdown-vue/style';
1210
import 'katex/dist/katex.min.css';
1311
1412
import 'shiki';
1513
import 'shiki-stream';
1614
15+
const MarkdownRenderer = shallowRef();
16+
onMounted(async () => {
17+
if (typeof window === 'undefined') return;
18+
await import('x-markdown-vue/style');
19+
const mod = await import('x-markdown-vue');
20+
MarkdownRenderer.value = mod.MarkdownRenderer ?? mod.default ?? mod;
21+
});
22+
1723
const list = ref([
1824
{
1925
key: '1',
@@ -82,7 +88,11 @@ console.log(greeting);
8288
<BubbleList :list="list" max-height="500px">
8389
<template #content="{ item }">
8490
<div class="markdown-content-wrapper">
85-
<MarkdownRenderer :markdown="item.content" />
91+
<component
92+
:is="MarkdownRenderer"
93+
v-if="MarkdownRenderer"
94+
:markdown="item.content"
95+
/>
8696
</div>
8797
</template>
8898
</BubbleList>

apps/docs/en/home/components/Contributors.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const repo = 'Element-Plus-X';
1414
1515
const targetElement = ref();
1616
17-
const contributors: RepoContributor[] = _repo_contributors[
18-
repo as keyof typeof _repo_contributors
19-
] as RepoContributor[];
17+
const contributors: RepoContributor[] =
18+
(_repo_contributors as Record<string, RepoContributor[]>)[repo] ?? [];
2019
// const loading = ref(false);
2120
// const error = ref('');
2221

apps/docs/en/home/components/FeaturesSection/index.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts">
22
import { gsap } from 'gsap';
3-
import { ScrollTrigger } from 'gsap/ScrollTrigger';
43
import { defineClientComponent } from 'vitepress';
54
import { markRaw, nextTick, onMounted, onUnmounted, ref } from 'vue';
65
import {
@@ -16,10 +15,9 @@ import {
1615
} from './starfield-manager';
1716
import { TechCircleManager } from './tech-circle-manager';
1817
19-
// 注册GSAP插件
20-
gsap.registerPlugin(ScrollTrigger);
21-
2218
// DOM引用
19+
let ScrollTrigger: any;
20+
2321
const cardWrapRef = ref<HTMLElement | null>(null);
2422
const canvases = ref<(HTMLCanvasElement | null)[]>([]);
2523
const backgroundContainerRef = ref<HTMLElement | null>(null);
@@ -242,7 +240,13 @@ function initBackgroundCircles() {
242240
}
243241
244242
// 生命周期
245-
onMounted(() => {
243+
onMounted(async () => {
244+
if (typeof window === 'undefined') return;
245+
if (!ScrollTrigger) {
246+
const mod = await import('gsap/ScrollTrigger');
247+
ScrollTrigger = mod.default ?? mod.ScrollTrigger;
248+
}
249+
if (ScrollTrigger) gsap.registerPlugin(ScrollTrigger);
246250
initBackgroundCircles();
247251
setTimeout(() => {
248252
initCardAnimations();

apps/docs/en/home/components/FeaturesSection/starfield-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export class StarfieldManager {
6464

6565
const resizeCanvas = () => {
6666
const { width, height } = innerWrap.getBoundingClientRect();
67-
const dpr = window.devicePixelRatio || 1;
67+
const dpr =
68+
typeof window === 'undefined' ? 1 : window.devicePixelRatio || 1;
6869
this.canvas.width = width * dpr;
6970
this.canvas.height = height * dpr;
7071
this.canvas.style.width = `${width}px`;

apps/docs/en/home/components/HeroSection.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts">
22
import { gsap } from 'gsap';
3-
import ScrollTrigger from 'gsap/ScrollTrigger';
4-
import { SplitText } from 'gsap/SplitText';
53
import { ref } from 'vue';
64
7-
gsap.registerPlugin(SplitText);
8-
gsap.registerPlugin(ScrollTrigger);
5+
let SplitText: any;
6+
let ScrollTrigger: any;
97
108
// 复制状态和安装命令
119
const copied = ref(false);
@@ -21,6 +19,17 @@ const previewText = 'Preview';
2119
const githubText = 'GitHub';
2220
2321
onMounted(async () => {
22+
if (typeof window === 'undefined') return;
23+
if (!SplitText) {
24+
const mod = await import('gsap/SplitText');
25+
SplitText = mod.SplitText;
26+
}
27+
if (!ScrollTrigger) {
28+
const mod = await import('gsap/ScrollTrigger');
29+
ScrollTrigger = mod.default ?? mod.ScrollTrigger;
30+
}
31+
if (SplitText) gsap.registerPlugin(SplitText);
32+
if (ScrollTrigger) gsap.registerPlugin(ScrollTrigger);
2433
await document.fonts?.ready;
2534
textAnimation();
2635
scrollTriggerAnimation();

apps/docs/en/home/components/ProductDisplayArea.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
<script setup lang="ts">
2-
import { onMounted, reactive, ref } from 'vue';
2+
import { onMounted, onUnmounted, reactive, ref } from 'vue';
33
44
const columnCount = 4;
55
const columnVerticalOffset = 60;
66
77
const responsive = reactive({ isMobile: false });
88
99
function checkScreenSize() {
10+
if (typeof window === 'undefined') return;
1011
responsive.isMobile = window.innerWidth < 1000;
1112
}
1213
1314
onMounted(() => {
1415
checkScreenSize();
16+
if (typeof window === 'undefined') return;
1517
window.addEventListener('resize', checkScreenSize);
16-
17-
return () => {
18-
window.removeEventListener('resize', checkScreenSize);
19-
};
2018
});
2119
22-
// onUnmounted(() => {
23-
// window.removeEventListener('resize', checkScreenSize);
24-
// });
20+
onUnmounted(() => {
21+
if (typeof window === 'undefined') return;
22+
window.removeEventListener('resize', checkScreenSize);
23+
});
2524
2625
// 为每张张张图片设置独特的阴影参数
2726
const chatImgs = ref([

apps/docs/en/home/components/ReviewsSection.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
<script setup lang="ts">
2-
import { onMounted, ref } from 'vue';
2+
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
33
import { reviews, shuffleReviews } from './reviews';
44
55
const WaterfallItem = ref();
66
77
async function calcSpan() {
8-
for (const el of WaterfallItem.value) {
8+
const items = WaterfallItem.value;
9+
if (!items) return;
10+
const list = Array.isArray(items) ? items : [items];
11+
12+
for (const el of list) {
913
await nextTick();
1014
const rows = Math.floor(el.clientHeight / 2) + 18;
1115
el.style.gridRowEnd = `span ${rows}`;
1216
}
1317
}
18+
19+
function handleResize() {
20+
void calcSpan();
21+
}
22+
1423
onMounted(async () => {
1524
await calcSpan();
25+
if (typeof window === 'undefined') return;
26+
window.addEventListener('resize', handleResize);
1627
});
1728
18-
window.addEventListener('resize', calcSpan);
29+
onUnmounted(() => {
30+
if (typeof window === 'undefined') return;
31+
window.removeEventListener('resize', handleResize);
32+
});
1933
</script>
2034

2135
<template>

apps/docs/en/home/components/SupportSection.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<script setup lang="ts">
22
import { Plus } from '@element-plus/icons-vue';
33
import { gsap } from 'gsap';
4-
import ScrollTrigger from 'gsap/ScrollTrigger';
54
import { onMounted, ref } from 'vue';
65
import { sponsors } from './reviews';
76
8-
gsap.registerPlugin(ScrollTrigger);
9-
7+
let ScrollTrigger: any;
108
const toBeSponsorUrl = ref<string>('https://chat.element-plus-x.com/chat');
119
1210
function toBeSponsor() {
@@ -15,7 +13,13 @@ function toBeSponsor() {
1513
window.open(toBeSponsorUrl.value, '_blank');
1614
}
1715
18-
onMounted(() => {
16+
onMounted(async () => {
17+
if (typeof window === 'undefined') return;
18+
if (!ScrollTrigger) {
19+
const mod = await import('gsap/ScrollTrigger');
20+
ScrollTrigger = mod.default ?? mod.ScrollTrigger;
21+
}
22+
if (ScrollTrigger) gsap.registerPlugin(ScrollTrigger);
1923
scrollTriggerAnimation();
2024
});
2125

0 commit comments

Comments
 (0)