This commit is contained in:
icssoa 2025-09-19 14:29:42 +08:00
parent 5535535439
commit 3cf7ee003e
3 changed files with 10 additions and 12 deletions

View File

@ -2148,10 +2148,6 @@ if (typeof window !== 'undefined') {
return;
}
let _node = node;
// 兼容 <input /> 标签
if (_node.startsWith("<input")) {
_node = _node.replace("/>", "</input>");
}
// uniappx 插件模式
if (!config.uniapp.isPlugin) {
// 为 text 节点添加暗黑模式文本颜色
@ -2192,7 +2188,10 @@ if (typeof window !== 'undefined') {
const hasDynamicClass = _node.includes(":class=");
// 如果没有动态类名,添加空的动态类名绑定
if (!hasDynamicClass) {
_node = _node.slice(0, -1) + ` :class="{}"` + ">";
// 优化写法,避免重复字符串拼接
const insertIndex = _node.length - (_node.endsWith("/>") ? 2 : 1);
_node =
_node.slice(0, insertIndex) + ` :class="{}"` + _node.slice(insertIndex);
}
// 获取暗黑模式类名
let darkClassNames = classNames.filter((name) => name.startsWith("dark-colon-"));

View File

@ -1,6 +1,6 @@
{
"name": "@cool-vue/vite-plugin",
"version": "8.2.12",
"version": "8.2.13",
"description": "cool-admin、cool-uni builder",
"types": "./dist/index.d.ts",
"main": "/dist/index.js",

View File

@ -282,11 +282,6 @@ function transformPlugin(): Plugin {
let _node = node;
// 兼容 <input /> 标签
if (_node.startsWith("<input")) {
_node = _node.replace("/>", "</input>");
}
// uniappx 插件模式
if (!config.uniapp.isPlugin) {
// 为 text 节点添加暗黑模式文本颜色
@ -332,7 +327,11 @@ function transformPlugin(): Plugin {
// 如果没有动态类名,添加空的动态类名绑定
if (!hasDynamicClass) {
_node = _node.slice(0, -1) + ` :class="{}"` + ">";
// 优化写法,避免重复字符串拼接
const insertIndex = _node.length - (_node.endsWith("/>") ? 2 : 1);
_node =
_node.slice(0, insertIndex) + ` :class="{}"` + _node.slice(insertIndex);
}
// 获取暗黑模式类名