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) }
+9
View File
@@ -1,4 +1,13 @@
export default {
skipAdmin: 'Skip to administration',
loading: 'Loading mirrors…',
stale: 'Connection interrupted. Showing the last collected data.',
unavailable: 'Mirror data is unavailable. Refresh shortly.',
noAnnouncements: 'No announcements',
noDownloads: 'No downloads configured',
noHelp: 'No usage guide has been added for this mirror.',
openDirectory: 'Browse mirror directory',
"brand": "MirrorOUC",
"university": "Ocean University of China",
"siteName": "Ocean University of China Software Mirrors",
+11 -1
View File
@@ -1,4 +1,14 @@
export default {
speedCollecting: 'Sampling',
speedDescription: 'TCP receive rate across this mirror’s parallel upstream connections, sampled about every 2 seconds.',
speedUnits: { bytes: '{value} B/s', kilobytes: '{value} KB/s', megabytes: '{value} MB/s', gigabytes: '{value} GB/s' },
live: 'Live monitoring',
stale: 'Metrics collection interrupted',
loading: 'Loading monitoring data…',
unavailable: 'Monitoring data is unavailable.',
collecting: 'Waiting for valid samples…',
capacityGB: '{value} GB',
title: 'Server monitoring',
demo: 'Demo data',
range: 'Monitoring time range',
@@ -33,6 +43,6 @@ export default {
chartHelp: '{title}. Use Left / Right to inspect samples, Home / End to jump to the endpoints, and Esc to dismiss the tooltip.',
toggleSeries: 'Show or hide {name}',
search: 'Search mirrors or upstream URLs…',
columns: { name: 'Mirror', update: 'Sync time', upstream: 'Upstream', status: 'Status', size: 'Size' },
columns: { speed: 'Pull speed', name: 'Mirror', update: 'Sync time', upstream: 'Upstream', status: 'Status', size: 'Size' },
syncTime: { success: 'Last successful sync', attempt: 'Last attempted sync', started: 'Sync started', next: 'Next scheduled sync' },
}
+3 -2
View File
@@ -7,12 +7,13 @@ import mirrorsEn from './en-US/mirrors'
import announcementsEn from './en-US/announcements'
import monitorZh from './zh-CN/monitor'
import monitorEn from './en-US/monitor'
import { adminZh, adminEn } from './admin-messages'
import { datetimeFormats as datetimeZh, numberFormats as numbersZh } from './zh-CN/formats'
import { datetimeFormats as datetimeEn, numberFormats as numbersEn } from './en-US/formats'
export const messages = {
'zh-CN': { common: commonZh, mirrors: mirrorsZh, announcements: announcementsZh, monitor: monitorZh },
'en-US': { common: commonEn, mirrors: mirrorsEn, announcements: announcementsEn, monitor: monitorEn },
'zh-CN': { common: commonZh, mirrors: mirrorsZh, announcements: announcementsZh, monitor: monitorZh, admin: adminZh },
'en-US': { common: commonEn, mirrors: mirrorsEn, announcements: announcementsEn, monitor: monitorEn, admin: adminEn },
}
export type Locale = keyof typeof messages
export const supportedLocales = Object.keys(messages) as Locale[]
+9
View File
@@ -1,4 +1,13 @@
export default {
skipAdmin: '跳转到站点管理',
loading: '正在加载镜像数据…',
stale: '连接暂时中断,显示最近一次同步数据。',
unavailable: '镜像数据暂时不可用,请稍后刷新。',
noAnnouncements: '暂无公告',
noDownloads: '暂无下载项',
noHelp: '此镜像暂未添加使用说明。',
openDirectory: '浏览镜像目录',
"brand": "MirrorOUC",
"university": "中国海洋大学",
"siteName": "中国海洋大学软件镜像源",
+11 -1
View File
@@ -1,4 +1,14 @@
export default {
speedCollecting: '采集中',
speedDescription: '约 2 秒采样窗口内,此仓库全部并行上游连接的 TCP 接收速率。',
speedUnits: { bytes: '{value} B/s', kilobytes: '{value} KB/s', megabytes: '{value} MB/s', gigabytes: '{value} GB/s' },
live: '实时监控',
stale: '数据采集暂时中断',
loading: '正在获取监控数据…',
unavailable: '暂时无法获取监控数据。',
collecting: '正在等待有效采样…',
capacityGB: '{value} GB',
title: '服务器监控',
demo: '演示数据',
range: '监控时间范围',
@@ -33,6 +43,6 @@ export default {
chartHelp: '{title}。使用左右方向键查看时间点,Home / End 跳到首尾,Esc 关闭提示。',
toggleSeries: '显示或隐藏 {name}',
search: '搜索镜像名称或上游地址…',
columns: { name: '镜像名称', update: '同步时间', upstream: '上游地址', status: '状态', size: '大小' },
columns: { speed: '拉取速度', name: '镜像名称', update: '同步时间', upstream: '上游地址', status: '状态', size: '大小' },
syncTime: { success: '最近成功同步', attempt: '最近尝试同步', started: '本次同步开始', next: '下次计划同步' },
}