@iasiv5/dsh-skins 1.5.23 → 1.5.24

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.
Files changed (2) hide show
  1. package/lib/client.js +15 -15
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -653,22 +653,22 @@ ${darkSelector}{${dark.join(";")}}`;
653
653
  return () => {
654
654
  };
655
655
  }
656
+ const SWEEP_SELECTOR = 'style[data-plugin-css^="dsh-skins/"]:not([data-plugin-css="dsh-skins/sidebar.css"])';
657
+ function flushStylesForSweep() {
658
+ try {
659
+ void document.body?.offsetHeight;
660
+ } catch {
661
+ }
662
+ }
656
663
  function refreshSkinStyleTags() {
657
- if (typeof requestAnimationFrame !== "function" || typeof document === "undefined" || document.head?.querySelectorAll === void 0) return;
658
- const tags = [...document.head.querySelectorAll('style[data-plugin-css^="dsh-skins/"]')];
664
+ if (typeof document === "undefined" || document.head?.querySelectorAll === void 0) return;
665
+ const tags = [...document.head.querySelectorAll(SWEEP_SELECTOR)];
659
666
  if (tags.length === 0) return;
660
- const saved = tags.map((tag) => ({ id: tag.dataset.pluginCss, content: tag.textContent }));
661
- for (const tag of tags) tag.remove();
662
- requestAnimationFrame(() => requestAnimationFrame(() => {
663
- for (const { id, content } of saved) {
664
- if (document.querySelector(`style[data-plugin-css="${id}"]`) !== null) continue;
665
- const fresh = document.createElement("style");
666
- fresh.dataset.plugin = "dsh-skins";
667
- fresh.dataset.pluginCss = id;
668
- fresh.textContent = content;
669
- document.head.append(fresh);
670
- }
671
- }));
667
+ const saved = tags.map((tag) => ({ tag, content: tag.textContent }));
668
+ for (const { tag } of saved) tag.textContent = "";
669
+ flushStylesForSweep();
670
+ for (const { tag, content } of saved) tag.textContent = content;
671
+ flushStylesForSweep();
672
672
  }
673
673
  let rightPanelRepaintHookInstalled = false;
674
674
  function installRightPanelRepaintHook() {
@@ -877,7 +877,7 @@ ${darkSelector}{${dark.join(";")}}`;
877
877
  selectedId = skin.id;
878
878
  announce(skin.id);
879
879
  installRightPanelRepaintHook();
880
- if (previous !== null) refreshSkinStyleTags();
880
+ if (previous !== null && previous.skin.id !== skin.id) refreshSkinStyleTags();
881
881
  return true;
882
882
  }
883
883
  function restorePrevious(previous, cause) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@iasiv5/dsh-skins",
3
3
  "description": "DSH Web 皮肤插件:多套品牌皮肤侧栏热切换。",
4
4
  "icon": "./icon.svg",
5
- "version": "1.5.23",
5
+ "version": "1.5.24",
6
6
  "homepage": "https://github.com/iasiv5/dsh-skins#readme",
7
7
  "repository": {
8
8
  "type": "git",