fix(frontend): keep asset and homepage filters in DOM
This commit is contained in:
1 parent
a0adddce59
commit
7308f055c7
23 files changed
+362
-305
No files matched your search
@@ -42,8 +42,10 @@
|
||||
|
||||
/* ==================== Dashboard 导航 ==================== */
|
||||
function initDashboardNavigation() {
|
||||
if (document.documentElement.dataset.aksrtUserCenterNavigationInitialized === 'true') return;
|
||||
var tabContainer = document.querySelector('.uc-mobile-tabs');
|
||||
if (!tabContainer) return;
|
||||
document.documentElement.dataset.aksrtUserCenterNavigationInitialized = 'true';
|
||||
|
||||
var tabs = tabContainer.querySelectorAll('[data-tab]');
|
||||
var sidebarBtns = document.querySelectorAll('.uc-sidebar [data-tab]');
|
||||
@@ -107,6 +109,7 @@
|
||||
if (name === 'revenue') allowedParams = ['reward_tab', 'commission_page', 'user_page'];
|
||||
if (name === 'posts') allowedParams = ['post_status', 'posts_page'];
|
||||
if (name === 'follow') allowedParams = ['follow_list', 'follow_page'];
|
||||
if (name === 'credits') allowedParams = ['asset', 'page'];
|
||||
allowedParams.forEach(function(key) {
|
||||
if (params.get(key)) url += (url.indexOf('?') === -1 ? '?' : '&') + key + '=' + encodeURIComponent(params.get(key));
|
||||
});
|
||||
@@ -166,8 +169,6 @@
|
||||
|
||||
function activate(name, updateHistory, forceLoad, queryParams) {
|
||||
if (!panels[name]) name = defaultTab;
|
||||
// VIP membership may change outside this page, so never reuse stale HTML.
|
||||
if (name === 'vip' && !forceLoad) forceLoad = true;
|
||||
return loadPanel(name, forceLoad, queryParams).then(function() {
|
||||
switchTo(name);
|
||||
if (updateHistory) updateUrl(name);
|
||||
@@ -187,11 +188,11 @@
|
||||
return tabAliases[name] || name;
|
||||
}
|
||||
|
||||
function updateUrl(name, sourceUrl) {
|
||||
if (!window.history.replaceState) return;
|
||||
function updateUrl(name, sourceUrl) {
|
||||
if (!window.history.pushState) return;
|
||||
var pathTab = name === 'credits' ? 'balance' : name;
|
||||
var u = new URL('/user/' + pathTab + '/', window.location.origin);
|
||||
if (sourceUrl && name !== 'revenue' && name !== 'orders') {
|
||||
if (sourceUrl && name !== 'revenue' && name !== 'orders' && name !== 'credits') {
|
||||
var source = new URL(sourceUrl, window.location.href);
|
||||
source.searchParams.forEach(function(value, key) { u.searchParams.set(key, value); });
|
||||
}
|
||||
@@ -249,8 +250,8 @@
|
||||
name = tabAliases[name] || name;
|
||||
if (!name || !panels[name]) return;
|
||||
e.preventDefault();
|
||||
var hasQuery = url.search !== '';
|
||||
activate(name, false, hasQuery, url.searchParams).then(function() { updateUrl(name, url.href); });
|
||||
var hasQuery = url.search !== '' && name !== 'credits';
|
||||
activate(name, false, hasQuery, name === 'credits' ? null : url.searchParams).then(function() { updateUrl(name, name === 'credits' ? '' : url.href); });
|
||||
}, true);
|
||||
var creatorPanel = panels.creator ? panels.creator.panel : null;
|
||||
if (creatorPanel) {
|
||||
@@ -269,11 +270,21 @@
|
||||
});
|
||||
}
|
||||
window.addEventListener('popstate', function() {
|
||||
activate(tabFromUrl(), false, window.location.search !== '', new URLSearchParams(window.location.search));
|
||||
var current = new URL(window.location.href);
|
||||
['wallet_page', 'credits_page', 'asset', 'page'].forEach(function (key) { current.searchParams.delete(key); });
|
||||
if (current.href !== window.location.href && window.history.replaceState) {
|
||||
window.history.replaceState({}, '', current.pathname + current.search + current.hash);
|
||||
}
|
||||
activate(tabFromUrl(), false, false, null);
|
||||
});
|
||||
if (drawerTrigger) drawerTrigger.addEventListener('click', openDrawer);
|
||||
if (drawerOverlay) drawerOverlay.addEventListener('click', closeDrawer);
|
||||
var initialTab = tabFromUrl();
|
||||
if (initialTab === 'credits' && window.history && window.history.replaceState) {
|
||||
var cleanUrl = new URL(window.location.href);
|
||||
['wallet_page', 'credits_page', 'asset', 'page'].forEach(function (key) { cleanUrl.searchParams.delete(key); });
|
||||
window.history.replaceState({}, '', cleanUrl.pathname + cleanUrl.search + cleanUrl.hash);
|
||||
}
|
||||
if (initialTab === 'orders' && window.location.search && window.history.replaceState) {
|
||||
window.history.replaceState({}, '', window.location.pathname + window.location.hash);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user