Skip to content

Commit 8e06fed

Browse files
authored
feat: resolve incomplete path error 404 (#54)
1 parent 51151ae commit 8e06fed

5 files changed

Lines changed: 66 additions & 15 deletions

File tree

.vitepress/config.mts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default defineConfig({
7777
'next-sdk/docs/:path*': 'next-sdk/:path*',
7878
'tiny-vue/examples/sites/demos/pc/webdoc/:path*': 'tiny-vue/guide/:path*',
7979
'tiny-engine/docs/:section(getting-started|basic-features|advanced-features|tutorials)/:path*':
80-
'tiny-engine/engines/:path*',
80+
'tiny-engine/guide/:path*',
8181
'tiny-engine/docs/:section(practical-cases|api|extension-capabilities-tutorial|development-getting-started|changelog|solutions|extension-capabilities-overview)/:path*':
8282
'tiny-engine/dev/:path*',
8383
'tiny-engine/docs/:section(ecosystem-center|about-applications|about-materials|about-designer)/:path*':
@@ -102,8 +102,8 @@ export default defineConfig({
102102
engineNav: [
103103
{
104104
text: '使用指南',
105-
link: '/tiny-engine/engines/introduction',
106-
activeMatch: '/engines/',
105+
link: '/tiny-engine/guide/introduction',
106+
activeMatch: '/guide/',
107107
},
108108
{
109109
text: '平台开发指南',
@@ -231,11 +231,11 @@ export default defineConfig({
231231
]
232232
}
233233
],
234-
'/tiny-engine/engines/': [
234+
'/tiny-engine/guide/': [
235235
{
236236
text: '新手指引',
237237
collapsed: false,
238-
base: '/tiny-engine/engines/',
238+
base: '/tiny-engine/guide/',
239239
items: [
240240
{ text: '简介', link: 'introduction' },
241241
{ text: '快速上手', link: 'quick-start' }
@@ -244,11 +244,10 @@ export default defineConfig({
244244
{
245245
text: '基础功能',
246246
collapsed: false,
247-
base: '/tiny-engine/engines/',
247+
base: '/tiny-engine/guide/',
248248
items: [
249-
{ text: '初识设计器', link: 'intro-to-designer' },
250-
{ text: '设计前端应用流程', link: 'frontend-application-flow' },
251249
{ text: '设计器界面模块简介', link: 'designer-ui-modules' },
250+
{ text: '设计前端应用流程', link: 'frontend-application-flow' },
252251
{ text: '页面管理', link: 'page-management' },
253252
{ text: '使用组件', link: 'using-components' },
254253
{ text: '样式设置', link: 'style-settings' },
@@ -262,7 +261,7 @@ export default defineConfig({
262261
{
263262
text: '进阶功能',
264263
collapsed: false,
265-
base: '/tiny-engine/engines/',
264+
base: '/tiny-engine/guide/',
266265
items: [
267266
{ text: '区块管理', link: 'block-management' },
268267
{ text: '使用JS面板和事件绑定', link: 'js-panel-and-event-binding' },
@@ -271,15 +270,14 @@ export default defineConfig({
271270
{ text: '如何使用插槽', link: 'how-to-use-slots' },
272271
{ text: '循环渲染', link: 'loop-rendering' },
273272
{ text: '条件渲染', link: 'conditional-rendering' },
274-
{ text: '集成ChatGPT搭建简单页面能力', link: 'integrating-chatgpt-for-simple-pages' },
275273
{ text: '新版AI插件使用', link: 'new-ai-plugin-usage' },
276274
{ text: '数据源和Collection—远程字段', link: 'data-source-and-collection-remote-fields' },
277275
{ text: '数据源和Collection—mock数据', link: 'data-source-and-collection-mock-data' },
278276
{ text: '数据源和Collection—使用数据源', link: 'data-source-and-collection-usage' },
279277
{
280278
text: '路由功能',
281279
collapsed: false,
282-
base: '/tiny-engine/engines/route-capabilities/',
280+
base: '/tiny-engine/guide/route-capabilities/',
283281
items: [
284282
{ text: '页面支持嵌套路由', link: 'page-support-nested-route' },
285283
{ text: '路由bar一键清除预览页面路径', link: 'route-bar-clear-preview-page' },
@@ -294,7 +292,7 @@ export default defineConfig({
294292
{
295293
text: '教程',
296294
collapsed: false,
297-
base: '/tiny-engine/engines/',
295+
base: '/tiny-engine/guide/',
298296
items: [{ text: '从零搭建一个页面', link: 'build-a-page-from-scratch' }]
299297
}
300298
],
@@ -388,7 +386,9 @@ export default defineConfig({
388386
{ text: '全局布局API', link: 'global-layout-api' },
389387
{ text: '物料API', link: 'material-api' },
390388
{ text: '设置面板API', link: 'settings-panel-api' },
391-
{ text: '预览API', link: 'preview-api' }
389+
{ text: '预览API', link: 'preview-api' },
390+
{ text: '元服务API', link: 'globalService-api' },
391+
{ text: '注册表API', link: 'registry-api' }
392392
]
393393
},
394394
{

.vitepress/theme/Layout.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const docTitle = ref('指南')
3434
const { site,theme } = useData()
3535
const route = useRoute()
3636
const themeConfig = computed(() => theme.value)
37+
const router = useRouter();
3738
3839
// 在客户端环境下同步 ColorModeSubject
3940
if (typeof window !== 'undefined') {
@@ -55,12 +56,51 @@ if (typeof window !== 'undefined') {
5556
// 获取 VitePress 默认布局组件
5657
const DefaultLayout = DefaultTheme.Layout
5758
59+
// 定义重定向映射
60+
const redirectMap = [
61+
{
62+
patterns: ['/tiny-engine.html', '/tiny-engine/', '/tiny-engine/guide.html', '/tiny-engine/guide/'],
63+
target: '/tiny-engine/guide/introduction'
64+
},
65+
{
66+
patterns: ['/tiny-engine/dev/', '/tiny-engine/dev.html'],
67+
target: '/tiny-engine/dev/dev-intro'
68+
},
69+
{
70+
patterns: ['/tiny-engine/portal/', '/tiny-engine/portal.html'],
71+
target: '/tiny-engine/portal/ecosystem-intro'
72+
},
73+
{
74+
patterns: ['/tiny-vue.html', '/tiny-vue/', '/tiny-vue/guide.html', '/tiny-vue/guide/'],
75+
target: '/tiny-vue/guide/introduce'
76+
},
77+
{
78+
patterns: ['/tiny-robot.html', '/tiny-robot/', '/tiny-robot/guide.html', '/tiny-robot/guide/'],
79+
target: '/tiny-robot/guide/quick-start'
80+
},
81+
{
82+
patterns: ['/tiny-robot/examples/', '/tiny-robot/examples.html'],
83+
target: '/tiny-robot/examples/assistant'
84+
},
85+
{
86+
patterns: ['/next-sdk.html', '/next-sdk/'],
87+
target: '/next-sdk/guide'
88+
}
89+
];
90+
5891
// 将文档标题更新逻辑提取为独立函数,便于维护和测试
5992
const updateDocTitle = () => {
6093
const base = site.value?.base || '/'
6194
const path = route.path.replace(new RegExp(`^${base}`), '/')
6295
const cfg = themeConfig.value || {}
6396
97+
for (const { patterns, target } of redirectMap) {
98+
if (patterns.includes(path)) {
99+
router.go(target);
100+
break;
101+
}
102+
}
103+
64104
// next-sdk / tiny-vue: 从对应 sidebar 的 guide 中寻找匹配项
65105
if (path.includes('/next-sdk/') || path.includes('/tiny-vue/')) {
66106
let sidebarConfig: any[] = []

.vitepress/theme/components/CustomHeader.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ const productTabs = computed(() => [
478478
{
479479
key: "tiny-engine",
480480
name: "TinyEngine",
481-
link: `${prefix}tiny-engine/engines/introduction`,
481+
link: `${prefix}tiny-engine/guide/introduction`,
482482
src: `${prefix}images/logo-${
483483
activeProductTab.value === "tiny-engine" ? "active" : "normal"
484484
}-tiny-engine.svg`,
@@ -514,6 +514,13 @@ watch(
514514
},
515515
{ deep: true, immediate: true }
516516
);
517+
watch(
518+
() => navigationTabs.value,
519+
() => {
520+
getActiveNavTab();
521+
},
522+
{ deep: true, immediate: true }
523+
);
517524
</script>
518525

519526
<style lang="less" scoped>

.vitepress/theme/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ info{
540540
.vp-doc :not(pre) > code{
541541
padding:0 6px;
542542
}
543+
img.image-inline {
544+
display: inline-block;
545+
margin: 0;
546+
}
543547

544548
/* 暗色模式下全局样式 */
545549
.dark h1{

tiny-engine

Submodule tiny-engine updated 422 files

0 commit comments

Comments
 (0)