添加Valkey支持
This commit is contained in:
@@ -116,12 +116,35 @@
|
||||
<input type="text" id="database" value="display_wall" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="init-header" style="margin: 24px 0 16px 0; text-align: left;">
|
||||
<h3 style="font-size: 16px; color: var(--text-main); margin: 0;">Valkey / Redis 缓存配置 (可选)</h3>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group" style="flex: 2;">
|
||||
<label for="vHost">Valkey 地址</label>
|
||||
<input type="text" id="vHost" value="localhost" placeholder="localhost" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label for="vPort">端口</label>
|
||||
<input type="number" id="vPort" value="6379" placeholder="6379" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group form-group-wide">
|
||||
<label for="vPassword">Valkey 密码</label>
|
||||
<input type="password" id="vPassword" placeholder="留空则无密码">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-message" id="messageBox"></div>
|
||||
|
||||
<div class="actions">
|
||||
<button class="btn btn-test" id="btnTest">测试连接</button>
|
||||
<button class="btn btn-add" id="btnInit">初始化数据库</button>
|
||||
<div class="actions" style="flex-wrap: wrap;">
|
||||
<button class="btn btn-test" id="btnTest" style="flex: 1 1 45%;">测试 MySQL</button>
|
||||
<button class="btn btn-test" id="btnTestValkey" style="flex: 1 1 45%;">测试 Valkey</button>
|
||||
<button class="btn btn-add" id="btnInit" style="flex: 1 1 100%;">确认并初始化系统</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,8 +4,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const userInput = document.getElementById('user');
|
||||
const passwordInput = document.getElementById('password');
|
||||
const databaseInput = document.getElementById('database');
|
||||
const vHostInput = document.getElementById('vHost');
|
||||
const vPortInput = document.getElementById('vPort');
|
||||
const vPasswordInput = document.getElementById('vPassword');
|
||||
|
||||
const btnTest = document.getElementById('btnTest');
|
||||
const btnTestValkey = document.getElementById('btnTestValkey');
|
||||
const btnInit = document.getElementById('btnInit');
|
||||
const messageBox = document.getElementById('messageBox');
|
||||
|
||||
@@ -101,6 +105,34 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
btnTest.textContent = oldText;
|
||||
}
|
||||
});
|
||||
|
||||
btnTestValkey.addEventListener('click', async () => {
|
||||
btnTestValkey.disabled = true;
|
||||
const oldText = btnTestValkey.textContent;
|
||||
btnTestValkey.textContent = '测试中...';
|
||||
try {
|
||||
const res = await fetch('/api/setup/test-valkey', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
host: vHostInput.value,
|
||||
port: vPortInput.value,
|
||||
password: vPasswordInput.value
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
showMessage('Valkey 连接成功!');
|
||||
} else {
|
||||
showMessage('Valkey 连接失败: ' + (data.error || '未知错误'), true);
|
||||
}
|
||||
} catch (err) {
|
||||
showMessage('Valkey 请求失败: ' + err.message, true);
|
||||
} finally {
|
||||
btnTestValkey.disabled = false;
|
||||
btnTestValkey.textContent = oldText;
|
||||
}
|
||||
});
|
||||
|
||||
btnInit.addEventListener('click', async () => {
|
||||
btnInit.disabled = true;
|
||||
@@ -115,7 +147,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
port: portInput.value,
|
||||
user: userInput.value,
|
||||
password: passwordInput.value,
|
||||
database: databaseInput.value
|
||||
database: databaseInput.value,
|
||||
vHost: vHostInput.value,
|
||||
vPort: vPortInput.value,
|
||||
vPassword: vPasswordInput.value
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
Reference in New Issue
Block a user