mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 23:47:17 +08:00
perf: 同步完整版分支代码
This commit is contained in:
parent
6b96aca136
commit
c4de900bc0
@ -9,20 +9,24 @@ import { iconComponents } from "/@/plugins/element-plus";
|
|||||||
* @returns component
|
* @returns component
|
||||||
*/
|
*/
|
||||||
export function findIconReg(icon: string) {
|
export function findIconReg(icon: string) {
|
||||||
// fontawesome
|
// fontawesome4
|
||||||
const faReg = /^FA-/;
|
const fa4Reg = /^fa-/;
|
||||||
|
// fontawesome5+
|
||||||
|
const fa5Reg = /^FA-/;
|
||||||
// iconfont
|
// iconfont
|
||||||
const iFReg = /^IF-/;
|
const iFReg = /^IF-/;
|
||||||
// remixicon
|
// remixicon
|
||||||
const riReg = /^RI-/;
|
const riReg = /^RI-/;
|
||||||
// typeof icon === "function" 属于SVG
|
// typeof icon === "function" 属于SVG
|
||||||
if (faReg.test(icon)) {
|
if (fa5Reg.test(icon)) {
|
||||||
const text = icon.split(faReg)[1];
|
const text = icon.split(fa5Reg)[1];
|
||||||
return findIcon(
|
return findIcon(
|
||||||
text.slice(0, text.indexOf(" ")),
|
text.slice(0, text.indexOf(" ") == -1 ? text.length : text.indexOf(" ")),
|
||||||
"FA",
|
"FA",
|
||||||
text.slice(text.indexOf(" ") + 1, text.length)
|
text.slice(text.indexOf(" ") + 1, text.length)
|
||||||
);
|
);
|
||||||
|
} else if (fa4Reg.test(icon)) {
|
||||||
|
return findIcon(icon.split(fa4Reg)[1], "fa");
|
||||||
} else if (iFReg.test(icon)) {
|
} else if (iFReg.test(icon)) {
|
||||||
return findIcon(icon.split(iFReg)[1], "IF");
|
return findIcon(icon.split(iFReg)[1], "IF");
|
||||||
} else if (typeof icon === "function") {
|
} else if (typeof icon === "function") {
|
||||||
@ -45,6 +49,14 @@ export function findIcon(icon: String, type = "EL", property?: string) {
|
|||||||
components: { FontAwesomeIcon },
|
components: { FontAwesomeIcon },
|
||||||
template: `<font-awesome-icon :icon="icon" v-bind:[property]="true" />`
|
template: `<font-awesome-icon :icon="icon" v-bind:[property]="true" />`
|
||||||
});
|
});
|
||||||
|
} else if (type === "fa") {
|
||||||
|
return defineComponent({
|
||||||
|
name: "faIcon",
|
||||||
|
data() {
|
||||||
|
return { icon: `fa ${icon}` };
|
||||||
|
},
|
||||||
|
template: `<i :class="icon" />`
|
||||||
|
});
|
||||||
} else if (type === "IF") {
|
} else if (type === "IF") {
|
||||||
return defineComponent({
|
return defineComponent({
|
||||||
name: "IfIcon",
|
name: "IfIcon",
|
||||||
|
@ -24,7 +24,7 @@ import { useAppStoreHook } from "/@/store/modules/app";
|
|||||||
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
||||||
import { storageLocal, storageSession } from "/@/utils/storage";
|
import { storageLocal, storageSession } from "/@/utils/storage";
|
||||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
||||||
import { createNewStyle, writeNewStyle } from "/@/utils/theme";
|
import { createNewStyle, writeNewStyle } from "../../theme/element-plus";
|
||||||
import { toggleTheme } from "@zougt/vite-plugin-theme-preprocessor/dist/browser-utils";
|
import { toggleTheme } from "@zougt/vite-plugin-theme-preprocessor/dist/browser-utils";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* 动态改变element-plus主题色 */
|
||||||
import rgbHex from "rgb-hex";
|
import rgbHex from "rgb-hex";
|
||||||
import color from "css-color-function";
|
import color from "css-color-function";
|
||||||
import epCss from "element-plus/dist/index.css";
|
import epCss from "element-plus/dist/index.css";
|
||||||
@ -15,13 +16,13 @@ const formula = {
|
|||||||
"light-9": "color(primary tint(90%))"
|
"light-9": "color(primary tint(90%))"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const writeNewStyle = newStyle => {
|
export const writeNewStyle = (newStyle: string): void => {
|
||||||
const style = window.document.createElement("style");
|
const style = window.document.createElement("style");
|
||||||
style.innerText = newStyle;
|
style.innerText = newStyle;
|
||||||
window.document.head.appendChild(style);
|
window.document.head.appendChild(style);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createNewStyle = primaryStyle => {
|
export const createNewStyle = (primaryStyle: string): string => {
|
||||||
const colors = createColors(primaryStyle);
|
const colors = createColors(primaryStyle);
|
||||||
let cssText = getOriginStyle();
|
let cssText = getOriginStyle();
|
||||||
Object.keys(colors).forEach(key => {
|
Object.keys(colors).forEach(key => {
|
||||||
@ -33,7 +34,7 @@ export const createNewStyle = primaryStyle => {
|
|||||||
return cssText;
|
return cssText;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createColors = primary => {
|
export const createColors = (primary: string) => {
|
||||||
if (!primary) return;
|
if (!primary) return;
|
||||||
const colors = {
|
const colors = {
|
||||||
primary
|
primary
|
||||||
@ -49,7 +50,7 @@ export const getOriginStyle = () => {
|
|||||||
return getStyleTemplate(epCss);
|
return getStyleTemplate(epCss);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStyleTemplate = data => {
|
const getStyleTemplate = (data: string): string => {
|
||||||
const colorMap = {
|
const colorMap = {
|
||||||
"#3a8ee6": "shade-1",
|
"#3a8ee6": "shade-1",
|
||||||
"#409eff": "primary",
|
"#409eff": "primary",
|
Loading…
x
Reference in New Issue
Block a user