Skip to content

Commit 3f593bb

Browse files
committed
修复官网路由回退并补充视觉资源
1 parent b095d3e commit 3f593bb

9 files changed

Lines changed: 117 additions & 19 deletions

File tree

index.html

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,25 @@
2929
<div id="root"></div>
3030
<script type="module" src="/src/main.tsx"></script>
3131

32-
<!-- GitHub Pages 重定向脚本 -->
32+
<!-- SPA fallback restore script for GitHub Pages/custom-domain refreshes -->
3333
<script>
34-
// 检查是否在 GitHub Pages 上运行
35-
if (window.location.hostname === 'quickmsg.github.io') {
36-
// 如果当前路径不是根路径,则重定向到根路径
37-
if (window.location.pathname !== '/' && !window.location.pathname.startsWith('/flux-message-flow/')) {
38-
window.location.replace('/');
34+
(function (l) {
35+
if (l.search && l.search[1] === '/') {
36+
var decoded = l.search
37+
.slice(1)
38+
.split('&')
39+
.map(function (segment) {
40+
return segment.replace(/~and~/g, '&');
41+
})
42+
.join('?');
43+
44+
window.history.replaceState(
45+
null,
46+
null,
47+
l.pathname.slice(0, -1) + decoded + l.hash
48+
);
3949
}
40-
}
50+
})(window.location);
4151
</script>
4252
</body>
4353
</html>

public/404.html

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,40 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>FluxMQ Documentation</title>
77
<script>
8-
// GitHub Pages 404 重定向脚本
9-
// 这个脚本会重定向到正确的路径
10-
var pathSegmentsToKeep = 1;
11-
12-
var l = window.location;
13-
l.replace(
14-
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
15-
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
16-
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
17-
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
18-
l.hash
19-
);
8+
// SPA fallback for GitHub Pages/custom domains.
9+
// Custom domain: /architecture -> /?/architecture
10+
// Project page: /flux-message-flow/architecture -> /flux-message-flow/?/architecture
11+
(function () {
12+
var l = window.location;
13+
var origin = l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '');
14+
var isProjectPage = l.hostname === 'quickmsg.github.io' && l.pathname.indexOf('/flux-message-flow/') === 0;
15+
var pathSegmentsToKeep = isProjectPage ? 1 : 0;
16+
var pathSegments = l.pathname.split('/');
17+
var basePath = pathSegments.slice(0, 1 + pathSegmentsToKeep).join('/');
18+
var routePath = l.pathname
19+
.slice(1)
20+
.split('/')
21+
.slice(pathSegmentsToKeep)
22+
.join('/')
23+
.replace(/^\/+|\/+$/g, '');
24+
25+
var search = l.search;
26+
27+
// Older fallback settings could create URLs like /architecture/?/&/~and~/...
28+
// Drop that generated query and keep the real route segment.
29+
if (search.indexOf('?/') === 0 || search.indexOf('?/&') === 0) {
30+
search = '';
31+
}
32+
33+
l.replace(
34+
origin +
35+
basePath +
36+
'/?/' +
37+
routePath.replace(/&/g, '~and~') +
38+
(search ? '&' + search.slice(1).replace(/&/g, '~and~') : '') +
39+
l.hash
40+
);
41+
})();
2042
</script>
2143
</head>
2244
<body>

public/demo-posters/instruct.svg

Lines changed: 19 additions & 0 deletions
Loading

public/demo-posters/overview.svg

Lines changed: 24 additions & 0 deletions
Loading
Lines changed: 23 additions & 0 deletions
Loading
142 KB
Loading
110 KB
Loading
149 KB
Loading

public/site-assets/suite-hero.webp

103 KB
Loading

0 commit comments

Comments
 (0)