Vue3 code generation methods and systems
By generating domain-specific languages and combining them with the real-time feedback mechanism of the sandbox renderer, the problem of traditional front-end development relying on human experience is solved, enabling rapid iterative delivery and flexible adjustment of Vue3 code generation, thus improving development efficiency and code quality.
Patent Information
- Application Number
- CN202611598017.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-15
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional front-end development relies on human experience, resulting in long development cycles and inconsistent standards. Existing large-scale models generate non-standard code that is difficult to integrate into the existing project context and lacks real-time interaction with the runtime environment. The correctness and usability of the generated code cannot be fed back in real time and iteratively optimized.
By acquiring user product requirements, domain-specific language is generated, parsed into Vue3 single-file component code, and rendered and optimized in real time. Combined with a sandbox renderer, it provides instant feedback and adjustments, offering a dual optimization method of directly modifying the code and reverse parsing configuration information.
It enables rapid iterative delivery from product requirements to a working, visual page, resulting in more controllable and reliable code that supports flexible code adjustment methods, shortens the development cycle, and improves code reusability and maintenance efficiency.
Smart Images

Figure CN123114438A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software development technology, and in particular to a Vue3 code generation method and system. Background Technology
[0002] Vue 3 is the third version of a progressive JavaScript framework for building user interfaces. JavaScript is a lightweight, interpreted programming language primarily used to add dynamic interactive functionality to web pages. Single File Components (SFCs) are a component organization method in the Vue framework. A standard Vue 3 SFC includes a template, a script, and a style, all encapsulated in a file with the .vue extension. As front-end business logic becomes increasingly complex, the traditional manual Vue 3 coding model has revealed numerous problems. Development heavily relies on engineers' personal experience and consistent coding standards, leading to differences in coding style and potential defects during team collaboration. Translating product requirements into code implementation requires significant time investment in interface layout, logic writing, and debugging, resulting in extended development cycles and reduced efficiency. Code reusability is low, and maintenance is difficult. To improve code development efficiency and reduce reliance on manpower, the industry has begun exploring the use of Large Language Models (LLMs) to assist in code generation.
[0003] Generative AI technologies, exemplified by large language models, have made groundbreaking progress in recent years, demonstrating powerful potential in code understanding, generation, and completion, capable of generating code snippets in multiple programming languages based on natural language descriptions. However, existing code generation solutions based on large models still have some limitations when handling Vue3 code generation tasks: First, the generated code often does not follow the coding standards of specific projects (such as code style guidelines, UI component library usage standards, state management scheme conventions, etc.), requiring manual adjustments; second, the generated results from existing large language models are mostly independent code snippets, making it difficult to directly integrate them into the context and architecture of existing projects; third, existing solutions lack real-time interaction with the runtime environment, resulting in the inability to obtain real-time feedback and iterative optimization on the correctness and usability of the generated code. Summary of the Invention
[0004] This application provides a Vue3 code generation method and system to solve the technical problems in related technologies, such as long development cycles and inconsistent standards caused by the reliance on human experience in traditional front-end development, as well as the non-standard code generation of existing large models.
[0005] This application provides a Vue3 code generation method, the method comprising: The process involves: acquiring user product requirements; inputting these requirements into a product requirement language conversion model to generate a domain-specific language; parsing the domain-specific language to obtain Vue3 single-file component code; rendering the Vue3 single-file component code to obtain a visual page; optimizing the Vue3 single-file component code in response to a modification command and updating the visual page until the visual page achieves the desired effect; optimizing the Vue3 single-file component code in the following ways: in response to a first modification operation on the Vue3 single-file component code, updating the Vue3 single-file component code to obtain optimized Vue3 single-file component code; or, performing reverse parsing on the Vue3 single-file component code to obtain a reverse-parsed domain-specific language; and in response to a second modification operation on the configuration information in the reverse-parsed domain-specific language, updating the Vue3 single-file component code to obtain optimized Vue3 single-file component code.
[0006] In one embodiment of this application, the data format of the user product requirements includes JSON format. The step of inputting the user product requirements into a product requirement language conversion model to generate a domain-specific language includes: parsing the user product requirements to obtain a first product requirement feature; filtering first specification information that matches the first product requirement feature from a project specification knowledge base; the project specification knowledge base stores project development specification information; and generating a domain-specific language based on the user product requirements and the first specification information.
[0007] In one embodiment of this application, the data format of the user product requirements includes natural language text. The step of inputting the user product requirements into a product requirement language conversion model to generate a domain-specific language includes: converting the user product requirements into pseudocode data, wherein the pseudocode data is in JSON format; parsing the pseudocode data to obtain second product requirement features; filtering second specification information matching the second product requirement features from a project specification knowledge base; wherein the project specification knowledge base stores project development specification information; and generating a domain-specific language based on the pseudocode data and the second specification information.
[0008] In one embodiment of this application, the project development specification information includes at least one of the following: code style guidelines, UI component library usage guidelines, state management conventions, API interface conventions, and routing structure conventions.
[0009] In one embodiment of this application, after obtaining user product requirements and converting the user product requirements into a domain-specific language, and before parsing the domain-specific language to obtain Vue3 single-file component code, the method further includes: performing a first verification on the domain-specific language; if the first verification passes, then parsing the domain-specific language; if the first verification fails, then triggering an error alarm and terminating the process.
[0010] In one embodiment of this application, the domain-specific language includes template structure information, component logic information, and style information of the code to be generated. Parsing the domain-specific language to obtain Vue3 single-file component code includes: generating template code based on the template structure information; generating script code based on the component logic information; generating style code based on the style information; formatting the template code, script code, and style code respectively; and combining them according to the Vue3 single-file component specification to obtain the Vue3 single-file component code.
[0011] In one embodiment of this application, after parsing the domain-specific language to obtain Vue3 single-file component code, and before performing real-time rendering of the Vue3 single-file component code to obtain a visual page, the method further includes performing a second verification on the Vue3 single-file component code. If the second verification passes, the Vue3 single-file component code is rendered in real time; if the second verification fails, an error alarm is triggered and the process terminates.
[0012] In one embodiment of this application, the second verification of the Vue3 single-file component code includes: performing syntax verification on the Vue3 single-file component code to obtain a syntax verification result; verifying the standardization of the setup function of the Vue3 single-file component code to obtain a standardization verification result; verifying the dependency integrity of the Vue3 single-file component code to obtain a dependency verification result; when the syntax verification result, the standardization verification result, and the dependency verification result are all passed, the second verification passes; if any one of the syntax verification result, the standardization verification result, and the dependency verification result fails, an error alarm is triggered and the process terminates, and the second verification fails.
[0013] In one embodiment of this application, the real-time rendering of the Vue3 single-file component code to obtain a visual page includes: inputting the generated Vue3 single-file component code into a sandbox renderer, and performing just-in-time compilation and isolated rendering in the sandbox runtime environment; the rendering method of the sandbox renderer includes node rendering and / or component rendering; the node rendering method is: determining the domain-specific language node to be rendered based on the declarative description object in the Vue3 single-file component code, converting the domain-specific language into a virtual node, calling the rendering function to render the virtual node, and obtaining a visual page; the component rendering method is: defining the domain-specific language node to be rendered as a Vue component, and then mounting the Vue component to a specified document object model element on the page, and obtaining a visual page.
[0014] This application also provides a Vue3 code generation system, the Vue3 code generation system comprising: The acquisition module is used to acquire user product requirements. The domain-specific language generation module is used to input the user's product requirements into the product requirement language conversion model and generate a domain-specific language; The code generation module is used to parse the domain-specific language and obtain Vue3 single-file component code; The visualization page generation module is used to render the Vue3 single-file component code to obtain a visualization page; The optimization module is used to optimize the Vue3 single-file component code in response to the modification command and update the visualization page until the visualization page achieves the desired effect. The method for optimizing the Vue3 single-file component code is as follows: In response to the first modification operation on the Vue3 single-file component code, the Vue3 single-file component code is updated to obtain the optimized Vue3 single-file component code; Alternatively, the Vue3 single-file component code can be reverse-parsed to obtain the domain-specific language after reverse parsing; In response to the second modification operation on the configuration information in the domain-specific language after reverse parsing, the Vue3 single-file component code is updated to obtain the optimized Vue3 single-file component code.
[0015] Beneficial Effects: This application proposes a Vue3 code generation method and system. This method generates a domain-specific language by inputting user product requirements into a product requirement language conversion model, and then parses this domain-specific language to generate Vue3 single-file component code. Through a step-by-step processing approach, it achieves gradual refinement and control from requirements to code generation, making the generated code more controllable and reliable. By combining "real-time rendering to generate a visual page" with "responding to modification instructions to optimize the code and update the page," users can preview the page effect immediately after code generation and continuously adjust it, achieving rapid iterative delivery from product requirements to a runnable visual page, shortening the front-end page development cycle. By providing two optimization methods—directly modifying the Vue3 single-file component code and regenerating code by modifying configuration information after reverse parsing the domain-specific language—it supports both direct and precise adjustments to the generated code and indirect adjustments by modifying high-level domain-specific language configurations, enabling flexible selection of code adjustment methods and improving the solution's adaptability to different adjustment needs. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0017] In the attached diagram: Figure 1 A flowchart illustrating a Vue3 code generation method provided in one embodiment of this application; Figure 2 This is a system architecture diagram corresponding to the Vue3 code generation method provided in one embodiment of this application; Figure 3 This is a schematic diagram of the complete workflow corresponding to the Vue3 code generation method in a preferred embodiment of this application; Figure 4 A flowchart illustrating the template parsing process in a parsing engine provided in an embodiment of this application; Figure 5 A flowchart illustrating the script parsing process in a parsing engine provided in an embodiment of this application; Figure 6 A schematic diagram illustrating the process of converting domain-specific language after reverse parsing into Vue3 single-file component code in a parsing engine provided in an embodiment of this application; Figure 7 This application provides a schematic diagram of the structure of a Vue3 code generation system as an example; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0019] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. The drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the shape, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0020] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the present application. However, it will be apparent to those skilled in the art that embodiments of the present application may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the present application.
[0021] The inventors discovered that traditional front-end development in related technologies heavily relies on engineers' individual experience and consistent coding standards, leading to potential differences in coding style and defects in team collaboration. Transforming product requirements into code implementation requires significant time investment in interface layout, logic writing, and debugging, resulting in long development cycles and low efficiency. Furthermore, code reusability is low, and maintenance is difficult. Simultaneously, existing large-model code generation solutions often fail to adhere to project standards (coding style, component library constraints, state management conventions), requiring manual adjustments. The generated results are often independent fragments, making it difficult to integrate into the existing project context. Moreover, the lack of real-time interaction with the runtime environment prevents real-time feedback and iterative optimization of the generated code's correctness and usability.
[0022] Please see Figure 1 , Figure 1This is a flowchart illustrating a Vue 3 code generation method according to an embodiment of this application. Vue 3 is the third major version of a progressive JavaScript framework for building user interfaces. Vue 3 adopts a component-based development model and supports new features such as the Composition API (Composition Application Programming Interface), Teleport, and Suspense. (See also...) Figure 1 and Figure 2 The Vue 3 code generation method includes the following steps: Step S120: Obtain user product requirements.
[0023] Specifically, users can submit product requirements through an interactive interface. The data format of these requirements can be structured data in JSON (JavaScript Object Notation) format or natural language text. JavaScript is a lightweight, interpreted programming language primarily used to add dynamic interactive functionality to web pages; JSON is a lightweight data exchange format that organizes data using key-value pairs, making it easy for machines to parse and generate; and natural language is the user's description of their requirements using everyday language, such as "Please help me generate a login page that includes a username input box and a login button."
[0024] Step S140: Input the user's product requirements into the product requirement language conversion model to generate a domain-specific language.
[0025] In this embodiment, the product requirement language conversion model is preferably a large language model (LLM), such as DeepSeek, GPT series, etc. After receiving the user's product requirements, the product requirement language conversion model can combine the project development specification information stored in the project specification knowledge base to generate domain specific language (DSL) data.
[0026] In this invention, domain-specific language specifically refers to a structured intermediate data in JSON format, used to describe all the information that the generated Vue3 single-file component code should contain. Domain-specific language includes template structure information, component logic information, and style information. Introducing domain-specific language as an intermediate layer between the output of the large language model and the code output decouples the unstable natural language generation process from the deterministic code transformation process, making the final generated code more controllable and reliable.
[0027] In this embodiment, the project specification knowledge base is a pre-built structured database that stores project development specification information followed by the project. For example, this information includes, but is not limited to: code style guidelines (defining indentation, naming rules, commenting standards, and other coding format requirements), UI component library usage specifications (specifying the usage methods and constraints of components selected in the project, such as those in Element Plus), state management conventions (specifying the usage rules of state management schemes adopted in the project, such as Pinia), API interface conventions (defining the calling methods and data format specifications of backend interfaces), and routing structure conventions (defining the organization and naming rules of frontend routes). By explicitly structuring these implicit project specifications into a project specification knowledge base, the product requirement language conversion model can be guided and constrained by the specification information when generating a domain-specific language (DSL), thereby ensuring that the output DSL conforms to the project architecture requirements.
[0028] The processing method for step S140 varies slightly depending on the different formats of user product requirements: As an example, if the user's product requirements are in JSON format, the product requirements language conversion model will handle the user's product requirements as follows: Step S1410: Analyze the user's product requirements to obtain the first product requirement characteristics.
[0029] Step S1420: Select first specification information that matches the first product requirement characteristics from the project specification knowledge base; the project specification knowledge base stores project development specification information.
[0030] Step S1430: Generate domain-specific language based on user product requirements and first specification information.
[0031] Specifically, if the user product requirements are in JSON format, the JSON requirements are first parsed to extract key features (referred to as the first product requirement features). Then, matching specification information (referred to as the first specification information) is selected from the project specification knowledge base based on the first product requirement features. Subsequently, the user product requirements and the first specification information are integrated. Specifically, the functional descriptions, interface structures, and interaction logic contained in the user product requirements are combined with the constraints such as code style conventions, UI component library usage rules, and state management schemes contained in the first specification information to form a structured prompt text. This prompt text is assembled by the specification-driven prompt engineering and then input into the large language model. Based on the requirement semantics and specification constraints contained in the prompt text, the large language model generates a domain-specific language (DSL) that conforms to the project architecture requirements. This integration mechanism allows the product requirement language conversion model to not only focus on the functional correctness of the requirements when generating the DSL, but also automatically follow the project's coding standards, thereby avoiding the problem of manual secondary adjustments required for generated code in traditional solutions.
[0032] For example, a user's product requirement in JSON format might contain a description of a "login form" component. The large language model identifies features such as "form," "input box," and "button" from this description. It then matches this with the project specification knowledge base, finding that the project uses the Element Plus component library and that the form layout follows specific specifications. After the system integrates the requirement features (i.e., the primary product requirement features) with the component library specification information (i.e., the primary specification information) into a structured prompt, the domain-specific language (DSL) generated by the large model will contain component descriptions such as el-form, el-input, and el-button that conform to the Element Plus usage specifications, rather than generic HTML form elements.
[0033] Second, if the data format of user product requirements is natural language text, then the product requirement language conversion model processes user product requirements as follows: Step S1401: Convert user product requirements into pseudocode data, which is in JSON format.
[0034] Step S1402: Parse the pseudocode data to obtain the second product demand characteristics.
[0035] Step S1403: Select second specification information that matches the second product requirement characteristics from the project specification knowledge base; the project specification knowledge base stores project development specification information.
[0036] Step S1404: Generate a domain-specific language based on pseudocode data and second specification information.
[0037] Specifically, if the user's product requirement is in natural language text, the large language model first converts the natural language text into pseudocode data in a pre-defined JSON format. This step eliminates potential ambiguities in the free text, converting it into a structured intermediate expression, providing more deterministic input for subsequent processing. Then, the pseudocode data is parsed to extract key features (i.e., second product requirement features). Next, matching specification information (i.e., second specification information) is retrieved and filtered from the project specification knowledge base based on these second product requirement features. Subsequently, the pseudocode data and second specification information are fused and arranged into structured prompt text, which is then input into the large language model. The large language model then generates a domain-specific language that conforms to the project architecture requirements.
[0038] For example, if a user inputs a product requirement such as "create a user information display card, including an avatar, name, and bio", the large language model first converts it into pseudocode data in JSON format and extracts features such as "card, avatar, name, and bio". It then matches the project with the Ant Design Vue component library from the knowledge base and finds that the card component has specific style specifications. The resulting domain-specific language will include usage descriptions of components such as a-card and a-avatar.
[0039] Through the two processing methods described above, regardless of whether the user inputs product requirements in JSON or natural language text format, they are ultimately normalized into a unified Domain-Specific Language (DSL) intermediate representation. This normalization process allows subsequent parsing, code generation, and rendering steps to be based on a unified DSL data structure, eliminating the need to distinguish the input format of upstream requirements and simplifying the overall architecture design.
[0040] In a preferred embodiment of this example, after obtaining user product requirements and converting them into a domain-specific language, and before parsing the domain-specific language, the Vue3 code generation method further includes: Step S150: Perform a first verification on the domain-specific language. If the first verification passes, the domain-specific language is parsed. If the first verification fails, an error alarm is triggered and the process terminates.
[0041] Specifically, after the domain-specific language is generated, a first verification is performed on the domain-specific language data to verify the correctness of its format and the integrity of its structure. The first verification includes the following aspects: First, format validation, which checks whether the domain-specific language (DSL) is a valid JSON format to ensure that the data structure can be parsed correctly; Second, there's structural validation, which checks whether the field names and types in the Domain-Specific Language (DSL) conform to the predefined node schema specification. A schema is a set of mandatory rules used to define and validate the structure and content of node documents. For example, it checks whether the node identifier (id) is a string, whether the component name (name) is required, and whether child nodes (children) are arrays. Third is integrity verification, which checks whether the required fields in the domain-specific language (DSL) are complete, such as whether the root node to be rendered has been defined, and whether the template structure is empty.
[0042] The above validation can be achieved using a JSON Schema validation tool (such as AJV) in conjunction with a predefined node schema configuration file. This involves comparing the domain-specific language data field-by-field with the schema file to check if its type, scope, and structure meet expectations. If the first validation passes, the process proceeds to step S160 for domain-specific language parsing. If the validation fails, a structured error feedback is generated based on the specific reason for the failure, such as "Field xxx should be a string, currently a number" or "Required field yyy is missing," and the user is prompted through the interface. The user can then choose to adjust their requirements and regenerate the domain-specific language. By adding a first validation before parsing, format-level errors can be intercepted early, preventing invalid data from entering subsequent stages and wasting resources.
[0043] Step S160: Parse the domain-specific language to obtain the Vue3 single-file component code.
[0044] Specifically, the domain-specific language is parsed to obtain Vue3 single-file component code, including: Step S161: Generate template code based on template structure information, generate script code based on component logic information, and generate style code based on style information.
[0045] Step S162: After formatting the template code, script code, and style code respectively, combine them according to the Vue3 single-file component specification to obtain the Vue3 single-file component code.
[0046] Specifically, the domain-specific language contains three parts: template structure information, component logic information, and style information for the code to be generated. During parsing, these three parts are processed separately: template code is generated based on the template structure information (the template code is an HTML structure used to define the DOM element hierarchy and attribute bindings of the page); script code is generated based on the component logic information (using Vue 3's...). <script setup>语法,包含数据状态、计算属性、监听器、生命周期钩子、方法和事件等),根据样式信息生成样式代码(例如层叠样式表CSS,用于定义组件的视觉呈现)。三部分代码生成后,通过代码格式化工具(如prettier)分别进行格式化以保持代码整齐规范,然后按照Vue3单文件组件的标准格式组合为一个完整的.vue文件。单文件组件的英文全称为Single File Component,简称为SFC),在Vue.js框架中,SFC特指以.vue为扩展名的文件格式,它将一个组件的模板(template,定义页面HTML结构)、脚本(script,定义组件的逻辑与状态管理)和样式(style,定义组件的视觉呈现)封装在同一个文件内。一个典型的单文件组件代码结构如下:<template><!-- 模板代码:定义页面结构和元素 -->< / template><script setup> / / 脚本代码:定义组件状态、逻辑和交互行为< / script> <style scoped> / 样式代码:定义组件的视觉样式 / < / style> By mapping domain-specific languages into three parts—template code, script code, and style code—each component operates independently and without interference during the generation phase. Each part can be formatted and optimized separately before being assembled together. This decoupled design results in a clear and readable structure for the generated Vue 3 single-file components, while also ensuring content integrity.
[0047] Reference Figure 3 In a preferred embodiment of this example, after parsing the domain-specific language to obtain the Vue3 single-file component code, the Vue3 code generation method further includes: Step S170: Perform a second check on the Vue3 single-file component code. If the second check passes, the Vue3 single-file component code is rendered in real time; if the second check fails, an error alert is triggered and the process terminates.
[0048] After the Vue3 single-file component code is generated, it undergoes a second validation to ensure that the code is syntactically and logically correct and executable. Specifically, the second validation of the Vue3 single-file component code includes: Step S171: Perform syntax validation on the Vue3 single-file component code and obtain the syntax validation result.
[0049] The Vue compiler (e.g., @vue / compiler-sfc) parses the Vue 3 single-file component code into an Abstract Syntax Tree (AST), and checks the HTML (HyperText Markup Language) syntax of the template part for validity, tag closure, and correct attribute binding. Simultaneously, a JavaScript parser (e.g., @babel / parser) checks the JavaScript syntax of the script part for correctness, including whether variable declarations conform to ES6+ specifications and whether arrow functions and asynchronous functions are valid. For styles, a CSS (Cascading Style Sheets) parser checks the style syntax for correctness, such as selector format, property names, and property values. If a syntax error occurs during parsing, the Vue compiler or JavaScript parser returns specific error information and the error location, which the system uses to determine that the syntax check fails.
[0050] The Vue compiler transforms declarative templates into imperative JavaScript code. The JavaScript parser, part of the browser's JavaScript engine, transforms JavaScript source code into a form that the computer can process. ES6+ is the modern standard for JavaScript, referring to all subsequent annual versions (ES7 to ES2025) from ECMAScript 2015 (ES6) onwards. It is not a new language, but rather an enhancement and extension of existing JavaScript.
[0051] Step S172: Verify the standardization of the setup function in the Vue3 single-file component code and obtain the standardization verification result.
[0052] The purpose of normative validation is to check the script section ( <script setup>部分)的结构是否符合Vue3的规范要求,具体包括:检查变量定义方式是否正确(如响应式数据是否使用ref(引用)或reactive(响应)声明而非普通变量)、检查生命周期钩子的使用方式是否规范(如onMounted、onUnmounted等是否在setup顶层调用而非嵌套在条件语句中)、检查组件注册方式是否正确(引入的组件是否已在模板中使用),以及检查是否在<script setup>中使用了正确的组合式API调用方式等。setup函数规范性校验可利用Vue编译器的静态分析功能结合预定义的规范性规则配置来实现。
[0053] 步骤S173,对Vue3单文件组件代码的依赖完整性进行校验,得到依赖校验结果。
[0054] 依赖完整性校验的目的是检查代码中import语句引入的外部依赖是否完整且可解析,具体包括:检查引入的第三方组件库(如Element Plus中的ElButton、ElInput等组件)是否在项目中已声明依赖;检查引入的自定义模块(如工具函数、业务组件等)路径是否正确、文件是否存在;检查项目中是否缺少必要的依赖包等。依赖完整性校验可通过静态依赖分析工具(如resolve模块解析器)遍历Vue3单文件组件代码中的所有import语句,结合项目的package.json配置和模块解析规则进行逐项比对来实现。import语句是JavaScript中用于引入外部模块、组件或函数的语法。在Vue3单文件组件的脚本部分(<script setup>)中,import语句用于引入组件所需的外部资源;package.json是npm(Node PackageManager,释义为Node.js 包管理器)项目中的核心配置文件,它记录了项目的元信息、依赖包列表、脚本命令等。
[0055] 步骤S174,当语法校验结果、规范性校验结果和依赖校验结果均为通过时,第二校验通过;若语法校验结果、规范性校验结果和依赖校验结果中任意一项结果为不通过,则触发错误警报并终止,第二校验不通过。
[0056] 只有当三项校验结果均为通过时,第二校验才算通过,流程进入步骤S180进行渲染。若任意一项不通过,系统会根据具体的校验失败原因生成结构化的错误反馈(例如"语法错误:第10行第5列,未闭合的标签<el-form>”或"依赖缺失:未找到模块element-plus,请检查package.json”),并通过界面提示用户,用户可以根据错误信息手动修正代码后重新提交校验,或调整需求后重新生成Vue3单文件组件代码。
[0057] 通过语法校验、setup函数规范性校验和依赖校验这三重校验机制,可以在代码进入渲染环节之前就把质量问题拦截下来,有效避免因代码错误导致的渲染失败。
[0058] 步骤S180,对Vue3单文件组件代码进行渲染,得到可视化页面。
[0059] 具体地,将生成的Vue3单文件组件代码输入沙箱渲染器,在沙箱运行时环境中进行即时编译与隔离渲染,得到可视化页面。沙箱渲染器是一个在浏览器中通过iframe等隔离技术实现的轻量级Vue3运行时环境,它能够安全地对输入的Vue3单文件组件代码进行即时编译和隔离渲染,即使生成的代码存在执行异常,也不会影响宿主页面的安全。渲染完成后,用户可以在浏览器中实时看到页面的外观和交互效果。
[0060] 沙箱渲染器的渲染方式包括节点渲染和组件渲染,可以根据实际需要灵活选择。
[0061] 其中,节点渲染的方式为:根据Vue3单文件组件代码中的声明式描述对象确定待渲染的领域特定语言节点,将领域特定语言转换为虚拟节点(Virtual DOM Node,简称VNode,即虚拟DOM节点),调用渲染函数对虚拟节点进行渲染,得到可视化页面;具体而言,该转换过程包括:先根据待渲染的领域特定语言节点的节点名称查找对应的Vue组件,该Vue组件既可以是浏览器内置的HTML元素标签(如div、span、input等),也可以是已注册的自定义Vue组件;随后通过属性解析函数(parseNodeProps)深度解析节点的属性配置,通过事件处理函数(parseNodeEvents)处理节点上绑定的事件;继而处理Vue的内置指令,包括条件渲染指令(v-if / v-else-if / v-else)、列表渲染指令(v-for)、属性绑定指令(v-bind)、显示隐藏指令(v-show)和双向绑定指令(v-model)等;再通过插槽处理函数(childrenToSlots)处理组件的插槽内容;最后使用Vue.createVNode函数创建虚拟节点,并调用渲染函数(即Vue渲染器的render方法)将其渲染到页面容器中。由于节点渲染无需经过完整的Vue组件实例化过程,因此更为轻量高效,适用于简单节点和一次性渲染场景。
[0062] 组件渲染的方式为:将待渲染的领域特定语言节点定义为Vue组件后,把Vue组件挂载至页面上的指定文档对象模型元素中,得到可视化页面;其中,指定文档对象模型的英文全称为Document Object Model,简称DOM。具体而言,组件渲染的过程包括:先使用Vue.defineComponent函数将待渲染的领域特定语言节点定义为一个Vue组件,并处理该组件的props(属性)、setup(组合式API入口)和render(渲染函数)等核心选项;然后使用Vue.createApp函数创建该组件的Vue应用实例;最后调用该应用实例的mount方法,将所述Vue组件挂载至页面中指定的文档对象模型元素上。与前述节点渲染方式不同,组件渲染提供了完整的组件生命周期(如onMounted、onUnmounted、onUpdated等)和独立的作用域,使组件能够拥有独立的状态管理和交互逻辑,因而更适用于需要复杂状态管理、精细交互控制的业务场景,例如下拉选择器、数据表格、弹窗等较复杂的组件。
[0063] 在实际应用中,节点渲染和组件渲染两种渲染方式互为补充、共同构成沙箱渲染器的完整渲染能力:对于简单的展示型节点(如文本标签、图片、输入框等)可采用节点渲染方式以获得更高的渲染性能;对于复杂的业务型节点(如下拉选择器、数据表格、弹窗等)则可采用组件渲染方式以获得更完善的功能支持。用户可以根据待渲染节点的复杂度灵活选择合适的渲染策略。
[0064] 沙箱渲染器支持设计模式与运行模式两种执行模式,以及H5和Web两种渲染模式。在呈现可视化页面的同时,沙箱渲染器还同步输出对应的实时代码视图,并在代码视图中以高亮形式标注语法错误、规范警告或运行时异常等信息,以辅助用户定位和修正生成代码中的问题。
[0065] 步骤S190,响应于修改指令,对Vue3单文件组件代码进行优化,并对可视化页面进行更新,直到可视化页面达到期望效果。
[0066] 具体地,参照图3,对Vue3单文件组件代码进行优化的方式为:响应对Vue3单文件组件代码的第一修改操作,更新Vue3单文件组件代码,得到优化后的Vue3单文件组件代码;或,对Vue3单文件组件代码进行反向解析,得到反向解析后的领域特定语言;响应对反向解析后的领域特定语言(DSL)中配置信息的第二修改操作,更新Vue3单文件组件代码,得到优化后的Vue3单文件组件代码。
[0067] 当用户对当前渲染得到的可视化页面效果不满意时,可以发起修改指令,触发对生成代码及可视化页面的迭代优化,直至页面达到预期效果。本申请提供了两种对Vue3单文件组件代码的优化方式,用户可根据自身技术水平和具体需求进行选择。
[0068] 第一种优化方式为直接修改Vue3单文件组件代码。用户可在代码编辑界面中直接编辑生成的Vue3单文件组件代码并发起第一修改操作;在接收到用户发起的第一修改操作后,更新Vue3单文件组件代码的内容,并通过沙箱渲染器对优化后的Vue3单文件组件代码重新编译与渲染,使可视化页面实时反映代码的修改效果。该方式允许用户直接操控底层代码细节,适合熟悉Vue3语法的开发者进行精确调整。
[0069] 第二种优化方式是通过修改领域特定语言来更新代码,首先将当前的Vue3单文件组件代码反向解析为领域特定语言,随后用户可在领域特定语言编辑界面中修改反向解析后的领域特定语言中的配置信息,例如调整组件属性、修改数据结构、更换样式等,发起第二修改操作;处理端接收到用户发起的第二修改操作后,基于修改后的领域特定语言重新生成Vue3单文件组件代码,再经沙箱渲染器渲染更新可视化页面。该方式使用户无需直接接触底层代码,通过修改高层次的领域特定语言配置即可实现页面调整,降低了对使用者Vue3技术水平的依赖。
[0070] 其中,反向解析过程的核心是将Vue3单文件组件代码转换回领域特定语言的JSON格式数据。该过程与步骤S160中的正向转换(由领域特定语言生成Vue3单文件组件代码)方向相反、逻辑对应,具体包含模板、脚本和样式三个部分的解析。
[0071] 参照图4,图4为解析引擎中模板解析过程的流程图,在模板解析过程中,首先借助Vue编译器(@vue / compiler-sfc)将模板内容解析为抽象语法树(Abstract Syntax Tree,以下简称AST),所述抽象语法树是一种以树状结构表示源代码语法结构的数据组织形式。然后遍历AST中的各个节点,针对不同类型的节点进行差异化的处理:对元素节点(ElementNode),即HTML元素节点,提取其标签名和属性,并对文本内容节点提取其文本内容;对插槽节点,提取其插槽名称和插槽内容;对指令节点,即包含条件渲染指令(v-if、v-else-if、v-else)、循环渲染指令(v-for)等指令的节点,分别提取其对应的条件表达式及节点内容、循环数据源及循环变量等;此外,对于其他类型的节点,可根据实际需要设置相应的解析规则。全部节点处理完成后,将提取到的数据整合到节点Schema(即领域特定语言)中,形成完整的组件结构描述。
[0072] 参照图5,图5为解析引擎中脚本解析过程的流程图,在脚本解析过程中,同样利用Vue编译器将脚本内容解析为抽象语法树,然后遍历AST中的各个脚本节点,分别处理以下信息:对data函数,提取组件的数据状态(state),即利用ref、reactive等响应式API创建的数据;对method函数,提取组件中定义的方法和事件处理函数;对computed函数,提取组件的计算属性;对lifecycle生命周期函数,提取组件定义的生命周期钩子(如onMounted、onUnmounted等);对watch监听函数,提取组件的监听器,即监听的数据源及对应的回调函数。同时,脚本解析过程还包括提取组件的属性声明(props,提取属性名称、类型、默认值及是否必填等)、事件声明(emits,提取事件名称及参数)、依赖注入(provide / inject,提取provide提供的数据和inject注入的数据)以及依赖包(import,提取引入的第三方组件库和工具函数)等信息。处理完成后,将全部数据存入领域特定语言中。
[0073] 在样式解析过程中,直接提取Vue3单文件组件中<style>标签内的CSS内容,将其置入领域特定语言即可,无需进行复杂的语法转换。
[0074] 参照图6,反向解析后的领域特定语言(节点Schema)还可以正向转换为Vue3单文件组件代码(Vue SFC),得到的节点通过上述反向解析过程,本申请实现了Vue3单文件组件代码与领域特定语言之间的双向转换:既可以将领域特定语言正向转换为Vue3单文件组件代码,也可以将Vue3单文件组件代码反向解析为领域特定语言。这种双向映射能力使得用户可以在源代码模式和领域特定语言模式之间自由切换,根据自身习惯选择最为合适的编辑方式,从而兼顾了不同技术背景用户的使用需求。
[0075] 在本实施例的优选实施方式中,还可以收集用户对代码优化结果的反馈结果,并根据用户反馈结果自适应优化项目规范知识库和Vue3单文件组件代码的生成策略,以实现生成质量的持续进化。
[0076] 具体而言,首先,采集并记录用户在可视化页面与代码编辑过程中产生的反馈行为(即用户反馈结果),其中,反馈行为包括用户对生成结果的接受、拒绝、手动修改,以及通过自然语言提出的修改意见中的至少一种。
[0077] 之后,对采集到的反馈行为进行结构化解析与偏好提取,得到用户偏好特征:例如,当用户出现反复将生成按钮的默认颜色改为某颜色、将组件间距调整为特定值或多次拒绝某一类组件使用方式的行为时,可从这些反馈行为中识别出用户在视觉风格、组件选型、布局习惯等方面的稳定偏好,并将这些偏好特征与对应的领域特定语言生成参数、代码结构选择建立关联,生成偏好知识。
[0078] 最后,将偏好知识以结构化的偏好配置形式存储,并同步至项目规范知识库,作为后续领域特定语言生成的规范约束之一。
[0079] 在此基础上,还可以对Vue3单文件组件代码的生成策略进行优化,例如采用偏好驱动的提示策略调整,即在下一次生成领域特定语言(DSL)时,将所述偏好知识作为附加约束纳入提示文本(Prompt),动态调整提示策略,使大语言模型在生成过程中遵循用户的个性化偏好;此外,还可以对产品需求语言转换模型的生成参数进行自适应调整,即根据偏好知识调整领域特定语言生成过程中的相关参数或模板选择,例如优先选用用户偏好的组件库、默认样式或布局结构,使模型在后续生成中直接内化用户的偏好。
[0080] 通过上述自适应优化机制,产品需求语言转换模型能够在持续的交互迭代中不断学习与适配具体项目团队及用户的偏好,使后续生成的Vue3单文件组件在满足功能需求和项目规范的基础上,逐渐贴合用户的个性化风格。相较于仅依据通用规范的一次性生成方案,本自适应优化机制使代码生成质量在多次使用中持续进化,进一步降低了人工二次调整的工作量,提升了开发效率与用户体验。
[0081] 需要说明的是,上述实施例提供的方法,其应用场景并非局限于前文具体阐述的Vue3前端开发及代码生成等内容。前端工程化开发仅为实际应用的领域之一,用以具体示例说明本专利技术方案的实施方式及所能达成的技术效果。凡是存在类似基于大语言模型进行代码生成需求,需要对代码进行规范化生成、实时可视化验证和动态迭代优化的领域,均属于本专利技术方案可适用的范围。
[0082] 上述实施例提供的一种Vue3代码生成方法,用户提交需求描述后,依次完成领域特定语言的生成与校验、Vue3单文件组件代码的转换与质量校验,以及在沙箱渲染器中的即时编译与隔离渲染,并通过基于代码与领域特定语言双向映射的迭代机制持续优化页面效果,直至达到预期目标,缩短了前端原型的开发周期,同时通过双重校验机制有效保障了最终交付代码的质量、规范性与可用性。
[0083] 参见图7,图7为本申请一实施例提供的Vue3代码生成系统的一个结构示意图,如图7所示,本发明实施例还提供了一种Vue3代码生成系统,该Vue3代码生成系统包括:获取模块710,用于获取用户产品需求;用户产品需求的数据格式为JSON格式和 / 或自然语言文本;领域特定语言生成模块720,用于将用户产品需求输入产品需求语言转换模型,生成领域特定语言;代码生成模块730,用于对领域特定语言进行解析,得到Vue3单文件组件代码;可视化页面生成模块740,用于对Vue3单文件组件代码进行实时渲染,得到可视化页面;优化模块750,用于响应于修改指令,对Vue3单文件组件代码进行优化,并对可视化页面进行更新,直到可视化页面达到期望效果;对Vue3单文件组件代码进行优化的方式为:响应对Vue3单文件组件代码的第一修改操作,更新Vue3单文件组件代码,得到优化后的Vue3单文件组件代码;或,对Vue3单文件组件代码进行反向解析,得到反向解析后的领域特定语言;响应对反向解析后的领域特定语言中配置信息的第二修改操作,更新Vue3单文件组件代码,得到优化后的Vue3单文件组件代码。
[0084] 关于Vue3代码生成系统的具体限定可以参见上文中对于Vue3代码生成方法的限定,在此不再赘述。上述Vue3代码生成系统中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于电子设备中的处理器中,也可以以软件形式存储于电子设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
[0085] 在本实施例中,该Vue3代码生成系统实质上是设置了多个模块用以执行上述任一实施例中的Vue3代码生成方法,具体功能和技术效果参照上述实施例即可,此处不再赘述。
[0086] 参见图8,图8为本申请一实施例提供的电子设备的一个结构示意图,如图8所示,本发明实施例还提供了一种电子设备800,包括处理器801、存储器802和通信总线803;通信总线803用于将处理器801和存储器802连接;处理器801用于执行存储器802中存储的计算机程序,以实现上述任一项实施例中提供的方法。
[0087] 本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序用于使计算机执行如上述实施例中的任一项所述的方法。
[0088] 本申请实施例还提供了一种计算机可读存储介质,该存储介质中存储有一个或多个模块(programs),该一个或多个模块被应用在设备时,可以使得该设备执行本申请实施例提供的所包含步骤的指令(instructions)。
[0089] 本申请实施例还提供了一种计算机程序产品,包括计算机程序或指令,计算机程序或指令被处理器执行时可实现前述方法实施例的步骤及相应内容。
[0090] 需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是但不限于电、磁、光、电磁、红外线或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件,或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。
[0091] 上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。
[0092] 可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如C语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行,或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
[0093] 附图中的流程图和框图,图示了按照本公开各种实施例的方法和计算机程序产品可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,该模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,依所涉及的功能而定。也要注意的是,框图和 / 或流程图中的每个方框,以及框图和 / 或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
[0094] 应该理解的是,本申请如果提到了术语"第一”、"第二”等是用于区别类似的对象,而非必然表征其指代了特定的顺序或先后次序。这些术语所在的技术特征在适当情况下可以互换,以便这里描述的本申请的实施例能够以除图示或文字描述以外的顺序实施。
[0095] 应该理解的是,虽然本申请实施例提供的流程图通过箭头指示各个步骤,但箭头所指示的顺序并非必然限制这些步骤的实施顺序。本领域技术人员可以根据这些步骤针对不同的实施场景按照需求以其他的顺序执行。
[0096] 上述实施例仅例示性说明本申请的原理及其功效,而非用于限制本申请。任何熟悉此技术的人士皆可在不违背本申请的精神及范畴下,对上述实施例进行修饰或改变。因此,举凡所属技术领域中具有通常知识者在未脱离本申请所揭示的精神与技术思想下所完成的一切等效修饰或改变,仍应由本申请的权利要求所涵盖。< / script>
Claims
1. A Vue3 code generation method, characterized in that, The method includes: Obtain user product requirements; The user's product requirements are input into the product requirement language conversion model to generate a domain-specific language; The domain-specific language is parsed to obtain Vue3 single-file component code; The Vue3 single-file component code is rendered to obtain a visual page; In response to the modification command, the Vue3 single-file component code is optimized, and the visualization page is updated until the visualization page achieves the desired effect; The method for optimizing the Vue3 single-file component code is as follows: In response to the first modification operation on the Vue3 single-file component code, the Vue3 single-file component code is updated to obtain the optimized Vue3 single-file component code; Alternatively, reverse-parse the Vue3 single-file component code to obtain the domain-specific language after reverse parsing; in response to the second modification operation on the configuration information in the domain-specific language after reverse parsing, update the Vue3 single-file component code to obtain the optimized Vue3 single-file component code.
2. The Vue3 code generation method as described in claim 1, characterized in that, The data format of the user product requirements includes JSON format. The step of inputting the user product requirements into a product requirement language conversion model to generate a domain-specific language includes: The user's product requirements are analyzed to obtain the first product requirement characteristics; First specification information matching the first product requirement characteristics is selected from the project specification knowledge base; the project specification knowledge base stores project development specification information. A domain-specific language is generated based on the user's product requirements and the first specification information.
3. The Vue3 code generation method as described in claim 1, characterized in that, The data format of the user product requirements includes natural language text. The step of inputting the user product requirements into a product requirement language conversion model to generate a domain-specific language includes: The user product requirements are converted into pseudocode data, which is in JSON format. The pseudocode data is parsed to obtain the second product demand characteristics; The second specification information that matches the second product requirement characteristics is selected from the project specification knowledge base; the project specification knowledge base stores project development specification information. A domain-specific language is generated based on the pseudocode data and the second specification information.
4. The Vue3 code generation method as described in claim 2 or 3, characterized in that, The project development specifications include at least one of the following: code style guidelines, UI component library usage guidelines, state management conventions, API interface conventions, and routing structure conventions.
5. The Vue3 code generation method as described in claim 1, characterized in that, After obtaining user product requirements and converting them into a domain-specific language, and before parsing the domain-specific language to obtain Vue3 single-file component code, the method further includes: A first verification is performed on the domain-specific language. If the first verification passes, the domain-specific language is parsed. If the first verification fails, an error alarm is triggered and the process terminates.
6. The Vue3 code generation method as described in claim 1, characterized in that, The domain-specific language includes template structure information, component logic information, and style information of the code to be generated. Parsing the domain-specific language to obtain Vue3 single-file component code includes: Generate template code based on the template structure information, generate script code based on the component logic information, and generate style code based on the style information; After formatting the template code, script code, and style code respectively, they are combined according to the Vue3 single-file component specification to obtain the Vue3 single-file component code.
7. The Vue3 code generation method as described in claim 1, characterized in that, After parsing the domain-specific language to obtain the Vue3 single-file component code, and before rendering the Vue3 single-file component code in real time to obtain the visual page, the method further includes performing a second verification on the Vue3 single-file component code. If the second verification passes, the Vue3 single-file component code is rendered in real time; if the second verification fails, an error alarm is triggered and the process terminates.
8. The Vue3 code generation method as described in claim 7, characterized in that, The second verification of the Vue3 single-file component code includes: The Vue3 single-file component code is subjected to syntax validation, and the syntax validation result is obtained; The code setup function of the Vue3 single-file component is checked for compliance, and the compliance check result is obtained. The dependency integrity of the Vue3 single-file component code is verified, and the dependency verification result is obtained; The second check passes when the syntax check result, the normativity check result, and the dependency check result are all passed. If any one of the syntax check result, the normativity check result, and the dependency check result fails, an error alarm is triggered and the process terminates, indicating that the second check has failed.
9. The Vue3 code generation method as described in claim 1, characterized in that, The real-time rendering of the Vue3 single-file component code to obtain a visual page includes: The generated Vue3 single-file component code is input into the sandbox renderer for real-time compilation and isolated rendering in the sandbox runtime environment; The sandbox renderer's rendering methods include node rendering and / or component rendering; The node rendering method is as follows: determine the domain-specific language node to be rendered based on the declarative description object in the Vue3 single-file component code, convert the domain-specific language into a virtual node, call the rendering function to render the virtual node, and obtain the visual page; The component rendering method is as follows: after defining the domain-specific language node to be rendered as a Vue component, the Vue component is mounted to the specified document object model element on the page to obtain the visual page.
10. A Vue3 code generation system, characterized in that, include: The acquisition module is used to acquire user product requirements. The domain-specific language generation module is used to input the user's product requirements into the product requirement language conversion model and generate a domain-specific language; The code generation module is used to parse the domain-specific language and obtain Vue3 single-file component code; The visualization page generation module is used to render the Vue3 single-file component code to obtain a visualization page; The optimization module is used to optimize the Vue3 single-file component code in response to the modification command and update the visualization page until the visualization page achieves the desired effect. The method for optimizing the Vue3 single-file component code is as follows: In response to the first modification operation on the Vue3 single-file component code, the Vue3 single-file component code is updated to obtain the optimized Vue3 single-file component code; Alternatively, the Vue3 single-file component code can be reverse-parsed to obtain the domain-specific language after reverse parsing; In response to the second modification operation on the configuration information in the domain-specific language after reverse parsing, the Vue3 single-file component code is updated to obtain the optimized Vue3 single-file component code.
