mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2026-01-08 11:21:56 +00:00
uniappx 添加编译平台判断
This commit is contained in:
parent
01a0917555
commit
a2d4ee9bbf
1
packages/vite-plugin/dist/config.d.ts
vendored
1
packages/vite-plugin/dist/config.d.ts
vendored
@ -35,4 +35,5 @@ export declare const config: {
|
||||
isPlugin: boolean;
|
||||
};
|
||||
clean: boolean;
|
||||
utsPlatform: string;
|
||||
};
|
||||
|
||||
10
packages/vite-plugin/dist/index.js
vendored
10
packages/vite-plugin/dist/index.js
vendored
@ -60,6 +60,7 @@
|
||||
isPlugin: false,
|
||||
},
|
||||
clean: false,
|
||||
utsPlatform: "web",
|
||||
};
|
||||
|
||||
// 根目录
|
||||
@ -1942,6 +1943,9 @@ if (typeof window !== 'undefined') {
|
||||
* 转换类名中的特殊字符为安全字符
|
||||
*/
|
||||
function toSafeClass(className) {
|
||||
if (config.utsPlatform == "web") {
|
||||
return className;
|
||||
}
|
||||
if (className.includes(":host")) {
|
||||
return className;
|
||||
}
|
||||
@ -2022,7 +2026,7 @@ if (typeof window !== 'undefined') {
|
||||
return;
|
||||
}
|
||||
// 转换选择器为安全的类名格式
|
||||
rule.selector = toSafeClass(rule.selector.replace(/\\/g, ""));
|
||||
rule.selector = toSafeClass(rule.selector);
|
||||
},
|
||||
// 处理声明规则
|
||||
Declaration(decl) {
|
||||
@ -2209,7 +2213,7 @@ if (typeof window !== 'undefined') {
|
||||
_node.slice(0, insertIndex) + ` :class="{}"` + _node.slice(insertIndex);
|
||||
}
|
||||
// 获取暗黑模式类名
|
||||
let darkClassNames = classNames.filter((name) => name.startsWith("dark-colon-"));
|
||||
let darkClassNames = classNames.filter((name) => name.startsWith("dark-colon-") || name.startsWith("dark:"));
|
||||
// 插件模式,不支持 dark:
|
||||
if (config.uniapp.isPlugin) {
|
||||
darkClassNames = [];
|
||||
@ -2448,6 +2452,8 @@ if (typeof window !== 'undefined') {
|
||||
// 请求地址
|
||||
config.reqUrl = getProxyTarget(options.proxy);
|
||||
if (config.type == "uniapp-x") {
|
||||
// 编译平台
|
||||
config.utsPlatform = process.env.UNI_UTS_PLATFORM ?? "web";
|
||||
// 是否纯净版
|
||||
config.clean = options.clean ?? true;
|
||||
if (config.clean) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-vue/vite-plugin",
|
||||
"version": "8.2.19",
|
||||
"version": "8.2.20",
|
||||
"description": "cool-admin、cool-uni builder",
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "/dist/index.js",
|
||||
|
||||
@ -57,4 +57,5 @@ export const config = {
|
||||
isPlugin: false,
|
||||
},
|
||||
clean: false,
|
||||
utsPlatform: "web",
|
||||
};
|
||||
|
||||
@ -15,6 +15,9 @@ export function cool(options: Config.Options) {
|
||||
config.reqUrl = getProxyTarget(options.proxy);
|
||||
|
||||
if (config.type == "uniapp-x") {
|
||||
// 编译平台
|
||||
config.utsPlatform = process.env.UNI_UTS_PLATFORM ?? "web";
|
||||
|
||||
// 是否纯净版
|
||||
config.clean = options.clean ?? true;
|
||||
|
||||
|
||||
@ -15,6 +15,10 @@ import {
|
||||
* 转换类名中的特殊字符为安全字符
|
||||
*/
|
||||
export function toSafeClass(className: string): string {
|
||||
if (config.utsPlatform == "web") {
|
||||
return className;
|
||||
}
|
||||
|
||||
if (className.includes(":host")) {
|
||||
return className;
|
||||
}
|
||||
@ -110,9 +114,7 @@ function postcssPlugin(): Plugin {
|
||||
}
|
||||
|
||||
// 转换选择器为安全的类名格式
|
||||
rule.selector = toSafeClass(
|
||||
rule.selector.replace(/\\/g, ""),
|
||||
);
|
||||
rule.selector = toSafeClass(rule.selector);
|
||||
},
|
||||
|
||||
// 处理声明规则
|
||||
@ -343,8 +345,8 @@ function transformPlugin(): Plugin {
|
||||
}
|
||||
|
||||
// 获取暗黑模式类名
|
||||
let darkClassNames = classNames.filter((name) =>
|
||||
name.startsWith("dark-colon-"),
|
||||
let darkClassNames = classNames.filter(
|
||||
(name) => name.startsWith("dark-colon-") || name.startsWith("dark:"),
|
||||
);
|
||||
|
||||
// 插件模式,不支持 dark:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user