This commit is contained in:
icssoa 2025-06-09 19:50:49 +08:00
parent da26abc4d7
commit aaf31e916a
5 changed files with 55 additions and 28 deletions

View File

@ -632,6 +632,12 @@ declare namespace ClForm {
changeTab(value: any, valid?: boolean): Promise<any>;
setTitle(value: string): void;
submit(cb?: (data: obj) => void): void;
Tabs: {
active: RefData<string>;
list: ClFormTabs.labels;
change(value: any, valid?: boolean): Promise<any>;
[key: string]: any;
};
[key: string]: any;
}

View File

@ -1,4 +1,4 @@
import { defineComponent, h, nextTick, } from "vue";
import { defineComponent, h, nextTick } from "vue";
import { assign, cloneDeep, isBoolean, isFunction, keys } from "lodash-es";
import { useAction, useForm, usePlugins, useTabs } from "./helper";
import { useBrowser, useConfig, useElApi, useRefs } from "../../hooks";
@ -16,7 +16,7 @@ export default defineComponent({
enablePlugin: {
type: Boolean,
default: true
},
}
},
setup(props, { expose, slots }) {
@ -39,7 +39,14 @@ export default defineComponent({
// 方法
const ElFormApi = useElApi(
["validate", "validateField", "resetFields", "scrollToField", "clearValidate", "fields"],
[
"validate",
"validateField",
"resetFields",
"scrollToField",
"clearValidate",
"fields"
],
Form
);
@ -291,7 +298,7 @@ export default defineComponent({
if (e.required) {
e.rules = {
required: true,
message: dict.label.nonEmpty.replace('{label}', e.label || '')
message: dict.label.nonEmpty.replace("{label}", e.label || "")
};
}
}
@ -635,9 +642,7 @@ export default defineComponent({
Tabs,
...Action,
...ElFormApi
}
// console.log(ctx)
};
expose(ctx);

View File

@ -307,16 +307,18 @@
*/
function getNodes(code) {
const nodes = [];
const templateMatch = /<template>([\s\S]*?)<\/template>/g.exec(code);
if (!templateMatch) {
return nodes;
}
const templateContent = templateMatch[1];
const regex = /<([^>]+)>/g;
let match;
while ((match = regex.exec(templateContent)) !== null) {
if (!match[1].startsWith("/")) {
nodes.push(match[1]);
const templateRegex = /<template[^>]*>([\s\S]*?)<\/template>/g;
let templateMatch;
// 找到所有的 template 标签内容
while ((templateMatch = templateRegex.exec(code)) !== null) {
const templateContent = templateMatch[1];
const regex = /<([^>]+)>/g;
let match;
// 提取每个 template 中的所有标签
while ((match = regex.exec(templateContent)) !== null) {
if (!match[1].startsWith("/")) {
nodes.push(match[1]);
}
}
}
return nodes.map((e) => `<${e}>`);
@ -1676,6 +1678,10 @@ if (typeof window !== 'undefined') {
return {
// 处理选择器规则
Rule(rule) {
if (rule.selector.includes("uni-") ||
[".button-hover"].some((e) => rule.selector.includes(e))) {
return;
}
// 转换选择器为安全的类名格式
rule.selector = toSafeClass(rule.selector.replace(/\\/g, ""));
},

View File

@ -112,6 +112,15 @@ function postcssPlugin(): Plugin {
return {
// 处理选择器规则
Rule(rule: any) {
if (
rule.selector.includes("uni-") ||
[".button-hover"].some((e) =>
rule.selector.includes(e),
)
) {
return;
}
// 转换选择器为安全的类名格式
rule.selector = toSafeClass(
rule.selector.replace(/\\/g, ""),

View File

@ -98,19 +98,20 @@ export function getClassContent(html: string) {
*/
export function getNodes(code: string) {
const nodes: string[] = [];
const templateMatch = /<template>([\s\S]*?)<\/template>/g.exec(code);
const templateRegex = /<template[^>]*>([\s\S]*?)<\/template>/g;
let templateMatch;
if (!templateMatch) {
return nodes;
}
// 找到所有的 template 标签内容
while ((templateMatch = templateRegex.exec(code)) !== null) {
const templateContent = templateMatch[1];
const regex = /<([^>]+)>/g;
let match;
const templateContent = templateMatch[1];
const regex = /<([^>]+)>/g;
let match;
while ((match = regex.exec(templateContent)) !== null) {
if (!match[1].startsWith("/")) {
nodes.push(match[1]);
// 提取每个 template 中的所有标签
while ((match = regex.exec(templateContent)) !== null) {
if (!match[1].startsWith("/")) {
nodes.push(match[1]);
}
}
}