修复访客浏览轨迹延迟与排序,增加演示站

保留 SPA hash 以正确区分页面;延迟采集 title 避免慢一页;轨迹改为最新在上;补充 demo-shop 测试页与 Vite 静态路由。
This commit is contained in:
yml2213
2026-07-18 23:22:47 +08:00
parent 81852e0ddd
commit 970bae16d1
9 changed files with 651 additions and 44 deletions
+21 -2
View File
@@ -1,10 +1,29 @@
import { defineConfig } from 'vite'
import { defineConfig, type Plugin } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
/** 避免 /demo-shop/ 被 SPA 回退成 React,导致 404;改为提供 public 静态页 */
function demoShopStatic(): Plugin {
return {
name: 'demo-shop-static',
configureServer(server) {
// 必须挂在内部中间件之前,否则会先进 React SPA
server.middlewares.use((req, _res, next) => {
const raw = req.url || ''
const pathname = raw.split('?')[0]
if (pathname === '/demo-shop' || pathname === '/demo-shop/') {
const qs = raw.includes('?') ? raw.slice(raw.indexOf('?')) : ''
req.url = `/demo-shop/index.html${qs}`
}
next()
})
},
}
}
export default defineConfig({
plugins: [react(), tailwindcss()],
plugins: [react(), tailwindcss(), demoShopStatic()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),