/* v26a: 分类管理页(视频管理:待发布/已发布/素材;素材管理:全部分类 tab) */
(function () {
'use strict';
if (window.__mobV26A) return;
window.__mobV26A = true;
var API26 = 'https://api-gateway.duoweiying.cn';
var X = window.__mksV26X = window.__mksV26X || {};
function $26(id) { return document.getElementById(id); }
function uid26() {
var u = null; try { u = JSON.parse(localStorage.getItem('user_info') || '{}'); } catch (e) {}
return (u && (u.id || u.username)) || localStorage.getItem('user_id') || 'anonymous';
}
function e26(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); }
function t26(t) {
try { var o = $26('v26tip'); if (o) o.remove(); var d = document.createElement('div'); d.id = 'v26tip';
d.style.cssText = 'position:fixed;left:50%;bottom:120px;transform:translateX(-50%);z-index:49000;background:#0f172a;color:#fff;font-size:13px;padding:9px 16px;border-radius:18px;max-width:84%;text-align:center;';
d.textContent = t; document.body.appendChild(d); setTimeout(function () { d.remove(); }, 2400); } catch (e) {}
}
function page26(title, html) {
var old = $26('v26Page'); if (old) old.remove();
var p = document.createElement('div'); p.id = 'v26Page';
p.style.cssText = 'position:fixed;inset:0;z-index:45000;background:#f1f5f9;display:flex;flex-direction:column;';
p.innerHTML = '
' +
'
‹ ' +
'
' + e26(title) + '
' +
'
';
document.body.appendChild(p);
$26('v26Back').onclick = function () { p.remove(); };
$26('v26Body').innerHTML = html;
return $26('v26Body');
}
function pick26(u, tp) {
if (!u) { t26('该素材暂无可访问地址'); return; }
/* WR-562k13d: 原生 confirm 在微信 WebView 被静默拦截 -> 页面内确认 */
try {
var go = function () {
try { localStorage.setItem('v26pick', u); } catch (e) {}
var ev = new CustomEvent('v26pick', { detail: u });
document.dispatchEvent(ev);
t26('素材已选,请描述创作需求或去「视频混剪」使用');
};
if (window.wrConfirm) {
window.wrConfirm('用此素材进行 AI 创作?将打开视频混剪/二创操作台(自动携带素材)。', { title: 'AI 创作', okText: '开始创作' }).then(function (ok) { if (ok) go(); });
} else if (confirm('用此素材进行 AI 创作?将打开视频混剪/二创操作台(自动携带素材)。')) { go(); }
} catch (e) {}
}
/* ===== WR-562k11: 直链归一 + 成片/素材操作 ===== */
var OBS_PUB_26 = 'https://categorized-assets-smart-center.obs.cn-east-3.myhuaweicloud.com';
function abs26(u) {
u = String(u || '');
if (!u) return '';
if (/^(https?:)?\/\//i.test(u) || /^data:/i.test(u) || /^blob:/i.test(u)) return u;
if (u.charAt(0) === '/') {
if (u.indexOf('/static/') === 0) return 'https://ai.duoweiying.cn' + u;
return OBS_PUB_26 + u;
}
return OBS_PUB_26 + '/' + u.replace(/^\.?\//, '');
}
function isVid26(u) { return /\.(mp4|webm|mov|m4v|avi|mkv)(\?|$)/i.test(String(u || '')); }
function ent26() {
var u = uid26();
if (!u || u === 'anonymous') return Promise.resolve(false);
if (u === 'admin-001' || u === 'admin') return Promise.resolve(true);
return fetch(API26 + '/api/user-settings/status?user_id=' + encodeURIComponent(u))
.then(function (r) { return r.json(); }).then(function (d) {
var st = (d && (d.data || d.status)) || {};
var sub = st.subscription || st.subscriptions || [];
var active = false;
try { active = Array.isArray(sub) ? sub.some(function (x) { return x && (x.status === 'active' || (x.end && new Date(x.end) > new Date())); }) : (sub && sub.status === 'active'); } catch (e) {}
return active || (Number(st.balance_yuan || st.balance || 0) > 0);
}).catch(function () { return false; });
}
window.v26Play = function (u) {
try {
var ov = $26('v26PlayOv');
if (!ov) {
ov = document.createElement('div'); ov.id = 'v26PlayOv';
ov.style.cssText = 'position:fixed;inset:0;background:rgba(2,6,23,.86);z-index:52000;display:flex;align-items:center;justify-content:center;';
ov.onclick = function (e) { if (e.target === ov) ov.remove(); };
document.body.appendChild(ov);
}
ov.innerHTML = '';
} catch (e) { try { window.open(abs26(u), '_blank'); } catch (e2) {} }
};
window.v26Save = function (u, n) {
var url = abs26(u);
ent26().then(function (ok) {
if (!ok) { t26('下载需先订阅/充值后使用(我的 → 充值/订阅)'); return; }
var fn = String(n || 'file').replace(/[\\/:*?"<>|]/g, '_');
var vid = isVid26(url);
if (!/\.(mp4|mov|webm|png|jpe?g|gif|webp|mp3|wav)$/i.test(fn)) fn += (vid ? '.mp4' : '');
fetch(url).then(function (r) { return r.blob(); }).then(function (b) {
var a = document.createElement('a'); a.href = URL.createObjectURL(b); a.download = fn || 'file';
document.body.appendChild(a); a.click(); a.remove();
setTimeout(function () { try { URL.revokeObjectURL(a.href); } catch (e) {} }, 4000);
t26('💾 已开始下载');
}).catch(function () { t26('下载失败,请稍后重试'); });
});
};
window.v26Share = function (u, n) {
var url = abs26(u);
try { if (navigator.share) { navigator.share({ title: n || '多维鹰', text: n || '', url: url }); return; } } catch (e) {}
try { navigator.clipboard.writeText(url); t26('链接已复制,可粘贴到社群/朋友圈分享'); }
catch (e) { try { window.prompt('复制链接分享:', url); } catch (e2) {} }
};
window.v26Del = function (id) {
if (!id) { t26('该条目不支持删除'); return; }
if (!confirm('确定删除该条目?删除后不可恢复。')) return;
fetch(API26 + '/ai-army/materials/' + encodeURIComponent(id) + '?user_id=' + encodeURIComponent(uid26()), { method: 'DELETE' })
.then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (d) { t26(d && d.success ? '🗑 已删除' : ('删除失败:' + ((d && (d.detail || d.message)) || '未知'))); })
.catch(function () { t26('删除网络错误'); });
};
function ops26(it, K2, u) {
var n = it.title || it.task_name || it.name || it.filename || '成片';
var bs = 'border:none;border-radius:8px;padding:6px 12px;font-size:12px;color:#fff;cursor:pointer;';
var h = '';
if (u) {
h += '▶ 播放 ';
h += '💾 保存/下载 ';
h += '📤 分享 ';
}
var id = K2 === 2 ? (it.id || '') : (it.id || it.task_id || '');
if (id) h += '🗑 删除 ';
h += '
';
return h;
}
/* ---------- 视频管理:待发布 / 已发布(回传数据) / 视频素材 ---------- */
X.video_management = function () {
page26('📹 视频管理',
'' +
[['v26Vt0', '待发布'], ['v26Vt1', '已发布'], ['v26Vt2', '素材']].map(function (b) {
return '' + b[1] + ' ';
}).join('') + '
加载中…
');
var K = 0;
function load() {
var box = $26('v26Vb'); if (!box) return;
box.innerHTML = '加载中…';
var url = K === 0 ? '/ai-army/tasks/scheduled-list?user_id=' : K === 1 ? '/ai-army/tasks/completed-list?user_id=' : '/ai-army/materials?user_id=';
var ext = K === 2 ? '&material_type=video' : '';
fetch(API26 + url + encodeURIComponent(uid26()) + ext + '&_t=' + Date.now()).then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (d) {
var rows = K === 2 ? (d.data || d.materials || []) : (d.data || d.tasks || []);
if (!rows.length) {
box.innerHTML = K === 0 ? '待发布队列为空创作完成后选择"定时/稍后发布"会进入此队列
'
: K === 1 ? '暂无已发布视频发布后回传数据(播放/点赞)显示在此
'
: '暂无视频素材
';
return;
}
box.innerHTML = rows.map(function (it) {
var t = it.title || it.task_name || it.name || it.filename || '未命名';
var pl = it.target_platforms || it.platforms || [];
if (typeof pl === 'string') { try { pl = JSON.parse(pl); } catch (e) { pl = []; } }
var meta = [];
if (it.scheduled_time) meta.push('⏰ ' + it.scheduled_time);
if (it.views != null) meta.push('播放 ' + it.views);
if (it.likes != null) meta.push('点赞 ' + it.likes);
if (it.status) meta.push(it.status);
var u = abs26(it.video_url || it.url || it.file_path || it.material_url || it.file_url || '');
var b1 = K === 0 ? '立即发布 ' : '';
var b2 = K === 2 && u ? 'AI 二创 ' : '';
return '' +
'
' + e26(t) + '
' +
(pl.length ? '
平台:' + e26(pl.join(' / ')) + '
' : '') +
(meta.length ? '
' + e26(meta.join(' · ')) + '
' : '') +
(u && isVid26(u) ? '
' : '') +
(u ? ops26(it, K, u) : '') + b1 + b2 + '
';
}).join('');
}).catch(function () { box.innerHTML = '加载失败'; });
}
window.v26PubNow = function (id2) {
if (!id2) { t26('无任务 ID'); return; }
t26('⏳ 发布中…');
fetch(API26 + '/ai-army/tasks/' + encodeURIComponent(id2) + '/publish', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: uid26() }) })
.then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (d) { t26((d && d.success) ? '✅ 发布成功(回传数据将出现在已发布)' : '发布失败:' + ((d && d.message) || '请重试')); load(); });
};
window.v26UsePick = function (u) { pick26(u, 'video'); };
['v26Vt0', 'v26Vt1', 'v26Vt2'].forEach(function (id, i) {
var b = $26(id);
if (b) b.onclick = function () { K = i; load(); };
});
load();
};
/* ---------- 素材管理:自动分类(图片/视频/音频/文档,同一 user_id 文件体系) ---------- */
X.material_library = function () {
page26('🎬 素材管理',
'' +
[['all', '全部'], ['image', '🖼️ 图片'], ['video', '🎬 视频'], ['audio', '🎵 音频'], ['document', '📄 文档']].map(function (c) {
return '' + c[1] + ' ';
}).join('') + '
加载中…
');
var K2 = 'all';
function load() {
var box = $26('v26Mb'); if (!box) return;
box.innerHTML = '加载中…';
fetch(API26 + '/ai-army/materials?user_id=' + encodeURIComponent(uid26()) + (K2 === 'all' ? '' : '&material_type=' + K2) + '&limit=200')
.then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (d) {
var rows = (d && (d.data || d.materials || d.items)) || [];
if (!rows.length) { box.innerHTML = '暂无素材创作台与对话生成的内容会自动归档到本账号文件体系
'; return; }
box.innerHTML = rows.map(function (m) {
var u = abs26(m.url || m.file_path || m.preview || '');
var low = String(u).toLowerCase(), media = '';
if (/\.(png|jpe?g|gif|webp)$/.test(low)) media = ' ';
else if (/\.(mp4|webm|mov)$/.test(low)) media = ' ';
else if (/\.(mp3|wav|m4a|ogg)$/.test(low)) media = ' ';
var tp = m.material_type || m.type || '';
return '' +
'
' + e26(m.name || m.filename || u.split('/').pop() || '素材') + '
' +
(u ? '
AI 二创 ' : '') + '
' +
'
' + e26((tp || '') + ' · ' + (m.created_at || m.upload_time || '')) + '
' + media + (u ? ops26(m, 2, u) : '') + '
';
}).join('');
}).catch(function () { box.innerHTML = '加载失败'; });
}
Object.keys({ all: 0, image: 0, video: 0, audio: 0, document: 0 }).forEach(function (k) {
var b = $26('v26Mk_' + k);
if (b) b.onclick = function () { K2 = k; load(); };
});
load();
};
console.log('[MobV26a] 分类管理就绪(视频/素材)');
})();