reactor:【infra 基础设施】build 进一步统一代码风格

This commit is contained in:
YunaiV
2025-09-09 23:24:31 +08:00
parent 0bff8bd7a9
commit 68f64c9d67

View File

@@ -24,7 +24,6 @@ const [Modal, modalApi] = useVbenModal();
const designer = ref(); // 表单设计器 const designer = ref(); // 表单设计器
// 表单设计器配置 // 表单设计器配置
// TODO @puhui999表单选择器版本号从 package.json 拿到全局哈
const designerConfig = ref({ const designerConfig = ref({
switchType: [], // 是否可以切换组件类型,或者可以相互切换的字段 switchType: [], // 是否可以切换组件类型,或者可以相互切换的字段
autoActive: true, // 是否自动选中拖入的组件 autoActive: true, // 是否自动选中拖入的组件
@@ -61,34 +60,34 @@ const formData = ref(''); // 表单数据
useFormCreateDesigner(designer); // 表单设计器增强 useFormCreateDesigner(designer); // 表单设计器增强
/** 打开弹窗 */ /** 打开弹窗 */
const openModel = (title: string) => { function openModel(title: string) {
dialogVisible.value = true; dialogVisible.value = true;
dialogTitle.value = title; dialogTitle.value = title;
modalApi.open(); modalApi.open();
}; }
/** 生成 JSON */ /** 生成 JSON */
const showJson = () => { function showJson() {
openModel('生成 JSON'); openModel('生成 JSON');
formType.value = 0; formType.value = 0;
formData.value = designer.value.getRule(); formData.value = designer.value.getRule();
}; }
/** 生成 Options */ /** 生成 Options */
const showOption = () => { function showOption() {
openModel('生成 Options'); openModel('生成 Options');
formType.value = 1; formType.value = 1;
formData.value = designer.value.getOption(); formData.value = designer.value.getOption();
}; }
/** 生成组件 */ /** 生成组件 */
const showTemplate = () => { function showTemplate() {
openModel('生成组件'); openModel('生成组件');
formType.value = 2; formType.value = 2;
formData.value = makeTemplate(); formData.value = makeTemplate();
}; }
const makeTemplate = () => { function makeTemplate() {
const rule = designer.value.getRule(); const rule = designer.value.getRule();
const opt = designer.value.getOption(); const opt = designer.value.getOption();
return `<template> return `<template>
@@ -112,10 +111,10 @@ const makeTemplate = () => {
} }
init() init()
<\/script>`; <\/script>`;
}; }
/** 复制 */ /** 复制 */
const copy = async (text: string) => { async function copy(text: string) {
const textToCopy = JSON.stringify(text, null, 2); const textToCopy = JSON.stringify(text, null, 2);
const { copy, copied, isSupported } = useClipboard({ source: textToCopy }); const { copy, copied, isSupported } = useClipboard({ source: textToCopy });
if (isSupported) { if (isSupported) {
@@ -126,12 +125,10 @@ const copy = async (text: string) => {
} else { } else {
ElMessage.error('复制失败'); ElMessage.error('复制失败');
} }
}; }
/** /** 代码高亮 */
* 代码高亮 function highlightedCode(code: string) {
*/
const highlightedCode = (code: string) => {
// 处理语言和代码 // 处理语言和代码
let language = 'json'; let language = 'json';
if (formType.value === 2) { if (formType.value === 2) {
@@ -144,7 +141,7 @@ const highlightedCode = (code: string) => {
// 高亮 // 高亮
const result = hljs.highlight(code, { language, ignoreIllegals: true }); const result = hljs.highlight(code, { language, ignoreIllegals: true });
return result.value || '&nbsp;'; return result.value || '&nbsp;';
}; }
/** 初始化 */ /** 初始化 */
onMounted(async () => { onMounted(async () => {