You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
871 B
JavaScript

const start = `<script setup>`;
const end = `</script>`;
let variablesData = ``;
let functionData = ``;
const scriptCombined = () => {
return `
${start}
import request from '@/utils/request';
const formDataOperation = ref({})
${getVariablesData()}
${functionData}
${end}
`;
};
let variablesStructure = {};
const addVariables = (tier, key, type) => {
let obj = variablesStructure;
if (tier.length > 0) {
tier.forEach((t) => {
obj = obj[t];
});
obj[key] = type;
} else {
obj[key] = type;
}
};
const getVariablesData = () => {
return `const pageForm = ref(${JSON.stringify(variablesStructure)})`;
};
const addFunction = (code) => {
functionData += code;
};
const resetScript = (data) => {
variablesData = ``;
variablesStructure = {};
functionData = ``;
};
export {
addVariables, addFunction, scriptCombined, resetScript
};