mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-11 04:22:54 +00:00
1
This commit is contained in:
parent
62f54008ce
commit
3b46c8cf07
27
packages/vite-plugin/dist/index.js
vendored
27
packages/vite-plugin/dist/index.js
vendored
@ -1815,6 +1815,23 @@ if (typeof window !== 'undefined') {
|
||||
"/": "-slash-",
|
||||
":": "-colon-",
|
||||
};
|
||||
/**
|
||||
* 特殊字符映射表(国际化)
|
||||
*/
|
||||
const SAFE_CHAR_MAP_LOCALE = {
|
||||
"[": "-bracket-start-",
|
||||
"]": "-bracket-end-",
|
||||
"(": "-paren-start-",
|
||||
")": "-paren-end-",
|
||||
"{": "-brace-start-",
|
||||
"}": "-brace-end-",
|
||||
$: "-dollar-",
|
||||
"#": "-hash-",
|
||||
"!": "-important-",
|
||||
"/": "-slash-",
|
||||
":": "-colon-",
|
||||
" ": "-space-",
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
/**
|
||||
@ -2146,9 +2163,9 @@ if (typeof window !== 'undefined') {
|
||||
if (id.includes("/cool/ctx/index.ts")) {
|
||||
const ctx = await createCtx();
|
||||
const theme = await readFile(rootDir("theme.json"), true);
|
||||
ctx["SAFE_CHAR_MAP"] = [];
|
||||
for (const i in SAFE_CHAR_MAP) {
|
||||
ctx["SAFE_CHAR_MAP"].push([i, SAFE_CHAR_MAP[i]]);
|
||||
ctx["SAFE_CHAR_MAP_LOCALE"] = [];
|
||||
for (const i in SAFE_CHAR_MAP_LOCALE) {
|
||||
ctx["SAFE_CHAR_MAP_LOCALE"].push([i, SAFE_CHAR_MAP_LOCALE[i]]);
|
||||
}
|
||||
ctx["theme"] = theme;
|
||||
code = code.replace("const ctx = {}", `const ctx = ${JSON.stringify(ctx, null, 4)}`);
|
||||
@ -2168,8 +2185,8 @@ if (typeof window !== 'undefined') {
|
||||
const d = JSON.parse(code);
|
||||
for (let i in d) {
|
||||
let k = i;
|
||||
for (let j in SAFE_CHAR_MAP) {
|
||||
k = k.replaceAll(j, SAFE_CHAR_MAP[j]);
|
||||
for (let j in SAFE_CHAR_MAP_LOCALE) {
|
||||
k = k.replaceAll(j, SAFE_CHAR_MAP_LOCALE[j]);
|
||||
}
|
||||
if (k != i) {
|
||||
d[k] = d[i];
|
||||
|
||||
@ -2,3 +2,7 @@
|
||||
* 特殊字符映射表
|
||||
*/
|
||||
export declare const SAFE_CHAR_MAP: Record<string, string>;
|
||||
/**
|
||||
* 特殊字符映射表(国际化)
|
||||
*/
|
||||
export declare const SAFE_CHAR_MAP_LOCALE: Record<string, string>;
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import type { Plugin } from "vite";
|
||||
import { SAFE_CHAR_MAP } from "./config";
|
||||
import { SAFE_CHAR_MAP_LOCALE } from "./config";
|
||||
import { createCtx } from "../ctx";
|
||||
import { readFile, rootDir } from "../utils";
|
||||
import { createEps } from "../eps";
|
||||
import { isEmpty, uniq } from "lodash";
|
||||
import { config } from "../config";
|
||||
import axios from "axios";
|
||||
import { uniq } from "lodash";
|
||||
|
||||
export function codePlugin(): Plugin[] {
|
||||
return [
|
||||
@ -17,9 +15,9 @@ export function codePlugin(): Plugin[] {
|
||||
const ctx = await createCtx();
|
||||
const theme = await readFile(rootDir("theme.json"), true);
|
||||
|
||||
ctx["SAFE_CHAR_MAP"] = [];
|
||||
for (const i in SAFE_CHAR_MAP) {
|
||||
ctx["SAFE_CHAR_MAP"].push([i, SAFE_CHAR_MAP[i]]);
|
||||
ctx["SAFE_CHAR_MAP_LOCALE"] = [];
|
||||
for (const i in SAFE_CHAR_MAP_LOCALE) {
|
||||
ctx["SAFE_CHAR_MAP_LOCALE"].push([i, SAFE_CHAR_MAP_LOCALE[i]]);
|
||||
}
|
||||
|
||||
ctx["theme"] = theme;
|
||||
@ -50,8 +48,8 @@ export function codePlugin(): Plugin[] {
|
||||
for (let i in d) {
|
||||
let k = i;
|
||||
|
||||
for (let j in SAFE_CHAR_MAP) {
|
||||
k = k.replaceAll(j, SAFE_CHAR_MAP[j]);
|
||||
for (let j in SAFE_CHAR_MAP_LOCALE) {
|
||||
k = k.replaceAll(j, SAFE_CHAR_MAP_LOCALE[j]);
|
||||
}
|
||||
|
||||
if (k != i) {
|
||||
|
||||
@ -14,3 +14,21 @@ export const SAFE_CHAR_MAP: Record<string, string> = {
|
||||
"/": "-slash-",
|
||||
":": "-colon-",
|
||||
};
|
||||
|
||||
/**
|
||||
* 特殊字符映射表(国际化)
|
||||
*/
|
||||
export const SAFE_CHAR_MAP_LOCALE: Record<string, string> = {
|
||||
"[": "-bracket-start-",
|
||||
"]": "-bracket-end-",
|
||||
"(": "-paren-start-",
|
||||
")": "-paren-end-",
|
||||
"{": "-brace-start-",
|
||||
"}": "-brace-end-",
|
||||
$: "-dollar-",
|
||||
"#": "-hash-",
|
||||
"!": "-important-",
|
||||
"/": "-slash-",
|
||||
":": "-colon-",
|
||||
" ": "-space-",
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user