v0.3.7: 恢复前端Vue源码 + 修复AdminDashboard 401根源

This commit is contained in:
2026-05-17 13:26:36 +08:00
parent 09be4c307e
commit 8cd4dabb60
178 changed files with 20570 additions and 5 deletions

View File

@@ -0,0 +1,80 @@
function togCloudType(type, cb){
__cloudToggles[type] = cb.checked;
api('/api/admin/system-configs', {
method:'PUT', headers:{'Content-Type':'application/json'},
body:JSON.stringify({entries:[{key:'cloud_type_'+type+'_enabled', value:cb.checked?'true':'false'}]})
});
}
function togCloudAcc(id, cb){
api('/api/admin/cloud-configs/'+id, {method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({is_active:cb.checked})})
.then(function(d){ if(d.error){ cb.checked=!cb.checked; toast(d.error,'error'); } });
}
function delCloudAcc(id){ var name = '账号#'+id;
if(!confirm('确定删除 '+name+' 吗?')) return;
api('/api/admin/cloud-configs/'+id, {method:'DELETE'}).then(function(d){
toast(d.error?d.error:'已删除 '+name, d.error?'error':'success');
nav('cloud-config');
});
}
function doSaveAccount(){
var body = {
cloud_type: document.getElementById('dlg_type').value,
// default off, will be set by manual toggle
};
var cookie = document.getElementById('dlg_cookie').value.trim();
if(!cookie){ toast('请先输入或扫码获取 Cookie','error'); return; }
body.cookie = cookie;
body.promotion_account = document.getElementById('dlg_promo').value.trim() || '';
body.nickname = document.getElementById('dlg_nick').value.trim() || '';
body.storage_used = __qrStorageUsed || '';
body.storage_total = __qrStorageTotal || '';
toast('⏳ 正在保存...');
api('/api/admin/cloud-configs', {
method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)
}).then(function(d){
if(d && d.error){ toast(d.error,'error'); return; }
var savedId = d.id;
toast('⏳ 正在验证 Cookie 并查询空间...');
return api('/api/admin/cloud-configs/'+body.cloud_type+'/test', {
method:'POST', headers:{'Content-Type':'application/json'},
body:JSON.stringify({id: savedId})
});
}).then(function(r){
if(r && r.success){
toast('✅ 验证通过!空间: '+(r.storage_used||'?')+'/'+(r.storage_total||'?'));
} else {
toast('⚠️ 已保存但验证失败: '+(r?r.message:'未知错误'),'error');
}
closeDialog();
nav('cloud-config');
}).catch(function(e){
toast('保存失败: '+(e.message||'网络错误'),'error');
console.error('doSaveAccount error:', e);
});
}
function doSaveAccount_OLD(){
var body = {
cloud_type: document.getElementById('dlg_type').value,
// default off, will be set by verification
};
var cookie = document.getElementById('dlg_cookie').value.trim();
if(!cookie){ toast('请先输入或扫码获取 Cookie','error'); return; }
body.cookie = cookie;
console.log("SAVE promo raw:", document.getElementById("dlg_promo").value); body.promotion_account = document.getElementById('dlg_promo').value.trim() || '';
body.nickname = document.getElementById('dlg_nick').value.trim() || '';
body.storage_used = __qrStorageUsed || '';
body.storage_total = __qrStorageTotal || '';
api('/api/admin/cloud-configs', {
method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)
}).then(function(d){
if(d && d.error){ toast(d.error,'error'); return; }
toast('✅ 网盘配置更新成功');
closeDialog();
nav('cloud-config');
}).catch(function(e){
toast('保存失败: '+(e.message||'网络错误'),'error');
console.error('doSaveAccount error:', e);
});
}

View File

@@ -0,0 +1,43 @@
function togCloudType(type, cb){
__cloudToggles[type] = cb.checked;
api('/api/admin/system-configs', {
method:'PUT', headers:{'Content-Type':'application/json'},
body:JSON.stringify({entries:[{key:'cloud_type_'+type+'_enabled', value:cb.checked?'true':'false'}]})
});
}
function togCloudAcc(id, cb){
api('/api/admin/cloud-configs/'+id, {method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({is_active:cb.checked})})
.then(function(d){ if(d.error){ cb.checked=!cb.checked; toast(d.error,'error'); } });
}
function delCloudAcc(id){ var name = '账号#'+id;
if(!confirm('确定删除 '+name+' 吗?')) return;
api('/api/admin/cloud-configs/'+id, {method:'DELETE'}).then(function(d){
toast(d.error?d.error:'已删除 '+name, d.error?'error':'success');
nav('cloud-config');
});
}
function doSaveAccount(){
var body = {
cloud_type: document.getElementById('dlg_type').value,
is_active: true
};
var cookie = document.getElementById('dlg_cookie').value.trim();
if(!cookie){ toast('请先输入或扫码获取 Cookie','error'); return; }
body.cookie = cookie;
console.log("SAVE promo raw:", document.getElementById("dlg_promo").value); body.promotion_account = document.getElementById('dlg_promo').value.trim() || '';
body.nickname = document.getElementById('dlg_nick').value.trim() || '';
body.storage_used = __qrStorageUsed || '';
body.storage_total = __qrStorageTotal || '';
api('/api/admin/cloud-configs', {
method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)
}).then(function(d){
if(d && d.error){ toast(d.error,'error'); return; }
toast('✅ 网盘配置更新成功');
closeDialog();
nav('cloud-config');
}).catch(function(e){
toast('保存失败: '+(e.message||'网络错误'),'error');
console.error('doSaveAccount error:', e);
});
}

View File

@@ -0,0 +1,43 @@
function togCloudType(type, cb){
__cloudToggles[type] = cb.checked;
api('/api/admin/system-configs', {
method:'PUT', headers:{'Content-Type':'application/json'},
body:JSON.stringify({entries:[{key:'cloud_type_'+type+'_enabled', value:cb.checked?'true':'false'}]})
});
}
function togCloudAcc(id, cb){
api('/api/admin/cloud-configs/'+id, {method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({is_active:cb.checked})})
.then(function(d){ if(d.error){ cb.checked=!cb.checked; toast(d.error,'error'); } });
}
function delCloudAcc(id){ var name = '账号#'+id;
if(!confirm('确定删除 '+name+' 吗?')) return;
api('/api/admin/cloud-configs/'+id, {method:'DELETE'}).then(function(d){
toast(d.error?d.error:'已删除 '+name, d.error?'error':'success');
nav('cloud-config');
});
}
function doSaveAccount(){
var body = {
cloud_type: document.getElementById('dlg_type').value,
// default off, will be set by verification
};
var cookie = document.getElementById('dlg_cookie').value.trim();
if(!cookie){ toast('请先输入或扫码获取 Cookie','error'); return; }
body.cookie = cookie;
console.log("SAVE promo raw:", document.getElementById("dlg_promo").value); body.promotion_account = document.getElementById('dlg_promo').value.trim() || '';
body.nickname = document.getElementById('dlg_nick').value.trim() || '';
body.storage_used = __qrStorageUsed || '';
body.storage_total = __qrStorageTotal || '';
api('/api/admin/cloud-configs', {
method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)
}).then(function(d){
if(d && d.error){ toast(d.error,'error'); return; }
toast('✅ 网盘配置更新成功');
closeDialog();
nav('cloud-config');
}).catch(function(e){
toast('保存失败: '+(e.message||'网络错误'),'error');
console.error('doSaveAccount error:', e);
});
}

View File

@@ -0,0 +1,38 @@
// --- Cloud Config ---
var CLOUD_TYPES = [
{type:'quark',label:'夸克网盘',icon:'/admin/icons/quark.png'},
{type:'baidu',label:'百度网盘',icon:'/admin/icons/baidu.png'},
{type:'aliyun',label:'阿里云盘',icon:'/admin/icons/aliyun.png'},
{type:'115',label:'115网盘',icon:'/admin/icons/115.png'},
{type:'tianyi',label:'天翼云盘',icon:'/admin/icons/tianyi.png'},
{type:'123pan',label:'123云盘',icon:'/admin/icons/123pan.png'},
{type:'uc',label:'UC网盘',icon:'/admin/icons/uc.png'},
{type:'xunlei',label:'迅雷网盘',icon:'/admin/icons/xunlei.png'},
{type:'pikpak',label:'PikPak',icon:'/admin/icons/pikpak.png'},
{type:'magnet',label:'磁力链接',icon:'🧲'},
{type:'ed2k',label:'电驴链接',icon:'🔗'},
{type:'others',label:'其他',icon:'⬜'}
];
var QR_TYPES = ['quark','baidu'];
var __cloudToggles = {};
var __qrType = '', __qrSession = '', __qrCookie = '', __qrTimer = null;
function page_cloud_config(c){
c.innerHTML = '<div class="loading">加载中...</div>';
Promise.all([
api('/api/admin/system-configs').catch(function(e){ console.error(e); return {}; }),
api('/api/admin/cloud-configs').catch(function(e){ console.error(e); return []; })
]).then(function(res){
var d = res[0]||{}, accounts = res[1]||[];
__cloudToggles = {};
CLOUD_TYPES.forEach(function(ct){
var v = d['cloud_type_'+ct.type+'_enabled'];
__cloudToggles[ct.type] = v===undefined ? (ct.type!=='others') : (v==='true'||v==='1');
});
renderCloudPage(c, accounts);
}).catch(function(e){
c.innerHTML = '<div class="card"><p style="color:var(--danger)">加载失败: '+e.message+'</p></div>';
});
}

View File

@@ -0,0 +1,107 @@
var __qrSession = '';
var __qrCookie = '';
var __qrType = '';
var __qrTimer = null;
var __qrNickname = '';
var __qrStorageUsed = '';
var __qrStorageTotal = '';
var QR_TYPES = ['quark','baidu'];
function openAddDialog(){
document.getElementById('dlg_type').value = 'quark';
document.getElementById('dlg_cookie').value = '';
document.getElementById('dlg_promo').value = '';
document.getElementById('dlg_nick').value = '';
document.getElementById('dlg_storage_info').textContent = '扫码后自动获取';
resetQR();
onDlgTypeChange();
document.getElementById('modalBg').style.display = 'flex';
}
function closeDialog(){
cancelQRPoll();
document.getElementById('modalBg').style.display = 'none';
}
function onDlgTypeChange(){
var t = document.getElementById('dlg_type').value;
document.getElementById('dlg_qr_section').style.display = (QR_TYPES.indexOf(t)!==-1) ? 'block' : 'none';
}
function resetQR(){
cancelQRPoll();
__qrSession = ''; __qrCookie = ''; __qrNickname = ''; __qrStorageUsed = ''; __qrStorageTotal = '';
document.getElementById('dlg_qr_status').textContent = '点击下方按钮生成扫码链接';
document.getElementById('dlg_qr_btn').disabled = false;
document.getElementById('dlg_qr_btn').textContent = '生成扫码链接';
document.getElementById('dlg_qr_btn').style.display = '';
document.getElementById('dlg_qr_hint').textContent = '';
}
function doStartQR(){
__qrType = document.getElementById('dlg_type').value;
document.getElementById('dlg_qr_btn').disabled = true;
document.getElementById('dlg_qr_btn').textContent = '生成中...';
document.getElementById('dlg_qr_status').textContent = '正在生成二维码...';
api('/api/admin/'+__qrType+'/qr-login/start', {method:'POST'}).then(function(d){
if(d.error){
document.getElementById('dlg_qr_status').innerHTML = '<span style="color:var(--danger)">❌ '+d.error+'</span>';
document.getElementById('dlg_qr_btn').disabled=false;
document.getElementById('dlg_qr_btn').textContent='重试';
return;
}
__qrSession = d.sessionId;
var url = d.qrUrl||d.url||'';
if(url){
var qrSrc = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=' + encodeURIComponent(url);
document.getElementById('dlg_qr_status').innerHTML = '<img src="'+qrSrc+'" style="max-width:200px;max-height:200px;border:1px solid var(--border);border-radius:4px;display:block;margin:0 auto"><p style="font-size:11px;color:var(--sub);margin-top:6px;text-align:center">用对应 App 扫码并在手机上确认登录</p>';
}
document.getElementById('dlg_qr_hint').textContent = '等待扫码确认...';
document.getElementById('dlg_qr_btn').textContent = '重新生成';
document.getElementById('dlg_qr_btn').disabled = false;
pollQR();
});
}
function pollQR(){
if(!__qrSession) return;
__qrTimer = setTimeout(function(){
api('/api/admin/'+__qrType+'/qr-login/'+__qrSession+'/status').then(function(d){
if(d.status==='logged_in'){
__qrCookie = d.cookie||'';
__qrNickname = d.nickname||'';
__qrStorageUsed = d.storage_used||'';
__qrStorageTotal = d.storage_total||'';
if(__qrNickname){ var n = document.getElementById('dlg_nick'); if(!n.value.trim()) n.value = __qrNickname; }
if(d.promotion_account){ var p = document.getElementById('dlg_promo'); if(!p.value.trim()) p.value = d.promotion_account; }
var si = document.getElementById('dlg_storage_info');
if(__qrStorageTotal){
si.textContent = '💾 ' + (__qrStorageUsed||'?') + ' / ' + __qrStorageTotal;
si.style.color = 'var(--success)';
} else { si.textContent = '空间信息未获取'; si.style.color = 'var(--sub)'; }
if(d.autoUpdated){
document.getElementById('dlg_qr_status').innerHTML = '<span style="color:var(--success);font-size:14px">✅ 扫码成功!已自动更新现有账号 #'+d.updatedConfigId+'</span>';
cancelQRPoll();
toast('✅ 已自动更新账号','success');
setTimeout(function(){ closeDialog(); nav('cloud-config'); }, 1000);
return;
}
document.getElementById('dlg_qr_hint').textContent = '✅ 登录成功!';
document.getElementById('dlg_qr_status').innerHTML = '<span style="color:var(--success);font-size:14px">✅ 扫码成功!已自动填入</span>';
document.getElementById('dlg_cookie').value = __qrCookie;
document.getElementById('dlg_qr_btn').style.display = 'none';
cancelQRPoll();
}else if(d.status==='expired'){
cancelQRPoll();
setTimeout(function(){ doStartQR(); }, 500);
}else{
pollQR();
}
}).catch(function(){ pollQR(); });
}, 3000);
}
function cancelQRPoll(){
if(__qrTimer){ clearTimeout(__qrTimer); __qrTimer = null; }
if(__qrSession){ api('/api/admin/'+__qrType+'/qr-login/'+__qrSession+'/cancel', {method:'POST'}).catch(function(){}); __qrSession=''; }
}

View File

@@ -0,0 +1,92 @@
function renderCloudPage(c, accounts){
accounts = accounts || [];
var h = '';
// Render icon: URL → <img>, emoji/text → plain text
function iconHtml(icon, size){
if(!icon) return '';
if(icon.indexOf('/')===0 || icon.indexOf('http')===0){
return '<img src="'+icon+'" style="width:'+size+'px;height:'+size+'px;vertical-align:middle;margin-right:4px" onerror="this.remove()">';
}
return '<span style="font-size:'+(size-2)+'px;vertical-align:middle;margin-right:4px">'+icon+'</span>';
}
// Toggle grid
h += '<div class="card"><div class="card-title">⚡ 搜索网盘类型控制</div>'+
'<p style="color:var(--sub);font-size:12px;margin-bottom:14px">控制搜索引擎检索哪些网盘类型的资源</p>'+
'<div class="stats-grid" style="grid-template-columns:repeat(auto-fill,minmax(170px,1fr))">';
CLOUD_TYPES.forEach(function(ct){
var on = __cloudToggles[ct.type];
h += '<div class="stat-card" style="padding:8px 12px;display:flex;align-items:center;justify-content:space-between">'+
'<span>'+iconHtml(ct.icon,20)+' <span style="font-size:12px">'+ct.label+'</span></span>'+
'<label class="toggle"><input type="checkbox" '+(on?'checked':'')+' onchange="togCloudType(\''+ct.type+'\',this)"><span class="toggle-slider"></span></label>'+
'</div>';
});
h += '</div></div>';
// Account list — table style
if(accounts.length > 0){
h += '<div class="card"><div class="card-title">📋 已有账号 ('+accounts.length+') <button class="btn btn-pri btn-sm" onclick="openAddDialog()" style="margin-left:12px"> 新增</button></div>';
h += '<div style="overflow-x:auto"><table style="width:100%;border-collapse:collapse;font-size:13px">';
h += '<thead><tr style="background:var(--bg);border-bottom:2px solid var(--border);text-align:left">'+
'<th style="padding:10px 12px;white-space:nowrap">📱推广平台</th>'+
'<th style="padding:10px 12px;white-space:nowrap">推广平台账号</th>'+
'<th style="padding:10px 12px;white-space:nowrap">网盘昵称</th>'+'<th style="padding:10px 12px;white-space:nowrap">网盘UID</th>'+
'<th style="padding:10px 12px;white-space:nowrap">验证</th>'+
'<th style="padding:10px 12px;white-space:nowrap">空间</th>'+
'<th style="padding:10px 12px;white-space:nowrap">转存</th>'+
'<th style="padding:10px 12px;white-space:nowrap">操作</th>'+
'</tr></thead><tbody>';
accounts.forEach(function(cfg){
var label = CLOUD_TYPES.find(function(ct){ return ct.type===cfg.cloud_type; });
var icon = (label||{}).icon||'⬜';
var active = cfg.is_active===1||cfg.is_active===true;
var ck = cfg.verification_status==='valid'?'✅':(cfg.verification_status==='invalid'?'❌':'⏳');
h += '<tr style="border-bottom:1px solid var(--border)">'+
'<td style="padding:10px 12px;white-space:nowrap">'+iconHtml(icon,18)+(label||{}).label+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap">'+(cfg.promotion_account||'—')+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap">'+(cfg.nickname||cfg.cloud_type)+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap;font-size:12px;color:var(--sub)">'+(cfg.cookie_uid||cfg.cloud_type)+'</td>'+
'<td style="padding:10px 12px">'+ck+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap;font-size:12px;color:var(--sub)">'+(cfg.storage_used||cfg.storage_total?'💾 '+(cfg.storage_used||'?')+'/'+(cfg.storage_total||'?'):'—')+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap;font-size:12px;color:var(--sub)">'+(cfg.total_saves?'转存'+cfg.total_saves+'次':'—')+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap">'+
'<label class="toggle"><input type="checkbox" '+(active?'checked':'')+' onchange="togCloudAcc('+cfg.id+',this)"><span class="toggle-slider"></span></label>'+
'<button class="btn btn-danger btn-sm" onclick="delCloudAcc('+cfg.id+')" style="margin-left:8px">🗑</button>'+
'</td>'+
'</tr>';
});
h += '</tbody></table></div></div>';
}
// No accounts yet — show add button
if(accounts.length === 0){
h += '<div class="card"><div class="card-title">📋 已有账号 (0)</div><p style="color:var(--sub);font-size:13px;margin-bottom:12px">还没有添加任何网盘账号</p><button class="btn btn-pri" onclick="openAddDialog()"> 新增网盘</button></div>';
}
// Modal dialog
h += '<div id="modalBg" style="display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.4);z-index:100;align-items:center;justify-content:center" onclick="if(event.target===this)closeDialog()">'+
'<div class="card" style="width:500px;max-width:95vw;max-height:90vh;overflow-y:auto" onclick="event.stopPropagation()">'+
'<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">'+
'<span style="font-weight:600;font-size:15px">新增网盘账号</span>'+
'<button class="btn btn-outline btn-sm" onclick="closeDialog()">✕</button></div>'+
'<div class="form-group"><label>网盘类型</label><select id="dlg_type" class="form-control" style="max-width:200px" onchange="onDlgTypeChange()">';
CLOUD_TYPES.forEach(function(ct){ h+='<option value="'+ct.type+'">'+ct.label+'</option>'; });
h+='</select></div>'+
'<div class="form-group"><label>推广平台账号</label><input id="dlg_promo" class="form-control" placeholder="平台注册所用手机号" style="max-width:250px"></div>'+
'<div class="form-group"><label>Cookie</label><textarea id="dlg_cookie" class="form-control wide" rows="5" placeholder="粘贴 Cookie 或通过下方扫码获取"></textarea></div>'+
'<div class="form-group"><label>网盘昵称</label><input id="dlg_nick" class="form-control" placeholder="扫码后自动获取" style="max-width:250px;background:#f5f6fa" readonly></div>'+
'<div class="form-group"><label>空间信息</label><span id="dlg_storage_info" style="font-size:13px;color:var(--sub);padding-top:6px">扫码后自动获取</span></div>'+
'<div id="dlg_qr_section" style="margin-top:12px;padding:12px;background:#f9fafb;border-radius:8px">'+
'<p style="font-size:12px;font-weight:600;margin-bottom:8px">📱 扫码获取 Cookie仅夸克/百度)</p>'+
'<div id="dlg_qr_status" style="font-size:12px;color:var(--sub);margin-bottom:8px">点击下方按钮生成扫码链接</div>'+
''+
'<div style="margin-top:8px;display:flex;gap:8px;align-items:center">'+
'<button class="btn btn-pri btn-sm" id="dlg_qr_btn" onclick="doStartQR()">生成扫码链接</button>'+
'<span id="dlg_qr_hint" style="font-size:11px;color:var(--sub)"></span></div></div>'+
'<div style="margin-top:16px;display:flex;gap:8px">'+
'<button class="btn btn-pri" onclick="doSaveAccount()">💾 保存账号</button>'+
'<button class="btn btn-outline" onclick="closeDialog()">取消</button></div></div></div>';
c.innerHTML = h;
}

View File

@@ -0,0 +1,92 @@
function renderCloudPage(c, accounts){
accounts = accounts || [];
var h = '';
// Render icon: URL → <img>, emoji/text → plain text
function iconHtml(icon, size){
if(!icon) return '';
if(icon.indexOf('/')===0 || icon.indexOf('http')===0){
return '<img src="'+icon+'" style="width:'+size+'px;height:'+size+'px;vertical-align:middle;margin-right:4px" onerror="this.remove()">';
}
return '<span style="font-size:'+(size-2)+'px;vertical-align:middle;margin-right:4px">'+icon+'</span>';
}
// Toggle grid
h += '<div class="card"><div class="card-title">⚡ 搜索网盘类型控制</div>'+
'<p style="color:var(--sub);font-size:12px;margin-bottom:14px">控制搜索引擎检索哪些网盘类型的资源</p>'+
'<div class="stats-grid" style="grid-template-columns:repeat(auto-fill,minmax(170px,1fr))">';
CLOUD_TYPES.forEach(function(ct){
var on = __cloudToggles[ct.type];
h += '<div class="stat-card" style="padding:8px 12px;display:flex;align-items:center;justify-content:space-between">'+
'<span>'+iconHtml(ct.icon,20)+' <span style="font-size:12px">'+ct.label+'</span></span>'+
'<label class="toggle"><input type="checkbox" '+(on?'checked':'')+' onchange="togCloudType(\''+ct.type+'\',this)"><span class="toggle-slider"></span></label>'+
'</div>';
});
h += '</div></div>';
// Account list — table style
if(accounts.length > 0){
h += '<div class="card"><div class="card-title">📋 已有账号 ('+accounts.length+') <button class="btn btn-pri btn-sm" onclick="openAddDialog()" style="margin-left:12px"> 新增</button></div>';
h += '<div style="overflow-x:auto"><table style="width:100%;border-collapse:collapse;font-size:13px">';
h += '<thead><tr style="background:var(--bg);border-bottom:2px solid var(--border);text-align:left">'+
'<th style="padding:10px 12px;white-space:nowrap">📱推广平台</th>'+
'<th style="padding:10px 12px;white-space:nowrap">推广平台账号</th>'+
'<th style="padding:10px 12px;white-space:nowrap">网盘昵称</th>'+'<th style="padding:10px 12px;white-space:nowrap">网盘UID</th>'+
'<th style="padding:10px 12px;white-space:nowrap">验证</th>'+
'<th style="padding:10px 12px;white-space:nowrap">空间</th>'+
'<th style="padding:10px 12px;white-space:nowrap">转存</th>'+
'<th style="padding:10px 12px;white-space:nowrap">操作</th>'+
'</tr></thead><tbody>';
accounts.forEach(function(cfg){
var label = CLOUD_TYPES.find(function(ct){ return ct.type===cfg.cloud_type; });
var icon = (label||{}).icon||'⬜';
var active = cfg.is_active===1||cfg.is_active===true;
var ck = cfg.verification_status==='valid'?'✅':(cfg.verification_status==='invalid'?'❌':'—');
h += '<tr style="border-bottom:1px solid var(--border)">'+
'<td style="padding:10px 12px;white-space:nowrap">'+iconHtml(icon,18)+(label||{}).label+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap">'+(cfg.promotion_account||'—')+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap">'+(cfg.nickname||cfg.cloud_type)+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap;font-size:12px;color:var(--sub)">'+(cfg.cookie_uid||cfg.cloud_type)+'</td>'+
'<td style="padding:10px 12px">'+ck+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap;font-size:12px;color:var(--sub)">'+(cfg.storage_used||cfg.storage_total?'💾 '+(cfg.storage_used||'?')+'/'+(cfg.storage_total||'?'):'—')+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap;font-size:12px;color:var(--sub)">'+(cfg.total_saves?'转存'+cfg.total_saves+'次':'—')+'</td>'+
'<td style="padding:10px 12px;white-space:nowrap">'+
'<label class="toggle"><input type="checkbox" '+(active?'checked':'')+' onchange="togCloudAcc('+cfg.id+',this)"><span class="toggle-slider"></span></label>'+
'<button class="btn btn-danger btn-sm" onclick="delCloudAcc('+cfg.id+')" style="margin-left:8px">🗑</button>'+
'</td>'+
'</tr>';
});
h += '</tbody></table></div></div>';
}
// No accounts yet — show add button
if(accounts.length === 0){
h += '<div class="card"><div class="card-title">📋 已有账号 (0)</div><p style="color:var(--sub);font-size:13px;margin-bottom:12px">还没有添加任何网盘账号</p><button class="btn btn-pri" onclick="openAddDialog()"> 新增网盘</button></div>';
}
// Modal dialog
h += '<div id="modalBg" style="display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.4);z-index:100;align-items:center;justify-content:center" onclick="if(event.target===this)closeDialog()">'+
'<div class="card" style="width:500px;max-width:95vw;max-height:90vh;overflow-y:auto" onclick="event.stopPropagation()">'+
'<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">'+
'<span style="font-weight:600;font-size:15px">新增网盘账号</span>'+
'<button class="btn btn-outline btn-sm" onclick="closeDialog()">✕</button></div>'+
'<div class="form-group"><label>网盘类型</label><select id="dlg_type" class="form-control" style="max-width:200px" onchange="onDlgTypeChange()">';
CLOUD_TYPES.forEach(function(ct){ h+='<option value="'+ct.type+'">'+ct.label+'</option>'; });
h+='</select></div>'+
'<div class="form-group"><label>推广平台账号</label><input id="dlg_promo" class="form-control" placeholder="平台注册所用手机号" style="max-width:250px"></div>'+
'<div class="form-group"><label>Cookie</label><textarea id="dlg_cookie" class="form-control wide" rows="5" placeholder="粘贴 Cookie 或通过下方扫码获取"></textarea></div>'+
'<div class="form-group"><label>网盘昵称</label><input id="dlg_nick" class="form-control" placeholder="扫码后自动获取" style="max-width:250px;background:#f5f6fa" readonly></div>'+
'<div class="form-group"><label>空间信息</label><span id="dlg_storage_info" style="font-size:13px;color:var(--sub);padding-top:6px">扫码后自动获取</span></div>'+
'<div id="dlg_qr_section" style="margin-top:12px;padding:12px;background:#f9fafb;border-radius:8px">'+
'<p style="font-size:12px;font-weight:600;margin-bottom:8px">📱 扫码获取 Cookie仅夸克/百度)</p>'+
'<div id="dlg_qr_status" style="font-size:12px;color:var(--sub);margin-bottom:8px">点击下方按钮生成扫码链接</div>'+
''+
'<div style="margin-top:8px;display:flex;gap:8px;align-items:center">'+
'<button class="btn btn-pri btn-sm" id="dlg_qr_btn" onclick="doStartQR()">生成扫码链接</button>'+
'<span id="dlg_qr_hint" style="font-size:11px;color:var(--sub)"></span></div></div>'+
'<div style="margin-top:16px;display:flex;gap:8px">'+
'<button class="btn btn-pri" onclick="doSaveAccount()">💾 保存账号</button>'+
'<button class="btn btn-outline" onclick="closeDialog()">取消</button></div></div></div>';
c.innerHTML = h;
}