mirror of https://github.com/ElemeFE/element
fix docs theme switch bug
parent
88811bd14e
commit
f073a087ce
|
@ -58,7 +58,8 @@
|
||||||
const docsHandler = getHandler(this.docs, 'docs-style');
|
const docsHandler = getHandler(this.docs, 'docs-style');
|
||||||
|
|
||||||
if (!this.chalk) {
|
if (!this.chalk) {
|
||||||
this.getCSSString(`https://unpkg.com/element-ui@${ version }/lib/theme-chalk/index.css`, chalkHandler);
|
const url = `https://unpkg.com/element-ui@${ version }/lib/theme-chalk/index.css`;
|
||||||
|
this.getCSSString(url, chalkHandler, 'chalk');
|
||||||
} else {
|
} else {
|
||||||
chalkHandler();
|
chalkHandler();
|
||||||
}
|
}
|
||||||
|
@ -67,7 +68,7 @@
|
||||||
const links = [].filter.call(document.querySelectorAll('link'), link => {
|
const links = [].filter.call(document.querySelectorAll('link'), link => {
|
||||||
return /docs\..+\.css/.test(link.href || '');
|
return /docs\..+\.css/.test(link.href || '');
|
||||||
});
|
});
|
||||||
links[0] && this.getCSSString(links[0].href, docsHandler);
|
links[0] && this.getCSSString(links[0].href, docsHandler, 'docs');
|
||||||
} else {
|
} else {
|
||||||
docsHandler();
|
docsHandler();
|
||||||
}
|
}
|
||||||
|
@ -94,11 +95,11 @@
|
||||||
return newStyle;
|
return newStyle;
|
||||||
},
|
},
|
||||||
|
|
||||||
getCSSString(url, callback) {
|
getCSSString(url, callback, variable) {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = () => {
|
xhr.onreadystatechange = () => {
|
||||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||||
this.chalk = xhr.responseText.replace(/@font-face{[^}]+}/, '');
|
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '');
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue