diff --git a/gmweb/app.js b/gmweb/app.js index f248463..64a16e7 100644 --- a/gmweb/app.js +++ b/gmweb/app.js @@ -66,6 +66,7 @@ for (var j = 0; j < panes.length; j++) { panes[j].className = 'pane' + (panes[j].id === 'pane-' + name ? ' on' : ''); } + try { if (location.hash !== '#' + name) location.hash = '#' + name; } catch (e) { } } function bindTabs() { @@ -73,6 +74,13 @@ for (var i = 0; i < tabs.length; i++) { tabs[i].onclick = function () { switchTab(this.getAttribute('data-tab')); }; } + // 支持用 #item / #char / #about / #home 直接打开某一页 + var h = (location.hash || '').replace('#', ''); + if (h && document.getElementById('pane-' + h)) switchTab(h); + window.onhashchange = function () { + var n = (location.hash || '').replace('#', ''); + if (n && document.getElementById('pane-' + n)) switchTab(n); + }; } /* ---------------------------------------------------------------- 状态页 */ @@ -419,16 +427,20 @@ function bindQr(id) { var img = $(id); if (!img) { return; } - img.onerror = function () { - var box = this.parentNode; + function showMiss() { + var box = img.parentNode; if (box) { box.className = 'qr-box miss'; } - this.style.display = 'none'; - }; - img.onload = function () { - var box = this.parentNode; + img.style.display = 'none'; + } + function showImg() { + var box = img.parentNode; if (box) { box.className = 'qr-box'; } - this.style.display = ''; - }; + img.style.display = ''; + } + img.onerror = showMiss; + img.onload = showImg; + /* 图片是 HTML 里带的 src,可能在脚本执行前就已经 404 了,onerror 来不及触发 */ + if (img.complete && img.naturalWidth === 0) { showMiss(); } } /* ---------------------------------------------------------------- 启动 */ @@ -501,6 +513,7 @@ fillTypeOptions(); bindQr('qr-alipay'); bindQr('qr-wechat'); + bindQr('qr-gzh'); renderPicked(); forceIME(); diff --git a/gmweb/index.html b/gmweb/index.html index 3f4057d..9b69f95 100644 --- a/gmweb/index.html +++ b/gmweb/index.html @@ -4,20 +4,19 @@
-
+
+
-
+