Files
CloudSearch/source_clean/frontend.bak.old/admin/js/cloud/cloud-actions.js.bak

44 lines
1.8 KiB
JavaScript

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);
});
}