fix: 管理页用户配置 React #31 —— getAllUsers() 对象当用户名写入列表
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s

- src/lib/config.ts: 两处统一取 username 字符串再补全用户列表
- src/middleware.ts: 跳过认证路径新增 /user-admin.js(全新用户管理面板)
- public/sw.js: 改为自毁式 Service Worker,清理旧缓存 chunk
- CHANGELOG: 新增 fixed44 条目
This commit is contained in:
jinghui committed 2026-11-06 22:55:56 +08:00
1 parent aa024ded11
commit b861304ad2
4 files changed
+26 -3

No files matched your search

+10 -2
View File
@@ -77,7 +77,12 @@ async function initConfig() {
let userNames: string[] = [];
if (storage && typeof (storage as any).getAllUsers === 'function') {
try {
userNames = await (storage as any).getAllUsers();
const rawUsers = await (storage as any).getAllUsers();
// getAllUsers 返回的是 User 对象数组,这里统一取用户名字符串,
// 否则会把整个对象写入 Users[].username(导致管理页渲染对象报 React #31)
userNames = (Array.isArray(rawUsers) ? rawUsers : [])
.map((u: any) => (typeof u === 'string' ? u : u && typeof u.username === 'string' ? u.username : ''))
.filter((n: string) => !!n);
} catch (e) {
console.error('获取用户列表失败:', e);
}
@@ -324,7 +329,10 @@ export async function resetConfig() {
let userNames: string[] = [];
if (storage && typeof (storage as any).getAllUsers === 'function') {
try {
userNames = await (storage as any).getAllUsers();
const rawUsers = await (storage as any).getAllUsers();
userNames = (Array.isArray(rawUsers) ? rawUsers : [])
.map((u: any) => (typeof u === 'string' ? u : u && typeof u.username === 'string' ? u.username : ''))
.filter((n: string) => !!n);
} catch (e) {
console.error('获取用户列表失败:', e);
}
+1
View File
@@ -127,6 +127,7 @@ function shouldSkipAuth(pathname: string): boolean {
'/screenshot.png',
'/ipv6',
'/live',
'/user-admin.js',
];
return skipPaths.some((path) => pathname.startsWith(path));