fix: fix all hardcoded /zh-cn/ links in home page components (HomeI18n, HomeAppleFooter, HomeFeatures)

This commit is contained in:
sanbuphy
2026-05-21 09:59:12 +08:00
parent df24d8f6de
commit 461ea357ab
8 changed files with 386 additions and 239 deletions
@@ -47,17 +47,13 @@ const isCjkLocale = computed(() => {
const topPromo = computed(() => { const topPromo = computed(() => {
const code = lang.value ? lang.value.toLowerCase() : 'en' const code = lang.value ? lang.value.toLowerCase() : 'en'
if (code === 'zh-cn' || code === 'zh-tw') { const isChinese = code === 'zh-cn' || code === 'zh-tw'
return {
text: '用 Easy-Vibe 构建你的第一个 AI 应用,最快当天可上线原型。',
cta: '开始学习 ',
link: '/zh-cn/stage-1/learning-map/'
}
}
return { return {
text: 'Build your first AI app with Easy-Vibe and ship a working prototype fast.', text: isChinese
cta: 'Start learning ', ? '用 Easy-Vibe 构建你的第一个 AI 应用,最快当天可上线原型。'
link: '/en/stage-1/learning-map/' : 'Build your first AI app with Easy-Vibe and ship a working prototype fast.',
cta: isChinese ? '开始学习 ' : 'Start learning ',
link: `/${code}/stage-1/learning-map/`
} }
}) })
@@ -88,6 +88,11 @@ const appleFooterInfo = computed(() => {
return content[locale] || content.en return content[locale] || content.en
}) })
const footerBtnLink = computed(() => {
const locale = t.value._locale || 'zh-cn'
return withBase(`/${locale}/stage-1/learning-map/`)
})
const footerRepositoryLink = 'https://github.com/datawhalechina/easy-vibe' const footerRepositoryLink = 'https://github.com/datawhalechina/easy-vibe'
const footerPolicyLinkMap = { const footerPolicyLinkMap = {
@@ -100,26 +105,34 @@ const footerPolicyLinkMap = {
} }
const footerColumnLinkMap = { const footerColumnLinkMap = {
'零基础入门': '/zh-cn/stage-1/', '零基础入门': '/stage-1/',
'初中级开发': '/zh-cn/stage-2/', '初中级开发': '/stage-2/',
'高级开发': '/zh-cn/stage-3/', '高级开发': '/stage-3/',
'附录': '/zh-cn/appendix/', '附录': '/appendix/',
'学习地图': '/zh-cn/stage-1/learning-map/', '学习地图': '/stage-1/learning-map/',
'课程总览': '/zh-cn/stage-1/', '课程总览': '/stage-1/',
'Foundations': '/stage-1/',
'Junior/Mid Dev': '/stage-2/',
'Senior Dev': '/stage-3/',
'Appendix': '/appendix/',
'Learning Map': '/stage-1/learning-map/',
'Course Outline': '/stage-1/',
'Overview': '/guide/introduction',
}
const footerExternalLinks = {
'GitHub 仓库': 'https://github.com/datawhalechina/easy-vibe', 'GitHub 仓库': 'https://github.com/datawhalechina/easy-vibe',
'Foundations': '/en/stage-1/',
'Junior/Mid Dev': '/en/stage-2/',
'Senior Dev': '/en/stage-3/',
'Appendix': '/en/appendix/',
'Learning Map': '/en/stage-1/learning-map/',
'Course Outline': '/en/stage-1/',
'GitHub Repository': 'https://github.com/datawhalechina/easy-vibe', 'GitHub Repository': 'https://github.com/datawhalechina/easy-vibe',
'Overview': '/en/guide/introduction', 'Changelog': 'https://github.com/datawhalechina/easy-vibe/releases',
'Changelog': 'https://github.com/datawhalechina/easy-vibe/releases'
} }
const getFooterLink = (label) => { const getFooterLink = (label) => {
return footerColumnLinkMap[label] || '#' const external = footerExternalLinks[label]
if (external) return external
const basePath = footerColumnLinkMap[label]
if (!basePath) return '#'
const locale = t.value._locale || 'zh-cn'
return `/${locale}${basePath}`
} }
const getPolicyLink = (label) => { const getPolicyLink = (label) => {
@@ -140,7 +153,7 @@ const resolveFooterHref = (link) => {
<p>{{ t.footer.desc }}</p> <p>{{ t.footer.desc }}</p>
<a <a
class="buy-btn large" class="buy-btn large"
:href="withBase('/zh-cn/stage-1/learning-map/')" :href="footerBtnLink"
>{{ t.footer.btn }}</a> >{{ t.footer.btn }}</a>
</div> </div>
File diff suppressed because it is too large Load Diff
@@ -41,8 +41,7 @@
color: #6e6e73; color: #6e6e73;
max-width: 760px; max-width: 760px;
font-family: font-family:
-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', sans-serif;
sans-serif;
} }
.dark .section-category, .dark .section-category,
@@ -65,13 +64,12 @@ a {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
:is( :is(.feature-card, .comm-card, .prod-card, .appendix-card, .buy-btn):is(
.feature-card, :hover,
.comm-card, :focus,
.prod-card, :focus-visible,
.appendix-card, :active
.buy-btn ) {
):is(:hover, :focus, :focus-visible, :active) {
border-bottom-color: transparent !important; border-bottom-color: transparent !important;
text-decoration: none !important; text-decoration: none !important;
outline: none !important; outline: none !important;
@@ -27,7 +27,6 @@ export const createReadingBookmark = ({
updatedAt: now() updatedAt: now()
}) })
export const createReadingBookmarkSnapshot = ({ export const createReadingBookmarkSnapshot = ({
path, path,
getTitle = () => '', getTitle = () => '',
@@ -74,13 +74,11 @@ describe('reading bookmarks', () => {
} }
) )
assert.equal( assert.equal(
readReadingBookmark(storage, '/easy-vibe/en/stage-1/intro/', 1000) readReadingBookmark(storage, '/easy-vibe/en/stage-1/intro/', 1000).title,
.title,
'English title' 'English title'
) )
}) })
it('keeps delayed saves bound to the path captured before navigation', () => { it('keeps delayed saves bound to the path captured before navigation', () => {
const storage = createStorage() const storage = createStorage()
let currentPath = '/easy-vibe/zh-cn/page-a/' let currentPath = '/easy-vibe/zh-cn/page-a/'
@@ -100,22 +98,16 @@ describe('reading bookmarks', () => {
}) })
) )
assert.equal( assert.equal(readReadingBookmark(storage, currentPath, 1000), null)
readReadingBookmark(storage, currentPath, 1000), assert.deepEqual(readReadingBookmark(storage, scheduledPath, 1000), {
null version: 1,
) path: scheduledPath,
assert.deepEqual( title: '页面 A',
readReadingBookmark(storage, scheduledPath, 1000), section: '小节 A',
{ scrollY: 240,
version: 1, progress: 32,
path: scheduledPath, updatedAt: 777
title: '页面 A', })
section: '小节 A',
scrollY: 240,
progress: 32,
updatedAt: 777
}
)
}) })
it('normalizes invalid numeric values', () => { it('normalizes invalid numeric values', () => {
+1 -1
View File
@@ -3,7 +3,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"> xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url> <url>
<loc>https://datawhalechina.github.io/easy-vibe/zh-cn/</loc> <loc>https://datawhalechina.github.io/easy-vibe/zh-cn/</loc>
<lastmod>2026-05-14T12:39:03+08:00</lastmod> <lastmod>2026-05-20T23:20:16+08:00</lastmod>
<changefreq>weekly</changefreq> <changefreq>weekly</changefreq>
<priority>1.0</priority> <priority>1.0</priority>
<xhtml:link rel="alternate" hreflang="zh-CN" href="https://datawhalechina.github.io/easy-vibe/zh-cn/"/> <xhtml:link rel="alternate" hreflang="zh-CN" href="https://datawhalechina.github.io/easy-vibe/zh-cn/"/>