Generation method and device, electronic equipment, storage medium and computer program product
By parsing and serializing front-end source code files on the cloud platform, the amount of front-end code on embedded devices is reduced, the problem of transplantation and adaptation of front-end frameworks and language engines on embedded devices is solved, and storage and processing performance requirements are reduced. and development costs.
Patent Information
- Application Number
- CN202410531403.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2024-10-18
AI Technical Summary
Transplanting the front-end framework and front-end language engine involved in front-end development technology on embedded devices prevents developers from focusing on application development, and consumes a large amount of storage resources and processing performance. Low-end development boards are difficult to adapt, resulting in product costs. Increase.
By parsing the front-end source code files on the cloud platform, generating graphical user interface component information, serializing it, and sending it to the terminal device, it reduces the amount of front-end code running on the embedded device and reduces storage and processing performance requirements. Avoid the workload of porting and adapting front-end frameworks and language engines.
It reduces the amount of front-end code on embedded devices, reduces storage and processing performance requirements, avoids the workload of transplanting and adapting front-end development technology, and reduces development costs and product costs.
Smart Images

Figure CN118796176A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device, storage medium and computer program product for generating a graphical user interface. Background Art
[0002] In the prior art, application development requires porting the front-end framework and front-end language engine involved in the required front-end development technology to the embedded device to form a complete application running environment on the embedded device.
[0003] However, porting the front-end framework and language engine involved in front-end development technology to embedded devices will bring about the problem of porting and adaptation workload, which prevents developers from focusing on application development at the beginning of the project. In addition, the front-end framework and language engine will occupy a large amount of storage resources, which is several times the resources occupied by the necessary back-end programs of embedded devices, and the processing performance requirements of the onboard central processor are very high. Low-end development boards cannot adapt, which will lead to a sharp increase in the cost of products equipped with applications. Summary of the invention
[0004] The present disclosure is proposed in view of the above problems. The present disclosure provides a method, device, electronic device, storage medium and computer program product for generating a graphical user interface.
[0005] According to one aspect of the present disclosure, a method for generating a graphical user interface is provided, which is applied to a cloud platform, and the method includes: receiving a front-end source code file; generating at least one graphical user interface component information based on the front-end source code file; generating a corresponding serialized graphical user interface component information set based on each graphical user interface component information; and sending the serialized graphical user interface component information set to a terminal device for display.
[0006] In addition, according to a generation method in one aspect of the present disclosure, at least one graphical user interface component information is generated based on a front-end source code file, including: compiling the front-end source code file to generate at least one preprocessing file containing the graphical user interface component information; extracting the graphical user interface component information from the preprocessing file to generate at least one corresponding graphical user interface component information.
[0007] In addition, according to a generation method in one aspect of the present disclosure, a serialized graphical user interface component information set is generated based on each graphical user interface component information, including: splitting each graphical user interface component information, and reorganizing each split graphical user interface component information based on the business logic information recorded in the front-end source code file; generating a serialized graphical user interface component information set based on each reorganized graphical user interface component information.
[0008] According to another aspect of the present disclosure, a method for generating a graphical user interface is provided, which is applied to a terminal device, and the method includes: receiving a serialized graphical user interface component information set sent by a cloud platform; parsing the serialized graphical user interface component information set, and calling a graphical user interface engine to render it for display; wherein the serialized graphical user interface component information set is generated by serializing the graphical user interface component information obtained by the cloud platform based on a front-end source code file.
[0009] According to another aspect of the present disclosure, there is provided a device for generating a graphical user interface, comprising:
[0010] The receiving module is configured to receive a front-end source code file; the graphical user interface component information module is configured to generate at least one graphical user interface component information based on the front-end source code file; the serialized graphical user interface component information set module is configured to generate a corresponding serialized graphical user interface component information set based on each graphical user interface component information; the sending module is configured to send the serialized graphical user interface component information set to the terminal device for display.
[0011] In addition, according to the generation device of another aspect of the present disclosure, the graphical user interface component information module is also configured to: compile the front-end source code file to generate at least one preprocessing file containing graphical user interface component information; extract the graphical user interface component information from the preprocessing file to generate a corresponding graphical user interface component information.
[0012] In addition, according to the generation device of another aspect of the present disclosure, the serialized graphical user interface component information set module is also configured to: split each graphical user interface component information, and reorganize each split graphical user interface component information based on the business logic information recorded in the front-end source code file; serialize each reorganized graphical user interface component information to generate a serialized graphical user interface component information set.
[0013] According to another aspect of the present disclosure, an electronic device is provided, including: a memory for storing computer-readable instructions; and a processor for executing the computer-readable instructions so that the electronic device executes the method for generating a graphical user interface as described above.
[0014] According to yet another aspect of the present disclosure, a computer-readable storage medium is provided for storing computer-readable instructions. When the computer-readable instructions are executed by a processor, the processor executes the method for generating a graphical user interface as described above.
[0015] According to yet another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method for generating a graphical user interface as described above is implemented.
[0016] As will be described in detail below, according to the graphical user interface generation method, device, electronic device, storage medium and computer program product of the embodiments of the present disclosure, the present disclosure parses the front-end source code file into graphical user interface component information, serializes it on the cloud platform, and sends it to the terminal device for display, thereby reducing the amount of front-end code that needs to be run on the embedded device, thereby reducing the requirements for storage resources and processing performance of the embedded device, and avoiding the problem of transplantation and adaptation workload caused by transplanting the front-end framework and front-end language engine involved in the front-end development technology to the embedded device.
[0017] It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the technology as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The above and other purposes, features and advantages of the present disclosure will become more apparent by describing the embodiments of the present disclosure in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same reference numerals generally represent the same components or steps.
[0019] Figure 1 It is a schematic diagram illustrating an application scenario of a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0020] Figure 2 is a flowchart illustrating a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0021] Figure 3 is a flowchart further illustrating a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0022] Figure 4 is a flowchart further illustrating a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0023] Figure 5 4 is a functional block diagram illustrating a device for generating a graphical user interface according to an embodiment of the present disclosure.
[0024] Figure 6 is a hardware block diagram illustrating an electronic device according to an embodiment of the present disclosure.
[0025] Figure 7is a schematic diagram illustrating a computer-readable storage medium according to an embodiment of the present disclosure.
[0026] Figure 8 is a schematic diagram illustrating a computer program product according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present disclosure more obvious, the exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described here.
[0028] Figure 1 The invention illustrates an application scenario of the method for generating a graphical user interface according to an embodiment of the present disclosure.
[0029] like Figure 1 As shown, the application scenario 100 of the method for generating a graphical user interface provided in an embodiment of the present disclosure includes a cloud platform 101, a terminal device 102 and a network 103, and the cloud platform and the terminal device 102 are connected to each other through the network 103. The cloud platform 101 refers to a service platform built on cloud computing technology, which provides computing resources, storage resources, applications and related services through the Internet or a dedicated network. The terminal device 102 refers to a device used to receive and send data in the network, which is an interface for users to interact with the network. The terminal device 102 is embedded with embedded devices, including but not limited to smart phones, tablet computers, desktop computers, laptops, smart TVs, Internet of Things devices, etc.
[0030] Among them, the cloud platform 101 is equipped with a middleware program 1011, in which the open source front-end framework VUE.JS is integrated. VUE.JS is a progressive framework for building user interfaces. The middleware program 1011 includes an application data preprocessing module 1012, a front-end and back-end capability fusion module 1013, and a graphical user interface component information private protocol encoding module / decoding module 1014. The terminal device 102 is installed with a terminal side plug-in 1021. The terminal side plug-in includes a graphical user interface component information private protocol encoding / decoding module 1022 and an adaptation module 1023.
[0031] Specifically, the application data preprocessing module 1012 also includes an application data modeling module and an application data template generating module.
[0032] The application data modeling module is used to abstract and clean the data features of the front-end demand information and the hardware information to be used input by the decision makers of the APP development project, obtain the data set required by the multivariate linear regression model, and then complete the model training based on this data set. The software and hardware information reported by the plug-in is then substituted into the model for verification to obtain the adaptability of the hardware and GUI components to help project decision makers make decisions.
[0033] The application data template generation module uses the key:value pair method to store all the data that the APP needs to run in the generated template file, including two parts of data: Data template 1 stores the data model template made by the present invention for various front-end technologies, including development language keywords, necessary members of DOM, etc. Data template 2 stores the various capabilities of each embedded device, that is, information such as onboard hardware, peripherals, and driver interfaces.
[0034] In one embodiment of the present disclosure, the person in charge of the application development project or the decision maker selects the embedded device hardware information and the front-end technology to be used, such as the front-end framework, coding language, etc., on the cloud platform 101. The back-end developer registers the existing hardware and software information of the embedded device on the terminal device 102 to the end-side plug-in. When the end-side plug-in is powered on and linked to the middleware program, the information selected on the cloud platform 101 and the uploaded data of the end-side plug-in (i.e., the existing hardware and software information of the embedded device) will be used through the application data modeling module in the middleware program to generate a data template file including all the information involved when the application is running, which is used to describe each business logic unit that ensures the operation of the application. In the subsequent description of the present disclosure, the hypertext markup language HTML + script language JavaScript will be used to represent the front-end technology for content description.
[0035] In one embodiment of the present disclosure, after the person in charge of the application development project or the decision maker logs in to the cloud platform 101, he first selects the embedded device hardware information on which the application will run, the graphical user interface component information required, the front-end framework to be used, etc. The back-end developer registers the capabilities of the embedded device on the terminal device to the end-side plug-in through coding, such as hardware peripheral information such as the frames per second fps of the onboard screen, the capacity of the external flash memory, the device name, type, and option interface of the development board, such as the timer interface provided by the operating system, etc., to the plug-in. When the end-side plug-in is loaded and connected to the cloud platform 101, the application data modeling module uses the multivariate linear regression modeling algorithm to give a decision recommendation on the adaptability of the back-end hardware and generate an application data template file.
[0036] In one embodiment of the present disclosure, taking the terminal side hardware shown below as an example, a data modeling method of multiple linear regression is used to obtain a decision suggestion, and the specific steps are as follows:
[0037] 1. First, determine the independent variables and dependent variables in the linear regression model. The independent variable is the hardware information required for the embedded device to run the application, such as device_info:{fps,memory,flash}, where device_info represents the hardware feature information, and its object fps (frames per second) is the frame rate, memory is the available memory space, and flash is the available flash memory space. The dependent variable is the set hardware adaptability, such as device_fm:{100,50,0}, where device_fm is the hardware adaptability score, 100 is a complete match, indicating that the hardware does not need to be adjusted; 50 is a partial match, indicating that adjustment and optimization are required; 0 is a complete mismatch, indicating that it is not suitable for the development of this application.
[0038] 2. Determine the linear regression model. The linear regression model type used in this disclosure is shown in the following formula:
[0039] d_fm=a*d_i.fps+b*d_i.mem+c*d_i.flash+d
[0040] Among them, d_fm is the dependent variable device_fm, d_i.fps is the fps in the independent variable device_info, d_i.mem is the memory in the independent variable device_info, d_i.flash is the flash in the independent variable device_info, a\b\c\d are model parameters and independent variable factors.
[0041] If the project decision maker enters a set of data, for example, when device_info:{fps:60, memory:120K, flash:3M}, device_fm:100, then the above formula is:
[0042] 100=a*60+b*120+c*3+d, and there is also some hardware information, such as the minimum storage resource configuration when running the application, the maximum hardware resources that the embedded device can support, etc. Therefore, the input data can be used as training data to obtain the model parameters.
[0043] 3. Use the error square sum function as the loss function, obtain the model parameters, and establish a linear regression model. The loss function is as follows:
[0044]
[0045] When there is a set of numbers (a', b', c', d') that minimizes L(a, b, c, d), this set of data is the model parameter to be used in the present disclosure. At this time, the complete formula of the linear regression model can be determined, that is, the formula of the trained linear regression model, as follows:
[0046] d_fm=a'*d_i.fps+b'*d_i.mem+c'*d_i.flash+d'
[0047] 4. When the embedded device side is powered on and connected to the middleware program of the present invention, the present invention will use the hardware information uploaded by the embedded device side as the verification set data, such as device_info:{fps1,memory1,flash1}, and substitute it into the above-mentioned trained linear regression model formula to obtain the hardware adaptability score: d_fm1=a*fps1+b*memory1+c*flash1+d.
[0048] 5. When d_fm1 is greater than or equal to 100, it means that the embedded device is fully suitable for the operation of this embedded device application and does not require adaptation or hardware resource changes; when d_fm1 is less than 100 and greater than or equal to 50, it means that the embedded device needs to adjust the software and hardware resources to meet the operation of the application; if d_fm1 is less than 50, it means that the embedded device cannot meet the operation of this application and the device needs to be replaced.
[0049] 6. If the hardware adaptability result is fully or partially adapted to the embedded application development project, the hardware information entered by the project decision maker will be filled into the back-end data template of the present disclosure, and a back-end data template file with environmental restrictions that the front-end and back-end developers need to refer to and comply with in the development activities will be generated. If the hardware adaptability result indicates that the device hardware and software information cannot meet the requirements of the current application, the project decision maker will be directly reminded in the middleware program of the cloud platform.
[0050] Similarly, taking the graphical user interface GUI component information as an example, the data modeling and decision suggestions of linear regression are also as described above. The difference from the linear regression model of hardware information lies in the data structure:
[0051] The independent variable is the abstract data of GUI components (widgets), such as widget_info:{attributes,style_color,style_layout,event,logic_entry}, where widget_info is a certain graphic component, such as a button, a switch, etc., attributes is the attribute type of the component, such as a switch has an attribute representing the "switch state", then the attributes value is 1, style_color is the color type required by the component, such as the switch component needs to support 255 colors of all RGB colors, then style_color is 255, style_layout is the layout type that the component needs to support, such as the switch component needs to support both horizontal and vertical layouts, then style_ The layout value is 2, event is the event type that the component needs to support, such as switch needs to support click, then event is 1, logic_entry is the logical business block that the component needs to support, such as switch component needs to support switch logic, then logic_entry is 1, so taking the switch component as an example, we can get the characteristic data of switch:{1,255,2,1,1}; the dependent variable is the set GUI component adaptability, such as widget_fm:{100,50,0}, widget_fm represents the adaptability of a component, where 100 means that a widget is completely suitable for this embedded application development and does not need to be optimized or modified; 50 means partially suitable and needs to be modified or supplemented before it can be suitable; 0 means it is completely unsuitable or missing and the component needs to be redeveloped.
[0052] When the middleware program uses the information of each GUI component input by the project decision maker to perform model training and obtains the decision model of each GUI component, when the embedded device is connected to the middleware program, the present invention uses the supported component information uploaded by the embedded device as the verification set data, substitutes it into the component decision model for prediction, obtains the fitness of each component, and gives decision recommendations for each component based on the fitness results.
[0053] If a component is fully or partially adapted to the embedded application development project, the independent variable data will be filled into the graphical user component information data template of the present invention, generating a graphical user interface GUI data template file that can be shared by front-end and back-end developers and can be encoded based on it. In the subsequent description of this public document, the hypertext markup language HTML + scripting language JavaScript will be used to represent the front-end technology for content description, and the graphical user component information is expressed by DOM (Described Object Model). This DOM is an original term in this disclosure and is similar to the DOM (Document Object Model) in the World Wide Web Consortium W3C. Both use codable descriptions to display the abstraction of real objects.
[0054] The contents of the application APP data template file disclosed in this disclosure are roughly as follows:
[0055] Contents of the front-end data template: graphic controls (widgets) to be used by the APP, layer information of a widget (i.e. its parent and child widget information), style (style) to be used by a widget, attributes (attributes) of a widget, data type, default value, value range of each attribute, events (event) to which a widget responds, etc.
[0056] Backend data template content: devices registered on the device (device), the name of a device (name), type (type), operation interface (read\wirte), GUI engine used, widgets provided by the engine, attributes supported by a widget, etc.
[0057] Finally, project decision makers can decide whether to supplement the back-end capabilities or modify the front-end requirements based on the fitness prediction results of the APP data modeling module, and decide what to supplement or modify based on the content of the APP data template file.
[0058] Then, when the application APP data model is confirmed, the front-end developer can complete the coding based on it.
[0059] During the workload assessment phase of a development project, the present invention can efficiently provide backend technology completion work through an application data modeling module.
[0060] It is easy to understand that Figure 1 The structure of the application scenario shown and the types and quantities of various devices are schematic rather than limiting on the present disclosure.
[0061] Figure 2 is a flowchart illustrating a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0062] like Figure 2 As shown, the method for generating a graphical user interface according to an embodiment of the present disclosure specifically includes the following steps.
[0063] In step S201, a front-end source code file is received.
[0064] It is understandable that after the front-end developer completes the coding work, he will upload the front-end source code file to the cloud platform, and the middleware program of the cloud platform will receive the front-end source code file. Among them, the front-end source code file contains all the necessary parts of the project, such as HTML, JavaScript files, etc.
[0065] In step S202, at least one graphical user interface component information is generated based on the front-end source code file.
[0066] In one embodiment of the present disclosure, after receiving the front-end source code file, the middleware program will extract the various components that constitute the graphical user interface, which may be composed of multiple different components, such as buttons, text boxes, drop-down menus, pictures, etc. For each component, the middleware program will further obtain its type, name, attributes, status, position, size, color and other detailed information. Type usually refers to the type of component, such as button, text box, etc.; name is the identifier defined by the developer for the component; attributes may include whether it is clickable, visible, etc.; status can reflect the current situation of the component, such as whether it is selected, whether it is in an activated state, etc.; position and size define the layout and size of the component on the interface; color affects the appearance of the component. By extracting this information, the middleware program can generate complete graphical user interface component information. Among them, each component corresponds to a graphical user interface component information.
[0067] In step S203, based on each GUI component information, a corresponding serialized GUI component information set is generated.
[0068] It is understandable that the purpose of serialization is to enable the GUI component information to be stored across platforms and transmitted over the network, while ensuring that the components can be correctly generated in the subsequent processing. If the GUI component information is out of order, it may be impossible to use the GUI component information to generate the correct components due to the confusion of information, and the application cannot be built.
[0069] In one embodiment of the present disclosure, after the middleware program extracts multiple graphical user component information from the front-end source code file, each graphical user component information is serialized according to a specific rule or order, so that in the subsequent processing, whether it is storage, transmission or parsing, the integrity and order of the information can be guaranteed, thereby ensuring that the correct component can be generated and the application can be built. Multiple serialized graphical user component information constitutes a serialized graphical user interface component information set, which contains all component information required to build the entire graphical user interface.
[0070] In step S204, a serialized graphical user interface component information set is sent to a terminal device for display.
[0071] In one embodiment of the present disclosure, the middleware program has extracted multiple graphical user interface component information from the front-end source code file, and after serialization processing, a corresponding serialized graphical user interface component information set is generated. This serialized graphical user interface component information set contains all component information required to build a graphical user interface. The middleware program sends the serialized graphical user interface component information set to the terminal device. The sending process can be carried out through a network. After receiving the serialized graphical user interface component information set, the terminal device will perform a deserialization operation to restore the serialized graphical user interface component information set to the original graphical user interface component information. This process is the reverse process of serialization, which ensures that the information can be accurately restored to the original format. Once the component information is restored, the terminal device can use this information to build and display the graphical user interface. For example: according to the type, attributes, status and other information of the component, the corresponding interface elements such as buttons, text boxes, pictures, etc. will be drawn on the screen.
[0072] The above step S204 uses the GUI information private protocol encoding / decoding module to send the serialized GUI component information set from the cloud middleware program to the terminal device.
[0073] The present disclosure parses the front-end source code file into graphical user interface component information, and after serialization processing on the cloud platform, sends it to the terminal device for display, thereby realizing the construction of the graphical user interface of the application. The present disclosure parses the front-end source code file and generates the graphical user interface component information, which means that before the application is developed, the front-end technicians can choose which front-end technology to use according to their own situation, without considering which front-end technology the embedded device side (i.e., the terminal device) has been equipped with. In the development of the application, the back-end technicians can improve the interface of the embedded device side according to the middleware program of the present invention, instead of communicating and confirming with the front-end technicians, reducing the communication cost and workload. After the application is developed, the joint debugging work is concentrated between the present invention and the back-end technology, without the need for the entire development team to participate, reducing labor costs.
[0074] Figure 3 The present invention further illustrates a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0075] like Figure 3 As shown, the method for generating a graphical user interface according to an embodiment of the present disclosure specifically includes the following steps.
[0076] Among them, step S301 is the same as step S201, and step S306 is the same as step S204, which will not be repeated here.
[0077] In step S302, the front-end source code file is compiled to generate at least one preprocessing file containing graphical user interface component information.
[0078] In one embodiment of the present disclosure, when the middleware program receives the front-end source code file, the front-end source code file is compiled using the scaffolding tool of the front-end framework to generate a preprocessed file containing graphical user interface component information. For example, the HTML file is compiled using the scaffolding of Vue.JS to obtain a .js file containing all DOM information, and its content is roughly as follows: "_c('div',{staticClass:["block"]},[_c('button',{staticClass:["bt_block"]}),_c('button',{staticClass:["bt_block"]})])". Among them, the preprocessed file is the .js file.
[0079] In step S303, the graphical user interface component information is extracted from the preprocessing file to generate at least one corresponding graphical user interface component information.
[0080] In one embodiment of the present disclosure, after obtaining the preprocessed file containing the GUI component information, the middleware program reads the preprocessed file and parses the content therein to further extract multiple GUI component information from the preprocessed file.
[0081] Specifically, the middleware separates the information contained in each GUI component, such as widget, style, attribute, event, and bound business logic, according to the object element keyword of the .js file, and reorganizes the GUI component information. Thus, multiple GUI component information can be obtained.
[0082] In step S304, each graphical user interface component information is split, and based on the business logic information recorded in the front-end source code file, each of the split graphical user interface component information is reorganized.
[0083] In one embodiment of the present disclosure, the purpose of splitting the graphical user interface component information is to better understand and process these components. Each component may contain multiple properties and settings, such as type, style, etc. The different aspects of each component can be separated by splitting. And using the business logic information recorded in the front-end source code file, each graphical user interface component information after splitting can be reorganized. The reorganization is to serialize the graphical user interface component information according to specific rules or sequences. Among them, business logic information refers to the rules and conditions that control how components are displayed and interacted, which determines the behavior and performance of components in different situations.
[0084] In one embodiment of the present disclosure, by reading the content of the .js file, it can be known from the keyword "_c" that when "_c" appears, a new widget object is to be created. Therefore, by judging the appearance of "_c", the widget object can be disassembled and assembled into graphical user interface component information, and the attribution relationship of each widget can be recorded by stacking and popping through a lexical analysis algorithm, and finally the serialized graphical user interface component information can be reassembled.
[0085] In step S305 , a serialized GUI component information set is generated based on the reorganized information of each GUI component.
[0086] In one embodiment of the present disclosure, multiple pieces of GUI component information generated after splitting and reorganization are combined together to form a serialized GUI component information set, that is, a .JS file is completely described by a string of serialized GUI component information.
[0087] Specifically, firstly, according to the search of "_c", three DOM nodes, DOM_div:{widget:"div", class:"block"}, DOM_button:{widget:"button", class:"bt_block"}, and DOM_button:{widget:"button", class:"bt_block"}, are created. At this time, the three DOM information obtained are out of order. If they are directly sent to the client plug-in for drawing, they are in a parallel relationship and the correct APP cannot be obtained. That is, now a 'div' is drawn on the embedded device, and then two 'buttons' are drawn on the screen. This is different from the .JS source code, which first draws a 'div' and then draws two 'buttons' on the 'div'.
[0088] Specifically, according to the "_c(" and ")" keywords, push and pop operations are performed to confirm the ownership relationship between DOMs. The process is as follows:
[0089] 1. The first thing scanned is "_c(", so the following 'div' is pushed into the stack. At this time, the stack content is: | bottom of the stack | div | top of the stack;
[0090] 2. Continue scanning backwards, and then scan "_c(", so push the following 'button' into the stack. At this time, the stack content is: | bottom of the stack | div | button | top of the stack;
[0091] 3. Continue scanning, and the content scanned at this time is ")", which means that the top content of the stack needs to be popped out, that is, "button" is popped out of the stack. At this time, there is "div" left in the stack, so the ownership of this button is recorded as "\div\", and the DOM information is updated to DOM_button:{widget:"button", class:"bt_block", parent:"\div\"}. The stack content at this time is:|bottom|div|top;
[0092] 4. Continue scanning backwards. When encountering “_c(”, push it into the stack. When encountering “)”, pop the widget at the top of the stack. Then record the remaining widgets in the stack as the affiliation in the DOM information of the popped-up widget until all scans are completed.
[0093] Finally, we get an ordered DOM node table with affiliation:
[0094] DOM_div:{widget: "button", class: "bt_block", parent: "\"},
[0095] DOM_button:{widget: "button", class: "bt_block", parent: "\div\"},
[0096] DOM_button:{widget:"button", class:"bt_block", parent:"\div\"}, which means that the client-side plug-in first draws a "div" widget, and then draws two "buttons" on the "div", which is consistent with the relationship described in the JS source code.
[0097] The serialized DOM information will be used as the feedback result after the front-end developer uploads the source code. After the front-end developer obtains it, it will first check it. After confirming that the serialized DOM is OK, it will encode the serialized graphical user interface component information set and send it to the terminal device.
[0098] The describable object (DOM) information of the private protocol in the present invention includes the following fields, wherein each field is divided by ',':
[0099] Field 0: app_name, application name, specific application name.
[0100] Field 1: dom_name, DOM name, indicating which DOM it is.
[0101] Field 2: unique_id, unique identifier, used as the unique identifier of the DOM.
[0102] Field 3: parent_id, unique_id of the DOM to which it belongs, unique_id of the parent DOM.
[0103] Field 4: widget, the name of the graphic control used by DOM, which is the UI graphic element represented by DOM.
[0104] Field 5: style, the style of the widget. This field is used when the widget has style encoding.
[0105] Field 6: attrs, attributes of the widget. This field is used when the widget has attributes.
[0106] Field 7: event, the event bound to the widget. This field is used when the widget is bound to an event.
[0107] Field 8: style_url, download link of the style. When the style content of the widget is too much and exceeds the value length range of field 5, this field needs to be used to obtain it separately from the middle platform.
[0108] Field 9: event_entry, event processing logic block. When the processing logic of the widget binding event belongs to a compound expression, this field needs to be used and obtained separately from the middle platform.
[0109] Field 10: bind_dev, the hardware device to which the event is bound. When the event bound to the widget is an event of an operable hardware on the embedded device, such as a click event of a button, this is an event of an operable hardware. In this case, this field is required to specify the hardware.
[0110] The above steps S302-S305 can be implemented through the front-end and back-end capability fusion module.
[0111] Specifically, the front-end and back-end capability fusion module has sub-modules, such as DOM splitting and DOM reorganization modules, which extract the DOM information contained in the front-end source code, and recombine and serialize it according to the business logic of the APP components developed by the front-end, so that it can be accurately parsed by the end-side plug-in.
[0112] Figure 4 The present invention further illustrates a method for generating a graphical user interface according to an embodiment of the present disclosure.
[0113] like Figure 4 As shown, the method for generating a graphical user interface according to an embodiment of the present disclosure specifically includes the following steps.
[0114] In step S401, a serialized graphical user interface component information set is received from a cloud platform.
[0115] It can be understood that the serialized GUI component information set is generated by serializing the GUI component information obtained by the cloud platform based on the front-end source code file. Specifically, the cloud platform first obtains the front-end source code file, extracts the GUI component information from it, and serializes the extracted GUI component information. After serialization, the cloud platform will obtain a serialized GUI component information set. This information set contains the serialized representation of all extracted component information.
[0116] In one embodiment of the present disclosure, the cloud platform encodes the serialized graphical user interface component information set and sends it to the terminal device, and the terminal device receives the serialized graphical user interface component information set.
[0117] In step S402, the serialized GUI component information set is parsed, and a GUI engine is called to render it for display.
[0118] In one embodiment of the present disclosure, after receiving the serialized graphical user interface component information set sent by the cloud platform, the terminal device will parse the serialized graphical user interface component information set and finally render the corresponding graphical user interface.
[0119] Specifically, the terminal device will first parse the received serialized GUI component information set. The purpose of parsing is to convert the serialized data back into a structure or object that can be processed internally. After parsing the serialized information, the terminal device will call the GUI engine and pass the parsed GUI component information to the engine for rendering. When all the parsed GUI component information has been rendered, the GUI engine will display the final rendering result on the screen of the terminal device.
[0120] In one embodiment of the present disclosure, when the end-side plug-in receives the encoded graphical user interface component information, it will parse the graphical user interface component information. First, parse the app_name field and find the corresponding application according to its value. Then, according to the dom_name field and unique_id field in the graphical user interface component information, a DOM node is created on this application, and its uniqueness is indicated by the unique_id field. Then, according to the parent_id and widget fields in the DOM node, the interface registered to the end-side plug-in by the graphical user interface engine is called to draw the graphic element. For example, in the DOM_button node in the above example, the button creation interface is called on the graphic element whose parent_id represents "div" to draw a button. Similarly, the end-side plug-in program calls the corresponding style and attrs apply interface to set the style and attributes of this widget according to the widget field, style and attrs fields in the DOM information. Finally, according to the event field, event_entry field and bind_dev field, the event is bound to the end-side hardware device. When an event occurs on the hardware device, the logic block of the event_entry field is called to process the event. When all GUI component information processing is completed, the entire application can run normally.
[0121] In the above step S401, the GUI information private protocol encoding / decoding module is used to receive the serialized GUI component information set.
[0122] In the above step S402, the adapter module is used to find and call the relevant interface of the parsed DOM information, so as to finally realize the normal operation of the APP on the embedded device side.
[0123] The above describes the method for generating a graphical user interface according to an embodiment of the present disclosure. The following further describes a graphical user interface generating device 500 for implementing the above method for generating a graphical user interface.
[0124] Figure 5 FIG. 5 is a functional block diagram of a graphical user interface generation device 500 according to an embodiment of the present disclosure. Figure 5 As shown, the GUI generation device 500 includes a receiving module 501 , a GUI component information module 502 , a serialized GUI component information set module 503 and a sending module 504 .
[0125] Specifically, the receiving module 501 is configured to receive a front-end source code file;
[0126] Specifically, the graphical user interface component information module 502 is configured to generate at least one graphical user interface component information based on the front-end source code file;
[0127] Specifically, the serialized GUI component information set module 503 is configured to generate a corresponding serialized GUI component information set based on each GUI component information;
[0128] Specifically, the sending module 504 is configured to send a serialized graphical user interface component information set to a terminal device for display.
[0129] Furthermore, the GUI component information module 502 is also configured to: compile the front-end source code file to generate at least one preprocessing file containing GUI component information; extract the GUI component information from the preprocessing file to generate corresponding GUI component information.
[0130] Specifically, the serialized GUI component information set module 503 is also configured to: split each GUI component information, and reorganize each split GUI component information based on the business logic information recorded in the front-end source code file; serialize each reorganized GUI component information to generate a serialized GUI component information set.
[0131] Figure 6The electronic device 600 shown specifically includes: a central processing unit (CPU) 601, a graphics processing unit (GPU) 602 and a memory 603. These units are interconnected via a bus 604. The central processing unit (CPU) 601 and / or the graphics processing unit (GPU) 602 can be used as the above-mentioned processor, and the memory 603 can be used as the above-mentioned memory for storing computer-readable instructions. In addition, the electronic device 600 may also include a communication unit 605, a storage unit 606, an output unit 607, an input unit 608 and an external device 609, which are also connected to the bus 604.
[0132] Figure 7 is a schematic diagram illustrating a computer-readable storage medium according to an embodiment of the present disclosure. Figure 7 As shown, a computer-readable storage medium 700 according to an embodiment of the present disclosure has computer-readable instructions 701 stored thereon. When the computer-readable instructions 701 are executed by a processor, the method for generating a graphical user interface according to an embodiment of the present disclosure described with reference to the above figures is executed. The computer-readable storage medium includes, but is not limited to, for example, a volatile memory and / or a non-volatile memory. The volatile memory may, for example, include a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may, for example, include a read-only memory (ROM), a hard disk, a flash memory, an optical disk, a magnetic disk, etc.
[0133] Figure 8 is a schematic diagram illustrating a computer program product according to an embodiment of the present disclosure. Figure 8 As shown, a computer program product 800 according to an embodiment of the present disclosure has a computer program 801 stored thereon. When the computer program is executed by a processor, the method for generating a graphical user interface as described above is implemented. Computer program products include, but are not limited to, system software, application software, and games. System software is the basic software of a computer, which is responsible for managing the hardware and application programs of the computer, including an operating system, device drivers, and the like. Application software is software designed to meet specific needs, such as office software, image processing software, and the like. Games are software used for entertainment, providing a variety of gaming experiences. In addition, computer program products may also include embedded software, firmware, and the like, which are used to control and operate various hardware devices.
[0134] The above describes in detail the method, device, electronic device, storage medium and computer program product for generating a graphical user interface according to the embodiments of the present disclosure. The present disclosure parses the front-end source code file into graphical user interface component information, serializes it on the cloud platform, and sends it to the terminal device for display, thereby reducing the amount of front-end code that needs to be run on the embedded device, thereby reducing the requirements for storage resources and processing performance of the embedded device, and avoiding the problem of transplantation and adaptation workload caused by transplanting the front-end framework and front-end language engine involved in the front-end development technology to the embedded device.
[0135] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can 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 disclosure.
[0136] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0137] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0138] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.
[0139] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0140] Various changes, substitutions, and modifications of the technology herein may be made without departing from the technology of the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the above processes, machines, manufactures, compositions of events, means, methods, and actions. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.
[0141] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0142] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A method for generating a graphical user interface, characterized in that: Applied to a cloud platform, the method includes: Receive front-end source code files; Based on the front-end source code file, generating at least one graphical user interface component information; Based on each of the graphical user interface component information, generate a corresponding serialized graphical user interface component information set; The serialized graphical user interface component information set is sent to the terminal device for display.
2. The method for generating a graphical user interface according to claim 1, characterized in that: The step of generating at least one graphical user interface component information based on the front-end source code file includes: Compiling the front-end source code file to generate at least one preprocessing file containing the graphical user interface component information; The graphical user interface component information is extracted from the preprocessing file to generate at least one corresponding graphical user interface component information.
3. The method for generating a graphical user interface according to any one of claims 1 to 2, characterized in that: The step of generating a serialized graphical user interface component information set based on each of the graphical user interface component information comprises: Splitting each of the graphical user interface component information, and reorganizing each of the split graphical user interface component information based on the business logic information recorded in the front-end source code file; The serialized GUI component information set is generated based on the reorganized information of each GUI component.
4. A method for generating a graphical user interface, characterized in that: Applied to a terminal device, the method comprises: Receiving a serialized graphical user interface component information set sent by a cloud platform; Parsing the serialized graphical user interface component information set and calling a graphical user interface engine to render for display; The serialized GUI component information set is generated by serializing the GUI component information obtained by the cloud platform based on the front-end source code file.
5. A graphical user interface generation device, characterized in that: include: A receiving module, configured to receive a front-end source code file; A graphical user interface component information module, configured to generate at least one graphical user interface component information based on the front-end source code file; A serialized graphical user interface component information set module is configured to generate a corresponding serialized graphical user interface component information set based on each of the graphical user interface component information; The sending module is configured to send the serialized graphical user interface component information set to the terminal device for display.
6. The graphical user interface generation device according to claim 5, characterized in that: The graphical user interface component information module is further configured to: Compiling the front-end source code file to generate at least one preprocessing file containing the graphical user interface component information; The graphical user interface component information is extracted from the preprocessing file to generate corresponding graphical user interface component information.
7. The graphical user interface generation device according to any one of claims 5 to 6, characterized in that: The serialized graphical user interface component information set module is further configured to: Splitting each of the graphical user interface component information, and reorganizing each of the split graphical user interface component information based on the business logic information recorded in the front-end source code file; The reorganized each graphical user interface component information is serialized to generate the serialized graphical user interface component information set.
8. An electronic device, characterized in that: include: a memory for storing computer readable instructions; as well as A processor is used to run the computer-readable instructions so that the electronic device executes the method for generating a graphical user interface as described in any one of claims 1 to 4.
9. A computer-readable storage medium for storing computer-readable instructions, characterized in that: When the computer-readable instructions are executed by a processor, the processor is caused to execute the method for generating a graphical user interface according to any one of claims 1 to 4.
10. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the method for generating a graphical user interface as claimed in any one of claims 1 to 4.
