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

10 months ago
const start = `<script setup>`;
const end = `</script>`;
let variablesData = ``;
let functionData = ``;
10 months ago
const scriptCombined = () => {
return `
${start}
10 months ago
import request from '@/utils/request';
const formDataOperation = ref({})
10 months ago
${getVariablesData()}
${functionData}
${end}
`;
};
let variablesStructure = {};
10 months ago
10 months ago
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)})`;
10 months ago
};
const addFunction = (code) => {
functionData += code;
};
10 months ago
const resetScript = (data) => {
variablesData = ``;
variablesStructure = {};
functionData = ``;
};
10 months ago
export {
10 months ago
addVariables, addFunction, scriptCombined, resetScript
10 months ago
};