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>; changeTab(value: any, valid?: boolean): Promise<any>;
setTitle(value: string): void; setTitle(value: string): void;
submit(cb?: (data: obj) => void): 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; [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 { assign, cloneDeep, isBoolean, isFunction, keys } from "lodash-es";
import { useAction, useForm, usePlugins, useTabs } from "./helper"; import { useAction, useForm, usePlugins, useTabs } from "./helper";
import { useBrowser, useConfig, useElApi, useRefs } from "../../hooks"; import { useBrowser, useConfig, useElApi, useRefs } from "../../hooks";
@ -16,7 +16,7 @@ export default defineComponent({
enablePlugin: { enablePlugin: {
type: Boolean, type: Boolean,
default: true default: true
}, }
}, },
setup(props, { expose, slots }) { setup(props, { expose, slots }) {
@ -39,7 +39,14 @@ export default defineComponent({
// 方法 // 方法
const ElFormApi = useElApi( const ElFormApi = useElApi(
["validate", "validateField", "resetFields", "scrollToField", "clearValidate", "fields"], [
"validate",
"validateField",
"resetFields",
"scrollToField",
"clearValidate",
"fields"
],
Form Form
); );
@ -291,7 +298,7 @@ export default defineComponent({
if (e.required) { if (e.required) {
e.rules = { e.rules = {
required: true, 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, Tabs,
...Action, ...Action,
...ElFormApi ...ElFormApi
} };
// console.log(ctx)
expose(ctx); expose(ctx);

View File

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

View File

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

View File

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