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

pull/211/head
YunaiV 2025-09-09 23:24:31 +08:00
parent 0bff8bd7a9
commit 68f64c9d67
1 changed files with 15 additions and 18 deletions

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 () => {