@kupola/kupola 1.6.9 → 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 +777 -775
- 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/kupola-config.js +0 -12
- package/js/theme.js +21 -12
- package/package.json +1 -1
package/js/kupola-config.js
CHANGED
|
@@ -95,18 +95,6 @@ const config = {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
export function setConfig(options) {
|
|
98
|
-
if (options && typeof options === 'object') {
|
|
99
|
-
if (options.iconsPath) {
|
|
100
|
-
options.paths = options.paths || {};
|
|
101
|
-
options.paths.icons = options.iconsPath;
|
|
102
|
-
delete options.iconsPath;
|
|
103
|
-
}
|
|
104
|
-
if (options.basePath) {
|
|
105
|
-
options.paths = options.paths || {};
|
|
106
|
-
options.paths.base = options.basePath;
|
|
107
|
-
delete options.basePath;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
98
|
mergeDeep(config, options);
|
|
111
99
|
}
|
|
112
100
|
|
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,19 +89,27 @@ function updateThemeIcon(toggleBtn) {
|
|
|
88
89
|
function initTheme() {
|
|
89
90
|
|
|
90
91
|
const toggleBtn = document.querySelector('[data-theme-toggle]');
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
});
|
|
102
111
|
}
|
|
103
|
-
}
|
|
112
|
+
}
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
}
|
package/package.json
CHANGED