V1.0正式版更新

This commit is contained in:
MasonLiu committed 2026-05-29 23:09:58 +08:00
1 parent 4d1a9111b6
commit 0d81e72ef1
18 files changed
+4146 -1203

No files matched your search

+205
View File
@@ -0,0 +1,205 @@
/**
* VPS Hub 配置管理页面交互脚本
*/
/**
* 切换网站URL输入框的提示和默认值
* @param {string} siteType - 网站类型
*/
function toggleSiteUrl(siteType) {
const urlGroup = document.getElementById('site_url_group');
const urlInput = document.getElementById('site_url_input');
if (!urlInput) return;
switch(siteType) {
case 'mofang':
urlInput.placeholder = '留空使用默认值: https://www.heyunidc.cn/v1';
urlInput.required = false;
break;
case 'aliyun':
urlInput.placeholder = '例如: https://ecs.aliyuncs.com';
urlInput.required = true;
break;
case 'tencent':
urlInput.value = 'https://cvm.tencentcloudapi.com/';
urlInput.placeholder = '腾讯云API地址';
urlInput.required = true;
break;
default:
urlInput.placeholder = '输入API地址';
urlInput.required = true;
}
}
/**
* 验证密码格式
* @returns {boolean} 是否通过验证
*/
function validatePassword() {
const passwordInput = document.getElementById('api_pass');
if (!passwordInput) return true;
const password = passwordInput.value;
if (password.length < 8) {
alert('密码至少需要8位!');
return false;
}
if (!/^[a-zA-Z0-9]+$/.test(password)) {
alert('密码只能包含字母和数字!');
return false;
}
return true;
}
/**
* 确认删除操作
* @param {string} message - 确认消息
* @returns {boolean} 是否确认
*/
function confirmDelete(message) {
return confirm(message || '确认删除此配置?');
}
/**
* 显示加载状态
* @param {HTMLElement} button - 按钮元素
*/
function showLoading(button) {
if (!button) return;
const originalText = button.textContent;
button.disabled = true;
button.textContent = '加载中...';
button.dataset.originalText = originalText;
}
/**
* 隐藏加载状态
* @param {HTMLElement} button - 按钮元素
*/
function hideLoading(button) {
if (!button) return;
button.disabled = false;
button.textContent = button.dataset.originalText || '提交';
}
/**
* AJAX提交表单
* @param {HTMLFormElement} form - 表单元素
* @param {Function} successCallback - 成功回调
* @param {Function} errorCallback - 失败回调
*/
function submitFormAjax(form, successCallback, errorCallback) {
const formData = new FormData(form);
const submitButton = form.querySelector('button[type="submit"]');
showLoading(submitButton);
fetch(form.action || window.location.href, {
method: form.method || 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
hideLoading(submitButton);
if (data.status === 200 || data.success) {
if (successCallback) successCallback(data);
} else {
if (errorCallback) errorCallback(data);
else alert('操作失败: ' + (data.msg || '未知错误'));
}
})
.catch(error => {
hideLoading(submitButton);
console.error('请求失败:', error);
if (errorCallback) errorCallback(error);
else alert('网络错误,请稍后重试');
});
}
/**
* 刷新VPS列表
*/
function refreshVpsList() {
const button = document.querySelector('.btn-refresh');
if (!button) return;
showLoading(button);
// 创建临时表单提交
const form = document.createElement('form');
form.method = 'POST';
form.action = window.location.href;
const actionInput = document.createElement('input');
actionInput.type = 'hidden';
actionInput.name = 'action';
actionInput.value = 'refresh_vps_list';
form.appendChild(actionInput);
document.body.appendChild(form);
form.submit();
}
/**
* 初始化页面
*/
document.addEventListener('DOMContentLoaded', function() {
// 自动聚焦第一个输入框
const firstInput = document.querySelector('input:not([type="hidden"]):not([type="checkbox"])');
if (firstInput && !firstInput.value) {
firstInput.focus();
}
// 为所有删除按钮添加确认对话框
const deleteButtons = document.querySelectorAll('.btn-delete');
deleteButtons.forEach(button => {
button.addEventListener('click', function(e) {
if (!confirmDelete('确认删除此配置?此操作不可恢复!')) {
e.preventDefault();
}
});
});
// 为所有操作按钮添加确认对话框
const actionButtons = document.querySelectorAll('.btn-success, .btn-danger, .btn-warning');
actionButtons.forEach(button => {
if (button.type === 'submit' && button.name === 'action') {
button.addEventListener('click', function(e) {
let message = '';
switch(this.value) {
case 'on':
message = '确认开机?';
break;
case 'off':
message = '确认关机?';
break;
case 'reboot':
message = '确认硬重启?';
break;
}
if (message && !confirm(message)) {
e.preventDefault();
}
});
}
});
console.log('VPS Hub 页面已加载');
});
// 导出函数供全局使用
window.VPSHub = {
toggleSiteUrl,
validatePassword,
confirmDelete,
refreshVpsList,
showLoading,
hideLoading
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

+121
View File
@@ -0,0 +1,121 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.config-container {
background: white;
border-radius: 16px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 40px;
max-width: 500px;
width: 100%;
}
.config-header {
text-align: center;
margin-bottom: 30px;
}
.config-header h1 {
color: #2d3748;
font-size: 24px;
margin-bottom: 10px;
}
.config-header p {
color: #718096;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
color: #4a5568;
font-weight: 600;
margin-bottom: 8px;
font-size: 14px;
}
.form-group input {
width: 100%;
padding: 12px 16px;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 14px;
transition: all 0.3s;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.form-group .help-text {
color: #a0aec0;
font-size: 12px;
margin-top: 6px;
}
.error-message {
background: #fed7d7;
border-left: 4px solid #f56565;
color: #c53030;
padding: 12px 16px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
}
.btn-submit {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
}
.btn-submit:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}
.btn-submit:active {
transform: translateY(0);
}
.info-box {
background: #ebf8ff;
border-left: 4px solid #4299e1;
padding: 12px 16px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 13px;
color: #2c5282;
}
@media (max-width: 480px) {
.config-container {
padding: 30px 20px;
}
}
+459
View File
@@ -0,0 +1,459 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
min-height: 100vh;
padding: 10px;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-radius: 16px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 25px 20px;
text-align: center;
}
.header h1 {
font-size: 24px;
margin-bottom: 8px;
font-weight: 600;
}
.header p {
opacity: 0.9;
font-size: 13px;
}
.content {
padding: 20px;
}
.token-info {
background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
border-left: 4px solid #00bcd4;
padding: 12px 16px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 13px;
color: #006064;
}
.token-info strong {
color: #00838f;
}
.stats-bar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
border-radius: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
gap: 10px;
}
.stats-item {
font-size: 14px;
color: #2d3748;
}
.stats-item strong {
color: #667eea;
font-size: 18px;
}
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
gap: 20px;
}
.vps-card {
background: white;
border-radius: 12px;
padding: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
border: 1px solid #e2e8f0;
}
.vps-card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 12px;
border-bottom: 2px solid #f0f0f0;
}
.vps-id {
font-size: 18px;
font-weight: 600;
color: #2d3748;
}
.status-badge {
display: inline-block;
padding: 6px 14px;
border-radius: 20px;
color: white;
font-size: 12px;
font-weight: 600;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.card-body {
margin-bottom: 15px;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px solid #f7fafc;
font-size: 13px;
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
color: #718096;
font-weight: 500;
}
.info-value {
color: #2d3748;
font-weight: 600;
text-align: right;
max-width: 60%;
word-break: break-all;
}
.power-status {
display: flex;
align-items: center;
gap: 8px;
padding: 10px;
background: #f7fafc;
border-radius: 8px;
margin-bottom: 15px;
}
.power-indicator {
width: 12px;
height: 12px;
border-radius: 50%;
display: inline-block;
}
.power-on {
background: #48bb78;
box-shadow: 0 0 8px #48bb78;
}
.power-off {
background: #e53e3e;
box-shadow: 0 0 8px #e53e3e;
}
.power-unknown {
background: #a0aec0;
}
.power-text {
font-size: 14px;
font-weight: 600;
color: #2d3748;
}
.card-actions {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
}
.btn {
padding: 10px 16px;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 13px;
font-weight: 600;
text-decoration: none;
color: white;
transition: all 0.3s;
text-align: center;
display: block;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.btn:active {
transform: translateY(0);
}
.btn-success {
background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}
.btn-warning {
background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
}
.btn-danger {
background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}
.btn-info {
background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
}
.error-message {
background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
border-left: 4px solid #f56565;
color: #c53030;
padding: 20px;
border-radius: 8px;
text-align: center;
}
.success-message {
background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%);
border-left: 4px solid #48bb78;
color: #22543d;
padding: 20px;
border-radius: 8px;
text-align: center;
margin-bottom: 20px;
}
.loading {
text-align: center;
padding: 40px;
color: #718096;
}
.loading-spinner {
display: inline-block;
width: 40px;
height: 40px;
border: 4px solid #e2e8f0;
border-top-color: #667eea;
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin-bottom: 15px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* 响应式设计 */
@media (max-width: 768px) {
body {
padding: 5px;
}
.header {
padding: 20px 15px;
}
.header h1 {
font-size: 20px;
}
.content {
padding: 15px;
}
.card-grid {
grid-template-columns: 1fr;
gap: 15px;
}
.vps-card {
padding: 15px;
}
.card-actions {
grid-template-columns: 1fr;
}
.stats-bar {
flex-direction: column;
align-items: flex-start;
}
.info-row {
flex-direction: column;
gap: 4px;
}
.info-value {
max-width: 100%;
text-align: left;
}
}
@media (max-width: 480px) {
.header h1 {
font-size: 18px;
}
.vps-id {
font-size: 16px;
}
.btn {
padding: 8px 12px;
font-size: 12px;
}
}
/* VPS Hub 新增样式 */
.config-container {
max-width: 600px;
margin: 50px auto;
background: white;
padding: 40px;
border-radius: 12px;
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.config-header {
text-align: center;
margin-bottom: 30px;
}
.config-header h1 {
color: #667eea;
margin-bottom: 10px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 500;
}
.form-group input,
.form-group select {
width: 100%;
padding: 10px 12px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 14px;
transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
outline: none;
border-color: #667eea;
}
.help-text {
font-size: 12px;
color: #999;
margin-top: 5px;
}
.btn-submit {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 6px;
font-size: 16px;
cursor: pointer;
transition: transform 0.2s;
}
.btn-submit:hover {
transform: translateY(-2px);
}
.error-message {
background: #fee;
border-left: 4px solid #dc3545;
padding: 12px 16px;
border-radius: 6px;
margin-bottom: 20px;
color: #dc3545;
}
.success-message {
background: #efe;
border-left: 4px solid #28a745;
padding: 12px 16px;
border-radius: 6px;
margin-bottom: 20px;
color: #28a745;
}
.info-box {
background: #e7f3ff;
border-left: 4px solid #007bff;
padding: 12px 16px;
border-radius: 6px;
margin-bottom: 20px;
color: #0056b3;
font-size: 14px;
}
.info-box code {
background: #f0f0f0;
padding: 2px 6px;
border-radius: 3px;
font-family: monospace;
}
.copyright {
margin-top: 30px;
padding: 20px;
color: #999;
font-size: 14px;
}
.copyright a {
color: #667eea;
text-decoration: none;
}
.copyright a:hover {
text-decoration: underline;
}