zsbqb-static 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # zsbqb-static
2
-
3
- baoqibiao.net 的公共静态资源包。页面按精确版本引用,不要用 `latest`。
4
- 国内优先 `https://registry.npmmirror.com/zsbqb-static/<version>/files/`。
1
+ # zsbqb-static
2
+
3
+ baoqibiao.net 的公共静态资源包(不含歌单 JSON)。页面按精确版本引用,不要用 `latest`。
4
+ 歌单见独立包 `zsbqb-catalog`。
@@ -1,45 +1,45 @@
1
- /**
2
- * 游客静态页与已登录动态页共用同一 URL。
3
- * 浏览器 HTTP 缓存 / bfcache 可能在登录后仍展示登录前的游客壳(或退出后仍展示用户壳)。
4
- * sessionid 为 HttpOnly,不可读;用非敏感 cookie zsbqb_auth 与 data-auth-shell 比对。
5
- * 不一致时强制重新拉取文档(每路径只重试一次,避免死循环)。
6
- */
7
- (function () {
8
- var AUTH_MARKER = "zsbqb_auth";
9
-
10
- function hasAuthMarker() {
11
- return document.cookie.split(";").some(function (part) {
12
- return part.trim().indexOf(AUTH_MARKER + "=") === 0;
13
- });
14
- }
15
-
16
- function shellMismatch() {
17
- var shell = document.documentElement.getAttribute("data-auth-shell");
18
- if (shell === "guest" && hasAuthMarker()) return true;
19
- if (shell === "user" && !hasAuthMarker()) return true;
20
- return false;
21
- }
22
-
23
- function syncAuthShell() {
24
- if (!shellMismatch()) return;
25
- var key = "auth-shell-reload:" + location.pathname;
26
- try {
27
- if (sessionStorage.getItem(key)) {
28
- sessionStorage.removeItem(key);
29
- return;
30
- }
31
- sessionStorage.setItem(key, "1");
32
- } catch (err) {
33
- /* private mode 等:仍尝试一次 reload */
34
- }
35
- location.reload();
36
- }
37
-
38
- window.addEventListener("pageshow", function (event) {
39
- if (event.persisted || shellMismatch()) {
40
- syncAuthShell();
41
- }
42
- });
43
-
44
- syncAuthShell();
45
- })();
1
+ /**
2
+ * 游客静态页与已登录动态页共用同一 URL。
3
+ * 浏览器 HTTP 缓存 / bfcache 可能在登录后仍展示登录前的游客壳(或退出后仍展示用户壳)。
4
+ * sessionid 为 HttpOnly,不可读;用非敏感 cookie zsbqb_auth 与 data-auth-shell 比对。
5
+ * 不一致时强制重新拉取文档(每路径只重试一次,避免死循环)。
6
+ */
7
+ (function () {
8
+ var AUTH_MARKER = "zsbqb_auth";
9
+
10
+ function hasAuthMarker() {
11
+ return document.cookie.split(";").some(function (part) {
12
+ return part.trim().indexOf(AUTH_MARKER + "=") === 0;
13
+ });
14
+ }
15
+
16
+ function shellMismatch() {
17
+ var shell = document.documentElement.getAttribute("data-auth-shell");
18
+ if (shell === "guest" && hasAuthMarker()) return true;
19
+ if (shell === "user" && !hasAuthMarker()) return true;
20
+ return false;
21
+ }
22
+
23
+ function syncAuthShell() {
24
+ if (!shellMismatch()) return;
25
+ var key = "auth-shell-reload:" + location.pathname;
26
+ try {
27
+ if (sessionStorage.getItem(key)) {
28
+ sessionStorage.removeItem(key);
29
+ return;
30
+ }
31
+ sessionStorage.setItem(key, "1");
32
+ } catch (err) {
33
+ /* private mode 等:仍尝试一次 reload */
34
+ }
35
+ location.reload();
36
+ }
37
+
38
+ window.addEventListener("pageshow", function (event) {
39
+ if (event.persisted || shellMismatch()) {
40
+ syncAuthShell();
41
+ }
42
+ });
43
+
44
+ syncAuthShell();
45
+ })();