Terminal adaptation method and device for application development, electronic equipment and storage medium
By receiving mobile service requests from cross-platform development clients and converting desktop Schema files into mobile Schema files, the existing low-code platforms need to maintain a large number of platform adaptation switching branches and complex judgment logic when generating application code, achieving higher application performance and network security performance, and improving code generation efficiency.
Patent Information
- Application Number
- CN202510003524.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-06
AI Technical Summary
When generating application code, existing low-code platforms need to maintain a large number of platform adaptation switching branches and complex judgment logic, resulting in degradation of application performance, security risks, and increasing the burden on low-code platforms.
By receiving the mobile service request from the cross-platform development client, obtain the desktop Schema file of the target application, and call the Schema converter to convert it into a mobile Schema file. Based on the mobile Schema file, the terminal adaptation is realized.
There is no need to maintain switching branches and complex logic in the same code, the code is more concise, which improves application performance, enhances network security performance, reduces the burden on code generators, and improves the efficiency of application code generation.
Smart Images

Figure CN119938137A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software startup, and in particular to a terminal adaptation method, device, electronic device and storage medium for application development. Background Art
[0002] During the application development process, in order to avoid the need for developers to write application codes for mobile platforms and desktop platforms respectively to adapt to desktop and mobile platforms, low-code platforms that can develop applications across platforms have appeared on the market.
[0003] When generating application code, the current low-code platform needs to add the switching business logic between mobile and desktop in the same code. When the application is running, the business logic is dynamically switched according to the mobile or desktop platform environment to adapt to the mobile or desktop. For example, when rendering the component, the corresponding rendering logic will be selected according to the environmental detection results. If it is a desktop, the desktop rendering logic will be used; if it is a mobile, the mobile rendering logic will be used. Or the mouse hover event on the desktop needs to be converted into a touch event on the mobile.
[0004] Existing low-code platforms generate code for mobile and desktop applications, and need to maintain a large number of branch switches and complex judgment logic for desktop and mobile terminals in the same code. On the one hand, the code should be large and complex, which reduces the performance of the application, and the runtime environment information needs to be retained in the application code. The exposed runtime environment is easy to become a target of vulnerability attacks, posing a security risk. On the other hand, when the low-code platform generates application code, it needs to generate a large number of branch switches and complex judgment logic codes, which increases the burden on the code platform, reduces the efficiency of application code generation, and affects application editing, previewing, and publishing. Summary of the invention
[0005] The present invention provides a terminal adaptation method, device, electronic device and storage medium for application development to solve the problem that when the existing low-code platform generates application code, it is necessary to maintain a large number of platform adaptation switching branches and judgment logic, which leads to reduced application performance, security risks and increased burden on the low-code platform.
[0006] In a first aspect, the present invention provides a terminal adaptation method for application development, comprising:
[0007] Receiving a mobile terminal service request for a target application sent by a cross-platform development client, wherein the mobile terminal service request includes one of switching to a mobile terminal editing mode, mobile terminal preview, and target application publishing;
[0008] Obtain the desktop Schema file of the target application;
[0009] Calling a Schema converter to convert the desktop Schema file into a mobile Schema file;
[0010] Respond to the mobile terminal service request based on the mobile terminal Schema file.
[0011] In a second aspect, the present invention provides a terminal adaptation device for application development, comprising:
[0012] A mobile terminal service request receiving module, used to receive a mobile terminal service request for a target application sent by a cross-platform development client, wherein the mobile terminal service request includes one of switching to a mobile terminal editing mode, a mobile terminal preview, and a target application release;
[0013] A desktop Schema file acquisition module, used to acquire the desktop Schema file of the target application;
[0014] A Schema file conversion module, used to call a Schema converter to convert the desktop Schema file into a mobile Schema file;
[0015] The mobile terminal service request response module is used to respond to the mobile terminal service request based on the mobile terminal Schema file.
[0016] In a third aspect, the present invention provides an electronic device, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the terminal adaptation method for application development described in the first aspect of the present invention.
[0020] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a processor to implement the terminal adaptation method for application development described in the first aspect of the present invention when executed.
[0021] In a fifth aspect, the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the terminal adaptation method for application development described in the first aspect.
[0022] When receiving a mobile terminal service request such as switching a target application to a mobile terminal editing mode, mobile terminal preview, and target application publishing sent by a cross-platform development client, the embodiment of the present invention obtains a desktop terminal Schema file of the target application, first calls a Schema converter to convert the desktop terminal Schema file into a Schema file suitable for the mobile terminal format, and responds to the mobile terminal service request based on the Schema file in the mobile terminal format, thereby realizing adaptation of the mobile terminal service through the converted mobile terminal Schema file, without the need to maintain a switching branch and complex logic for switching to the mobile terminal on the basis of the desktop terminal, the application codes of the mobile terminal and the desktop terminal are independent of each other, and there is no need to maintain a switching branch and complex logic in the same code, the code is more concise, the performance of the target application can be improved, and the relevant runtime environment of the mobile terminal and the desktop terminal does not need to be exposed in the code, thereby improving the network security performance of the target application. In addition, since the code is more concise, the burden of the development platform code generator can be reduced, the generation efficiency of the application code can be improved, and the efficiency of editing, previewing and publishing the application on the mobile terminal or desktop terminal can be improved.
[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 is a flow chart of a terminal adaptation method for application development provided by Embodiment 1 of the present invention;
[0026] Figure 2 is a flow chart of a terminal adaptation method for application development provided by Embodiment 2 of the present invention;
[0027] Figure 3 Traversing the data nodes for the depth-first traversal algorithm is a schematic diagram of the entry and exit stages;
[0028] Figure 4 Schematic diagram of page routing division;
[0029] Figure 5 is a flow chart of a terminal adaptation method for application development provided by Embodiment 3 of the present invention;
[0030] Figure 6It is a schematic diagram of the interaction between the user, platform and server when responding to the preview service;
[0031] Figure 7 is a flow chart of a terminal adaptation method for application development provided by a fourth embodiment of the present invention;
[0032] Figure 8 It is a structural diagram of a terminal adaptation device for application development provided by Embodiment 5 of the present invention;
[0033] Fig. 9 It is a schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention. DETAILED DESCRIPTION
[0034] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 should fall within the scope of protection of the present invention.
[0035] Embodiment 1
[0036] Figure 1 This is a flow chart of a terminal adaptation method for application development provided in the first embodiment of the present invention. This embodiment is applicable to the case where a cross-platform development client performs mobile terminal business processing during the application development process. The method can be executed by a terminal adaptation device for application development. The terminal adaptation device for application development can be implemented in the form of hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the terminal adaptation method developed by the application includes:
[0037] S101: receiving a mobile terminal service request for a target application sent by a cross-platform development client, where the mobile terminal service request includes one of switching to a mobile terminal editing mode, mobile terminal preview, and target application publishing.
[0038] In this embodiment, the target application may refer to an application that can be run on both the mobile terminal and the desktop terminal, wherein the mobile terminal may be a mobile phone, a tablet computer, a personal digital assistant, etc., and the desktop terminal may refer to a desktop computer, a laptop computer, a workstation, etc. The cross-platform development client may be an application development platform that is suitable for both the mobile terminal and the desktop terminal. For example, in the cross-platform development client, the user may first design and develop a desktop application, and then generate application code suitable for the mobile terminal and the desktop terminal through the cross-platform development client. In the prior art, the cross-platform development client generates a code for an application, and there are a large number of mobile terminal and desktop terminal switching branches and complex logic judgments in the code, so that the application code detects whether the operating environment is a desktop terminal or a mobile terminal at runtime, and executes corresponding logic according to the detection environment to adapt to mobile terminal services and desktop terminal services.
[0039] In this embodiment, the mobile terminal service request may be a request related to the mobile terminal in the process of designing and developing the target application in the cross-platform development client. For example, the mobile terminal service request may include:
[0040] Switch to mobile editing mode: Usually, application development is performed on a personal PC or laptop. The default editing page of the cross-platform development client is in desktop editing mode. When the user needs to edit the relevant functions of the design target application on the mobile terminal, the editing page needs to be switched to mobile editing mode. The business request to switch to mobile editing mode can be generated through the relevant controls of the cross-platform development client.
[0041] Mobile preview: When a cross-platform development client needs to preview the display effect of the target application on the mobile terminal, a mobile service request for mobile preview can be generated.
[0042] Release: When the target application development is completed and the mobile and desktop application packages need to be released, a release request can be generated.
[0043] After the cross-platform development client generates a mobile terminal service request, the mobile terminal service request can be sent to the server, and the server receives the mobile terminal service request.
[0044] S102: Obtain the desktop Schema file of the target application.
[0045] A Schema file can be a data file generated by a user after editing a target application in a cross-platform development client and stored in a server. A Schema file refers to the definition of a data model or data structure, which describes how data is organized, field types, and their relationships. Schema files allow users to design and manage applications through a graphical or simplified interface without writing complex code, and are the basis for building applications.
[0046] In this embodiment, the desktop Schema file may be a file of a target desktop application developed by a user. In actual applications, a desktop application is usually developed first, and the desktop Schema file of the target application can be read from a database on a server.
[0047] S103, calling a Schema converter to convert the desktop Schema file into a mobile Schema file.
[0048] The target application is mainly composed of pages and components in the pages. In this embodiment, relevant components of the desktop and mobile terminals can be developed in advance. After switching the desktop target application to obtain the desktop Schema file, the data nodes in the desktop Schema file can be traversed by the Schema converter to convert the page routes and components. Specifically, the conversion rule can be to convert all routing pages into first-level routing pages (the mobile terminal usually has only a single first-level route), and replace the desktop components with mobile components. The Schema converter traverses and converts the data nodes in the desktop Schema file according to the above conversion rules, and obtains the mobile Schema file after the conversion.
[0049] S104: Respond to the mobile terminal service request based on the mobile terminal Schema file.
[0050] Specifically, different mobile service requests can be processed differently based on the mobile Schema file. For example, for switching to the mobile editing page, the corresponding mobile editing page can be generated based on the mobile Schema file and returned to the cross-platform development client; for mobile preview service requests, the mobile application code can be generated based on the mobile Schema file, and the mobile preview page is generated by the mobile application code and sent to the user for preview; for publishing requests, the mobile code of the target application can be generated based on the mobile Schema file, and the desktop code of the target application can be generated based on the desktop Schema file, and the mobile application package and desktop application package of the target application can be obtained by packaging the mobile code and the desktop code respectively, and the mobile application package and the desktop application package can be published.
[0051] When receiving a mobile terminal service request such as switching a target application to a mobile terminal editing mode, mobile terminal preview, and target application publishing sent by a cross-platform development client, the embodiment of the present invention obtains a desktop terminal Schema file of the target application, first calls a Schema converter to convert the desktop terminal Schema file into a Schema file suitable for the mobile terminal format, and responds to the mobile terminal service request based on the Schema file in the mobile terminal format, thereby achieving adaptation of the mobile terminal service through the converted mobile terminal Schema file, eliminating the need to maintain switching branches and complex logic for switching to the mobile terminal on the basis of the desktop terminal, and eliminating the need to maintain switching branches and complex logic in the same code. The code is more concise, which can improve the performance of the target application, and there is no need to expose the relevant runtime environment of the mobile terminal and the desktop terminal in the code, thereby improving the network security performance of the target application. In addition, since the code is more concise, the burden of the development platform code generator can be reduced, the generation efficiency of the application code can be improved, and the efficiency of editing, previewing, and publishing the application on the mobile terminal or desktop terminal can be improved.
[0052] Embodiment 2
[0053] Figure 2 This is a flow chart of a terminal adaptation method for application development provided in the second embodiment of the present invention. The embodiment of the present invention optimizes the mobile terminal service request for switching to the mobile terminal editing mode based on the above-mentioned first embodiment, such as Figure 2 As shown, the terminal adaptation method developed by the application includes:
[0054] S201: Receive a service request sent by a cross-platform development client for switching a target application to a mobile terminal editing mode.
[0055] In this embodiment, the cross-platform development client can implement visual editor switching, that is, when the user edits the target application on the cross-platform development client, the design editing interface can freely switch between the mobile editing mode and the desktop editing mode. Exemplarily, the design editing interface is provided with "Switch to Desktop" and "Switch to Mobile" controls. The design editing interface displays the desktop editing by default. When the user chooses to click "Switch to Mobile", the editor of the cross-platform development client will automatically adjust the design editing interface to the mobile editing mode; conversely, if "Switch to Desktop" is clicked, it will be converted to the desktop editing mode.
[0056] When the desktop editing mode is currently in progress, if it is detected that the user chooses to click the "Switch to Mobile" control, the cross-platform development client generates a business request to switch to the mobile editing mode and sends it to the server, and the server receives the mobile business request.
[0057] S202: Obtain the desktop Schema file of the target application.
[0058] In one embodiment, the mobile service request may include a target application identifier, and the server may read the latest desktop Schema file of the target application from the database through the target application identifier. The desktop Schema file describes the desktop data model of the target application.
[0059] S203, calling the Schema converter to traverse the data nodes in the desktop Schema file according to the depth-first traversal algorithm.
[0060] The desktop Schema file organizes data in a tree structure. In order to realize the conversion of the desktop Schema file, it is necessary to access each data node in the desktop Schema file so as to modify, delete or replace it, and finally achieve the purpose of converting it into a mobile Schema file. In one embodiment, the data nodes in the desktop Schema file can be traversed by a depth-first traversal algorithm. Depth-first traversal (DFS) is an algorithm for traversing a tree or graph data structure. Its core idea is to start from a node and search the child nodes of the node as deeply as possible until it cannot continue, and then go back to the previous node to continue searching other child nodes until all nodes are visited. Depth-first traversal can be implemented by recursion. The basic steps of recursion include: marking the current node as visited (entering the stage), traversing all unvisited neighbor nodes of the current node, recursively visiting each neighbor node, and finally returning (exiting the stage) to the previous node to continue visiting other neighbor nodes.
[0061] S204. Each time a data node is traversed, the data node is converted according to a pre-configured conversion strategy to obtain a mobile-side Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes and modify the attributes of component nodes from desktop-side attributes to mobile-side attributes.
[0062] In the process of converting the desktop schema file, the way to process the current node needs to be determined based on the status of the child nodes. That is, the conversion operation of the parent node can only be performed after all its child nodes have completed the conversion. For example Figure 3 A schematic diagram of the depth-first traversal algorithm traversing the transition entry phase and exit phase, Figure 3 It can be seen that the depth-first traversal algorithm's access to nodes is divided into two stages, namely the entry stage and the exit stage. In the entry stage, the parent node is visited first, and then the child node is visited. In the exit stage, the child node is left first, and then the parent node is left. Therefore, processing the currently visited node in the exit stage can ensure that all its child nodes have been processed.
[0063] In an optional embodiment, during the entry phase of traversal, a conversion function is called each time a data node is traversed, and the type of the data node is obtained through the conversion function. If the type of the data node is the initial root node, traversal continues to the next data node. If the type of the data node is a routing node, it is determined whether the data node has a page node set. If so, traversal continues to the next data node. If not, a page node set of the data node is created, and traversal continues to the next data node. If the type of the data node is a page node, the data node is cached in the page node set of the routing node. If the type of the data node is a component node, the field attribute value of the component name of the data node is modified to the component name of the mobile terminal.
[0064] Specifically, Figure 4 The routing page is divided into primary routing, secondary routing, tertiary routing or quaternary routing. Figure 4 In the page shown, the entire page can be divided into first-level routes based on the page structure, and the dotted box part represents the content of the second-level route. On the mobile side, such as on a mobile phone, only the content of the second-level route in the dotted box needs to be displayed, so the second-level route needs to be converted to a first-level route. There is only a single first-level route on the mobile phone, so the conversion strategy can be to convert all routing nodes into first-level routing nodes and modify the attributes of the component nodes from desktop attributes to mobile attributes. Based on this conversion strategy, the depth-first traversal algorithm process of the desktop Schema file can be defined as follows:
[0065] S1, Initialization: Use the entire desktop Schema file as the starting node;
[0066] S2. Define a recursive function: The recursive function accepts the current node and its context as parameters and implements the following steps:
[0067] 1. Define the callback function array for the exit phase of the traversal;
[0068] 2. Execute the conversion function, which can return the callback function of the exit phase and cache it in the callback function array of the exit phase;
[0069] 3. Traverse the child nodes of the current node and call the defined recursive function on the child nodes;
[0070] 4. In the final stage, all callback functions cached in the callback function array of the exit stage are executed;
[0071] S3. Call recursive function: Call the recursive function starting from the starting node:
[0072] When traversing the desktop schema file, the conversion function is called each time a node is traversed. The conversion function performs the following judgment logic:
[0073] If the node has a viewsTree attribute, the node is determined to be the initial root node. If the node has a viewName attribute, the node is determined to be a page node. If the node has a componentName attribute, the node is determined to be a component node. If the node is a page node, if the value of its componentName is LowCodeRouterView, the node is determined to be a routing node. The conversion logic for different nodes is as follows:
[0074] In the entry phase, if it is the initial root node, no processing is done and no callback function is returned;
[0075] In the entry phase, if it is a routing node, check whether a page node set already exists. If no page node set exists, it means that the node is the first first-level routing node visited. Create an empty page node set and return a callback function to be executed at the exit phase of the node. Add all collected page nodes as child nodes of the node. If a page node set already exists, it means that all page node sets of the node have been collected. There is no need to create a page node set again, and no function needs to be returned.
[0076] In the entry phase, if it is a page node, the page node needs to be cached into the page node collection;
[0077] During the entry phase, if it is a component node, the component information stored therein needs to be converted into the component information of the mobile terminal, and the attribute value of the componentName field representing the component name is modified to the component name of the mobile terminal, for example, to the name of the corresponding component in the mobile terminal component library.
[0078] After the above conversion, all routing nodes of the desktop Schema file are converted to first-level routing nodes, and the componentName field attribute value in the component node is modified to the component name of the mobile terminal, realizing the replacement of desktop components to mobile components, thereby obtaining the converted mobile terminal Schema file.
[0079] S205: Call a renderer to render the mobile terminal Schema file to obtain a mobile terminal editing page.
[0080] Specifically, the renderer is used to render each node according to the information of the data node of the mobile-side Schema file to obtain the mobile-side editing page. The specific rendering method can refer to the rendering of the existing low-code platform and will not be described in detail here.
[0081] S206: Send the mobile terminal editing page to the cross-platform development client. After receiving the mobile terminal editing page, the cross-platform development client is used to switch from displaying the desktop terminal editing page to displaying the mobile terminal editing page.
[0082] After rendering the mobile-end editing page, the server may send the mobile-end editing page to the cross-platform development client, so that the cross-platform development client switches from displaying the desktop-end editing page to displaying the mobile-end editing page.
[0083] When receiving a mobile terminal service request to switch to the mobile terminal editing mode, this embodiment calls the Schema converter to traverse the data nodes in the desktop terminal Schema file according to the depth-first traversal algorithm, and converts the data node according to the pre-configured conversion strategy every time a data node is traversed to obtain the mobile terminal Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes, modify the attributes of the component nodes from desktop attributes to mobile terminal attributes, call the renderer to render the mobile terminal Schema file to obtain a mobile terminal editing page, and send the mobile terminal editing page to the cross-platform development client. The cross-platform development client is used to display the mobile terminal editing page after receiving the mobile terminal editing page. The desktop editing page switches to display the mobile editing page. Compared with the existing low-code platform, the Schema file remains unchanged. The mobile adaptation is achieved by changing the rendering logic according to whether it is a mobile terminal or a desktop terminal. The embodiment of the present invention first converts the desktop Schema file into a mobile terminal Schema file through a Schema converter. The mobile terminal Schema file renderer can directly determine the relevant information of the rendered component, and directly render the component nodes in the Schema file to adapt to the mobile terminal page editing business without additional processing, thereby improving the generation and display efficiency of the editing page, improving the user experience of the cross-platform development client and the development efficiency of the target application.
[0084] Embodiment 3
[0085] Figure 5 This is a flow chart of a terminal adaptation method for application development provided in Embodiment 3 of the present invention. Based on Embodiment 1 above, this embodiment of the present invention optimizes the mobile terminal preview mobile terminal service request, such as Figure 5 As shown, the terminal adaptation method developed by the application includes:
[0086] S501: Receive a first preview request for a target application from a cross-platform development client, where the first preview request includes a target application identifier.
[0087] During the development process or before release, the target application needs to be previewed to determine the effect. The user can trigger a first preview request for the target application in the cross-platform development client. The first preview request may include a target application identifier, which may be unique information representing the identity of the target application.
[0088] S502: Generate a first preview path and send it to a cross-platform development client, the cross-platform development client is used to pre-process the first preview path to obtain a second preview request including a second preview path, send the second preview request to a server, and load a preview page based on the second preview request.
[0089] After receiving the first preview request, the server may generate a first preview path including the target application identifier, and send the first preview path to the cross-platform development client. For example, after the user sends a preview request of the target application test_lskd through the cross-platform development client, the server generates a first preview path http: / / test_lskd.preview.xx.com and returns it to the cross-platform development client. The cross-platform development client modifies the first preview path http: / / test_lskd.preview.xx.com according to the development editing mode (mobile terminal or desktop terminal), or modifies the first preview path according to whether the developer selects the mobile terminal or the desktop terminal for preview. http: / / test_lskd.preview.xx.com is modified. For example, if it is necessary to preview the effect of the target application on the mobile terminal, the second preview path after the first preview path is modified is http: / / test_lskd.preview.xx.com / index-mobile.html# / viewA / viewB, wherein viewA and viewB represent the currently activated nodes. The cross-platform development client jumps to the second preview path in a new tab in the browser through the second preview path, waits for the preview page to be loaded from the server, and generates a second preview request including the second preview path and sends it to the server to request the preview service.
[0090] S503: Receive a second preview request.
[0091] S504: Obtain the desktop Schema file of the target application.
[0092] In one embodiment, the mobile service request may include a target application identifier, and the server may read the latest desktop Schema file of the target application from the database through the target application identifier. The desktop Schema file describes the desktop data model of the target application.
[0093] S505, calling the Schema converter to traverse the data nodes in the desktop Schema file according to the depth-first traversal algorithm;
[0094] S506. Each time a data node is traversed, the data node is converted according to a pre-configured conversion strategy to obtain a mobile-side Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes and modify the attributes of component nodes from desktop-side attributes to mobile-side attributes.
[0095] The above S505-S506 can refer to S203-S204 in Example 2. The difference is that in the entry stage of the traversal, if the type of the data node is a page node, the conversion function returns a callback function, and the callback function is used to adjust the dependency information of the component node under the page node to the dependency information of the mobile terminal. For example, the component library name of the component node is adjusted from design to design-mobile, and the component path is adjusted from component to component-mobile, so that when previewing the business, the conversion processing obtains the resource library on which the component node depends in the mobile terminal Schema file, which is converted from the desktop resource library to the mobile terminal resource library.
[0096] S507: Call a code generator to generate mobile terminal code of a target application based on the mobile terminal Schema file.
[0097] Specifically, the code generator may be called to generate the mobile code of the target application for the mobile Schema file, wherein the code generator may generate the code for the Schema file based on an existing low-code platform, and the embodiments of the present invention will not be described in detail herein.
[0098] S508: Generate a mobile terminal preview page of the target application based on the mobile terminal code.
[0099] For example, you can install mobile dependencies, such as open source code libraries, component libraries, Vue series packages, lodash tools, etc., and then render to generate a mobile preview page.
[0100] S509: Send the mobile terminal preview page to the cross-platform development client.
[0101] like Figure 6 The following is a schematic diagram of the interaction between the user, platform, and server during preview, as follows:
[0102] The user edits the application, and the platform saves the application schema to the server. The user issues a preview operation, and the low-code platform responds to the preview operation and requests the preview path from the server. The server returns the preview path to the platform. The platform processes the preview path according to the page nodes activated by the editor and the operating environment and displays the final preview link to the user. After the user automatically accesses the preview link, the platform requests the preview service from the server, and the server starts the preview process and returns the preview server page to the platform. The user previews the service page, and the platform queries the preview service status. After the server returns the preview status, the platform updates the preview server page status. After the server processes the preview service, the server redirects the application preview page to the platform.
[0103] When receiving a mobile terminal preview request for a target application from a cross-platform development client, this embodiment obtains a desktop terminal Schema file of the target application, calls a Schema converter to traverse the data nodes in the desktop terminal Schema file according to a depth-first traversal algorithm, and converts each data node according to a pre-configured conversion strategy when traversing to a data node to obtain a mobile terminal Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes, modify the attributes of component nodes from desktop terminal attributes to mobile terminal attributes, call a code generator to generate a mobile terminal code for the target application from the mobile terminal Schema file, generate a mobile terminal preview page for the target application based on the mobile terminal code, and convert the mobile terminal Schema file into a mobile terminal preview page. The terminal preview page is sent to the cross-platform development client. The desktop Schema file is first converted into a mobile Schema file through the Schema converter. The code generator can directly generate mobile code for the mobile Schema file to adapt to the mobile application preview business. The generated mobile code does not have switching branches and complex logic conversions between the mobile and desktop terminals. The mobile terminal code is more concise and does not require mobile and desktop operating environment information. It can quickly generate concise mobile terminal code, improve the performance of mobile applications, and ensure the network security of mobile applications. It can quickly generate mobile preview pages, improve the user experience of the cross-platform development client and the development efficiency of the target application.
[0104] Embodiment 4
[0105] Figure 7 This is a flow chart of a terminal adaptation method for application development provided in a fourth embodiment of the present invention. The present embodiment optimizes the publishing service of the target application based on the first embodiment above. Figure 7 As shown, the terminal adaptation method developed by the application includes:
[0106] S701: Receive a publishing request for a target application sent by a cross-platform development client.
[0107] After the target application is designed and previewed, the developer can trigger a publishing request for the target application through a publishing control of a cross-platform development client, and the server can receive the publishing request for the target application.
[0108] S702: Obtain the desktop Schema file of the target application.
[0109] In one embodiment, the mobile service request may include a target application identifier, and the server may read the latest desktop Schema file of the target application from the database through the target application identifier. The desktop Schema file describes the desktop data model of the target application.
[0110] S703 , calling the Schema converter to traverse the data nodes in the desktop Schema file according to the depth-first traversal algorithm.
[0111] S704. Each time a data node is traversed, the data node is converted according to a pre-configured conversion strategy to obtain a mobile-side Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes and modify the attributes of component nodes from desktop-side attributes to mobile-side attributes.
[0112] The above S703-S704 can refer to S203-S204 in Example 2. The difference is that in the entry stage of the traversal, if the type of the data node is a page node, the conversion function returns a callback function, and the callback function is used to adjust the dependency information of the component node under the page node to the dependency information of the mobile terminal. For example, the component library name of the component node is adjusted from design to design-mobile, and the component path is adjusted from component to component-mobile, so that when previewing the business, the conversion processing obtains the resource library on which the component node depends in the mobile terminal Schema file, which is converted from the desktop resource library to the mobile terminal resource library.
[0113] S705 . Call a code generator to generate application codes for the mobile-side Schema file and the desktop-side Schema file respectively, to obtain a mobile-side application code and a desktop-side application code.
[0114] Specifically, the embodiment of the present invention calls a code generator to generate application codes for the mobile-side Schema file and the desktop-side Schema file respectively, thereby obtaining the mobile-side application code and the desktop-side application code.
[0115] S706: Obtain mobile-side dependencies and desktop-side dependencies.
[0116] In this embodiment, the dependency can be an open source code library, such as a component library, a Vue series bucket, a lodash tool, etc. The Schema file contains the dependency information required for the application to run. The dependency information will be recorded in a fixed field in the Schema file. When the code generator generates the code, the dependency information is extracted into a file named package.json. After the code is generated, the node technology can be used to execute the npminstall command to complete the installation of the required dependencies.
[0117] S707: Pack the mobile application code and the mobile dependencies to obtain a mobile application package, and pack the desktop application code and the desktop dependencies to obtain a desktop application package.
[0118] Packaging can be the synthesis of generated code and required dependencies into one or more distributable files or file sets for easy distribution, deployment and installation. Specifically, the application code packaging can be completed by executing the packaging instruction of vite. When multi-terminal packaging is performed, the number of packaging entries is consistent with the number of terminals. For example, if you need to package the application packages for the desktop and mobile terminals, the packaging entries are entry.ts and entry-mobile.ts respectively. The code and dependencies are packaged through their respective packaging entries. The obtained application package only contains content related to itself. For example, the desktop packaging entry only packages the code and dependencies related to the desktop, and the mobile packaging entry only packages the code and dependencies related to the mobile terminal.
[0119] S708. Release the mobile application package and the desktop application package.
[0120] After obtaining the mobile application package and the desktop application package, the mobile application package and the desktop application package can be published and put on the shelves through various channels.
[0121] When receiving a publishing request for a target application sent by a cross-platform development client, an embodiment of the present invention obtains a desktop-side Schema file of the target application, calls a Schema converter to traverse data nodes in the desktop-side Schema file according to a depth-first traversal algorithm, converts the data node according to a pre-configured conversion strategy each time a data node is traversed to obtain a mobile-side Schema file, wherein the conversion strategy is to convert all routing nodes into first-level routing nodes, modify the attributes of component nodes from desktop-side attributes to mobile-side attributes, calls a code generator to generate application code for the mobile-side Schema file and the desktop-side Schema file respectively, obtains a mobile-side application code and a desktop-side application code, obtains mobile-side dependencies and desktop-side dependencies, packages the mobile-side application code and the mobile-side dependencies to obtain a mobile-side application package, and packages the desktop-side application code and the desktop-side dependencies into a package. The desktop application package is obtained by packaging, and the mobile application package and the desktop application package are released. Since application codes are generated for the mobile terminal and the desktop terminal respectively, the desktop application code is loaded when the target application on the desktop is accessed, and the mobile application code is loaded when the target application on the mobile terminal is accessed to adapt to the mobile application. Compared with the existing low-code platform that only generates one code and realizes the switching between the mobile terminal and the desktop terminal by judging the operating environment in one code, on the one hand, the independent mobile terminal code and desktop terminal code generated by the embodiment of the present invention do not require an operating environment judgment mechanism, and no business branch logic based on environment switching will appear during the operation process, which not only improves the performance of the application, but also avoids network security risks caused by variables related to the operating environment. In addition, there is no need to maintain the business branch logic of the mobile terminal and the desktop terminal when generating the code, the code is more concise, the burden on the code generator is reduced, and the code generation efficiency is higher.
[0122] Embodiment 5
[0123] Figure 8 This is a schematic diagram of the structure of a terminal adapter device for application development provided in Embodiment 5 of the present invention. Figure 8 As shown, the terminal adapter device developed by the application includes:
[0124] The mobile terminal service request receiving module 801 is used to receive a mobile terminal service request for a target application sent by a cross-platform development client, wherein the mobile terminal service request includes one of switching to a mobile terminal editing mode, mobile terminal preview, and target application publishing;
[0125] The desktop Schema file acquisition module 802 is used to acquire the desktop Schema file of the target application;
[0126] Schema file conversion module 803, used to call the Schema converter to convert the desktop Schema file into a mobile Schema file;
[0127] The mobile terminal service request response module 804 is used to respond to the mobile terminal service request based on the mobile terminal Schema file.
[0128] Optionally, the mobile terminal service request includes a request to switch to a mobile terminal editing mode, and the mobile terminal service request response module 804 includes:
[0129] A rendering unit, used for calling a renderer to render the mobile terminal Schema file to obtain a mobile terminal editing page;
[0130] The editing page sending unit is used to send the mobile terminal editing page to the cross-platform development client. After receiving the mobile terminal editing page, the cross-platform development client is used to switch from displaying the desktop terminal editing page to displaying the mobile terminal editing page.
[0131] Optionally, the mobile terminal service request is a mobile terminal preview request, and the mobile terminal service request receiving module 801 includes:
[0132] A first preview request receiving unit, configured to receive a first preview request from a cross-platform development client for a target application, wherein the first preview request includes a target application identifier;
[0133] The terminal adapter device for application development also includes:
[0134] A first preview path sending module, configured to generate a first preview path and send it to the cross-platform development client, wherein the cross-platform development client is configured to pre-process the first preview path to obtain a second preview request including a second preview path, send the second preview request to the server, and load a preview page based on the second preview request;
[0135] The second preview request receiving module is configured to receive the second preview request.
[0136] Optionally, the mobile terminal service request response module 804 includes:
[0137] A mobile terminal code generation unit, used for calling a code generator to generate a mobile terminal code of the target application from the mobile terminal Schema file;
[0138] A mobile terminal preview page generating unit, configured to generate a mobile terminal preview page of the target application based on the mobile terminal code;
[0139] The mobile terminal preview page sending unit is used to send the mobile terminal preview page to the cross-platform development client.
[0140] Optionally, the mobile terminal service request is a target application publishing request, and the mobile terminal service request response module 804 includes:
[0141] The mobile terminal and desktop terminal code generation unit is used to call the code generator to generate application code for the mobile terminal Schema file and the desktop terminal Schema file respectively, so as to obtain the mobile terminal application code and the desktop terminal application code;
[0142] Dependency acquisition unit, used to acquire mobile dependencies and desktop dependencies;
[0143] a packaging unit, configured to package the mobile application code and the mobile dependencies to obtain a mobile application package, and to package the desktop application code and the desktop dependencies to obtain a desktop application package;
[0144] A publishing unit is used to publish the mobile application package and the desktop application package.
[0145] Optionally, the Schema file conversion module 803 includes:
[0146] A variable unit, used to call a Schema converter to traverse the data nodes in the desktop Schema file according to a depth-first traversal algorithm;
[0147] The node conversion unit is used to convert the data node according to the pre-configured conversion strategy each time a data node is traversed to obtain a mobile terminal Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes and modify the attributes of the component nodes from desktop attributes to mobile terminal attributes.
[0148] Optionally, the node conversion unit includes:
[0149] A type determination subunit is used to call a conversion function each time a data node is traversed during the traversal entry phase, and obtain the type of the data node through the conversion function;
[0150] An initial root node processing subunit, used for continuing to traverse the next data node if the type of the data node is an initial root node;
[0151] A routing node processing subunit is used to determine whether the data node has a page node set if the data node is a routing node, and if so, continue to traverse the next data node; if not, create a page node set for the data node and continue to traverse the next data node;
[0152] A page node processing subunit, configured to cache the data node into a page node set of a routing node if the type of the data node is a page node;
[0153] The component node processing subunit is used to modify the field attribute value of the component name of the data node to the component name of the mobile terminal if the type of the data node is a component node.
[0154] Optionally, when the mobile terminal service request is a target application publishing request, the node conversion unit further includes:
[0155] The dependency information conversion subunit is used to, during the entry phase of traversal, if the type of the data node is a page node, the conversion function returns a callback function, and the callback function is used to adjust the dependency information of the component node under the page node to the dependency information of the mobile terminal.
[0156] The terminal adaptation device for application development provided in the embodiment of the present invention can execute the terminal adaptation method for application development provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0157] Embodiment 6
[0158] Fig. 9 A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0159] like Fig. 9 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0160] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0161] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 41 executes the various methods and processes described above, such as the terminal adaptation method for application development.
[0162] In some embodiments, the terminal adaptation method for application development may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the terminal adaptation method for application development described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to execute the terminal adaptation method for application development in any other appropriate manner (e.g., by means of firmware).
[0163] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0164] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0165] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer 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 of the foregoing.
[0166] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0167] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web previewer through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0168] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0169] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0170] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A terminal adaptation method for application development, characterized in that: Applicable to servers, including: Receiving a mobile terminal service request for a target application sent by a cross-platform development client, wherein the mobile terminal service request includes one of switching to a mobile terminal editing mode, mobile terminal preview, and target application publishing; Obtain the desktop Schema file of the target application; Calling a Schema converter to convert the desktop Schema file into a mobile Schema file; Respond to the mobile terminal service request based on the mobile terminal Schema file.
2. The method according to claim 1, characterized in that The mobile terminal service request includes a request to switch to a mobile terminal editing mode, and responding to the mobile terminal service request based on the mobile terminal Schema file includes: Calling a renderer to render the mobile terminal Schema file to obtain a mobile terminal editing page; The mobile terminal editing page is sent to the cross-platform development client, and the cross-platform development client is used to switch from displaying the desktop terminal editing page to displaying the mobile terminal editing page after receiving the mobile terminal editing page.
3. The method according to claim 1, characterized in that The mobile terminal service request is a mobile terminal preview request, and receiving a mobile terminal service request for a target application from a cross-platform development client includes: Receive a first preview request from a cross-platform development client for a target application, where the first preview request includes a target application identifier; Before obtaining the desktop Schema file of the target application, the method further includes: generating a first preview path and sending it to the cross-platform development client, wherein the cross-platform development client is used to pre-process the first preview path to obtain a second preview request including a second preview path, send the second preview request to the server, and load a preview page based on the second preview request; The second preview request is received.
4. The method according to claim 3, characterized in that Responding to the mobile terminal service request based on the mobile terminal Schema file includes: Calling a code generator to generate a mobile terminal code of the target application based on the mobile terminal Schema file; Generate a mobile terminal preview page of the target application based on the mobile terminal code; The mobile terminal preview page is sent to the cross-platform development client.
5. The method according to claim 1, characterized in that: The mobile terminal service request is a target application publishing request, and responding to the mobile terminal service request based on the mobile terminal Schema file includes: Calling a code generator to generate application codes for the mobile-side Schema file and the desktop-side Schema file respectively, to obtain a mobile-side application code and a desktop-side application code; Get mobile dependencies and desktop dependencies; Packing the mobile application code and the mobile dependencies to obtain a mobile application package, and packing the desktop application code and the desktop dependencies to obtain a desktop application package; The mobile application package and the desktop application package are released.
6. The method according to any one of claims 1 to 5, characterized in that: Calling a Schema converter to convert the desktop Schema file into a mobile Schema file includes: Calling the Schema converter to traverse the data nodes in the desktop Schema file according to the depth-first traversal algorithm; Each time a data node is traversed, the data node is converted according to a pre-configured conversion strategy to obtain a mobile-side Schema file. The conversion strategy is to convert all routing nodes into first-level routing nodes and modify the attributes of component nodes from desktop attributes to mobile-side attributes.
7. The method according to claim 6, characterized in that Each time a data node is traversed, the data node is converted according to the pre-configured conversion strategy to obtain a mobile terminal Schema file, including: In the entry phase of traversal, a conversion function is called each time a data node is traversed, and the type of the data node is obtained through the conversion function; If the type of the data node is an initial root node, continue traversing the next data node; If the type of the data node is a routing node, determine whether the data node has a page node set, if so, continue to traverse the next data node, if not, create a page node set for the data node, and continue to traverse the next data node; If the type of the data node is a page node, cache the data node into a page node set of the routing node; If the type of the data node is a component node, the field attribute value of the component name of the data node is modified to the component name of the mobile terminal.
8. A terminal adaptation device for application development, characterized in that: include: A mobile terminal service request receiving module, used to receive a mobile terminal service request for a target application sent by a cross-platform development client, wherein the mobile terminal service request includes one of switching to a mobile terminal editing mode, a mobile terminal preview, and a target application release; A desktop Schema file acquisition module, used to acquire the desktop Schema file of the target application; A Schema file conversion module, used to call a Schema converter to convert the desktop Schema file into a mobile Schema file; The mobile terminal service request response module is used to respond to the mobile terminal service request based on the mobile terminal Schema file.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the terminal adaptation method for application development according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the terminal adaptation method for application development according to any one of claims 1 to 7 when executed.