From d656cddfd3da6a902202a336795d9526339184e0 Mon Sep 17 00:00:00 2001
From: icssoa <2570063477@qq.com>
Date: Tue, 10 Jun 2025 10:41:09 +0800
Subject: [PATCH] yh
---
packages/vite-plugin/dist/index.js | 41 +++++--------------
packages/vite-plugin/src/uniapp-x/code.ts | 34 ---------------
packages/vite-plugin/src/uniapp-x/tailwind.ts | 17 ++++++--
3 files changed, 25 insertions(+), 67 deletions(-)
diff --git a/packages/vite-plugin/dist/index.js b/packages/vite-plugin/dist/index.js
index a7eda3e..586f1e7 100644
--- a/packages/vite-plugin/dist/index.js
+++ b/packages/vite-plugin/dist/index.js
@@ -1687,9 +1687,6 @@ if (typeof window !== 'undefined') {
},
// 处理声明规则
Declaration(decl) {
- // 跳过包含 no-rem 注释的声明
- if (decl.value.includes("/* no-rem */"))
- return;
// 处理 Tailwind 自定义属性
if (decl.prop.includes("--tw-")) {
colorValues[decl.prop] = decl.value.includes("rem")
@@ -1738,6 +1735,13 @@ if (typeof window !== 'undefined') {
if (hasChanges) {
decl.value = parsed.toString();
}
+ // 删除不支持的属性
+ if (["filter"].includes(decl.prop)) {
+ decl.remove();
+ return;
+ }
+ // 移除 undefined
+ decl.value = decl.value.replaceAll(" undefined", "");
},
};
},
@@ -1766,6 +1770,10 @@ if (typeof window !== 'undefined') {
// 遍历处理每个节点
nodes.forEach((node) => {
let _node = node;
+ // 兼容 标签
+ if (_node.startsWith("", "");
+ }
// 为 text 节点添加暗黑模式文本颜色
if (!_node.includes(darkTextClass) && _node.startsWith(" {
- // const { code, data } = res.data as { code: number; data: any[] };
- // if (code === 1000) {
- // if (!isEmpty(data)) {
- // DictKey = data.map((e) => `"${e.key}"`).join(" | ");
- // DictData = data.map((e) => `${e.key}: UTSJSONObject[];`).join("\n");
- // }
- // }
- // });
- // code = code.replace(
- // "export type DictKey = string;",
- // `export type DictKey = ${DictKey};`,
- // );
- // code = code.replace(
- // "export type DictData = {};",
- // `export type DictData = {${DictData}};`,
- // );
- // code = code.replace(
- // "const data = {} as DictData;",
- // `const data = {} as {${DictDataCode}};`,
- // );
- // }
if (id.endsWith(".json")) {
const d = JSON.parse(code);
for (let i in d) {
diff --git a/packages/vite-plugin/src/uniapp-x/code.ts b/packages/vite-plugin/src/uniapp-x/code.ts
index dd6ee0f..f54f6c6 100644
--- a/packages/vite-plugin/src/uniapp-x/code.ts
+++ b/packages/vite-plugin/src/uniapp-x/code.ts
@@ -44,40 +44,6 @@ export function codePlugin(): Plugin[] {
}
}
- // if (id.includes("/cool/hooks/dict.ts")) {
- // const url = config.reqUrl + "/app/dict/info/types";
-
- // let DictKey = "string";
- // let DictData = "UTSJSONObject";
- // let DictDataCode = "{}";
-
- // await axios.get(url).then((res) => {
- // const { code, data } = res.data as { code: number; data: any[] };
-
- // if (code === 1000) {
- // if (!isEmpty(data)) {
- // DictKey = data.map((e) => `"${e.key}"`).join(" | ");
- // DictData = data.map((e) => `${e.key}: UTSJSONObject[];`).join("\n");
- // }
- // }
- // });
-
- // code = code.replace(
- // "export type DictKey = string;",
- // `export type DictKey = ${DictKey};`,
- // );
-
- // code = code.replace(
- // "export type DictData = {};",
- // `export type DictData = {${DictData}};`,
- // );
-
- // code = code.replace(
- // "const data = {} as DictData;",
- // `const data = {} as {${DictDataCode}};`,
- // );
- // }
-
if (id.endsWith(".json")) {
const d = JSON.parse(code);
diff --git a/packages/vite-plugin/src/uniapp-x/tailwind.ts b/packages/vite-plugin/src/uniapp-x/tailwind.ts
index e7567c0..d608bba 100644
--- a/packages/vite-plugin/src/uniapp-x/tailwind.ts
+++ b/packages/vite-plugin/src/uniapp-x/tailwind.ts
@@ -129,9 +129,6 @@ function postcssPlugin(): Plugin {
// 处理声明规则
Declaration(decl: any) {
- // 跳过包含 no-rem 注释的声明
- if (decl.value.includes("/* no-rem */")) return;
-
// 处理 Tailwind 自定义属性
if (decl.prop.includes("--tw-")) {
colorValues[decl.prop] = decl.value.includes("rem")
@@ -193,6 +190,15 @@ function postcssPlugin(): Plugin {
if (hasChanges) {
decl.value = parsed.toString();
}
+
+ // 删除不支持的属性
+ if (["filter"].includes(decl.prop)) {
+ decl.remove();
+ return;
+ }
+
+ // 移除 undefined
+ decl.value = decl.value.replaceAll(" undefined", "");
},
};
},
@@ -227,6 +233,11 @@ function transformPlugin(): Plugin {
nodes.forEach((node) => {
let _node = node;
+ // 兼容 标签
+ if (_node.startsWith("", "");
+ }
+
// 为 text 节点添加暗黑模式文本颜色
if (!_node.includes(darkTextClass) && _node.startsWith("