Method and apparatus for generating framework code file for user interface (UI) file

By generating organization, model, view and controller code files bound to the target UI file, a unified MVC framework is established, which solves the problem of inconsistency in code frameworks in UI file development and improves collaborative development efficiency.

CN114691131BActive Publication Date: 2025-08-05MINI CREATIVE TECH (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210148065.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-17
Publication Date
2025-08-05
Estimated Expiration
2042-02-17

AI Technical Summary

Technical Problem

In the prior art, since developers develop UI files according to different code frameworks, the code of UI files is inconsistent and cannot cooperate smoothly, resulting in inefficient collaborative development.

Method used

By generating organization code files, model code files, view code files and controller code files bound to the target UI file, a unified MVC framework is established, so that the code frameworks of different developers can be consistent, and methods of parsing UI files, loading framework code files, creating objects and binding UI controls are adopted.

Benefits of technology

It realizes collaborative development of UI files by different developers under the unified MVC framework, and improves collaborative development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691131B_ABST
    Figure CN114691131B_ABST
Patent Text Reader

Abstract

The present application provides a method and device for generating a framework code file for a user interface (UI) file. The method includes: parsing a target UI file and identifying UI controls contained in the target UI file; loading the framework code file according to the variables recorded in the global variable list; when loading an organization code file, creating objects corresponding to the framework code file respectively through the organization code file initialization method, and saving the objects of the model code file and the objects of the view code file as sub-objects of the controller code file; after creating the objects corresponding to the framework code file respectively, calling the UI controls and calling the startup method of the controller code file through the organization code file initialization method; based on the created objects, generating the organization code file, model code file, view code file, and controller code file bound to the target UI file. The embodiments of the present application can improve the efficiency of collaborative development for UI files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of user interface (UI) file development, and in particular to a method and device for generating a framework code file for a user interface (UI) file. Background Art

[0002] During the development of user interface (UI) files, developers often need to modify the UI code to achieve personalized development effects. In existing technologies, each developer develops the UI file according to a different code framework, resulting in individual UI code and inefficient collaborative development. Summary of the Invention

[0003] One purpose of the present application is to propose a method and device for generating a framework code file for a user interface UI file. By generating an organization code file, a model code file, a view code file, and a controller code file bound to the target UI file, different developers can further develop the target UI file with a unified MVC framework, so that the code frameworks developed by different developers can remain unified, thereby improving the efficiency of collaborative development of UI files.

[0004] According to one aspect of an embodiment of the present application, a method for generating a framework code file for a user interface UI file is disclosed, the method comprising:

[0005] Parsing the target UI file to identify the UI controls contained in the target UI file;

[0006] Loading a framework code file according to the variables recorded in the global variable list, wherein the framework code file includes an organization code file, a model code file, a view code file, and a controller code file, wherein the model code file is used to access data, the view code file is used to visually display data, and the controller code file is used to read data from the view code file and send data to the model code file;

[0007] When the organization code file is loaded, objects corresponding to the framework code files are created through the initialization method of the organization code file, and the objects of the model code file and the objects of the view code file are saved as sub-objects of the controller code file;

[0008] After creating the objects corresponding to the framework code files respectively, calling the UI control through the initialization method of the organization code file and calling the startup method of the controller code file to bind the organization code file, the model code file, the view code file and the controller code file to the target UI file;

[0009] Based on the created object, an organization code file, a model code file, a view code file, and a controller code file bound to the target UI file are generated.

[0010] According to one aspect of an embodiment of the present application, a device for generating a framework code file for a user interface UI file is disclosed, the device comprising:

[0011] A parsing and identifying module configured to parse a target UI file and identify UI controls contained in the target UI file;

[0012] a loading module configured to load a framework code file according to the variables recorded in the global variable list, wherein the framework code file includes an organization code file, a model code file, a view code file, and a controller code file, the model code file is used to access data, the view code file is used to visually display data, and the controller code file is used to read data from the view code file and send data to the model code file;

[0013] an object creation module configured to, when loading the organization code file, create objects corresponding to the framework code files respectively through the initialization method of the organization code file, and save the objects of the model code file and the objects of the view code file as sub-objects of the controller code file;

[0014] a calling module configured to, after creating the objects corresponding to the framework code files respectively, call the UI control through the initialization method of the organization code file and call the startup method of the controller code file to bind the organization code file, the model code file, the view code file, and the controller code file to the target UI file;

[0015] The file generation module is configured to generate, based on the created object, an organization code file, a model code file, a view code file, and a controller code file that are bound to the target UI file.

[0016] According to one aspect of an embodiment of the present application, an electronic device is disclosed, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements any one of the above embodiments.

[0017] According to one aspect of an embodiment of the present application, a computer program medium is disclosed, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute any one of the above embodiments.

[0018] According to one aspect of an embodiment of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations described above.

[0019] Since the model code file, the view code file and the controller code file are all bound to the target UI file under the action of the organization code file, and since the model code file, the view code file and the controller code file jointly build the MVC framework, in the embodiment of the present application, through the organization code file, the model code file, the view code file and the controller code file bound to the target UI file, different developers can further develop the target UI file with a unified MVC framework, so that the code frameworks developed by different developers can be maintained unified, thereby improving the efficiency of collaborative development of UI files.

[0020] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by practice of the present application.

[0021] It should be understood that the foregoing general description and the following detailed description are merely illustrative and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The above and other objects, features and advantages of the present application will become more apparent by describing in detail example embodiments thereof with reference to the attached drawings.

[0023] Figure 1 A flowchart of a method for generating framework code for a user interface UI file according to an embodiment of the present application is shown.

[0024] Figure 2 A schematic diagram of selecting a target UI file through a code file generation tool according to an embodiment of the present application is shown.

[0025] Figure 3 A schematic diagram of selecting a framework code file saving path through a code file generation tool according to an embodiment of the present application is shown.

[0026] Figure 4A schematic diagram of selecting a loading code storage path through a code file generation tool according to an embodiment of the present application is shown.

[0027] Figure 5 A schematic diagram of completing file selection and path selection in a code file generation tool according to an embodiment of the present application is shown.

[0028] Figure 6 A schematic diagram of a framework code file generated by a code file generation tool according to an embodiment of the present application is shown.

[0029] Figure 7 A block diagram of a device for generating framework code for a user interface UI file according to an embodiment of the present application is shown.

[0030] Figure 8 A hardware diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0031] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these example embodiments are provided so that the description of this application will be more comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The accompanying drawings are merely schematic illustrations of the present application and are not necessarily drawn to scale. Identical reference numerals in the figures indicate identical or similar parts, and thus repeated descriptions thereof will be omitted.

[0032] In addition, the described features, structures or characteristics may be combined in one or more example embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the example embodiments of the present application. However, those skilled in the art will appreciate that the technical solutions of the present application may be practiced while omitting one or more of the specific details, or other methods, components, steps, etc. may be adopted. In other cases, known structures, methods, implementations or operations are not shown or described in detail to avoid obscuring the main content and making various aspects of the present application vague.

[0033] Some of the blocks shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0034] This application provides a framework code file generation method for UI files, which is mainly used to generate a set of MVC (Model View Controller) framework code files, so that developers can further develop UI files based on the MVC framework code files.

[0035] Figure 1 The flowchart of the method for generating a framework code file for a UI file provided by the present application is shown. The exemplary execution subject of the method is a code file generation tool integrated with the processing logic of the method, and the method includes:

[0036] Step S110: Parse the target UI file to identify the UI controls contained in the target UI file;

[0037] Step S120: Loading a framework code file according to the variables recorded in the global variable list, wherein the framework code file includes an organization code file, a model code file, a view code file, and a controller code file. The model code file is used to access data, the view code file is used to visualize the data, and the controller code file is used to read data from the view code file and send data to the model code file.

[0038] Step S130: When loading the organization code file, create objects corresponding to the framework code file through the organization code file initialization method, and save the objects of the model code file and the objects of the view code file as sub-objects of the controller code file;

[0039] Step S140: After creating the objects corresponding to the framework code files, call the UI control through the initialization method of the organization code file, and call the startup method of the controller code file to bind the organization code file, the model code file, the view code file, and the controller code file to the target UI file;

[0040] Step S150: Based on the created object, generate an organization code file, a model code file, a view code file, and a controller code file bound to the target UI file.

[0041] In this embodiment of the present application, the framework code files to be generated for the target UI file include: an organization code file, a model code file, a view code file, and a controller code file. The model code file corresponds to the Model in the MVC framework and is used to access data; the view code file corresponds to the View in the MVC framework and is used to visually display data; the controller code file corresponds to the Controller in the MVC framework and is used to read data from the view code file and send data to the model code file; the organization code file is used to bind the model code file, view code file, and controller code file to the target UI file.

[0042] The four files included in the framework code file are recorded as variables in the global variable list in advance. During the process of generating the framework code file, the four files included in the framework code are loaded according to the variables recorded in the global variable list.

[0043] When loading the organization code file, the objects corresponding to the organization code file, the objects corresponding to the model code file, the objects corresponding to the view code file, and the objects corresponding to the controller code file are created through the initialization method of the organization code file; and the objects of the model code file and the objects of the view code file are saved as sub-objects of the controller code file.

[0044] After the object is created, the initialization method of the organization code file is used to call the UI controls identified by parsing the target UI file; and the startup method of the controller code file is called, so that the controller code file can directly use the objects of the model code file and the objects of the view code file, thereby realizing the binding of the MVC framework and the target UI file.

[0045] Then, based on the four created objects, files corresponding to the respective objects are generated to obtain an organization code file, a model code file, a view code file, and a controller code file bound to the target UI file.

[0046] Since the model code file, the view code file and the controller code file are all bound to the target UI file under the action of the organization code file, and since the model code file, the view code file and the controller code file jointly build the MVC framework, in the embodiment of the present application, through the organization code file, the model code file, the view code file and the controller code file bound to the target UI file, different developers can further develop the target UI file with a unified MVC framework, so that the code frameworks developed by different developers can be maintained unified, thereby improving the efficiency of collaborative development of UI files.

[0047] In one embodiment, the target UI file is parsed to identify UI controls with preset control affixes contained in the target UI file. After creating objects corresponding to the framework code files, the UI controls with preset control affixes are called through the initialization method of the organization code file and are saved as variables.

[0048] In this embodiment, when developers use the UI editing tool to perform UI editing, they can modify the names of UI controls that need to be used in the development process by adding prefixes or suffixes. The code file generation tool used to implement the method provided in the embodiment of the present application parses the target UI file and identifies the UI controls with preset control suffixes contained in the target UI file. After creating the objects corresponding to the framework code files, the UI controls with preset control suffixes are called through the initialization method of the organization code file, and the UI controls with preset control suffixes are saved as variables. Thus, after generating the organization code file bound to the target UI file, the developer can take out the UI controls that need to be used in the development process from the organization code file.

[0049] In one embodiment, when developers use FairyGUI for UI editing, they add the prefix "m1_" or "m2_" to the names of UI controls that need to be used in the development process. Among them, "m1_" means using hierarchical recursive naming, and "m2_" means using the naming of the current level. Then, the code file generation tool parses the target UI file and identifies the UI controls with the prefix "m1_" or "m2_" contained in the target UI. Then, after creating the objects corresponding to the framework code files, the UI controls with the prefix "m1_" or "m2_" are called through the initialization method of the organization code file, and the UI controls with the prefix "m1_" or "m2_" are saved as variables.

[0050] In one embodiment, the target UI file is parsed to identify the necessary UI controls contained in the target UI file. After creating objects corresponding to the framework code files, the necessary UI controls are called by organizing the initialization methods of the code files, and events and callback methods are registered for the necessary UI controls and saved.

[0051] In this embodiment, the required UI controls refer to UI controls that are predetermined and required during the development process, such as a sliding list UI control, a button UI control, etc. After creating the objects corresponding to the framework code files, the code file generation tool used to implement the method provided in the embodiment of the present application calls the required UI controls through the initialization method of the organization code file, registers events for the required UI controls, registers callback methods, and saves them. Thus, after generating the organization code file bound to the target UI file, the developer can directly call the events registered for the required UI controls based on the organization code file.

[0052] In one embodiment, the required UI control includes a sliding list UI control. Registering events for the required UI control includes: registering a rendering event for the sliding list UI control, registering a click event for the sliding list UI control, and the like.

[0053] In one embodiment, the required UI control includes a button UI control. Registering events for the required UI control includes: registering touch events for the button UI control, registering press events for the button UI control, registering lift events for the button UI control, and the like.

[0054] In one embodiment, in response to the triggering of the file selection button, the storage path directory of the UI file is retrieved, the UI file selected in the storage path directory is used as the target UI file, and the target UI file is obtained.

[0055] In this embodiment, the code file generation tool for implementing the method provided in the embodiment of the present application provides a file selection button in its user interface for the developer to trigger. After the developer triggers the file selection button, the code file generation tool calls up the storage path directory of the UI file so that the developer can select the UI file for generating the framework code file according to the storage path directory. After the developer selects the UI file in the storage path directory, the code file generation tool uses the selected UI file as the target UI file and obtains the target UI file, and then generates the organization code file, model code file, view code file and controller code file bound to the target UI file according to the method provided in the embodiment of the present application.

[0056] Figure 2 A schematic diagram of selecting a target UI file through a code file generation tool according to an embodiment of the present application is shown. Figure 3 A schematic diagram illustrating selecting a framework code file saving path through a code file generation tool according to an embodiment of the present application is shown. Figure 4 A schematic diagram of selecting a loading code storage path through a code file generation tool according to an embodiment of the present application is shown. Figure 5 A schematic diagram illustrating completing file selection and path selection in a code file generation tool according to an embodiment of the present application is shown. Figure 6 A schematic diagram showing a framework code file generated by a code file generation tool according to an embodiment of the present application is shown.

[0057] refer to Figures 2 to 6 In one embodiment, a code file generation tool is run.

[0058] The developer clicks the "Select File" button in the user interface, and the code file generation tool such as Figure 2 The storage path directory of the UI file is called up as shown, so that the developer can select the target UI file in the storage path directory.

[0059] Then the developer clicks the "Save Path" button in the user interface, and the code file generation tool such as Figure 3 The directory selection window is called up as shown, so that the developer can select the saving path of the framework code file in the directory selection window.

[0060] Then the developer clicks the "Too Path" button in the user interface, and the code file generation tool such as Figure 4 The target selection window is called up as shown, so that the developer can select the loading code storage path of the framework code file in the target selection window.

[0061] After the target UI file, save path, and loaded code storage path are configured, Figure 5 Click the "Start Generation" button on the user interface to generate Figure 6 The framework code files shown in the figure are: Code files ending with AutoGen are organization code files, code files ending with Ctrl are controller code files, code files ending with Model are model code files, and code files ending with View are view code files.

[0062] Figure 7 A device for generating a framework code for a UI file according to an embodiment of the present application is shown, the device comprising:

[0063] The parsing and identifying module 210 is configured to parse the target UI file and identify the UI controls contained in the target UI file;

[0064] The loading module 220 is configured to load a framework code file according to the variables recorded in the global variable list, wherein the framework code file includes an organization code file, a model code file, a view code file, and a controller code file, wherein the model code file is used to access data, the view code file is used to visually display data, and the controller code file is used to read data from the view code file and send data to the model code file;

[0065] The object creation module 230 is configured to create objects corresponding to the framework code files respectively through the initialization method of the organization code file when the organization code file is loaded, and save the objects of the model code file and the objects of the view code file as sub-objects of the controller code file;

[0066] The calling module 240 is configured to, after creating the objects corresponding to the framework code files, call the UI control through the initialization method of the organization code file and call the startup method of the controller code file to bind the organization code file, the model code file, the view code file, and the controller code file to the target UI file;

[0067] The file generation module 250 is configured to generate an organization code file, a model code file, a view code file, and a controller code file bound to the target UI file based on the created object.

[0068] In an exemplary embodiment of the present application, the parsing and identifying module is configured to: parse the target UI file to identify UI controls with preset control affixes contained in the target UI file;

[0069] The calling module is configured to: call the UI control of the preset control affix, and save the UI control of the preset control affix as a variable.

[0070] In an exemplary embodiment of the present application, the parsing and identifying module is configured to: parse the target UI file to identify necessary UI controls contained in the target UI file;

[0071] The calling module is configured to: call the necessary UI controls, register events for the necessary UI controls, register callback methods, and save them.

[0072] In an exemplary embodiment of the present application, the required UI control includes a sliding list UI control, and the calling module is configured to: register a rendering event for the sliding list UI control, and register a click event for the sliding list UI control.

[0073] In an exemplary embodiment of the present application, the required UI control includes a button UI control, and the calling module is configured to: register a touch event for the button UI control, register a press event for the button UI control, and register a lift event for the button UI control.

[0074] In an exemplary embodiment of the present application, the device is configured as follows:

[0075] In response to the triggering of the file selection button, the storage path directory of the UI file is called;

[0076] The UI file selected in the storage path directory is used as the target UI file, and the target UI file is acquired.

[0077] Reference below Figure 8 The electronic device 30 according to an embodiment of the present application is described. Figure 8 The electronic device 30 shown is only an example and should not limit the functions and scope of use of the embodiments of the present application.

[0078] like Figure 8 As shown, the electronic device 30 is implemented as a general-purpose computing device. Components of the electronic device 30 may include, but are not limited to, the aforementioned at least one processing unit 310, the aforementioned at least one storage unit 320, and a bus 330 connecting various system components (including the storage unit 320 and the processing unit 310).

[0079] The storage unit stores program codes that can be executed by the processing unit 310, so that the processing unit 310 performs the steps according to various exemplary embodiments of the present invention described in the description of the exemplary method above. For example, the processing unit 310 may perform the following steps: Figure 1 The steps shown in .

[0080] The storage unit 320 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 3201 and / or a cache memory unit 3202 , and may further include a read-only memory unit (ROM) 3203 .

[0081] The storage unit 320 may also include a program / utility 3204 having a set (at least one) of program modules 3205, such program modules 3205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0082] Bus 330 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0083] The electronic device 30 can also communicate with one or more external devices 400 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 30, and / or any device that enables the electronic device 30 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). This communication can occur via an input / output (I / O) interface 350. The I / O interface 350 is connected to a display unit 340. Furthermore, the electronic device 30 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 360. As shown, the network adapter 360 communicates with other modules of the electronic device 30 via the bus 330. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 30, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0084] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present application.

[0085] In an exemplary embodiment of the present application, a computer-readable storage medium is further provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the method described in the above method embodiment.

[0086] According to one embodiment of the present application, a program product for implementing the method in the above method embodiment is also provided. The program product may be a portable compact disc read-only memory (CD-ROM) and includes program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0087] The program product may be implemented in any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0088] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0089] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0090] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as JAVA, C++, and the like, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0091] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the application, the features and functions of two or more modules or units described above can be concretized in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.

[0092] Furthermore, although the steps of the method of the present application are described in a particular order in the accompanying drawings, this does not require or imply that the steps must be performed in this particular order, or that all steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0093] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.

[0094] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered merely as exemplary, and the true scope and spirit of the present application are indicated by the appended claims.

Claims

1. A method for generating a framework code file for a user interface UI file, characterized in that: The method comprises: Parsing the target UI file to identify the UI controls contained in the target UI file; Loading a framework code file according to the variables recorded in the global variable list, wherein the framework code file includes an organization code file, a model code file, a view code file, and a controller code file, wherein the model code file is used to access data, the view code file is used to visually display data, and the controller code file is used to read data from the view code file and send data to the model code file; wherein the model code file, the view code file, and the controller code file constitute an MVC structure, and the organization code file is used to bind the model code file, the view code file, and the controller code file to the target UI file; When the organization code file is loaded, objects corresponding to the framework code files are created through the initialization method of the organization code file, and the objects of the model code file and the objects of the view code file are saved as sub-objects of the controller code file; After creating objects corresponding to the framework code files respectively, calling the UI control through the initialization method of the organization code file and calling the startup method of the controller code file to bind the organization code file, the model code file, the view code file, and the controller code file to the target UI file, so that the MVC structure is bound to the target UI file; Based on the created object, an organization code file, a model code file, a view code file, and a controller code file bound to the target UI file are generated.

2. The method according to claim 1, characterized in that Parsing the target UI file and identifying the UI controls contained in the target UI file, including: parsing the target UI file and identifying the UI controls with preset control affixes contained in the target UI file; Calling the UI control includes: calling the UI control of the preset control affix, and saving the UI control of the preset control affix as a variable.

3. The method according to claim 1, characterized in that Parsing the target UI file and identifying the UI controls contained in the target UI file, including: parsing the target UI file and identifying the necessary UI controls contained in the target UI file; Calling the UI control includes: calling the necessary UI control, registering an event for the necessary UI control, and registering and saving a callback method.

4. The method according to claim 3, characterized in that The required UI control includes a sliding list UI control, and registering events for the required UI control includes: registering a rendering event for the sliding list UI control, and registering a click event for the sliding list UI control.

5. The method according to claim 3, characterized in that The required UI control includes a button UI control, and registering events for the required UI control includes: registering a touch event for the button UI control, registering a press event for the button UI control, and registering a lift event for the button UI control.

6. The method according to claim 1, characterized in that The method further comprises: In response to the triggering of the file selection button, the storage path directory of the UI file is called; The UI file selected in the storage path directory is used as the target UI file, and the target UI file is acquired.

7. A framework code generation device for a user interface UI file, characterized in that: The device comprises: A parsing and identifying module configured to parse a target UI file and identify UI controls contained in the target UI file; a loading module configured to load a framework code file according to the variables recorded in the global variable list, wherein the framework code file includes an organization code file, a model code file, a view code file, and a controller code file, wherein the model code file is used to access data, the view code file is used to visually display data, and the controller code file is used to read data from the view code file and send data to the model code file; wherein the model code file, the view code file, and the controller code file constitute an MVC structure, and the organization code file is used to bind the model code file, the view code file, and the controller code file to the target UI file; an object creation module configured to, when loading the organization code file, create objects corresponding to the framework code files respectively through the initialization method of the organization code file, and save the objects of the model code file and the objects of the view code file as sub-objects of the controller code file; a calling module configured to, after creating the objects corresponding to the framework code files respectively, call the UI control through the initialization method of the organization code file and call the startup method of the controller code file to bind the organization code file, the model code file, the view code file, and the controller code file to the target UI file, so that the MVC structure is bound to the target UI file; The file generation module is configured to generate, based on the created object, an organization code file, a model code file, a view code file, and a controller code file that are bound to the target UI file.

8. An electronic device, characterized in that: include: a memory storing computer-readable instructions; The processor reads the computer-readable instructions stored in the memory to execute the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that Computer-readable instructions are stored thereon, which, when executed by a processor of a computer, cause the computer to perform the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Screen control zooming method and device, and mobile terminal equipment

    CN111522489A

  • Game interface code generation method, device and equipment and storage medium

    CN112099786A

  • Front-end code generation method and device and computer equipment

    CN113805871A