优化备注与封禁

This commit is contained in:
yml2213
2026-07-23 17:05:23 +08:00
parent d4e674f8f6
commit edbe8ca227
6 changed files with 149 additions and 16 deletions
+35 -13
View File
@@ -1,4 +1,5 @@
import './style.css';
import { ClipboardGetText } from '../wailsjs/runtime/runtime.js';
const storageKey = 'hfb-upload-settings';
@@ -9,7 +10,7 @@ app.innerHTML = `
<section class="topbar">
<div>
<h1>哈夫币外部上传</h1>
<p>粘贴账号数据,预览确认后上传到服务器。</p>
<p>粘贴账号数据,确认后上传到服务器。</p>
</div>
<div class="status" id="status">准备就绪</div>
</section>
@@ -41,7 +42,7 @@ app.innerHTML = `
打开文件
<input id="fileInput" type="file" accept=".txt,.log,.md,.json" hidden />
</label>
<button class="button secondary" id="previewBtn">预览 JSON</button>
<button class="button secondary" id="pasteBtn">粘贴剪贴板</button>
<button class="button primary" id="uploadBtn">上传</button>
</section>
@@ -54,7 +55,7 @@ app.innerHTML = `
<section class="panel result-panel">
<div class="panel-title">结果</div>
<pre id="result">暂无结果
点击“预览 JSON”或“上传”后,这里会显示多行结果。</pre>
点击“上传”后,这里会显示多行结果。</pre>
</section>
</section>
</main>
@@ -69,7 +70,7 @@ const elements = {
data: document.querySelector('#data'),
result: document.querySelector('#result'),
fileInput: document.querySelector('#fileInput'),
previewBtn: document.querySelector('#previewBtn'),
pasteBtn: document.querySelector('#pasteBtn'),
uploadBtn: document.querySelector('#uploadBtn'),
};
@@ -83,7 +84,7 @@ function setStatus(text, tone = 'neutral') {
}
function setBusy(busy) {
elements.previewBtn.disabled = busy;
elements.pasteBtn.disabled = busy;
elements.uploadBtn.disabled = busy;
}
@@ -115,6 +116,21 @@ function collectForm() {
};
}
async function readClipboardText() {
try {
const text = await ClipboardGetText();
if (typeof text === 'string' && text.trim() !== '') {
return text;
}
} catch {
// 回退到浏览器剪贴板 API
}
if (navigator.clipboard?.readText) {
return await navigator.clipboard.readText();
}
throw new Error('无法读取剪贴板内容');
}
async function init() {
const api = backend();
if (!api) {
@@ -140,7 +156,7 @@ elements.fileInput.addEventListener('change', async (event) => {
if (!file) return;
try {
elements.data.value = await file.text();
elements.result.textContent = '文件已载入,可以预览或上传。';
elements.result.textContent = '文件已载入,可以上传。';
setStatus('已载入文件', 'ok');
} catch (err) {
setStatus('读取文件失败', 'error');
@@ -150,17 +166,23 @@ elements.fileInput.addEventListener('change', async (event) => {
}
});
elements.previewBtn.addEventListener('click', async () => {
const api = backend();
elements.pasteBtn.addEventListener('click', async () => {
setBusy(true);
setStatus('正在生成预览...', 'neutral');
saveSettings();
setStatus('正在读取剪贴板...', 'neutral');
try {
elements.result.textContent = await api.Preview(collectForm());
setStatus('预览已生成', 'ok');
const text = await readClipboardText();
if (!text || !text.trim()) {
setStatus('剪贴板为空', 'error');
elements.result.textContent = '剪贴板没有可用的文本内容。';
return;
}
elements.data.value = text;
elements.result.textContent = '已从剪贴板填入账号数据,可以上传。';
setStatus('已粘贴剪贴板', 'ok');
elements.data.focus();
} catch (err) {
elements.result.textContent = String(err);
setStatus('预览失败', 'error');
setStatus('读取剪贴板失败', 'error');
} finally {
setBusy(false);
}
+10
View File
@@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
// 使用项目专属端口,避免多项目同时开发时与 Vite 默认 5173 冲突
export default defineConfig({
server: {
host: 'localhost',
port: 5188,
strictPort: true,
},
})