feat: add backend, admin console and live monitoring

Integrate tunasync management, SQLite authentication and content settings, real monitoring and per-repository pull speeds. Add Chinese-only announcements and mirror help, editable related links, admin layout updates, deployment tools and tests.
This commit is contained in:
2026-11-01 18:04:01 +08:00
parent addadd7d15
commit f8cef413d6
57 changed files with 4222 additions and 101 deletions
+25
View File
@@ -0,0 +1,25 @@
const pairs = {
relatedLinks: ['首页相关链接', 'Home page related links'], linkType: ['链接类型', 'Link type'], urlLink: ['网址', 'URL'], helpLink: ['软件源使用帮助', 'Mirror usage guides'], linkEntry: ['相关链接 {index}', 'Related link {index}'], moveUp: ['上移', 'Move up'], moveDown: ['下移', 'Move down'],
helpChinese: ['使用说明(中文,Markdown)', 'Usage guide (Chinese, Markdown)'], descriptionLanguage: ['介绍语言', 'Description language'],
contentLanguage: ['内容语言', 'Content language'],
title: ['站点管理', 'Site administration'], login: ['登录', 'Sign in'], logout: ['退出登录', 'Sign out'], username: ['用户名', 'Username'], password: ['密码', 'Password'], checking: ['正在检查登录状态…', 'Checking session…'],
overview: ['运行概况', 'Overview'], mirrors: ['镜像与任务', 'Mirrors & tasks'], announcements: ['公告', 'Announcements'], config: ['同步配置', 'Sync configuration'], settings: ['站点设置', 'Site settings'], users: ['账户', 'Accounts'], audit: ['操作记录', 'Audit log'],
save: ['保存', 'Save'], saved: ['已保存', 'Saved'], cancel: ['取消', 'Cancel'], confirm: ['确认', 'Confirm'], close: ['关闭', 'Close'], edit: ['编辑', 'Edit'], remove: ['删除', 'Delete'], add: ['添加', 'Add'], refresh: ['刷新', 'Refresh'], loading: ['加载中…', 'Loading…'], empty: ['暂无内容', 'No entries'], busy: ['处理中…', 'Working…'],
worker: ['同步节点', 'Worker'], total: ['镜像总数', 'Mirrors'], active: ['正在同步', 'Syncing'], failed: ['同步失败', 'Failed'], updated: ['最近采集', 'Last collected'], sourceError: ['同步节点暂时不可用,显示最近一次数据。', 'Worker unavailable. Showing the last collected data.'],
name: ['名称', 'Name'], status: ['状态', 'Status'], upstream: ['上游地址', 'Upstream'], size: ['大小', 'Size'], actions: ['操作', 'Actions'], search: ['搜索镜像', 'Search mirrors'], metadata: ['展示信息', 'Display information'], description: ['介绍', 'Description'], help: ['使用说明(Markdown)', 'Help (Markdown)'], website: ['官方网站', 'Official website'], visible: ['在首页显示', 'Show on home page'], category: ['分类', 'Category'], os: ['操作系统', 'Operating system'], language: ['语言与工具', 'Languages & tools'], other: ['其他', 'Other'],
start: ['开始同步', 'Start sync'], stop: ['停止同步', 'Stop sync'], restart: ['重新同步', 'Restart sync'], disable: ['禁用同步', 'Disable sync'], logs: ['日志', 'Logs'], logTail: ['显示日志末尾,最多 64 KiB。', 'Showing the log tail, up to 64 KiB.'], commandConfirm: ['确认对 {name} 执行“{action}”?这会影响实际同步任务。', 'Run “{action}” for {name}? This affects the live sync task.'], submitted: ['命令已提交,实际状态稍后更新。', 'Command submitted. The live status will update shortly.'],
newArticle: ['新建公告', 'New announcement'], articleTitle: ['标题', 'Title'], body: ['正文(Markdown)', 'Body (Markdown)'], date: ['发布时间', 'Publication date'], published: ['发布', 'Published'], draft: ['草稿', 'Draft'], pinned: ['置顶', 'Pinned'], preview: ['预览', 'Preview'], deleteConfirm: ['确认删除 {name}?', 'Delete {name}?'],
siteName: ['站点名称', 'Site name'], email: ['联系邮箱', 'Contact email'], address: ['地址', 'Address'], logoLight: ['亮色主题 Logo', 'Light theme logo'], logoDark: ['暗色主题 Logo', 'Dark theme logo'], favicon: ['网站图标', 'Favicon'], avatar: ['站点头像', 'Site avatar'], upload: ['上传 PNG / JPEG', 'Upload PNG / JPEG'], links: ['友情链接', 'Footer links'], downloads: ['常用下载', 'Downloads'], url: ['链接', 'URL'], version: ['版本', 'Version'],
currentPassword: ['当前密码', 'Current password'], newPassword: ['新密码', 'New password'], confirmPassword: ['确认新密码', 'Confirm new password'], changePassword: ['修改密码', 'Change password'], passwordHint: ['密码至少 12 个字符。修改后需重新登录。', 'Use at least 12 characters. Changing your password signs out all your sessions.'], passwordMismatch: ['两次输入的密码不同。', 'Passwords do not match.'], newUser: ['创建账户', 'Create account'], role: ['权限', 'Role'], admin: ['管理员', 'Administrator'], editor: ['公告编辑', 'Announcement editor'],
concurrent: ['最大并发任务', 'Maximum concurrent jobs'], interval: ['同步间隔(分钟)', 'Sync interval (minutes)'], retry: ['失败重试次数', 'Retries'], timeout: ['超时(秒)', 'Timeout (seconds)'], global: ['全局调度', 'Global schedule'], mirrorConfig: ['单个镜像', 'Individual mirror'], newMirror: ['新增镜像', 'New mirror'], provider: ['同步方式', 'Provider'], intervalHint: ['同步间隔从上次同步结束后计算。配置应用时将通知 Worker 重新加载。', 'The interval starts when the previous sync finishes. Applying configuration asks the worker to reload.'], previewConfig: ['生成变更预览', 'Preview changes'], apply: ['应用配置', 'Apply configuration'], applyConfirm: ['确认应用此配置并通知 Worker 重新加载?', 'Apply this configuration and ask the worker to reload?'], before: ['修改前', 'Before'], after: ['修改后', 'After'], versions: ['配置历史', 'Configuration history'], rollback: ['恢复此版本之前的配置', 'Restore configuration before this version'], rollbackConfirm: ['确认恢复此变更前的配置并重新加载?后续有冲突时会拒绝恢复。', 'Restore the configuration before this change and reload? Conflicting subsequent changes will block the restore.'], applied: ['已应用', 'Applied'],
target: ['对象', 'Target'], action: ['动作', 'Action'], result: ['结果', 'Result'], time: ['时间', 'Time'], actor: ['操作人', 'User'], notice: ['提示', 'Notice'], conflictHint: ['数据已被其他操作修改,请重新加载后再编辑。', 'Another operation changed this data. Reload before editing.'],
} as const
const errors = {
NETWORK_ERROR: ['网络连接失败。', 'Network connection failed.'], INVALID_RESPONSE: ['服务器响应无效。', 'Invalid server response.'], INTERNAL_ERROR: ['服务器处理失败,请稍后重试。', 'Server error. Try again shortly.'], INVALID_INPUT: ['请检查填写的内容和数值范围。', 'Check the form values and allowed ranges.'], UNAUTHORIZED: ['请重新登录。', 'Please sign in again.'], FORBIDDEN: ['没有执行此操作的权限。', 'You do not have permission for this action.'], CSRF_INVALID: ['登录状态已变化,请重新登录。', 'Your session has changed. Sign in again.'], INVALID_CREDENTIALS: ['用户名或密码不正确。', 'Incorrect username or password.'], RATE_LIMITED: ['登录尝试过于频繁,请稍后重试。', 'Too many sign-in attempts. Try again shortly.'], CONFLICT: ['内容已发生变化,请刷新后重新编辑。', 'The content has changed. Reload and edit again.'], NOT_FOUND: ['未找到对应记录。', 'The entry was not found.'], CONFIG_UNAVAILABLE: ['无法读取 Worker 配置。', 'Worker configuration is unavailable.'], NO_CHANGES: ['配置没有变化。', 'There are no configuration changes.'], CONFIG_APPLY_FAILED: ['配置应用失败,已尝试恢复原文件。请检查 Worker 状态。', 'Configuration failed. Original files were restored where possible. Check the worker status.'], CONFIG_ROLLBACK_FAILED: ['配置恢复未完成,需要检查服务器配置与 Worker 状态。', 'Configuration restore did not complete. Check the server files and worker.'], CONFIG_STATE_UNCERTAIN: ['文件可能已生效,但版本记录未完成,请检查配置。', 'Files may have been applied, but the version record failed. Check the configuration.'], COMMAND_UNCERTAIN: ['命令结果未确认,请检查节点状态后再操作。', 'Command delivery is unconfirmed. Check the worker before retrying.'], MANAGER_UNAVAILABLE: ['同步管理器暂时不可用。', 'The sync manager is unavailable.'], LOGS_UNAVAILABLE: ['日志暂时不可用。', 'Logs are unavailable.'], UPLOAD_INVALID: ['请选择不超过 4 MB 的 PNG 或 JPEG 图片。', 'Choose a PNG or JPEG image of at most 4 MB.'], INVALID_PASSWORD: ['密码需要 12 至 256 个字符。', 'The password must contain 12 to 256 characters.'], TUNASYNC_UNAVAILABLE: ['同步节点暂时不可用。', 'The sync worker is unavailable.'], LOG_UNAVAILABLE: ['日志暂时不可用。', 'Logs are unavailable.'], INVALID_IMAGE: ['图片无效,请使用不超过 4 MB 的 PNG 或 JPEG。', 'Use a valid PNG or JPEG image of at most 4 MB.'], PASSWORD_TOO_SHORT: ['密码至少需要 12 个字符。', 'Use at least 12 characters for the password.'],
} as const
const events = {
login: ['登录', 'Sign in'], logout: ['退出', 'Sign out'], password_change: ['修改密码', 'Change password'], user_create: ['创建账户', 'Create account'], record_save: ['保存内容', 'Save content'], record_delete: ['删除内容', 'Delete content'], upload: ['上传图片', 'Upload image'], config_preview: ['预览配置', 'Preview configuration'], config_apply: ['应用配置', 'Apply configuration'], config_rollback: ['恢复配置', 'Restore configuration'], password: ['修改密码', 'Change password'], job_start: ['开始同步', 'Start sync'], job_stop: ['停止同步', 'Stop sync'], job_restart: ['重新同步', 'Restart sync'], job_disable: ['禁用同步', 'Disable sync'], denied: ['已拒绝', 'Denied'], uncertain: ['未确认', 'Unconfirmed'], command: ['任务命令', 'Task command'], success: ['成功', 'Success'], submitted: ['已提交', 'Submitted'], failed: ['失败', 'Failed'], draft: ['草稿', 'Draft'], applied: ['已应用', 'Applied'],
} as const
const translate = (source: Record<string, readonly [string, string]>, index: number) => Object.fromEntries(Object.entries(source).map(([key, value]) => [key, value[index]!]))
export const adminZh = { ...translate(pairs, 0), errors: translate(errors, 0), events: translate(events, 0) }
export const adminEn = { ...translate(pairs, 1), errors: translate(errors, 1), events: translate(events, 1) }