@kupola/kupola 1.7.0 → 1.7.1
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/dist/kupola.cjs.js +17 -17
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.esm.js +756 -754
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.umd.js +17 -17
- package/dist/kupola.umd.js.map +1 -1
- package/js/theme.js +21 -15
- package/package.json +1 -1
package/js/theme.js
CHANGED
|
@@ -2,6 +2,7 @@ import { getIconsPath, getDefaultTheme, getDefaultBrand, setConfig } from './kup
|
|
|
2
2
|
|
|
3
3
|
const THEME_KEY = 'kupola-theme';
|
|
4
4
|
const BRAND_KEY = 'kupola-brand';
|
|
5
|
+
let _themeInitialized = false;
|
|
5
6
|
|
|
6
7
|
const BRAND_OPTIONS = [
|
|
7
8
|
{ id: 'green', name: '翠绿', color: '#32F08C' },
|
|
@@ -88,21 +89,26 @@ function updateThemeIcon(toggleBtn) {
|
|
|
88
89
|
function initTheme() {
|
|
89
90
|
|
|
90
91
|
const toggleBtn = document.querySelector('[data-theme-toggle]');
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
|
|
93
|
+
if (!_themeInitialized) {
|
|
94
|
+
_themeInitialized = true;
|
|
95
|
+
|
|
96
|
+
if (toggleBtn) {
|
|
97
|
+
const iconEl = toggleBtn.querySelector('.theme-icon');
|
|
98
|
+
if (iconEl && iconEl.src) {
|
|
99
|
+
const currentIconsPath = getIconsPath();
|
|
100
|
+
if (currentIconsPath === '/icons/') {
|
|
101
|
+
const iconPath = iconEl.src.substring(0, iconEl.src.lastIndexOf('/') + 1);
|
|
102
|
+
const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
|
|
103
|
+
const relativeIconsPath = iconPath.replace(window.location.origin + basePath, '');
|
|
104
|
+
if (relativeIconsPath !== iconPath) {
|
|
105
|
+
setConfig({
|
|
106
|
+
paths: {
|
|
107
|
+
icons: relativeIconsPath,
|
|
108
|
+
base: basePath
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
}
|
package/package.json
CHANGED