R42: 账号详情 tab/翻页 replaceState 同步 hash(从视频详情返回精确恢复离开前视图,视频列表翻页位置也保留;data-pages.js ad→ae)
This commit is contained in:
1 parent
8a1f379c7d
commit
878d479fa4
3 files changed
+26
-3
No files matched your search
@@ -915,9 +915,17 @@ function updateFollowedAccounts(btn) {
|
||||
async function renderAccountDetail(view, id) {
|
||||
const accountId = Number(id);
|
||||
let page = 1, tab = 'info';
|
||||
// hash 第三段支持直达指定 tab:#/account/1629/persona → 视频列表(含趋势图)
|
||||
// hash 第三段支持直达指定 tab:#/account/1629/persona → 视频列表(含趋势图);第四段=视频列表翻页页码
|
||||
const seg = (location.hash || '').replace(/^#\/?/, '').split('/');
|
||||
if (seg.length >= 3 && ['info', 'persona', 'analysis'].includes(seg[2])) tab = seg[2];
|
||||
if (seg.length >= 4 && tab === 'persona') { const p = Number(seg[3]); if (p >= 1) page = p; }
|
||||
// 当前 tab/翻页 replaceState 同步进 hash(不进历史记录):从视频详情等页面返回时能恢复离开前的视图
|
||||
function syncHash() {
|
||||
let h = '#/account/' + accountId;
|
||||
if (tab !== 'info') h += '/' + tab;
|
||||
if (tab === 'persona' && page > 1) h += '/' + page;
|
||||
if (h !== location.hash) history.replaceState(null, '', h);
|
||||
}
|
||||
const bstate = { batch: false };
|
||||
const d = await api('/api/dsh/account-videos?accountId=' + accountId + '&page=1&pageSize=20').catch((e) => ({ ok: false, error: e.message }));
|
||||
if (!d.ok) { view.innerHTML = `<div class="page"><div class="page-toolbar">${toolbarBack()}</div><div class="empty">${esc(d.error || '账号不存在')}</div></div>`; bindBack(view); return; }
|
||||
@@ -1029,9 +1037,10 @@ async function renderAccountDetail(view, id) {
|
||||
view.querySelectorAll('[data-tab]').forEach((b) => b.addEventListener('click', async () => {
|
||||
tab = b.dataset.tab;
|
||||
if (tab === 'analysis' && analysis === null) await loadAnalysis();
|
||||
syncHash();
|
||||
load(); // info tab 的账号设定加载已在 load() 内处理
|
||||
}));
|
||||
bindPager(view, (p) => { page = p; load(); });
|
||||
bindPager(view, (p) => { page = p; syncHash(); load(); });
|
||||
bindBatchBar(view, {
|
||||
state: bstate, kind: 'videos',
|
||||
getSelected: () => [...view.querySelectorAll('.batch-cb:checked')].map((c) => Number(c.dataset.id)),
|
||||
|
||||
@@ -42,6 +42,6 @@
|
||||
</div>
|
||||
|
||||
<script src="app.js?v=20260903y"></script>
|
||||
<script src="data-pages.js?v=20260903ad"></script>
|
||||
<script src="data-pages.js?v=20260903ae"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user