This commit is contained in:
爱喝水的木子
2026-03-02 15:35:39 +08:00
commit 00b48da363
1590 changed files with 285117 additions and 0 deletions

172
public/css/style.css Normal file
View File

@@ -0,0 +1,172 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
overflow: hidden;
}
h1 {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
text-align: center;
padding: 24px;
font-size: 24px;
}
.tabs {
display: flex;
border-bottom: 1px solid #eee;
}
.tab {
flex: 1;
padding: 16px;
border: none;
background: #f8f9fa;
cursor: pointer;
font-size: 16px;
color: #666;
transition: all 0.3s;
}
.tab:hover {
background: #e9ecef;
}
.tab.active {
background: white;
color: #667eea;
border-bottom: 3px solid #667eea;
}
.panel {
display: none;
padding: 24px;
}
.panel.active {
display: block;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #333;
}
input, select, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 14px;
transition: border-color 0.3s;
}
input:focus, select:focus, textarea:focus {
outline: none;
border-color: #667eea;
}
.btn {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: transform 0.2s;
}
.btn:hover {
transform: translateY(-2px);
}
.result {
margin-top: 24px;
padding: 20px;
background: #f0f9ff;
border-radius: 8px;
text-align: center;
}
.result p {
margin-bottom: 8px;
}
#suggestion-id {
color: #667eea;
font-size: 18px;
}
.tip {
color: #666;
font-size: 14px;
}
.detail-row {
display: flex;
margin-bottom: 12px;
}
.detail-row .label {
font-weight: 500;
min-width: 80px;
color: #666;
}
.status-badge {
padding: 4px 12px;
border-radius: 12px;
font-size: 14px;
}
.status-badge.待处理 { background: #fff3cd; color: #856404; }
.status-badge.处理中 { background: #cce5ff; color: #004085; }
.status-badge.已完成 { background: #d4edda; color: #155724; }
.status-badge.已拒绝 { background: #f8d7da; color: #721c24; }
.progress-section {
margin-top: 16px;
}
.progress-bar {
height: 8px;
background: #e9ecef;
border-radius: 4px;
overflow: hidden;
margin: 8px 0;
}
.progress-fill {
height: 100%;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
transition: width 0.3s;
}
#progress-text {
color: #667eea;
font-weight: 500;
}

89
public/index.html Normal file
View File

@@ -0,0 +1,89 @@
<!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/style.css">
</head>
<body>
<div class="container">
<h1>建议收集系统</h1>
<div class="tabs">
<button class="tab active" data-tab="submit">提交建议</button>
<button class="tab" data-tab="query">查询进度</button>
</div>
<div id="submit-panel" class="panel active">
<form id="suggestion-form">
<div class="form-group">
<label for="title">建议标题 *</label>
<input type="text" id="title" name="title" required placeholder="请输入建议标题">
</div>
<div class="form-group">
<label for="type">建议类型 *</label>
<select id="type" name="type" required>
<option value="">请选择类型</option>
<option value="网站建议">网站建议</option>
<option value="其他建议">其他建议</option>
<option value="个人建议">个人建议</option>
<option value="开发建议">开发建议</option>
</select>
</div>
<div class="form-group">
<label for="text">建议内容 *</label>
<textarea id="text" name="text" required placeholder="请详细描述您的建议" rows="5"></textarea>
</div>
<button type="submit" class="btn">提交建议</button>
</form>
<div id="submit-result" class="result" style="display: none;">
<p>建议提交成功!</p>
<p>您的查询ID: <strong id="suggestion-id"></strong></p>
<p class="tip">请妥善保存此ID用于查询建议进度</p>
</div>
</div>
<div id="query-panel" class="panel">
<div class="form-group">
<label for="query-id">请输入查询ID</label>
<input type="text" id="query-id" placeholder="请输入您的查询ID">
</div>
<button id="query-btn" class="btn">查询</button>
<div id="query-result" class="result" style="display: none;">
<h3>建议详情</h3>
<div class="detail-row">
<span class="label">标题:</span>
<span id="detail-title"></span>
</div>
<div class="detail-row">
<span class="label">类型:</span>
<span id="detail-type"></span>
</div>
<div class="detail-row">
<span class="label">内容:</span>
<span id="detail-text"></span>
</div>
<div class="detail-row">
<span class="label">状态:</span>
<span id="detail-status" class="status-badge"></span>
</div>
<div class="progress-section">
<label>处理进度:</label>
<div class="progress-bar">
<div id="progress-fill" class="progress-fill"></div>
</div>
<span id="progress-text">0%</span>
</div>
</div>
</div>
</div>
<script src="/js/app.js"></script>
</body>
</html>

146
public/js/app.js Normal file
View File

@@ -0,0 +1,146 @@
document.addEventListener('DOMContentLoaded', () => {
const tabs = document.querySelectorAll('.tab');
const panels = document.querySelectorAll('.panel');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const target = tab.dataset.tab;
tabs.forEach(t => t.classList.remove('active'));
panels.forEach(p => p.classList.remove('active'));
tab.classList.add('active');
document.getElementById(`${target}-panel`).classList.add('active');
});
});
const API_BASE = '';
const toBase64 = (str) => btoa(unescape(encodeURIComponent(str)));
const getDeviceInfo = async () => {
const getHardwareInfo = async () => {
try {
if (navigator.hardwareConcurrency || navigator.deviceMemory) {
const nav = navigator;
const canvas = document.createElement('canvas');
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
const debugInfo = gl ? gl.getExtension('WEBGL_debug_renderer_info') : null;
const renderer = debugInfo ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : '';
return {
cpuCores: nav.hardwareConcurrency || '',
deviceMemory: nav.deviceMemory ? `${nav.deviceMemory}GB` : '',
gpu: renderer || '',
hardDisk: ''
};
}
} catch (e) {}
return { cpuCores: '', deviceMemory: '', gpu: '', hardDisk: '' };
};
const hardware = await getHardwareInfo();
const info = {
userAgent: navigator.userAgent,
language: navigator.language,
platform: navigator.platform,
screenWidth: screen.width,
screenHeight: screen.height,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
cpuCores: hardware.cpuCores,
deviceMemory: hardware.deviceMemory,
gpu: hardware.gpu,
hardDisk: hardware.hardDisk
};
return JSON.stringify(info);
};
document.getElementById('suggestion-form').addEventListener('submit', async (e) => {
e.preventDefault();
const submitBtn = e.target.querySelector('button[type="submit"]');
const originalText = submitBtn.textContent;
submitBtn.textContent = '提交中...';
submitBtn.disabled = true;
const title = document.getElementById('title').value;
const type = document.getElementById('type').value;
const text = document.getElementById('text').value;
if (!title || !type || !text) {
alert('请填写所有必填字段');
submitBtn.textContent = originalText;
submitBtn.disabled = false;
return;
}
try {
const deviceInfo = getDeviceInfo();
const payload = {
title: toBase64(title),
type: type,
text: toBase64(text),
deviceInfo: toBase64(deviceInfo)
};
console.log('Sending:', payload);
const res = await fetch('/api/suggestions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const data = await res.json();
console.log('Response:', res.status, data);
if (res.ok && data.id) {
document.getElementById('suggestion-id').textContent = data.id;
document.getElementById('submit-result').style.display = 'block';
document.getElementById('suggestion-form').reset();
alert('提交成功ID: ' + data.id);
} else {
alert((data && data.error) || '提交失败,请重试');
}
} catch (err) {
console.error('Error:', err);
alert('网络错误: ' + err.message);
} finally {
submitBtn.textContent = originalText;
submitBtn.disabled = false;
}
});
document.getElementById('query-btn').addEventListener('click', async () => {
const id = document.getElementById('query-id').value.trim();
if (!id) {
alert('请输入查询ID');
return;
}
try {
const res = await fetch(`/api/suggestions/${id}`);
const data = await res.json();
if (res.ok) {
document.getElementById('detail-title').textContent = data.title;
document.getElementById('detail-type').textContent = data.type;
document.getElementById('detail-text').textContent = data.text;
const statusEl = document.getElementById('detail-status');
statusEl.textContent = data.status;
statusEl.className = `status-badge ${data.status}`;
document.getElementById('progress-fill').style.width = `${data.progress}%`;
document.getElementById('progress-text').textContent = `${data.progress}%`;
document.getElementById('query-result').style.display = 'block';
} else {
alert(data.error || '查询失败');
document.getElementById('query-result').style.display = 'none';
}
} catch (err) {
alert('网络错误,请稍后重试');
}
});
});