Add server components
build-winui / winui (push) Has been cancelled

This commit is contained in:
QWQLwToo
2026-06-26 13:28:09 +08:00
parent 7ecc6a8923
commit 079ee4eaeb
168 changed files with 37475 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.title}}</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="error-page">
<div class="container">
<div class="error-code error-404">404</div>
<h2 class="error-title">页面未找到</h2>
<p class="error-message">
抱歉,您访问的页面不存在或已被移动
</p>
<div class="error-path">
访问路径: {{.path}}
</div>
<a href="/" class="back-home-btn">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 12H5M12 19l-7-7 7-7"/>
</svg>
返回首页
</a>
</div>
</div>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.title}}</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="error-page">
<div class="container">
<div class="error-code error-500">500</div>
<h2 class="error-title">服务器内部错误</h2>
<p class="error-message">
抱歉,服务器在处理您的请求时发生错误
</p>
{{if .message}}
<div class="error-path">
错误信息: {{.message}}
</div>
{{end}}
<a href="/" class="back-home-btn">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 12H5M12 19l-7-7 7-7"/>
</svg>
返回首页
</a>
</div>
</div>
</body>
</html>
+253
View File
@@ -0,0 +1,253 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.title}} - 后台管理</title>
<link rel="stylesheet" href="/css/admin.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="admin-container">
<header class="admin-header">
<div class="header-left">
<h1>后台管理</h1>
</div>
<div class="header-right">
<span id="current-user"></span>
<a href="/admin/settings" class="btn btn-icon" title="设置">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="3"/>
<path d="M12 1v6m0 6v6M5.64 5.64l4.24 4.24m4.24 4.24l4.24 4.24M1 12h6m6 0h6M5.64 18.36l4.24-4.24m4.24-4.24l4.24-4.24"/>
</svg>
</a>
<button id="logout-btn" class="btn btn-secondary">登出</button>
</div>
</header>
<div class="admin-layout">
<aside class="admin-sidebar">
<nav class="sidebar-nav">
<a href="#" class="nav-item active" data-page="dashboard">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
<rect x="3" y="14" width="7" height="7"></rect>
</svg>
<span>仪表盘</span>
</a>
<a href="#" class="nav-item" data-page="routes">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
</svg>
<span>路由管理</span>
</a>
<a href="#" class="nav-item" data-page="files">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
</svg>
<span>文件管理</span>
</a>
<a href="#" class="nav-item" data-page="config">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"></circle>
<path d="M12 1v6m0 6v6M5.64 5.64l4.24 4.24m4.24 4.24l4.24 4.24M1 12h6m6 0h6M5.64 18.36l4.24-4.24m4.24-4.24l4.24-4.24"></path>
</svg>
<span>配置管理</span>
</a>
<a href="#" class="nav-item" data-page="logs">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="9 11 12 14 22 4"></polyline>
<path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"></path>
</svg>
<span>日志查看</span>
</a>
</nav>
</aside>
<main class="admin-content">
<!-- 仪表盘 -->
<div id="page-dashboard" class="page active">
<div class="page-header">
<h2>系统概览</h2>
</div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-icon">👥</div>
<div class="stat-info">
<div class="stat-value" id="stat-users">-</div>
<div class="stat-label">用户总数</div>
</div>
</div>
<div class="stat-card">
<div class="stat-icon">🛣️</div>
<div class="stat-info">
<div class="stat-value" id="stat-routes">-</div>
<div class="stat-label">路由总数</div>
</div>
</div>
<div class="stat-card">
<div class="stat-icon">📝</div>
<div class="stat-info">
<div class="stat-value" id="stat-logs">-</div>
<div class="stat-label">日志条目</div>
</div>
</div>
<div class="stat-card">
<div class="stat-icon"></div>
<div class="stat-info">
<div class="stat-value" id="stat-time">-</div>
<div class="stat-label">服务器时间</div>
</div>
</div>
</div>
</div>
<!-- 路由管理 -->
<div id="page-routes" class="page">
<div class="page-header">
<h2>路由管理</h2>
<button class="btn btn-primary" id="add-route-btn">添加路由</button>
</div>
<div class="table-container">
<table class="data-table">
<thead>
<tr>
<th>ID</th>
<th>方法</th>
<th>路径</th>
<th>类型</th>
<th>描述</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody id="routes-table-body">
<tr>
<td colspan="7" class="empty-state">加载中...</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 文件管理 -->
<div id="page-files" class="page">
<div class="page-header">
<h2>文件管理</h2>
<button class="btn btn-primary" id="refresh-files-btn">刷新</button>
</div>
<div class="file-browser" id="file-browser">
<div class="empty-state">加载中...</div>
</div>
</div>
<!-- 配置管理 -->
<div id="page-config" class="page">
<div class="page-header">
<h2>配置管理</h2>
</div>
<div class="config-controls">
<select id="config-select">
<option value="tool-status.json">tool-status.json</option>
<option value="update-info.json">update-info.json</option>
<option value="media-types.json">media-types.json</option>
<option value="modules.json">modules.json</option>
<option value="plugins.json">plugins.json</option>
<option value="lang/zh-CN.json">lang/zh-CN.json</option>
<option value="lang/en-US.json">lang/en-US.json</option>
</select>
<button class="btn btn-primary" id="load-config-btn">加载配置</button>
</div>
<div class="editor-container">
<textarea id="config-editor" class="code-editor"></textarea>
</div>
<div class="button-group" style="margin-top: 1rem;">
<button id="save-config-btn" class="btn btn-primary">保存配置</button>
<button id="save-reload-config-btn" class="btn btn-success">保存并立即加载</button>
</div>
</div>
<!-- 日志查看 -->
<div id="page-logs" class="page">
<div class="page-header">
<h2>日志查看</h2>
<div class="button-group">
<button class="btn btn-primary" id="refresh-logs-btn">刷新</button>
<button class="btn btn-secondary" id="clear-logs-btn">清空</button>
</div>
</div>
<div class="logs-container">
<div id="logs-content" class="logs-content"></div>
</div>
</div>
</main>
</div>
</div>
<!-- 路由编辑模态框 -->
<div id="route-modal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3 id="route-modal-title">添加路由</h3>
<button class="modal-close">&times;</button>
</div>
<div class="modal-body">
<form id="route-form">
<input type="hidden" id="route-id">
<div class="form-group">
<label>HTTP 方法</label>
<select id="route-method" required>
<option value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
<option value="DELETE">DELETE</option>
<option value="PATCH">PATCH</option>
</select>
</div>
<div class="form-group">
<label>路径</label>
<input type="text" id="route-path" required placeholder="/api/example">
</div>
<div class="form-group">
<label>类型</label>
<select id="route-type" required>
<option value="view">视图 (view)</option>
<option value="json">JSON (json)</option>
<option value="file">文件 (file)</option>
<option value="static">静态 (static)</option>
<option value="custom">自定义 (custom)</option>
</select>
</div>
<div class="form-group">
<label>处理器/文件路径</label>
<input type="text" id="route-handler" required placeholder="views/index.html 或 handler 函数">
</div>
<div class="form-group">
<label>描述</label>
<input type="text" id="route-description" placeholder="路由描述">
</div>
<div class="form-group">
<label>
<input type="checkbox" id="route-active" checked>
启用
</label>
</div>
<div class="form-group">
<label>排序</label>
<input type="number" id="route-order" value="0">
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" id="route-cancel-btn">取消</button>
<button class="btn btn-primary" id="route-save-btn">保存</button>
</div>
</div>
</div>
<script src="/js/admin.js"></script>
</body>
</html>
+196
View File
@@ -0,0 +1,196 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.pageTitle}}</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body class="shad-app">
<header class="site-header">
<div class="shad-container header-inner">
<div>
<span class="eyebrow">YMhut Release Center</span>
<h1>YMhut Box 下载与模块分发中心</h1>
<p>自动识别 <code>public/downloads</code> 下的安装包,生成主程序更新、历史版本和模块化工具分发清单。</p>
</div>
<div class="header-actions">
<a class="shad-button shad-button--secondary" href="/api/update-info">更新清单</a>
<a class="shad-button shad-button--secondary" href="/api/modules">模块清单</a>
<a class="shad-button shad-button--primary" href="/admin">管理后台</a>
</div>
</div>
</header>
<main class="shad-main">
<div class="shad-container">
<section class="summary-grid">
<article class="summary-card">
<span>自动扫描</span>
<strong>downloads</strong>
<p>无需手工维护下载卡片,刷新页面即可读取安装包并按产品分组。</p>
</article>
<article class="summary-card">
<span>兼容更新</span>
<strong>v1 + v2</strong>
<p>保留旧版 <code>update-info.json</code>,同时提供模块化清单。</p>
</article>
<article class="summary-card">
<span>校验能力</span>
<strong>SHA256</strong>
<p>服务端自动为主程序、资源包和未来模块包生成校验字段。</p>
</article>
</section>
{{if .errorMessage}}
<section class="shad-card shad-card--state shad-card--danger">
<h2>读取目录失败</h2>
<p>{{.errorMessage}}</p>
</section>
{{else if not .products}}
<section class="shad-card shad-card--state">
<h2>暂无可识别安装包</h2>
<p>请将 Windows、Android、macOS 或 Linux 安装包放入 <code>public/downloads</code></p>
</section>
{{else}}
<section class="section-title">
<div>
<span class="eyebrow">Packages</span>
<h2>安装包列表</h2>
</div>
<p>按产品自动分组,默认展示每个产品的最新版本。</p>
</section>
<section class="shad-grid">
{{range $productName, $versions := .products}}
{{$latestVersion := index $versions 0}}
{{$historyVersions := slice $versions 1}}
{{$meta := index $.productMeta $productName}}
{{if not $meta}}
{{$meta = $.defaultMeta}}
{{end}}
<article class="shad-card shad-product">
<div class="shad-product__head">
<div class="shad-product__icon">{{$meta.Icon | safeHTML}}</div>
<div class="shad-product__title">
<h3>{{$productName}}</h3>
<p>{{$meta.Description}}</p>
</div>
</div>
<div class="shad-stack shad-stack--row shad-stack--wrap">
{{range $meta.Tags}}
<span class="shad-badge shad-badge--outline">{{.}}</span>
{{end}}
<span class="shad-badge shad-badge--muted">{{len $versions}} 个版本</span>
</div>
<div class="shad-panel">
<div class="shad-panel__main">
<div>
<span class="shad-muted">最新版本</span>
<strong>{{$latestVersion.Version}}</strong>
</div>
<span class="shad-badge shad-badge--subtle">{{$latestVersion.Extension}}</span>
</div>
<div class="shad-meta-grid">
<div class="shad-meta">
<span class="shad-muted">更新时间</span>
<span>{{$latestVersion.UpdateDate}}</span>
</div>
<div class="shad-meta">
<span class="shad-muted">文件大小</span>
<span>{{$latestVersion.Size}}</span>
</div>
<div class="shad-meta">
<span class="shad-muted">文件名</span>
<span class="shad-truncate">{{$latestVersion.FileName}}</span>
</div>
</div>
</div>
<div class="shad-actions">
<a href="{{$latestVersion.DownloadPath}}" class="shad-button shad-button--primary" download>下载最新版本</a>
{{if $historyVersions}}
<button class="shad-button shad-button--secondary history-btn"
data-product-name="{{$productName}}"
data-history='{{marshalJSON $historyVersions}}'>历史版本</button>
{{end}}
</div>
</article>
{{end}}
</section>
{{end}}
</div>
</main>
<div class="shad-dialog" id="history-modal" aria-hidden="true">
<div class="shad-dialog__overlay"></div>
<div class="shad-dialog__content">
<div class="shad-dialog__header">
<h3 id="modal-title">历史版本</h3>
<button class="shad-icon-button" id="close-modal" aria-label="关闭">&times;</button>
</div>
<div class="shad-dialog__body">
<ul class="shad-history" id="history-list"></ul>
</div>
</div>
</div>
<footer class="shad-footer">
<div class="shad-container shad-footer__inner">
<span>YMhut 下载中心</span>
<span>主程序、资源包与模块包统一分发</span>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
const modal = document.getElementById('history-modal');
const modalTitle = document.getElementById('modal-title');
const historyList = document.getElementById('history-list');
const closeModalBtn = document.getElementById('close-modal');
function closeHistoryModal() {
modal.classList.remove('is-open');
modal.setAttribute('aria-hidden', 'true');
document.body.style.overflow = '';
}
document.querySelectorAll('.history-btn').forEach(button => {
button.addEventListener('click', () => {
const versions = JSON.parse(button.dataset.history || '[]');
modalTitle.textContent = `${button.dataset.productName} 历史版本`;
historyList.innerHTML = versions.length ? '' : '<li class="shad-history__item"><strong>暂无历史版本</strong></li>';
versions.forEach(version => {
const item = document.createElement('li');
item.className = 'shad-history__item';
item.innerHTML = `
<div>
<strong>版本 ${version.version}</strong>
<p>${version.updateDate} · ${version.size} · ${version.extension}</p>
</div>
<a href="${version.downloadPath}" class="shad-button shad-button--secondary" download>下载</a>
`;
historyList.appendChild(item);
});
modal.classList.add('is-open');
modal.setAttribute('aria-hidden', 'false');
document.body.style.overflow = 'hidden';
});
});
closeModalBtn.addEventListener('click', closeHistoryModal);
modal.addEventListener('click', event => {
if (event.target === modal || event.target.classList.contains('shad-dialog__overlay')) {
closeHistoryModal();
}
});
document.addEventListener('keydown', event => {
if (event.key === 'Escape') closeHistoryModal();
});
});
</script>
</body>
</html>
+184
View File
@@ -0,0 +1,184 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据库配置 - 系统安装</title>
<link rel="stylesheet" href="/css/admin.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="auth-container">
<div class="auth-box" style="max-width: 600px;">
<div class="auth-header">
<div class="auth-logo">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
</div>
<h1>数据库配置</h1>
<p>请配置数据库连接信息</p>
</div>
<div class="install-info" style="background: #e3f2fd; border: 1px solid #2196f3; border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem;">
<p style="margin: 0; color: #1976d2; font-size: 0.9rem;">
<strong>默认管理员账号:</strong><br>
用户名: <code>admin</code><br>
密码: <code>admin123456</code>
</p>
</div>
<form id="install-form" class="auth-form">
<div class="form-group">
<label for="db-type">数据库类型</label>
<select id="db-type" name="type" required>
<option value="mysql">MySQL</option>
<option value="sqlite">SQLite</option>
</select>
</div>
<!-- MySQL 配置 -->
<div id="mysql-config">
<div class="form-group">
<label for="db-host">数据库主机</label>
<input type="text" id="db-host" name="host" placeholder="localhost 或远程IP地址" value="localhost">
<small>支持远程数据库,请输入IP地址或域名</small>
</div>
<div class="form-group">
<label for="db-port">端口</label>
<input type="text" id="db-port" name="port" placeholder="3306" value="3306">
</div>
<div class="form-group">
<label for="db-user">用户名</label>
<input type="text" id="db-user" name="user" placeholder="root" value="root" required>
</div>
<div class="form-group">
<label for="db-password">密码</label>
<input type="password" id="db-password" name="password" placeholder="数据库密码">
</div>
<div class="form-group">
<label for="db-database">数据库名</label>
<input type="text" id="db-database" name="database" placeholder="software_download_center" value="software_download_center" required>
</div>
<div class="form-group">
<label for="db-prefix">表前缀(可选)</label>
<input type="text" id="db-prefix" name="table_prefix" placeholder="例如: sd_">
<small>留空则无前缀</small>
</div>
</div>
<!-- SQLite 配置 -->
<div id="sqlite-config" style="display: none;">
<div class="form-group">
<label for="db-dsn">数据目录</label>
<input type="text" id="db-dsn" name="dsn" placeholder="data" value="data">
<small>数据库文件将保存在此目录下</small>
</div>
</div>
<button type="submit" class="btn btn-primary">
<span>保存并连接</span>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14"/>
<polyline points="12 5 19 12 12 19"/>
</svg>
</button>
</form>
<div id="install-error" class="error-message"></div>
</div>
</div>
<script>
// 数据库类型切换
document.getElementById('db-type').addEventListener('change', (e) => {
const type = e.target.value;
const mysqlConfig = document.getElementById('mysql-config');
const sqliteConfig = document.getElementById('sqlite-config');
if (type === 'mysql') {
mysqlConfig.style.display = 'block';
sqliteConfig.style.display = 'none';
} else {
mysqlConfig.style.display = 'none';
sqliteConfig.style.display = 'block';
}
});
// 表单提交
document.getElementById('install-form').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const data = {
type: formData.get('type'),
host: formData.get('host'),
port: formData.get('port'),
user: formData.get('user'),
password: formData.get('password'),
database: formData.get('database'),
table_prefix: formData.get('table_prefix'),
dsn: formData.get('dsn'),
};
const submitBtn = e.target.querySelector('button[type="submit"]');
const originalText = submitBtn.innerHTML;
submitBtn.disabled = true;
submitBtn.innerHTML = '<span>连接中...</span>';
const errorEl = document.getElementById('install-error');
errorEl.classList.remove('show');
errorEl.textContent = '';
try {
const response = await fetch('/admin/install/database', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
const result = await response.json();
if (!response.ok) {
throw new Error(result.error || '安装失败');
}
alert('数据库配置成功!正在跳转到登录页面...');
window.location.href = '/admin/login';
} catch (error) {
errorEl.textContent = error.message;
errorEl.classList.add('show');
submitBtn.disabled = false;
submitBtn.innerHTML = originalText;
}
});
// 检查安装状态
async function checkInstallStatus() {
try {
const response = await fetch('/admin/install/status');
const data = await response.json();
if (data.initialized) {
// 已安装,跳转到登录页
window.location.href = '/admin/login';
}
} catch (error) {
console.error('Check install status error:', error);
}
}
// 页面加载时检查
checkInstallStatus();
</script>
</body>
</html>
+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录 - 后台管理</title>
<link rel="stylesheet" href="/css/admin.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="auth-container">
<div class="auth-box">
<div class="auth-header">
<div class="auth-logo">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
</div>
<h1>欢迎回来</h1>
<p>登录您的管理员账户</p>
</div>
<form id="login-form" class="auth-form">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required placeholder="请输入用户名" autocomplete="username">
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required placeholder="请输入密码" autocomplete="current-password">
</div>
<button type="submit" class="btn btn-primary">
<span>登录</span>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14"/>
<polyline points="12 5 19 12 12 19"/>
</svg>
</button>
<div class="auth-footer">
<a href="/admin/register" class="auth-link">还没有账户?立即注册</a>
</div>
</form>
<div id="auth-error" class="error-message"></div>
</div>
</div>
<script src="/js/auth.js"></script>
</body>
</html>
+68
View File
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>注册 - 后台管理</title>
<link rel="stylesheet" href="/css/admin.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="auth-container">
<div class="auth-box">
<div class="auth-header">
<div class="auth-logo">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
</div>
<h1>创建管理员账户</h1>
<p>第一个注册的用户将自动成为管理员</p>
</div>
<form id="register-form" class="auth-form">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required minlength="3" maxlength="50" placeholder="请输入用户名">
<small>3-50个字符</small>
</div>
<div class="form-group">
<label for="email">邮箱</label>
<input type="email" id="email" name="email" required placeholder="your@email.com">
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required minlength="8" placeholder="至少8个字符">
<small>至少8个字符,包含大小写字母、数字和特殊字符</small>
<div class="password-strength" id="password-strength"></div>
</div>
<div class="form-group">
<label for="confirm-password">确认密码</label>
<input type="password" id="confirm-password" name="confirm-password" required placeholder="再次输入密码">
</div>
<button type="submit" class="btn btn-primary">
<span>创建账户</span>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14"/>
<polyline points="12 5 19 12 12 19"/>
</svg>
</button>
<div class="auth-footer">
<a href="/admin/login" class="auth-link">已有账户?立即登录</a>
</div>
</form>
<div id="auth-error" class="error-message"></div>
</div>
</div>
<script src="/js/auth.js"></script>
</body>
</html>
+143
View File
@@ -0,0 +1,143 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统设置 - 后台管理</title>
<link rel="stylesheet" href="/css/admin.css">
<link rel="icon" href="/img/favicon.png" type="image/png">
</head>
<body>
<div class="admin-container">
<header class="admin-header">
<div class="header-left">
<a href="/admin" class="back-link">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="15 18 9 12 15 6"/>
</svg>
</a>
<h1>系统设置</h1>
</div>
<div class="header-right">
<span id="current-user"></span>
<button id="logout-btn" class="btn btn-secondary">登出</button>
</div>
</header>
<main class="admin-content">
<div class="settings-container">
<!-- 数据库设置 -->
<section class="settings-section">
<div class="section-header">
<h2>数据库设置</h2>
<p class="section-description">管理数据库连接和配置</p>
</div>
<div class="settings-card">
<div class="database-info" id="database-info">
<div class="info-item">
<span class="info-label">数据库类型</span>
<span class="info-value" id="db-type">-</span>
</div>
<div class="info-item">
<span class="info-label">连接状态</span>
<span class="info-value status-badge" id="db-status">-</span>
</div>
<div class="info-item" id="db-file-item" style="display: none;">
<span class="info-label">数据库文件</span>
<span class="info-value" id="db-file">-</span>
</div>
</div>
<!-- 数据库密码修改(仅 MySQL -->
<div class="database-password" id="database-password-section" style="display: none;">
<h3>修改数据库 Root 密码</h3>
<p class="password-warning">⚠️ 警告:修改密码后需要更新环境变量 DB_PASSWORD 并重启服务器!</p>
<form id="password-form" class="password-form">
<div class="form-group">
<label>当前密码</label>
<input type="password" id="current-password" class="form-input" required>
</div>
<div class="form-group">
<label>新密码</label>
<input type="password" id="new-password" class="form-input" required>
</div>
<div class="form-group">
<label>确认新密码</label>
<input type="password" id="confirm-password" class="form-input" required>
</div>
<button type="submit" class="btn btn-danger">更新密码</button>
</form>
<div id="password-result"></div>
</div>
<!-- 数据库转换 -->
<div class="database-convert">
<h3>数据库转换</h3>
<p class="convert-warning">⚠️ 警告:数据库转换会导出当前数据并导入到新数据库,请确保已备份数据!</p>
<div class="convert-form">
<select id="target-db-type">
<option value="sqlite">SQLite</option>
<option value="mysql">MySQL</option>
</select>
<button class="btn btn-danger" id="convert-db-btn">转换数据库</button>
</div>
<div id="convert-result"></div>
</div>
</div>
</section>
<!-- 系统信息 -->
<section class="settings-section">
<div class="section-header">
<h2>系统信息</h2>
<p class="section-description">查看系统运行状态和统计信息</p>
</div>
<div class="settings-card">
<div class="system-stats" id="system-stats">
<div class="stat-item">
<span class="stat-label">用户总数</span>
<span class="stat-value" id="stat-users">-</span>
</div>
<div class="stat-item">
<span class="stat-label">路由总数</span>
<span class="stat-value" id="stat-routes">-</span>
</div>
<div class="stat-item">
<span class="stat-label">日志条目</span>
<span class="stat-value" id="stat-logs">-</span>
</div>
<div class="stat-item">
<span class="stat-label">服务器时间</span>
<span class="stat-value" id="stat-time">-</span>
</div>
</div>
</div>
</section>
<!-- 操作系统信息 -->
<section class="settings-section">
<div class="section-header">
<h2>运行环境</h2>
<p class="section-description">查看服务器运行环境信息</p>
</div>
<div class="settings-card">
<div class="os-info" id="os-info">
<div class="info-item">
<span class="info-label">操作系统</span>
<span class="info-value" id="os-type">-</span>
</div>
<div class="info-item">
<span class="info-label">系统架构</span>
<span class="info-value" id="os-arch">-</span>
</div>
</div>
</div>
</section>
</div>
</main>
</div>
<script src="/js/admin.js"></script>
<script src="/js/settings.js"></script>
</body>
</html>