A cross-platform code generation method, device, equipment and storage medium
Through the semantic model, the functional interface is converted into platform-free information and the adapter is used to run on multiple platforms, solving the problem of functional compatibility between computer and mobile phones in low-code technology, realizing cross-platform code reuse and efficient development .
Patent Information
- Application Number
- CN202411117169.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-08-15
AI Technical Summary
The existing low-code technology is difficult to achieve functional compatibility and development on both the computer and mobile phones, and cannot effectively solve the problem of cross-platform development.
The functional interface of the first platform is converted into information that has no dependency relationship with the platform through a semantic model, and the adapter is used to parse and run on the second platform to realize the multiplexing of code logic on multiple platforms.
It realizes cross-platform code reuse, improves development efficiency, and makes it easier to migrate converted information to a new platform, solving the problem of functional compatibility.
Smart Images

Figure CN118642702B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of low-code development technology, and in particular to a cross-platform code generation method, device, equipment and storage medium. Background Art
[0002] At present, the current technology route mainly involves the use of cross-platform frameworks (such as React Native, Flutter and other application development frameworks) to implement a set of codes on multiple operating systems (iOS, Android and other operating systems), combining cloud services and APIs (Application Programming Interface) to handle back-end logic and data storage, and using visual design tools and pre-built modules to accelerate the development of front-end interfaces. This method can be used to solve the cross-platform development problems of iOS and Android, which can greatly improve the efficiency of development. However, in the digital transformation business of enterprises, there are a large number of computer-side and mobile-side applications coexisting, and the current technology cannot solve the compatibility and development problems of functions on the computer and mobile terminals.
[0003] It can be seen that how to realize cross-platform operation of application programs is a problem to be solved in this field. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a cross-platform code generation method, device, equipment and storage medium, which uses a semantic model to convert the functional interface of the first platform into information that has no dependency on the platform; the corresponding functional interface can be parsed and run on the second platform based on an adapter; developers write code logic once and can run on multiple platforms, thereby improving code reusability. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a cross-platform code generation method, comprising:
[0006] Determine the functional interface running on the first platform;
[0007] Extracting parameters from the functional information of the functional interface to obtain corresponding functional configuration information;
[0008] The function configuration information is converted based on a preset semantic model to obtain corresponding converted information; the preset semantic model is a model for describing the configuration information that has no dependency on any platform;
[0009] The converted information is parsed using an adapter corresponding to the second platform, and the functional interface is run on the second platform based on the code corresponding to the functional interface obtained by the parsing.
[0010] Optionally, determining the functional interface running on the first platform includes:
[0011] Displaying several components, several business logics and several data models for building a functional interface through a preset visual designer of the first platform, and obtaining corresponding functional interface building instructions; the data model is a data structure and relationship;
[0012] A target functional interface corresponding to the functional interface building instruction is built on the first platform using the components, the business logics and the data model.
[0013] Optionally, the extracting parameters of the function information of the function interface to obtain corresponding function configuration information includes:
[0014] Extracting parameters of the function information of the target function interface respectively to obtain first configuration information corresponding to the component, second configuration information corresponding to the business logic, and third configuration information corresponding to the data model;
[0015] The first configuration information, the second configuration information and the third configuration information are packaged based on a preset data format to obtain function configuration information of the target function interface corresponding to the first platform.
[0016] Optionally, converting the function configuration information based on a preset semantic model to obtain corresponding converted information includes:
[0017] The components, business logic and data model in the functional configuration information are described based on a preset semantic model, so as to convert the functional configuration information to obtain corresponding converted information.
[0018] Optionally, the parsing and processing the converted information by using an adapter corresponding to the second platform includes:
[0019] Determine a target adapter corresponding to the platform type of the second platform from the preset platform adapters so that the converted information can be processed using the target adapter; the preset platform adapter is a pre-set adapter used to parse the converted information corresponding to the preset semantic model to obtain program code adapted to its own platform type.
[0020] Optionally, the using an adapter corresponding to the second platform to parse the converted information, and running the functional interface on the second platform based on the code corresponding to the functional interface obtained by parsing, includes:
[0021] parsing the converted information using the target adapter corresponding to the second platform to obtain corresponding parsed information;
[0022] The parsed information is filled into a code generation template in the target adapter to obtain a code corresponding to the functional interface, and the functional interface is run on the second platform based on the code.
[0023] Optionally, running the function interface on the second platform based on the code includes:
[0024] The code is run through the code compilation template and code running framework information corresponding to the second platform in the target adapter to run the function interface on the second platform.
[0025] In a second aspect, the present application provides a cross-platform code generation device, comprising:
[0026] A function interface determination module, used to determine the function interface running on the first platform;
[0027] A parameter extraction module is used to extract parameters from the function information of the function interface to obtain corresponding function configuration information;
[0028] A conversion module, used to convert the functional configuration information based on a preset semantic model to obtain corresponding converted information; the preset semantic model is a model for describing configuration information that has no dependency on any platform;
[0029] The parsing module is used to parse the converted information using an adapter corresponding to the second platform, and run the functional interface on the second platform based on the code corresponding to the functional interface obtained by the parsing.
[0030] In a third aspect, the present application provides an electronic device, including:
[0031] Memory, used to store computer programs;
[0032] A processor is used to execute the computer program to implement the cross-platform code generation method as described above.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the cross-platform code generation method as described above.
[0034] It can be seen that the present application first determines the function interface running on the first platform; extracts parameters from the function information of the function interface to obtain the corresponding function configuration information; then converts the function configuration information based on the preset semantic model to obtain the corresponding converted information; the preset semantic model is a model for describing configuration information that has no dependency on any platform; then uses the adapter corresponding to the second platform to parse and process the converted information, and runs the function interface on the second platform based on the code corresponding to the function interface obtained by parsing. In this way, the present application can extract parameters from the function interface running on the first platform, and use the semantic model to convert the function configuration information of the relevant function interface into converted information that has no dependency on the platform; further, the converted information can be parsed into the code corresponding to the second platform through the adapter corresponding to the second platform, so that the corresponding function interface can be run on the second platform based on the code parsed by the adapter; the developer writes the code logic once and can run it on multiple platforms, which improves the code reusability; and the semantic model that does not rely on any platform can make the converted information easier to migrate to the new platform. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0036] Figure 1 A flow chart of a cross-platform code generation method disclosed in this application;
[0037] Figure 2 A flow chart of a specific cross-platform code generation method disclosed in this application;
[0038] Figure 3 This is a schematic diagram of the structure of a cross-platform code generation device disclosed in this application;
[0039] Figure 4 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] See also Figure 1 As shown, an embodiment of the present invention discloses a cross-platform code generation method, including:
[0042] Step S11, determining a function interface running on the first platform.
[0043] In the embodiment of the present application, when the function interface running on the first platform is transferred to another platform, it is first necessary to determine the function interface that can be run in the current first platform; for example, the construction of the relevant function interface can be completed through a rich interface and function design program on the computer side. In a specific embodiment, the function interface determined to be running on the first platform may include: displaying a number of components, a number of business logics and a number of data models used to build the function interface through the preset visual designer of the first platform, and obtaining the corresponding function interface construction instructions; the data model is a data structure and relationship; using the several components, the several business logics and the data model to build the target function interface corresponding to the function interface construction instruction on the first platform. Specifically, on the first platform, a visual designer can be pre-set, including a rich UI (User Interface) component library, which can be built by dragging and dropping; arrange the front-end and back-end functions through a visual method, bind the business logic with the interface components, and provide a number of data models to define the structure and relationship of the data, and provide data support for the interface; the rapid construction of the function interface can be achieved through a visual operation method.
[0044] Step S12: extracting parameters from the function information of the function interface to obtain corresponding function configuration information.
[0045] In the embodiment of the present application, after determining the function interface, it is necessary to extract parameters of the function information of the function interface and convert the function interface into corresponding function configuration information. In a specific embodiment, the function information of the function interface is extracted to obtain the corresponding function configuration information, which may include: extracting parameters of the function information of the target function interface respectively to obtain the first configuration information corresponding to the component, the second configuration information corresponding to the business logic, and the third configuration information corresponding to the data model; packaging the first configuration information, the second configuration information, and the third configuration information based on the preset data format to obtain the function configuration information of the target function interface corresponding to the first platform. Specifically, extracting the corresponding configuration information for the UI components, business logic, and data models in the function interface respectively may include extracting the configuration information required for the deployment of the application corresponding to the function interface; after extracting all the function configuration information corresponding to the function interface, for the convenience of storage and transmission, the information may be packaged, and the function configuration information may be described based on JSON (JavaScript Object Notation, a data exchange format) or XML (eXtensible Markup Language).
[0046] Step S13: convert the function configuration information based on a preset semantic model to obtain corresponding converted information; the preset semantic model is a model for describing configuration information that has no dependency on any platform.
[0047] Furthermore, in an embodiment of the present application, the functional configuration information obtained in the above steps is in a form that has a relationship with the first platform. On this basis, the functional configuration information obtained above can be converted using a preset semantic model. The semantic model is a pre-set model for describing UI components, layouts, styles, business logic, and data models. The functional configuration information is converted into an intermediate representation that has no dependency on any platform through the semantic model to obtain the corresponding converted information.
[0048] In a specific embodiment, the converting the function configuration information based on the preset semantic model to obtain the corresponding converted information may include: describing the components, business logic and data model in the function configuration information based on the preset semantic model to convert the function configuration information to obtain the corresponding converted information. The components, business logic and data model in the function configuration information are converted by the preset semantic model respectively, and the converted information that has no dependency on any platform can be obtained. In a specific embodiment, the semantic model may include 1. Component: basic UI building blocks, such as buttons, text boxes, lists, etc. 2. Property: characteristics of components, such as color, size, text content, etc. 3. Event: actions triggered when users interact with components, such as clicks, touches, inputs, etc. 4. Behavior: the response of a component to an event, which may be a change in internal state or a call to a backend service. 5. Layout: defines the position and arrangement of components on the interface. 6. Style: rules for visual expression, such as fonts, color schemes, animations, etc. 7. Data Model: The data structure and data flow of the application, defining the type, source, and interaction method of the data. For example, the intermediate representation of a button component after being processed by the semantic model is:
[0049] {
[0050] "component": "Button",
[0051] "properties": {
[0052] "text": "Click Me",
[0053] "backgroundColor": "#FF5733",
[0054] "fontSize": "14px"
[0055] },
[0056] "events": {
[0057] "onClick": "submitForm"
[0058] },
[0059] "style": {
[0060] "hover": {
[0061] "backgroundColor": "#FF7E66"
[0062] }
[0063] },
[0064] "layout": {
[0065] "position": "center",
[0066] "size": {
[0067] "width": "200px",
[0068] "height": "50px"
[0069] }
[0070] },
[0071] "dataBindings": {
[0072] "disabled": "form.isSubmitting"
[0073] }
[0074] }
[0075] Among them, this button component has properties such as text, background color, font size, a click event is bound to the submitForm behavior, the style defines the background color change on hover, the layout specifies the position and size of the button, and the data binding specifies that the disabled state of the button is associated with the form submission state.
[0076] Step S14: parse and process the converted information using an adapter corresponding to the second platform, and run the functional interface on the second platform based on the code corresponding to the functional interface obtained by the analysis.
[0077] In the embodiment of the present application, the above steps can be used to obtain converted information of the functional interface corresponding to the first platform that has no dependency on any platform, and then the converted information is parsed by an adapter corresponding to the second platform; it should be pointed out that the adapter is a development tool that is seamlessly integrated with the second platform, and can parse the converted information to obtain the code of the functional interface that matches the second platform; and then run the functional interface on the second platform.
[0078] In a specific embodiment, the use of the adapter corresponding to the second platform to parse and process the converted information may include: determining a target adapter corresponding to the platform type of the second platform from the preset platform adapter, so as to use the target adapter to process the converted information; the preset platform adapter is a pre-set adapter, which is used to parse the converted information corresponding to the preset semantic model to obtain program code adapted to its own platform type. It is understandable that the second platform may include multiple platforms, each of which has its own platform adapter; in a specific embodiment, the converted information is processed by the target adapter corresponding to the second platform to obtain program code adapted to the corresponding platform.
[0079] In another specific embodiment, the use of the adapter corresponding to the second platform to parse the converted information, and running the functional interface on the second platform based on the code corresponding to the functional interface obtained by the analysis, may include: using the target adapter corresponding to the second platform to parse the converted information to obtain the corresponding parsed information; filling the parsed information into the code generation template in the target adapter to obtain the code corresponding to the functional interface, and running the functional interface on the second platform based on the code. Specifically, the target adapter corresponding to the second platform includes information such as code generation template, compilation template and running framework, which can parse and understand the converted information of the intermediate representation, fill the parsed information into the corresponding code generation template to obtain the code corresponding to the functional interface, and then based on the code, the corresponding functional interface can be run on the second platform to achieve platform migration of the code. Correspondingly, running the functional interface on the second platform based on the code may include: running the code through the code compilation template and code running framework information corresponding to the second platform in the target adapter to run the functional interface on the second platform. Specifically, the code corresponding to the functional interface can be obtained by running and parsing the code compilation template and the code running framework information of the target adapter, so that the corresponding functional interface can be run on the second platform.
[0080] It can be seen that the present application can enable developers to quickly design functional interfaces through a visual designer, reduce the amount of manually written code, and can extract parameters of the functional interface running on the first platform, and use the semantic model to convert the functional configuration information of the relevant functional interface into converted information that has no platform dependency; further, the converted information can be parsed into code corresponding to the second platform through an adapter corresponding to the second platform, so that the second platform can run the corresponding functional interface based on the code parsed by the adapter; developers write the code logic once and can run it on multiple platforms, which improves code reusability; and the semantic model that does not rely on any platform can make the converted information easier to migrate to the new platform.
[0081] like Figure 2 As shown, the embodiment of the present application discloses a cross-platform code generation method, including:
[0082] In an embodiment of the present application, a user can build a functional interface through a visual designer, and then the intermediate interpretation layer converts the parameters corresponding to the functional interface into a unified functional representation, and then the code conversion layer uses different platform adapters to complete the packaging and deployment of the functional interface.
[0083] Specifically, users can design the interface and functions of the functional interface through the visual designer, and design a functional interface that meets business needs with the help of the built-in UI components and front-end and back-end function arrangement of the visual designer. Specifically, using the rich UI component library provided by the visual designer, quickly build the basic framework of the interface by dragging and dropping, and set the properties and styles of the components, such as the text, color, size of the button, and the placeholder and validation rules of the input box. While designing the interface, arrange the front-end and back-end functions in a visual way, bind the business logic such as data addition, deletion, modification and query operations, workflow triggering, etc. with the interface components, and realize seamless integration of functions and interfaces. Design the data model through the visual designer, define the structure and relationship of the data in the application, and provide data support for the interface.
[0084] The designer can then extract the user-designed functions into parameter form, which represents the layout, style, interaction logic, parameters and other configuration information of the interface and functions. First, the designer will identify all UI components on the interface and capture their respective properties, such as the text, color, size of buttons, and the placeholders and validation rules of input boxes. Next, the designer will parameterize the layout and style information, and record the position, size, spacing and alignment of components in detail, usually in the form of CSS (Cascading Style Sheets) styles or layout parameters. The event binding and interaction logic of components, such as the mapping of button click events to backend API calls, will also be recorded in detail and parameterized. At the same time, the user-defined data model and data binding information, including data sources, field types, data validation rules, etc., will also be extracted and serialized. The configuration of business logic, such as workflow, conditional judgment, loop, etc., will be converted into executable logic configuration parameters after being arranged by visual tools. The definition of front-end and back-end interactions, including data request and response formats, API call methods, data transmission parameters, etc., will also be clearly defined and parameterized. Security and permission settings, such as user authentication, authorization rules, data access permissions, etc., will also be extracted as parameters to ensure the security of the application. In addition, the configuration information required for application deployment, such as server settings, environment variables, third-party service integration, etc., will also be collected and serialized. All these parameters and configuration information will be packaged into a format that can be stored and transmitted, such as JSON or XML, for further processing. It is a high-level description of the application, which contains all the logic and structure information of the application, but has not yet been converted into platform-specific code.
[0085] Furthermore, based on the above steps, the intermediate interpretation of this embodiment can output a unified, abstract code representation (i.e., the converted information in the above embodiment) through a pre-set semantic model, and the intermediate representation can be understood by different platform converters. Specifically, cross-platform semantic definition: define a cross-platform semantic model that can describe UI components, layouts, styles, business logic, and data models. Intermediate representation generation: convert the high-level description of the interpretation layer into an intermediate representation, ensuring that it contains enough information to support multi-platform development. Platform independence: ensure that the intermediate representation does not depend on the development language or framework of any specific platform.
[0086] Then, the code of the corresponding platform is generated through the adapter. First, the standardized UI components, layouts, styles, events, data models, and business logic are parsed, and then mapped to the platform development environment. For example, the UI components are converted to Android views and controls, the layout description is converted to XML layout files, and the corresponding styles and themes are applied. The event processing logic is bound to the event listener of Android, and the data model is adapted to the local database or network service. The implementation of the business logic calls the Android API or integrates third-party services. It should be pointed out that the adapter is seamlessly integrated with popular Android IDEs (such as Android Studio, Android development tools) to provide a consistent and efficient development experience. Through such a design, the Android code adapter can effectively convert the standardized parameters of the low-code platform into high-quality code that can run on the Android platform, realizing fast and reliable cross-platform application development. In this way, the converted information of the intermediate representation generated by the above steps of the adapter can be parsed into the code of a specific platform (Web, iOS, Android); specifically, in the code conversion layer, this step can include three adapters: PC (personal computer, personal computer) end, Android end, and iOS end, and the adapter contains code generation templates, code compilation templates, and code running framework information. Based on the unified representation, the adapter can parse and understand the intermediate representation provided by the intermediate interpretation layer, and generate source code for the corresponding platform by combining template-driven and dynamic generation methods. Then the parsed code is filled into the code generation template, and the converted information of the intermediate representation is compiled into the code of the target running platform according to the compilation template.
[0087] It can be seen from this that the present application can perform parameter extraction on the functional interface running on the first platform, and use the semantic model in the intermediate interpretation layer to convert the functional configuration information of the relevant functional interface into converted information that has no platform dependency. The application does not directly depend on the technology stack of a specific platform, making it easier for the application to migrate to the new platform; further, the converted information can be parsed into code corresponding to the second platform through an adapter corresponding to the second platform, so that the second platform can run the corresponding functional interface based on the code parsed by the adapter; the developer writes the code logic once and can run it on multiple platforms, which improves code reusability; and the semantic model that does not rely on any platform can make the converted information easier to migrate to the new platform.
[0088] like Figure 3 As shown, the embodiment of the present application discloses a cross-platform code generation device, including:
[0089] A function interface determination module 11, used to determine the function interface running on the first platform;
[0090] The parameter extraction module 12 is used to extract parameters from the function information of the function interface to obtain corresponding function configuration information;
[0091] The conversion module 13 is used to convert the function configuration information based on a preset semantic model to obtain corresponding converted information; the preset semantic model is a model for describing the configuration information that has no dependency on any platform;
[0092] The parsing module 14 is used to parse the converted information using an adapter corresponding to the second platform, and run the functional interface on the second platform based on the code corresponding to the functional interface obtained by the parsing.
[0093] It can be seen that the present application can extract parameters of the functional interface running on the first platform, and use the semantic model to convert the functional configuration information of the relevant functional interface into converted information that has no platform dependency; further, the converted information can be parsed into code corresponding to the second platform through an adapter corresponding to the second platform, so that the second platform can run the corresponding functional interface based on the code parsed by the adapter; the developer writes the code logic once and can run it on multiple platforms, which improves the code reusability; and the semantic model that does not rely on any platform can make the converted information easier to migrate to the new platform.
[0094] In a specific embodiment, the function interface determination module 11 may include:
[0095] An instruction acquisition unit, used to display several components, several business logics and several data models for building a functional interface through a preset visual designer of the first platform, and acquire corresponding functional interface building instructions; the data model is a data structure and relationship;
[0096] A function interface building unit is used to build a target function interface corresponding to the function interface building instruction on the first platform by using the several components, the several business logics and the data model.
[0097] In a specific embodiment, the parameter extraction module 12 may include:
[0098] A parameter extraction unit, used to extract parameters from the function information of the target function interface respectively, to obtain first configuration information corresponding to the component, second configuration information corresponding to the business logic, and third configuration information corresponding to the data model;
[0099] An information packaging unit is used to package the first configuration information, the second configuration information and the third configuration information based on a preset data format to obtain function configuration information of the target function interface corresponding to the first platform.
[0100] In a specific embodiment, the conversion module 13 may include:
[0101] An information conversion unit is used to describe the components, business logic and data model in the function configuration information based on a preset semantic model, so as to convert the function configuration information to obtain corresponding converted information.
[0102] In a specific embodiment, the parsing module 14 may include:
[0103] An adapter determination unit is used to determine a target adapter corresponding to the platform type of the second platform from a preset platform adapter so as to process the converted information using the target adapter; the preset platform adapter is a pre-set adapter used to parse the converted information corresponding to a preset semantic model to obtain a program code adapted to its own platform type.
[0104] In another specific embodiment, the parsing module 14 may include:
[0105] An information parsing unit, configured to parse the converted information using the target adapter corresponding to the second platform to obtain corresponding parsed information;
[0106] An information filling unit is used to fill the parsed information into the code generation template in the target adapter, obtain the code corresponding to the functional interface, and run the functional interface on the second platform based on the code.
[0107] In another specific embodiment, the parsing module 14 may include:
[0108] A code running unit is used to run the code through the code compilation template corresponding to the second platform and the code running framework information in the target adapter, so as to run the function interface on the second platform.
[0109] Furthermore, the present application also discloses an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0110] Figure 4A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the cross-platform code generation method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0111] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0112] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0113] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the cross-platform code generation method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0114] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the cross-platform code generation method disclosed above. The specific steps of the method can refer to the corresponding contents disclosed in the above embodiments, and will not be repeated here.
[0115] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0116] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0117] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0118] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0119] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A cross-platform code generation method, characterized in that: include: Determine the functional interface running on the first platform through a visual designer; Extracting parameters of the functional information of the functional interface through the visual designer to obtain corresponding functional configuration information; Convert the function configuration information based on a preset semantic model to obtain corresponding converted information; The preset semantic model is a model for describing configuration information that has no dependency on any platform; The converted information is parsed using a target adapter corresponding to the platform type of the second platform determined from the preset platform adapter, and the functional interface is run on the second platform based on the code corresponding to the functional interface obtained by the parsing; wherein the preset platform adapter is a pre-set adapter, which is used to parse the converted information corresponding to the preset semantic model to obtain a program code adapted to its own platform type, and the target adapter is seamlessly integrated with the development tool of the second platform; Wherein, determining the functional interface running on the first platform through the visual designer includes: Displaying several components, several business logics and several data models for building a functional interface through a preset visual designer of the first platform, and obtaining corresponding functional interface building instructions; the data model is a data structure and relationship; Using the plurality of components, the plurality of business logics and the data model, a target functional interface corresponding to the functional interface building instruction is built on the first platform; The step of extracting parameters from the function information of the function interface by the visual designer to obtain corresponding function configuration information includes: By using the visual designer, parameter extraction is performed on the function information of the target function interface to obtain first configuration information corresponding to the component, second configuration information corresponding to the business logic, and third configuration information corresponding to the data model; The first configuration information, the second configuration information and the third configuration information are packaged based on a preset data format to obtain function configuration information of the target function interface corresponding to the first platform; the function configuration information includes the extracted security permission information corresponding to the target function interface and the environment configuration information required for deployment; The converting of the function configuration information based on the preset semantic model to obtain corresponding converted information includes: Describing the components, business logic and data model in the function configuration information based on a preset semantic model, so as to convert the function configuration information to obtain corresponding converted information; Wherein, the target adapter includes code generation template, code compilation template and code running framework information; Correspondingly, the process of parsing the converted information using a target adapter corresponding to the platform type of the second platform determined from the preset platform adapter, and running the functional interface on the second platform based on the code corresponding to the functional interface obtained by the parsing includes: parsing the converted information using the target adapter corresponding to the second platform to obtain corresponding parsed information; Fill the parsed information into the code generation template in the target adapter to obtain the code corresponding to the functional interface, and run the code through the code compilation template corresponding to the second platform in the target adapter and the code execution framework information to run the functional interface on the second platform.
2. A cross-platform code generation device, characterized in that: include: A function interface determination module, used to determine the function interface running on the first platform through a visual designer; A parameter extraction module, used to extract parameters of the function information of the function interface through the visual designer to obtain corresponding function configuration information; A conversion module, used to convert the function configuration information based on a preset semantic model to obtain corresponding converted information; The preset semantic model is a model for describing configuration information that has no dependency on any platform; A parsing module, used to parse the converted information using a target adapter corresponding to the platform type of the second platform determined from the preset platform adapter, and run the functional interface on the second platform based on the code corresponding to the functional interface obtained by the parsing; wherein the preset platform adapter is a pre-set adapter, used to parse the converted information corresponding to the preset semantic model to obtain a program code adapted to its own platform type, and the target adapter is seamlessly integrated with the development tool of the second platform; Wherein, the function interface determination module includes: An instruction acquisition unit, used to display several components, several business logics and several data models for building a functional interface through a preset visual designer of the first platform, and acquire corresponding functional interface building instructions; the data model is a data structure and relationship; A function interface building unit, used to build a target function interface corresponding to the function interface building instruction on the first platform by using the components, the business logics and the data model; Wherein, the parameter extraction module includes: A parameter extraction unit, used to extract parameters of the function information of the target function interface respectively through the visual designer to obtain first configuration information corresponding to the component, second configuration information corresponding to the business logic, and third configuration information corresponding to the data model; an information packaging unit, configured to package the first configuration information, the second configuration information, and the third configuration information based on a preset data format to obtain function configuration information of the target function interface corresponding to the first platform; the function configuration information includes the extracted security permission information corresponding to the target function interface and the environment configuration information required for deployment; Wherein, the conversion module includes: An information conversion unit, used to describe the components, business logic and data model in the function configuration information based on a preset semantic model, so as to convert the function configuration information to obtain corresponding converted information; The target adapter includes a code generation template, a code compilation template, and code execution framework information; correspondingly, the parsing module includes: An information parsing unit, configured to parse the converted information using the target adapter corresponding to the second platform to obtain corresponding parsed information; An information filling unit is used to fill the parsed information into the code generation template in the target adapter to obtain the code corresponding to the functional interface, and run the code through the code compilation template corresponding to the second platform in the target adapter and the code running framework information to run the functional interface on the second platform.
3. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the cross-platform code generation method as claimed in claim 1.
4. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the cross-platform code generation method as claimed in claim 1.
