WO2024046313A1 - Visual processing method, apparatus, and system for front-end service logic - Google Patents
Visual processing method, apparatus, and system for front-end service logic Download PDFInfo
- Publication number
- WO2024046313A1 WO2024046313A1 PCT/CN2023/115511 CN2023115511W WO2024046313A1 WO 2024046313 A1 WO2024046313 A1 WO 2024046313A1 CN 2023115511 W CN2023115511 W CN 2023115511W WO 2024046313 A1 WO2024046313 A1 WO 2024046313A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- component
- logical
- node
- document object
- Prior art date
Links
- 230000000007 visual effect Effects 0.000 title claims abstract description 94
- 238000003672 processing method Methods 0.000 title claims abstract description 20
- 238000000034 method Methods 0.000 claims abstract description 56
- 238000009877 rendering Methods 0.000 claims abstract description 47
- 230000006870 function Effects 0.000 claims description 47
- 238000012800 visualization Methods 0.000 claims description 42
- 238000012545 processing Methods 0.000 claims description 31
- 238000004590 computer program Methods 0.000 claims description 17
- 230000001960 triggered effect Effects 0.000 claims description 3
- 230000004044 response Effects 0.000 claims 7
- 230000008569 process Effects 0.000 description 19
- 238000010586 diagram Methods 0.000 description 16
- 238000007667 floating Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 8
- 238000011161 development Methods 0.000 description 6
- 239000000243 solution Substances 0.000 description 5
- 238000004458 analytical method Methods 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000006467 substitution reaction Methods 0.000 description 3
- 238000013473 artificial intelligence Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012552 review Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 238000002347 injection Methods 0.000 description 1
- 239000007924 injection Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/34—Graphical or visual programming
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the embodiments of the present application relate to the field of computer technology, for example, to a visual processing method, device and system for front-end business logic.
- front-end applications carry more and more complex business logic than ever before. Since enterprise-level application development is component-oriented, modules that are reused in multiple areas will be extracted into reusable components. As the complexity of the project increases, the logic carried by each component will also become complex.
- This application provides a visual processing method, device and system for front-end business logic to improve the visual review of front-end business logic code.
- a visual processing method for front-end business logic including:
- a visual processing device for front-end business logic including:
- the precompiled data acquisition module is configured to obtain the precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;
- a data update module configured to update the original data in the component based on the precompiled data corresponding to the component
- the page rendering module is set to render multiple updated components to obtain a business display page
- the visualization processing module is configured to set a visual identifier for the document object model obtained by rendering the business display page by the update component, wherein the document object model corresponding to the visual identifier triggers the display of the document object when selected.
- the model corresponds to the logical data of the component.
- a front-end business logic visualization system including a server and a client, wherein the client includes a visualization plug-in and a processor;
- the visualization plug-in is configured to send the source code of the front-end business logic file to the server, send a data request to the server, and receive precompiled data fed back by the server;
- the server is configured to precompile the source code of the front-end business logic file to obtain precompiled data, wherein the precompiled data includes the logical data of the component;
- the visualization plug-in is configured to update the original data in the component based on the precompiled data corresponding to the component, send the updated component data to the processor, and upon receiving a visual instruction, send the updated component data to the processor.
- the processor sends trigger instructions;
- the processor is configured to render the updated multiple components to obtain a business display page, and when receiving a trigger instruction, set a visual identifier for the document object model obtained by rendering the business display page on the updated component. , wherein when the document object model corresponding to the visual identification is selected, it triggers the display of logical data of the corresponding component of the document object model.
- an electronic device including:
- the memory stores a computer program that can be executed 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 method described in any embodiment of the present application.
- Visual processing method of front-end business logic is executed by the at least one processor, so that the at least one processor can execute the method described in any embodiment of the present application.
- a computer-readable storage medium stores computer instructions, and the computer instructions are used to implement any of the embodiments of the present application when executed by a processor.
- Visual processing method of front-end business logic is provided.
- Figure 1 is a flow chart of a visual processing method for front-end business logic provided by an embodiment of the present application
- Figure 2 is a schematic diagram of a service display page provided by an embodiment of the present application.
- Figure 3 is a flow chart of another visual processing method of front-end business logic provided by an embodiment of the present application.
- Figure 4 is a schematic structural diagram of a front-end business logic visual processing device provided by an embodiment of the present application.
- Figure 5 is a schematic structural diagram of a front-end business logic visualization system provided by an embodiment of the present application.
- Figure 6 is a schematic flow chart of another visual processing method of front-end business logic provided by an embodiment of the present application.
- Figure 7 is a schematic diagram of abstract syntax tree parsing provided by an embodiment of the present application.
- Figure 8 is a schematic diagram of the generation of instruction-type logical data provided by an embodiment of the present application.
- Figure 9 is a schematic diagram of a rendering stage provided by an embodiment of the present application.
- Figure 10 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
- Figure 1 is a flow chart of a visual processing method of front-end business logic provided by an embodiment of the present application. This embodiment can be applied to the situation where the front-end business logic is visually displayed in a business display page. This method can be implemented by the embodiment of the present application.
- the provided front-end business logic visual processing device is executed.
- the front-end business logic visual processing device can be implemented by software and/or hardware.
- the front-end business logic visual processing device can be configured on an electronic computing device, including the following steps:
- the front-end business logic file may be a business logic file of a front-end application, where the front-end application may include but is not limited to a web application or an H5 application.
- the front-end application may be an application developed based on a preset framework.
- the preset framework may include but is not limited to the Vue framework.
- the front-end business logic file can be a .vue file.
- each .vue file consists of three parts, namely the template part (template), the control part (script) and the style part (style).
- the template part is responsible for the rendering of the main view of the page.
- the control part is responsible for providing the data required for rendering the template part and responsible for some logical processing, such as ajax requests, interaction-related processing, etc.
- the style part is css (Cascading Style Sheets, cascading style sheets). ), responsible for page styling. It should be noted that in front-end applications developed by other frameworks, the front-end business logic file can include different parts, and there is no limit to this.
- the core of the compiler processing is to compile the template part into a pure JavaScript function render. Then the component will execute the render function to generate a virtual DOM before being mounted on the page, which will then be rendered into a real DOM element by Vue's runtime module, so that it can be displayed on the browser.
- Each .vue file will eventually be executed into an instance vm of a component (i.e. VueComponent).
- the vm object includes the _vnode object, which stores the return value of the component render function, that is, the virtual DOM (Document Object Model). model), is a pure JavaScript object.
- the virtual DOM in the component instance can be as follows:
- the virtual DOM does not include logical data (that is, there is no logical data after the data attribute), making the business display page rendered based on the above virtual DOM impossible.
- Visual display of logical data and corresponding operations Personnel needs to query logical data from the source code of the front-end business logic file.
- the source code of the front-end business logic file is pre-compiled to obtain pre-compiled data including logical data, so that the business display page obtained by rendering the pre-compiled data can realize the processing of the front-end business logic file.
- Logical data is displayed visually.
- the generation method of the precompiled data and the execution subject that executes the precompiled process are not limited, as long as the precompiled data containing logical data can be obtained.
- the original data of the front-end business logic file of each component does not include logical data.
- the original data of the front-end business logic file can be the original compiled data obtained through regular compilation based on the source code of the front-end business logic file.
- the original compiled data includes the original Rendering function, the original rendering function does not include logical data.
- the original data of the corresponding component is updated through precompiled data, and the component instance is rendered based on the precompiled data of the component to obtain a business display page that can visualize logical data.
- match the precompiled data with the component and update the data of the successfully matched component, for example, replace the original data of the component based on the precompiled data.
- replace the component that does not contain logical data through the render function that contains logical data. render function.
- the matching of precompiled data and components may be achieved through component identifiers or through path data matching.
- the path summary data of the precompiled data is generated during the precompilation process of the original data.
- the path summary data of the precompiled data includes the precompiled data and the corresponding relationship between the path data.
- the path summary data rendermap of the precompiled data can be stored in the form of a key-value pair.
- the path data of the precompiled data is stored in the key and the precompiled data is stored in the value.
- the precompiled data and corresponding path data can be obtained by obtaining the path summary data of the precompiled data.
- updating the original data in the component based on the precompiled data corresponding to the component includes: when the component executes the hook function, obtain the current path data of the component, and when the current path data of the component is in the path If the matching in the summary data is successful, the original data in the component is updated based on the precompiled data corresponding to the component.
- the timing of the component executing the hook function is detected.
- the current path data of the component is obtained.
- the __file attribute information of the component is obtained.
- the __file attribute information includes the current path data of the component, and matches the current path data of the component with the path summary data of the precompiled data. If the current path data and any path data of the path summary data match successfully, it indicates that the The component is a custom component in the front-end business.
- the custom component can display logical data visually, and replace the original data of the component with the precompiled data corresponding to the successfully matched path data.
- the components used to render the business display page include custom components and non-custom components.
- the non-custom component can be a third-party component.
- the logical data of the non-custom component cannot be obtained. Accordingly, it cannot be processed.
- Non-custom components perform visual display of logical data.
- the components used to render the business display page include custom components after data update and non-custom components without data update. By rendering each of the above components, the business display page is obtained.
- rendering multiple updated components to obtain a business display page includes: obtaining precoding data of components in the front-end business, executing the precoding data, and obtaining component instances.
- the component instances include corresponding At least one virtual document object model; traverse the virtual document object model in the component instance, and render the document object model in the business display page.
- the preset field position of the precoded data of the component is set to the logical data of the component.
- the logical data in the precoded data is injected into the virtual document object model of the component instance.
- a virtual DOM including the logical data is obtained.
- Any component instance can include multiple virtual DOMs, and there can be a parent-child relationship between different virtual DOMs.
- Each virtual DOM corresponds to a real DOM in the business display page.
- Each virtual DOM of each component instance is traversed, and each real DOM in the business display page is rendered.
- the business display page is obtained.
- the visual processing may be to set a visual identification on the real DOM corresponding to the custom component on the business display page, so that the operator can determine the custom component in the business display page through the visual identification.
- the custom component can be a component that updates precompiled data, that is, an update component.
- a meta tag may be set for the data attribute in which logical data is injected, so as to quickly identify the virtual DOM in which logical data exists during the traversal process of the virtual DOM.
- the virtual DOM set with meta tags and the corresponding real DOM settings can be visualized.
- setting a visual identifier for the document object model obtained by the update component when rendering the business display page includes: setting a mask layer for the document object model obtained when the update component renders the business display page.
- a layer can be set on the document object model (real DOM) to block the document object model and set a visual mark.
- the mask layer can be a color different from the document object model or the business display page to facilitate visual prompts.
- the size of the mask layer may be determined based on the size of the document object model, where the size of the mask layer may be greater than or equal to the size of the document object model.
- the shape of the mask layer may be consistent with the shape of the document object model.
- Figure 2 is a schematic diagram of a service display page provided by an embodiment of the present application.
- Figure 2 includes some document object models with visual identifiers and some document object models without visual identifiers.
- the document object models without visual identifiers can be document object models that do not have logical data and/or The document object model corresponding to the non-custom component of the logical data cannot be obtained.
- setting a visual identifier for the document object model obtained by rendering the business display page by the update component includes: setting a visual identifier at a preset position of the document object model obtained by rendering the business display page by the update component.
- the preset mark may be a graphical mark of a preset shape and/or a preset color (for example, including but not limited to a triangle mark, a five-pointed star mark or a red circle mark, etc.), or a preset symbol mark ( For example, including but not limited to tags such as "!, "*" or fixed numbers or strings, etc.), or serialization tags (such as but not limited to 123, serialization tags of ABC, etc.), etc.
- each document object model containing logical data is set with a serialization mark.
- the serialization mark can be determined according to the traversal order of the corresponding virtual DOM.
- the document object model setting visual identification may include both a mask layer and a preset mark.
- the method further includes: setting a floating window at a preset position of the document object model in the business display page, and the floating window is used to display logical data corresponding to the document object model.
- the floating window can be closed to close the floating window that does not need to be viewed or the floating window that has been viewed according to the operator's needs.
- the document object model set with visual identification when the document object model set with visual identification is selected, its corresponding logical data is displayed, so that the operator can visually view each document object model set with visual identification on the business display page.
- the logical data does not need to be viewed in the source code of the front-end business logic file, which simplifies the viewing method of logical data and improves the viewing efficiency of logical data.
- targeted logical data can be displayed according to the operator's viewing needs.
- the method further includes: when a visual operation on any of the document object models is detected, reading the logical data of the corresponding component of the document object model and displaying it based on a preset window.
- a visual operation on any of the document object models is detected, reading the logical data of the corresponding component of the document object model and displaying it based on a preset window.
- the visual operation on any of the document object models includes but is not limited to clicking on the document object model, clicking on the document object model, and clicking on the document object model. The selection of the visual identification of the object model, the mouse or cursor being located in the detection range of the document object model, etc.
- Detecting visual operations on any of the document object models generating visual instructions for logical data, executing the visual instructions, and reading logical data from the virtual DOM corresponding to the document object model, for example, reading the virtual DOM corresponding to the document object model.
- data attribute data Display the read logical data on the business display page.
- Domain displays the logical data of the selected document object model in the display area.
- display the logical data of the selected document object model in the form of a pop-up window or a floating window.
- the display method of the logical data of the document object model is not limited. It can be visually displayed on the business display page, and there is no limitation on this.
- step S130 it may also include receiving a visualization instruction to enter the visualization mode, that is, executing step S130.
- the visualization mode the visual identification and logical data of the document object model may be displayed.
- step S130 it may also include receiving a cancellation instruction to exit the visualization mode to avoid the impact of the visualization mode on other operations.
- the business display page may be provided with a visual switching control, and the visual switching control may be implemented by one or two controls.
- the visualization switch control is set to realize the entry and exit of the visualization mode.
- the technical solution provided by this embodiment is to update the original data of each component with pre-compiled data containing logical data, and perform page rendering through the pre-compiled data of each component, so as to set the document object model of each document in the rendered business display page.
- Visual identification through which the document object model with logical data can be intuitively determined in the business display page.
- each document object model in the business display page has the display function of logical data. When the document object model is triggered, The corresponding logical data can be visually displayed without querying the source code of the front-end business logic file.
- Logical data query can be realized on the business display page, which simplifies the query method of logical data and improves the query efficiency of logical data, especially When multiple people collaborate on development or new people take over the project, it is convenient to quickly check the development progress and the editing method of logical data.
- the visual display of logical data relies on the pre-compilation process of the original data.
- the client obtains the source code of the front-end business logic file, pre-compiles the source code, and obtains the pre-compile process. Compile data.
- the client sends the source code of the front-end business logic file to the server, and the server pre-compiles the source code to obtain pre-compiled data.
- the server has strong computing power, which can improve the efficiency of the pre-compilation process.
- FIG. 3 is a flow chart of another visual processing method of front-end business logic provided by an embodiment of the present application. The method includes the following steps:
- S220 Send a precompiled data request to the server, and receive the precompiled data fed back by the server.
- the generation process of precompiled data is the same on the client and server.
- the generation method of precompiled data includes: obtaining the source code of the front-end business logic file, converting the first code part in the source code into the first syntax tree,
- the first syntax tree includes instruction type logical nodes and computational attribute logical nodes; logical data of the instruction type logical nodes and the computational attribute logical nodes are extracted respectively, and corresponding precompiled data is generated.
- the front-end application in this embodiment is the front-end application of the Vue framework.
- the pre-compilation process of the source code of the front-end business logic file is to pass the information related to the logic control part in the template part template and control part script of the source code through the object Write the string form into the rendering function (i.e. render function) to get the precompiled data.
- Both the template part and the control part involve the front-end business logic: the template part includes the use of v-if, v-show, v-for and other instructions to mount, display, loop and other instruction logic of elements; the control part includes Computed attribute logic is used to control the data required for template rendering by using the computed attribute. That is, the template part also includes rendering data that depends on the calculated attribute logic.
- the first code part in the source code is the template part. Convert the template part template into a first syntax tree.
- the first syntax tree includes a plurality of nodes, and the plurality of nodes include instruction class logic. Edit nodes and computed attribute logical nodes.
- the instruction logic in the template part includes directly using v-if to control element mounting, directly using v-show to control whether elements are displayed, and using v-if, v-else-if, and v-else nested logic.
- each node corresponds to an el object, and the logical information on the el object is parsed to obtain the logical data of each instruction type logical node.
- extracting the logical data of the instruction type logical node includes: traversing the instruction type logical node in the first syntax tree, and when the node object of the instruction type logical node includes an instruction class identifier. Next, read the instruction type logical data in the node object.
- the nodes in the first syntax tree may be distinguished between instruction type logical nodes and computational attribute logical nodes, and the instruction type logical nodes are traversed to obtain instruction type logical data of the instruction type logical nodes.
- the nodes in the first syntax tree do not have a distinction between instruction type logical nodes and computed attribute logical nodes. The nodes in the first syntax tree are traversed, and whether the nodes are instruction type logical nodes is determined by determining whether there is an instruction class identifier. And when the instruction class identifier exists in the node object, the instruction class logical data of the instruction class logical node is obtained.
- instruction class identifiers may include but are not limited to el.if and el.show.
- reading the instruction class logical data in the node object includes: if the instruction class identifier of the node object includes el.if, then based on the node object, the parent node object of the node object, and the The logical data of the sibling node object of the node object is obtained to obtain the instruction type logical data of the node object; if the instruction type identifier of the node object includes el.show, the expression in the V-show element is read as the node The instruction-type logical data of the object.
- the node object that is, the el object
- the instruction class identifier el. it is determined whether the parent node of the node object has an if attribute, and whether the node object has sibling nodes of el.elseif and el.else.
- the parent node does not have an if attribute and there are no sibling nodes of el.elseif and el.else
- the logical information in the el object is extracted, and the extracted logical information is determined as the instruction type logical data of the node.
- the parent node has an if attribute
- extract the logical information in the parent node's if attribute extract the logical information in the parent node's if attribute.
- the node object When the node object has el.elseif and/or el.else's sibling nodes, extract the sibling nodes el.elseif and el.elseif. /or logical information in el.else. After negating the extracted logical information of the parent node and/or the logical data of the sibling nodes, they are spliced with the logical information in the el object to obtain the instruction type logical data of the node.
- the expression in the V-show element is read as the instruction class logical data of the node object.
- extracting the logical data of the computed attribute logical node includes: traversing the computed attribute logical node in the first syntax tree, and matching the node information of the computed attribute logical node in the preset matching data. If successful, read the attribute name of the calculated attribute logical node as logical data.
- the preset matching data is a summary of the information of the calculated attribute logic obtained by parsing the control part script. When the node information of any node in the first syntax tree is successfully matched in the preset matching data, it indicates that the corresponding calculated attribute logic data can be read depending on the calculated attribute logic in the control part script.
- the node information of the calculated attribute logical node includes the attribute name of the component attribute or the element content of the text element.
- the node object corresponds to a component
- read the component attributes of the node object such as the attrs attribute
- match the attribute names of the component attributes in the preset matching data If the matching is successful, it indicates that the node object depends on Computed attribute logic can use the matched attribute name as calculated attribute logic data.
- the node object corresponds to a text element, read the element content of the text element and match the element content of the text element in the preset matching data. If the match is successful, it indicates that the node object relies on calculated attribute logic.
- the attribute name matched to the node information can be used as calculated attribute logical data.
- the preset matching data is generated based on the control part script in the source code of the front-end business logic file, wherein the method for generating the preset matching data includes: converting the second code part in the source code Convert to a second syntax tree, traverse the node objects in the second syntax tree, and when the corresponding function of any node object includes a specific statement block, generate a prediction based on the calculated attribute name and corresponding function of the node object.
- matching data namely computedmap.
- Intercept the second code part that is, the control part script
- execute the second code part and generate a js object, that is, the computed object, which contains Include computed function.
- the computed object includes key-value pairs, where key is the computed attribute name and value is the computed function.
- Traverse the computed object perform abstract syntax tree analysis through the babel tool, and obtain the second syntax tree.
- any node object includes a specific statement block such as Switch statement SwitchStatement, ifelse statement IfStatement, ternary expression ConditionalExpression, etc.
- a specific statement block such as Switch statement SwitchStatement, ifelse statement IfStatement, ternary expression ConditionalExpression, etc.
- the calculated attribute name of the node object containing a specific statement block is used as the key value, and true is used as the value value to generate preset matching data.
- the logical data in the front-end business logic file is obtained, and corresponding precompiled data is generated based on each logical data.
- an initial function may be created, and the obtained logical data may be added to a preset field of the initial function to obtain precompiled data.
- the precompiled data may be a recompiled render function, and the render function may be a _c function.
- the first parameter of the _c function is the tag name of the element
- the second parameter is a piece of data or a An object. If it is an object, it represents some attribute data of the tag, such as some static styles, class names, element ids, etc. These data will be completely retained in the data attribute of the object in the virtual DOM of the component.
- any object node create a _c function, set the label name of the object node in the first parameter position of the _c function, and set the logical data of the object node in the second parameter position of the _c function. parameter position to obtain the corresponding precompiled data.
- the technical solution provided by this embodiment is to pre-compile the source code to obtain pre-compiled data that can realize the visual display of logical data.
- the pre-compilation process through abstract syntax tree analysis of the source code, the abstract syntax tree corresponding to the source code is obtained, and based on the abstract syntax tree, the instruction type logical data and computational attribute logical data are extracted, and through the preset compilation method And the above logical data obtains corresponding precompiled data to extract the data basis for the visual display of logical data.
- embodiments of the present application also provide a visual processing device for front-end business logic. See Figure 4.
- Figure 4 is a visualization of front-end business logic provided by embodiments of the present application. Structural diagram of the processing device. The device includes:
- the precompiled data acquisition module 310 is configured to obtain precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;
- the data update module 320 is configured to update the original data in the component based on the precompiled data corresponding to the component;
- the page rendering module 330 is configured to render the updated multiple components to obtain a business display page
- the visualization processing module 340 is configured to set a visual identifier for the document object model obtained by the update component when rendering the business display page, wherein the document object model corresponding to the visual identifier triggers the display of the document when selected.
- the object model corresponds to the logical data of the component.
- the visualization processing module 340 is configured to: set a mask layer on the document object model obtained by rendering the business display page by the update component; and/or,
- the update component sets a preset mark at a preset position of the document object model obtained by rendering the business display page.
- the device also includes:
- the logical data display module is configured to read the logical data of the corresponding component of the document object model and display it based on a preset window when a visual operation on any of the document object models is detected.
- the device also includes:
- the path summary data acquisition module is configured to obtain the path summary data of the precompiled data
- the data update module 320 is configured to: when the component executes the hook function, obtain the current path data of the component, and when the current path data of the component is successfully matched in the path summary data, based on the precompilation corresponding to the component Data updates the original data in said component.
- the page rendering module 330 is set to:
- Obtain the precoding data of each component in the front-end business execute the precoding data, and obtain each component instance, and the component instance includes at least one corresponding virtual document object model;
- Each virtual document object model in the component instance is traversed, and each document object model in the business display page is rendered.
- the device also includes: a precompiled data generation module.
- the precompiled data generation module includes:
- the first syntax tree generation submodule is configured to obtain the source code of the front-end business logic file, and convert the first code part in the source code into a first syntax tree.
- the first syntax tree includes instruction class logical nodes and Computed attribute logical node;
- the logical data acquisition submodule is configured to respectively extract the logical data of the instruction type logical node and the computational attribute logical node;
- the data compilation submodule is set to generate corresponding precompiled data.
- the logical data acquisition sub-module is configured to: traverse each instruction class logical node in the first syntax tree, and when the node object of the instruction class logical node includes an instruction class identifier, read the instruction class identifier. Instruction-type logical data in node objects.
- the logical data acquisition submodule is set to:
- the instruction class identifier of the node object includes el.if, then the instruction class of the node object is obtained based on the logical data of the node object, the parent node object of the node object, and the sibling node object of the node object. logical data;
- the expression in the V-show element is read as the instruction class logical data of the node object.
- the logical data acquisition submodule is set to:
- the node information of the calculated attribute logical node includes the attribute name of the component attribute or the element content of the text element.
- the precompiled data generation module also includes:
- the preset matching data generation sub-module is configured to convert the second code part in the source code into The second syntax tree traverses each node object in the second syntax tree, and when the corresponding function of any node object includes a specific statement block, generates a preset match based on the calculated attribute name of the node object and the corresponding function. data.
- the visual processing device for front-end business logic provided by the embodiments of this application can execute the visual processing method of front-end business logic provided by any embodiment of this application, and has corresponding functional modules for executing the visual processing method of front-end business logic.
- embodiments of the present application also provide a front-end business logic visualization system. See Figure 5 , which is a schematic structural diagram of a front-end business logic visualization system provided by embodiments of the present application.
- the front-end business logic visualization system includes a server 410 and a client 420, where the client includes a visualization plug-in 421 and a processor 422;
- the visualization plug-in 421 is configured to generate the source code of the front-end business logic file to the server 410, send a data request to the server 410, and receive the precompiled data fed back by the server 410;
- the server 410 is configured to precompile the source code of the front-end business logic file to obtain precompiled data, where the precompiled data includes the logical data of the component;
- the visualization plug-in 421 is configured to update the original data in the component based on the precompiled data corresponding to the component, and send the updated component data to the processor 422, and when receiving the visualization instruction, send a trigger instruction to the processor 422;
- the processor 422 is configured to render the updated multiple components to obtain a business display page, and upon receiving a trigger instruction, set a visual identifier for the document object model obtained by rendering the business display page with the updated component, wherein, When the visual identifier is selected, it triggers the display of logical data of the corresponding component of the document object model.
- the source code is pre-compiled through the server, and the processing efficiency of the pre-compilation is improved based on the powerful computing power of the server.
- a visualization plug-in is set on the client to replace the original data based on precompiled data containing logical data, so that the processor renders the page based on the updated precompiled data.
- the visualization plug-in can receive an input visualization instruction, or detect a user-input visualization operation, send a visualization trigger signal to the processor so that the processor enters the visualization mode, and the visualization plug-in can receive an input cancellation visualization instruction, or detect a user-input visualization To exit the operation, send a visual exit trigger signal to the processor so that the processor exits the visualization mode to meet the different needs of operating users.
- embodiments of the present application provide an optional example of visual processing of front-end business logic. See Figure 6.
- Figure 6 is another method of visual processing of front-end business logic provided by embodiments of the present application. process diagram.
- the server performs pre-compilation processing of the source code, and obtains pre-compiled data (i.e., compilation results) and sends it to the client.
- the plug-in i.e., visualization plug-in
- pre-injected by the client receives the pre-compiled data and generates data based on the pre-compiled data.
- the new rendering function replaces the original rendering function.
- the client's processor performs visual processing of logical data, obtains component instances, traverses each virtual DOM object in the component instance, and adds a floating window to the corresponding real DOM, and displays the real DOM through the floating window.
- Logical data corresponding to dom logical data corresponding to dom.
- the process of precompiling the source code on the server side can be as follows: intercepting the template part and the control part script respectively from the source code of each .vue file, and processing the control part script to obtain the preset matching data, that is, computedMap.
- the obtained script part is copied into the memory to become a js object, and then the computed value of the object is obtained; the computed object is traversed, the key of the object is the calculated attribute name, the value is a function, the function is serialized, and then Use the babel tool to perform abstract syntax tree analysis; deeply traverse the parsed syntax tree object.
- the logic of the template part mainly consists of three instruction types: directly using v-if to control element mounting, directly using v-show to control whether elements are displayed, and using v-if, v-else-if, and v-else for embedding. set of logic; and the parts that rely on computed properties.
- Convert the template part template into an abstract syntax tree according to The hierarchical relationship generates compiled code, and each node corresponds to an el object.
- Figure 8 is a schematic diagram of the generation of instruction type logical data provided by an embodiment of the present application. Determine whether the el object (i.e. node object) of each element (i.e. node) exists the instruction class identifier el.if.
- each sibling node After negation, it is spliced after the logical information of the el object, or after the splicing information of the if logical information of the el object and the if logical information of the parent node of the el object, to obtain the logical data of the el object.
- FIG. 9 is a schematic diagram of a rendering phase provided by an embodiment of the present application.
- Vue plug-in that is, visualization plug-in
- injection when detecting that the component executes the create hook function, obtains the _file attribute of the component, that is, the current path data of the component. Match the _file attribute in renderMap.
- renderMap stores the correspondence between the render function and its path. If the file attribute is successfully matched in renderMap, replace the component itself with the new rendering function in renderMap (the rendering function in the precompiled data). render function. And after the data update is completed, the processor is triggered to render the component and generate the real DOM.
- Each virtual DOM corresponds to a real DOM on the page, and the element bits of the real DOM can be accurately obtained.
- the visualization phase starts from the root component instance corresponding to the root node of the current page, recursively compiles the nodes with meta tags in the data in the _vnode object in the sub-component, and then appends an absolute layout mask layer after these nodes to implement the
- the logic control elements are visualized, and the logic details are also recorded in the logic data.
- the implementation logic can be obtained and viewed in the logic data.
- FIG. 10 shows a schematic structural diagram of an electronic device 10 that can be used to implement embodiments of the present application.
- Electronic devices are intended to refer to various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers.
- Electronic devices may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (eg, helmets, glasses, watches, etc.), and other similar computing devices.
- the components shown herein, their connections and relationships, and their functions are examples only and are not intended to limit the implementation of the present application as described and/or claimed herein.
- the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (Read-Only Memory, ROM) 12, a random access memory (Random Access Memory, RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can be loaded into the random access memory (RAM) according to the computer program stored in the read-only memory (ROM) 12 or from the storage unit 18.
- a computer program in RAM) 13 to perform various appropriate actions and processes.
- various programs and data required for the operation of the electronic device 10 can also be stored.
- the processor 11, the ROM 12 and the RAM 13 are connected to each other via the bus 14.
- An input/output (I/O) interface 15 is also connected to the bus 14 .
- the I/O interface 15 Multiple components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc. etc.; and communication unit 19, such as network card, modem, wireless communication transceiver, etc.
- the communication unit 19 allows the electronic device 10 to exchange information/data with other devices through computer networks such as the Internet and/or various telecommunications networks.
- Processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. deal with Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (Artificial Intelligence, AI) computing chips, various running machines Processor of learning model algorithm, digital signal processor (Digital Signal Processing, DSP), and any appropriate processor, controller, microcontroller, etc.
- the processor 11 executes various methods and processes described above, such as the visual processing method of front-end business logic.
- the visual processing method of front-end business logic can be implemented as a computer program, which is tangibly included in a computer-readable storage medium, such as the storage unit 18 .
- part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19.
- the processor 11 may be configured to execute the visual processing method of the front-end business logic in any other suitable manner (eg, by means of firmware).
- FPGAs Field Programmable Gate Arrays
- ASICs Application Specific Integrated Circuits
- ASSP Application Specific Standard Parts
- SOC System on Chip
- CPLD Complex Programmable Logic Device
- These various embodiments may include implementation in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor
- the processor which may be a special purpose or general purpose programmable processor, may 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.
- An output device may be a special purpose or general purpose programmable processor, may 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.
- An output device may be a special purpose or general purpose programmable processor, may 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.
- Computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided for general-purpose computers, special-purpose computers, or other programmable The computer program, when executed by the processor, causes the functions/operations specified in the flowcharts and/or block diagrams to be implemented. A computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
- a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device.
- Computer-readable storage media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any suitable combination of the foregoing.
- the computer-readable storage medium may be a machine-readable signal medium.
- machine-readable storage media would include electrical connections based on one or more wires, laptop disks, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM (Erasable Programmable Read-Only Memory) or flash memory), optical fiber, portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical storage device, magnetic storage device, or the above content Any suitable combination.
- RAM random access memory
- ROM read only memory
- EPROM Erasable Programmable Read-Only Memory
- CD-ROM Compact Disc Read-Only Memory
- optical storage device magnetic storage device, or the above content Any suitable combination.
- the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., CRT (Cathode Ray Tube, cathode ray tube) or LCD) for displaying information to the user (Liquid Crystal Display, LCD monitor); and a keyboard and pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device.
- a display device e.g., CRT (Cathode Ray Tube, cathode ray tube) or LCD
- a keyboard and pointing device e.g., a mouse or a trackball
- Other kinds 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 may be provided in any form, including Acoustic input, voice input or tactile input) to receive input from the user.
- the systems and techniques described herein may be implemented in a computing system that includes back-end 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 front-end components (e.g., A user's computer with a graphical user interface or web browser through which the user can interact with the systems and systems described herein technology implementations interact), or in a computing system that includes any combination of such backend components, middleware components, or front-end components.
- the components of the system may be interconnected by any form or medium of digital data communication (eg, a communications network). Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN), blockchain network, and the Internet.
- Computing systems may include clients and servers.
- Clients and servers are generally remote from each other and typically interact over a communications network.
- the relationship of client and server is created by computer programs running on corresponding computers and having a client-server relationship with each other.
- the server can be a cloud server, also known as cloud computing server or cloud host. It is a host product in the cloud computing service system to solve the problems that exist in traditional physical host and virtual private server (VPS) services. It has the disadvantages of difficult management and weak business scalability.
- VPN virtual private server
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Document Processing Apparatus (AREA)
Abstract
Embodiments of the present application disclose a visual processing method, apparatus, and system for front-end service logic. The method comprises: acquiring pre-compiled data of a front-end service logic file, the pre-compiled data comprising logic data of a component; updating original data in the component on the basis of the pre-compiled data corresponding to the component, rendering a plurality of updated components, and obtaining a service display page; and setting a visual identifier for a document object model obtained by rendering the updated component in the service display page, the document object model corresponding to the visual identifier triggering and displaying the logic data of the component corresponding to the document object model when the document object model is selected.
Description
本申请要求在2022年8月30日提交中国专利局、申请号为202211059031.5的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application with application number 202211059031.5, which was submitted to the China Patent Office on August 30, 2022. The entire content of this application is incorporated into this application by reference.
本申请实施例涉及计算机技术领域,例如涉及一种前端业务逻辑的可视化处理方法、装置及系统。The embodiments of the present application relate to the field of computer technology, for example, to a visual processing method, device and system for front-end business logic.
在企业级的前端应用开发过程中,随着web标准化的确立和浏览器的性能提升,前端应用承载了比以往更多且复杂的业务逻辑。由于企业级的应用开发是面向组件维度的,会把在多个区域重复使用的模块抽离成为可复用的组件,随着项目的复杂程度变大,每个组件承载的逻辑也会变得复杂。In the development process of enterprise-level front-end applications, with the establishment of web standardization and the improvement of browser performance, front-end applications carry more and more complex business logic than ever before. Since enterprise-level application development is component-oriented, modules that are reused in multiple areas will be extracted into reusable components. As the complexity of the project increases, the logic carried by each component will also become complex.
在前端应用开发过程中,存在从代码中去了解逻辑详情的需要(例如后续开发人员不了解已开发逻辑,或者需要对已开发逻辑进行再次查看等),需要去阅读源代码,操作繁琐不直观,且查看效率低。In the process of front-end application development, there is a need to understand the logic details from the code (for example, subsequent developers do not understand the developed logic, or need to review the developed logic again, etc.). The source code needs to be read, and the operation is cumbersome and unintuitive. , and the viewing efficiency is low.
发明内容Contents of the invention
本申请提供了一种前端业务逻辑的可视化处理方法、装置及系统,以提高前端业务逻辑代码的可视化查阅。This application provides a visual processing method, device and system for front-end business logic to improve the visual review of front-end business logic code.
根据本申请的一方面,提供了一种前端业务逻辑的可视化处理方法,包括:According to one aspect of this application, a visual processing method for front-end business logic is provided, including:
获取前端业务逻辑文件的预编译数据,其中,所述预编译数据中包括组件的逻辑数据;Obtain the precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;
基于所述组件对应的预编译数据更新所述组件中的原始数据,并对更新后的多个组件进行渲染,得到业务显示页面;Update the original data in the component based on the precompiled data corresponding to the component, and render the updated multiple components to obtain a business display page;
对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标
识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。Set the visual markup for the document object model obtained by rendering the business display page of the update component. identification, wherein when the document object model corresponding to the visual identification is selected, it triggers the display of logical data of the corresponding component of the document object model.
根据本申请的另一方面,提供了一种前端业务逻辑的可视化处理装置,包括:According to another aspect of this application, a visual processing device for front-end business logic is provided, including:
预编译数据获取模块,设置为获取前端业务逻辑文件的预编译数据,其中,所述预编译数据中包括组件的逻辑数据;The precompiled data acquisition module is configured to obtain the precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;
数据更新模块,设置为基于所述组件对应的预编译数据更新所述组件中的原始数据;A data update module configured to update the original data in the component based on the precompiled data corresponding to the component;
页面渲染模块,设置为对更新后的多个组件进行渲染,得到业务显示页面;The page rendering module is set to render multiple updated components to obtain a business display page;
可视化处理模块,设置为对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。The visualization processing module is configured to set a visual identifier for the document object model obtained by rendering the business display page by the update component, wherein the document object model corresponding to the visual identifier triggers the display of the document object when selected. The model corresponds to the logical data of the component.
根据本申请的另一方面,提供了一种前端业务逻辑的可视化系统,包括服务端和客户端,其中,所述客户端包括可视化插件和处理器;According to another aspect of the present application, a front-end business logic visualization system is provided, including a server and a client, wherein the client includes a visualization plug-in and a processor;
所述可视化插件设置为将前端业务逻辑文件的源代码发生至所述服务端,以及向服务端发送数据请求,并接收所述服务器反馈的预编译数据;The visualization plug-in is configured to send the source code of the front-end business logic file to the server, send a data request to the server, and receive precompiled data fed back by the server;
所述服务端设置为对前端业务逻辑文件的源代码进行预编译处理,得到预编译数据,其中,所述预编译数据中包括组件的逻辑数据;The server is configured to precompile the source code of the front-end business logic file to obtain precompiled data, wherein the precompiled data includes the logical data of the component;
所述可视化插件设置为基于所述组件对应的预编译数据更新所述组件中的原始数据,并将更新后的组件数据发送至所述处理器,以及在接收到可视化指令的情况下,向所述处理器发送触发指令;The visualization plug-in is configured to update the original data in the component based on the precompiled data corresponding to the component, send the updated component data to the processor, and upon receiving a visual instruction, send the updated component data to the processor. The processor sends trigger instructions;
所述处理器设置为对更新后的多个组件进行渲染,得到业务显示页面,以及在接收到触发指令的情况下,对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。The processor is configured to render the updated multiple components to obtain a business display page, and when receiving a trigger instruction, set a visual identifier for the document object model obtained by rendering the business display page on the updated component. , wherein when the document object model corresponding to the visual identification is selected, it triggers the display of logical data of the corresponding component of the document object model.
根据本申请的另一方面,提供了一种电子设备,所述电子设备包括:
According to another aspect of the present application, an electronic device is provided, the electronic device including:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行本申请任一实施例所述的前端业务逻辑的可视化处理方法。The memory stores a computer program that can be executed 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 method described in any embodiment of the present application. Visual processing method of front-end business logic.
根据本申请的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本申请任一实施例所述的前端业务逻辑的可视化处理方法。According to another aspect of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions, and the computer instructions are used to implement any of the embodiments of the present application when executed by a processor. Visual processing method of front-end business logic.
图1为本申请实施例提供的一种前端业务逻辑的可视化处理方法的流程图;Figure 1 is a flow chart of a visual processing method for front-end business logic provided by an embodiment of the present application;
图2是本申请实施例提供的一种业务显示页面的示意图;Figure 2 is a schematic diagram of a service display page provided by an embodiment of the present application;
图3是本申请实施例提供的另一种前端业务逻辑的可视化处理方法的流程图;Figure 3 is a flow chart of another visual processing method of front-end business logic provided by an embodiment of the present application;
图4是本申请实施例提供的一种前端业务逻辑的可视化处理装置的结构示意图;Figure 4 is a schematic structural diagram of a front-end business logic visual processing device provided by an embodiment of the present application;
图5是本申请实施例提供的一种前端业务逻辑的可视化系统的结构示意图;Figure 5 is a schematic structural diagram of a front-end business logic visualization system provided by an embodiment of the present application;
图6是本申请实施例提供的另一种前端业务逻辑的可视化处理方法的流程示意图;Figure 6 is a schematic flow chart of another visual processing method of front-end business logic provided by an embodiment of the present application;
图7是本申请实施例提供的抽象语法树解析示意图;Figure 7 is a schematic diagram of abstract syntax tree parsing provided by an embodiment of the present application;
图8是本申请实施例提供的一种指令类逻辑数据的生成示意图;Figure 8 is a schematic diagram of the generation of instruction-type logical data provided by an embodiment of the present application;
图9是本申请实施例提供的一种渲染阶段的示意图;Figure 9 is a schematic diagram of a rendering stage provided by an embodiment of the present application;
图10是本申请实施例提供的一种电子设备的结构示意图。Figure 10 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施
例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。In order to enable those in the technical field to better understand the solution of this application, the following will be implemented in conjunction with this application The accompanying drawings in the examples clearly and completely describe the technical solutions in the embodiments of the present application.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances so that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus that encompasses a series of steps or units and need not be limited to those explicitly listed. Those steps or elements may instead include other steps or elements not expressly listed or inherent to the process, method, product or apparatus.
图1为本申请实施例提供的一种前端业务逻辑的可视化处理方法的流程图,本实施例可适用于对前端业务逻辑在业务显示页面中进行可视化显示的情况,该方法可以由本申请实施例提供的前端业务逻辑的可视化处理装置来执行,该前端业务逻辑的可视化处理装置可以由软件和/或硬件来实现,该前端业务逻辑的可视化处理装置可以配置在电子计算设备上,包括如下步骤:Figure 1 is a flow chart of a visual processing method of front-end business logic provided by an embodiment of the present application. This embodiment can be applied to the situation where the front-end business logic is visually displayed in a business display page. This method can be implemented by the embodiment of the present application. The provided front-end business logic visual processing device is executed. The front-end business logic visual processing device can be implemented by software and/or hardware. The front-end business logic visual processing device can be configured on an electronic computing device, including the following steps:
S110、获取前端业务逻辑文件的预编译数据,其中,所述预编译数据中包括组件的逻辑数据。S110. Obtain the precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component.
S120、基于所述组件对应的预编译数据更新所述组件中的原始数据,并对更新后的多个组件进行渲染,得到业务显示页面。S120. Update the original data in the component based on the precompiled data corresponding to the component, and render the updated multiple components to obtain a business display page.
S130、对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。S130. Set a visual identifier for the document object model obtained by rendering the business display page by the update component. When the document object model corresponding to the visual identifier is selected, it triggers the display of the component corresponding to the document object model. logical data.
本实施例中,前端业务逻辑文件可以是前端应用的业务逻辑文件,其中,前端应用可以包括但不限于web端应用或者H5端应用等。在一些实施例中,前端应用可以是基于预设框架开发的应用,例如预设框架可以是包括但不限于Vue框架。以Vue框架开发的前端应用为例,前端业务逻辑文件可以是.vue文件,
其中,每一.vue文件包括三部分构成,即模板部分(template)、控制部分(script)和样式部分(style)。模板部分负责的是页面主要视图的渲染,控制部分负责提供模板部分渲染所需的数据及负责一些逻辑处理,如ajax请求、交互相关的处理等,样式部分即css(Cascading Style Sheets,层叠样式表),负责页面样式。需要说明的是,在其他框架开发的前端应用中,前端业务逻辑文件可以包括不同的部分,对此不作限定。In this embodiment, the front-end business logic file may be a business logic file of a front-end application, where the front-end application may include but is not limited to a web application or an H5 application. In some embodiments, the front-end application may be an application developed based on a preset framework. For example, the preset framework may include but is not limited to the Vue framework. Taking the front-end application developed by the Vue framework as an example, the front-end business logic file can be a .vue file. Among them, each .vue file consists of three parts, namely the template part (template), the control part (script) and the style part (style). The template part is responsible for the rendering of the main view of the page. The control part is responsible for providing the data required for rendering the template part and responsible for some logical processing, such as ajax requests, interaction-related processing, etc. The style part is css (Cascading Style Sheets, cascading style sheets). ), responsible for page styling. It should be noted that in front-end applications developed by other frameworks, the front-end business logic file can include different parts, and there is no limit to this.
由于浏览器只能加载.js文件,因此.vue文件需要通过预设的编译器vue-template-compiler来编译成为.js文件。由于控制部分本身就是纯JavaScript代码,因此这部分无须额外编译。编译器处理的核心是将模板部分编译成一个纯的JavaScript函数render。随后组件在挂载在页面之前会执行render函数生成虚拟DOM,随后会由Vue的运行时模块将其渲染成为真正的DOM元素,从而能够展现在浏览器上。而每一个.vue文件最终会被执行成为一个组件的实例vm(即VueComponent),其中vm对象中包括_vnode对象,里面保存着组件render函数的返回值,即虚拟DOM(Document Object Model,文档对象模型),是一个纯的JavaScript对象。Since the browser can only load .js files, the .vue file needs to be compiled into a .js file through the default compiler vue-template-compiler. Since the control part itself is pure JavaScript code, no additional compilation is required for this part. The core of the compiler processing is to compile the template part into a pure JavaScript function render. Then the component will execute the render function to generate a virtual DOM before being mounted on the page, which will then be rendered into a real DOM element by Vue's runtime module, so that it can be displayed on the browser. Each .vue file will eventually be executed into an instance vm of a component (i.e. VueComponent). The vm object includes the _vnode object, which stores the return value of the component render function, that is, the virtual DOM (Document Object Model). model), is a pure JavaScript object.
示例性的,组件实例中虚拟DOM可如下所示:For example, the virtual DOM in the component instance can be as follows:
vnode:VNodevnode:VNode
tag:“div”tag: "div"
data属性:undefineddata attribute:undefined
children:Array(2)children:Array(2)
text:undefinedtext:undefined
elm:<div>…<div>elm:<div>…<div>
ns:undefinedns:undefined
……
需要说明的是,在上述vue-template-compiler编码器的编译方式中,虚拟DOM中不包括逻辑数据(即data属性后不存在逻辑数据),使得基于上述虚拟DOM渲染得到的业务显示页面无法进行逻辑数据的可视化显示,相应的,操作
人员需求从前端业务逻辑文件的源代码中查询逻辑数据。It should be noted that in the compilation method of the above vue-template-compiler encoder, the virtual DOM does not include logical data (that is, there is no logical data after the data attribute), making the business display page rendered based on the above virtual DOM impossible. Visual display of logical data and corresponding operations Personnel needs to query logical data from the source code of the front-end business logic file.
针对上述技术问题,本申请中对前端业务逻辑文件的源代码进行预编译处理,得到包括逻辑数据的预编译数据,以使得通过预编译数据渲染得到的业务显示页面可实现对前端业务逻辑文件的逻辑数据进行可视化显示。需要说明的是,本实施例中不限定预编译数据的生成方式,以及执行预编译过程的执行主体,可得到包含逻辑数据的预编译数据即可。In view of the above technical problems, in this application, the source code of the front-end business logic file is pre-compiled to obtain pre-compiled data including logical data, so that the business display page obtained by rendering the pre-compiled data can realize the processing of the front-end business logic file. Logical data is displayed visually. It should be noted that in this embodiment, the generation method of the precompiled data and the execution subject that executes the precompiled process are not limited, as long as the precompiled data containing logical data can be obtained.
各组件的前端业务逻辑文件的原始数据中不包括逻辑数据,其中,前端业务逻辑文件的原始数据可以是基于前端业务逻辑文件的源代码经过常规编译得到原始编译数据,该原始编译数据中包括原始渲染函数,该原始渲染函数中不包括逻辑数据。本实施例中,在对组件实例进行渲染之前,通过预编译数据更新对应组件的原始数据,以基于组件的预编译数据进行组件实例的渲染,得到可进行逻辑数据可视化的业务显示页面。The original data of the front-end business logic file of each component does not include logical data. The original data of the front-end business logic file can be the original compiled data obtained through regular compilation based on the source code of the front-end business logic file. The original compiled data includes the original Rendering function, the original rendering function does not include logical data. In this embodiment, before rendering the component instance, the original data of the corresponding component is updated through precompiled data, and the component instance is rendered based on the precompiled data of the component to obtain a business display page that can visualize logical data.
可选的,将预编译数据与组件进行匹配,对匹配成功的组件进行数据更新,例如基于预编译数据替换组件的原始数据,示例性的,通过包含逻辑数据的render函数替换不包含逻辑数据的render函数。在一些实施例中,预编译数据与组件的匹配可以是通过组件标识实现,或者通过路径数据匹配实现。Optionally, match the precompiled data with the component, and update the data of the successfully matched component, for example, replace the original data of the component based on the precompiled data. For example, replace the component that does not contain logical data through the render function that contains logical data. render function. In some embodiments, the matching of precompiled data and components may be achieved through component identifiers or through path data matching.
在上述实施例的基础上,在对原始数据的预编译过程中生成预编译数据的路径汇总数据,该预编译数据的路径汇总数据包括预编译数据以及其路径数据的对应关系。示例性的,预编译数据的路径汇总数据rendermap可以是以键值对的形式进行存储,例如key中存储一预编译数据的路径数据,value中存储该预编译数据。相应的,可以通过获取所述预编译数据的路径汇总数据的方式,得到预编译数据以及对应的路径数据。Based on the above embodiment, the path summary data of the precompiled data is generated during the precompilation process of the original data. The path summary data of the precompiled data includes the precompiled data and the corresponding relationship between the path data. For example, the path summary data rendermap of the precompiled data can be stored in the form of a key-value pair. For example, the path data of the precompiled data is stored in the key and the precompiled data is stored in the value. Correspondingly, the precompiled data and corresponding path data can be obtained by obtaining the path summary data of the precompiled data.
可选的,基于所述组件对应的预编译数据更新所述组件中的原始数据,包括:在组件执行钩子函数时,获取所述组件的当前路径数据,在组件的当前路径数据在所述路径汇总数据中匹配成功的情况下,基于所述组件对应的预编译数据更新所述组件中的原始数据。
Optionally, updating the original data in the component based on the precompiled data corresponding to the component includes: when the component executes the hook function, obtain the current path data of the component, and when the current path data of the component is in the path If the matching in the summary data is successful, the original data in the component is updated based on the precompiled data corresponding to the component.
本实施例中,检测组件执行钩子函数的时机,在检测到组件执行钩子函数时,获取所述组件的当前路径数据,示例性的,在组件执行created钩子函数时,获取组件的__file属性信息,该__file属性信息包括组件的当前路径数据,将组件的当前路径数据与预编译数据的路径汇总数据进行匹配,在当前路径数据与路径汇总数据任一路径数据匹配成功的情况下,表明该组件是该前端业务中的自定义组件,可对该自定义组件进行逻辑数据的可视化显示,将匹配成功的路径数据对应的预编译数据替代该组件的原始数据。In this embodiment, the timing of the component executing the hook function is detected. When it is detected that the component executes the hook function, the current path data of the component is obtained. For example, when the component executes the created hook function, the __file attribute information of the component is obtained. , the __file attribute information includes the current path data of the component, and matches the current path data of the component with the path summary data of the precompiled data. If the current path data and any path data of the path summary data match successfully, it indicates that the The component is a custom component in the front-end business. The custom component can display logical data visually, and replace the original data of the component with the precompiled data corresponding to the successfully matched path data.
需要说明的是,用于渲染业务显示页面的组件包括自定义组件和非自定义组件,该非自定义组件可以是第三方组件,无法获取该非自定义组件的逻辑数据,相应的,无法对非自定义组件进行逻辑数据的可视化显示。相应的,用于渲染业务显示页面的组件包括数据更新后的自定义组件和未进行数据更新的非自定义组件。通过对上述各组件进行渲染,得到业务显示页面。It should be noted that the components used to render the business display page include custom components and non-custom components. The non-custom component can be a third-party component. The logical data of the non-custom component cannot be obtained. Accordingly, it cannot be processed. Non-custom components perform visual display of logical data. Correspondingly, the components used to render the business display page include custom components after data update and non-custom components without data update. By rendering each of the above components, the business display page is obtained.
可选的,对更新后的多个组件进行渲染,得到业务显示页面,包括:获取前端业务中组件的预编码数据,执行所述预编码数据,得到组件实例,所述组件实例中包括对应的至少一个虚拟文档对象模型;遍历所述组件实例中的虚拟文档对象模型,渲染得到业务显示页面中的文档对象模型。Optionally, rendering multiple updated components to obtain a business display page includes: obtaining precoding data of components in the front-end business, executing the precoding data, and obtaining component instances. The component instances include corresponding At least one virtual document object model; traverse the virtual document object model in the component instance, and render the document object model in the business display page.
本实施例中,组件的预编码数据的预设字段位置,设置该组件的逻辑数据,在执行预编码数据的过程中,将预编码数据中的逻辑数据注入到组件实例的虚拟文档对象模型的实例中,示例性的,将逻辑数据拼接到上述“data属性”之后,得到包括逻辑数据的虚拟DOM。分别执行自定义组件的预编码数据和非自定义组件的原始数据,分别得到各个组件实例,即更新后的组件实例和未更新的组件实例。任意一个组件实例中可以是包括多个虚拟DOM,不同的虚拟DOM之间可以是存在父子关系。每一虚拟DOM在业务显示页面中对应一真实DOM,遍历各组件实例的各个虚拟DOM,渲染得到业务显示页面中的各真实DOM,相应的,得到业务显示页面。In this embodiment, the preset field position of the precoded data of the component is set to the logical data of the component. During the process of executing the precoded data, the logical data in the precoded data is injected into the virtual document object model of the component instance. In the example, after splicing the logical data to the above-mentioned "data attribute", a virtual DOM including the logical data is obtained. Execute the precoded data of the custom component and the original data of the non-custom component respectively to obtain each component instance, that is, the updated component instance and the non-updated component instance. Any component instance can include multiple virtual DOMs, and there can be a parent-child relationship between different virtual DOMs. Each virtual DOM corresponds to a real DOM in the business display page. Each virtual DOM of each component instance is traversed, and each real DOM in the business display page is rendered. Correspondingly, the business display page is obtained.
在遍历每一虚拟DOM渲染得到业务显示页面中的真实DOM之后,还可以
是对自定义组件进行可视化处理。其中,可视化处理可以是在业务显示页面对自定义组件对应的真实DOM设置可视化标识,便于操作人员可通过可视化标识确定业务显示页面中的自定义组件。其中,自定义组件可以是更新了预编译数据的组件,即更新组件。After traversing each virtual DOM and rendering to obtain the real DOM in the business display page, you can also It is a visual processing of custom components. The visual processing may be to set a visual identification on the real DOM corresponding to the custom component on the business display page, so that the operator can determine the custom component in the business display page through the visual identification. Among them, the custom component can be a component that updates precompiled data, that is, an update component.
在一些实施例中,可以是对注入逻辑数据的data属性设置元标记,便于在在进行虚拟DOM的遍历过程中,快速识别存在逻辑数据的虚拟DOM。相应的,可将设置有元标记的虚拟DOM,对应的真实dom设置进行可视化处理。In some embodiments, a meta tag may be set for the data attribute in which logical data is injected, so as to quickly identify the virtual DOM in which logical data exists during the traversal process of the virtual DOM. Correspondingly, the virtual DOM set with meta tags and the corresponding real DOM settings can be visualized.
在一些实施例中,对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,包括:对所述更新组件在对所述业务显示页面渲染得到的文档对象模型设置遮罩层。其中,可以是通过对文档对象模型(真实DOM)上设置一图层,以对文档对象模型进行遮挡形式,设置可视化标识。其中,遮罩层可以是区别于文档对象模型或者业务显示页面的颜色,便于进行直观提示。可选的,遮罩层的尺寸可以是根据文档对象模型的尺寸确定,其中,遮罩层的尺寸可以是大于等于文档对象模型的尺寸。可选的,遮罩层的形状可以是与文档对象模型的形状一致,本实施例对遮罩层的形状不作限定。不同的文档对象模型的遮罩层可以不同形式展示。示例性的,参见图2,图2是本申请实施例提供的一种业务显示页面的示意图。其中,图2中包括部分设置有可视化标识的文档对象模型,也包括部分未设置可视化标识的文档对象模型,该未设置可视化标识的文档对象模型可以是不存在逻辑数据的文档对象模型和/或无法得到逻辑数据的非自定义组件对应的文档对象模型。In some embodiments, setting a visual identifier for the document object model obtained by the update component when rendering the business display page includes: setting a mask layer for the document object model obtained when the update component renders the business display page. . Among them, a layer can be set on the document object model (real DOM) to block the document object model and set a visual mark. Among them, the mask layer can be a color different from the document object model or the business display page to facilitate visual prompts. Optionally, the size of the mask layer may be determined based on the size of the document object model, where the size of the mask layer may be greater than or equal to the size of the document object model. Optionally, the shape of the mask layer may be consistent with the shape of the document object model. This embodiment does not limit the shape of the mask layer. Mask layers of different document object models can be displayed in different forms. For example, see Figure 2, which is a schematic diagram of a service display page provided by an embodiment of the present application. Among them, Figure 2 includes some document object models with visual identifiers and some document object models without visual identifiers. The document object models without visual identifiers can be document object models that do not have logical data and/or The document object model corresponding to the non-custom component of the logical data cannot be obtained.
在一些实施例中,对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,包括:在所述更新组件在对所述业务显示页面渲染得到的文档对象模型的预设位置处设置预设标记。可选的,预设标记可以是预设形状和/或预设颜色的图形标记(例如包括但不限于三角形标记、五角星标记或者红色圆形标记等),还可以是预设的符号标记(例如包括但不限于诸如“!”、“*”或者固定数字或者字符串等的标记),还可以是序列化标记(例如包括但不限于
123、ABC等的序列化标记等)等。示例性的,参见图2,图2中各包含逻辑数据的文档对象模型设置有序列化标记,该序列化标记可以是根据对应虚拟DOM的遍历顺序确定。In some embodiments, setting a visual identifier for the document object model obtained by rendering the business display page by the update component includes: setting a visual identifier at a preset position of the document object model obtained by rendering the business display page by the update component. Set a preset mark at. Optionally, the preset mark may be a graphical mark of a preset shape and/or a preset color (for example, including but not limited to a triangle mark, a five-pointed star mark or a red circle mark, etc.), or a preset symbol mark ( For example, including but not limited to tags such as "!", "*" or fixed numbers or strings, etc.), or serialization tags (such as but not limited to 123, serialization tags of ABC, etc.), etc. For example, see Figure 2. In Figure 2, each document object model containing logical data is set with a serialization mark. The serialization mark can be determined according to the traversal order of the corresponding virtual DOM.
在一些实施例中,文档对象模型设置可视化标识可以同时包括遮罩层和预设标记。In some embodiments, the document object model setting visual identification may include both a mask layer and a preset mark.
在上述实施例的基础上,在得到业务显示页面之后,还包括:在业务显示页面中文档对象模型的预设位置处设置浮窗,该浮窗用于显示对应文档对象模型的逻辑数据。通过将具有逻辑数据的文档对象模型,分别设置浮窗,以同步显示各文档对象模型的逻辑数据,便于操作用户直观查看各文档对象模型的逻辑数据。在一些实施例中,浮窗可关闭,以根据操作人员需求关闭无需查看的浮窗或者已查看的浮窗。Based on the above embodiment, after obtaining the business display page, the method further includes: setting a floating window at a preset position of the document object model in the business display page, and the floating window is used to display logical data corresponding to the document object model. By setting up floating windows for document object models with logical data, the logical data of each document object model can be displayed synchronously, making it easier for operating users to intuitively view the logical data of each document object model. In some embodiments, the floating window can be closed to close the floating window that does not need to be viewed or the floating window that has been viewed according to the operator's needs.
在上述实施例的基础上,设置有可视化标识的文档对象模型在被选择的情况下,显示其对应的逻辑数据,以使得操作人员在业务显示页面可视化的查看每一设置有可视化标识文档对象模型的逻辑数据,无需进入前端业务逻辑文件的源代码中查看,简化了逻辑数据的查看方式,提高了逻辑数据的查看效率。同时,可根据操作人员的查看需求进行针对性的逻辑数据的显示。On the basis of the above embodiment, when the document object model set with visual identification is selected, its corresponding logical data is displayed, so that the operator can visually view each document object model set with visual identification on the business display page. The logical data does not need to be viewed in the source code of the front-end business logic file, which simplifies the viewing method of logical data and improves the viewing efficiency of logical data. At the same time, targeted logical data can be displayed according to the operator's viewing needs.
可选的,所述方法还包括:在检测到对任一所述文档对象模型的可视化操作的情况下,读取所述文档对象模型对应组件的逻辑数据,并基于预设窗口进行显示。本实施例中,通过检测操作用户对文档对象模型的可视化操作,确定文档对象模型被选择,其中,对任一所述文档对象模型的可视化操作包括但不限于对文档对象模型的点击、对文档对象模型的可视化标识的选择、鼠标或光标位于文档对象模型的检测范围等。Optionally, the method further includes: when a visual operation on any of the document object models is detected, reading the logical data of the corresponding component of the document object model and displaying it based on a preset window. In this embodiment, it is determined that the document object model is selected by detecting the user's visual operation on the document object model. The visual operation on any of the document object models includes but is not limited to clicking on the document object model, clicking on the document object model, and clicking on the document object model. The selection of the visual identification of the object model, the mouse or cursor being located in the detection range of the document object model, etc.
检测对任一所述文档对象模型的可视化操作,生成逻辑数据的可视化指令,执行该可视化指令,从文档对象模型对应的虚拟DOM中读取逻辑数据,例如读取文档对象模型对应的虚拟DOM中data属性数据。将读取的逻辑数据在业务显示页面进行显示,可选的,可以是在业务显示页面设置一逻辑数据的显示区
域,在显示区域内显示被选择的文档对象模型的逻辑数据。可选的,通过弹窗或者悬浮窗的形式显示被选择的文档对象模型的逻辑数据。本实施例中,不限定文档对象模型的逻辑数据的显示方式,可在业务显示页面进行可视化显示即可,对此不作限定。Detecting visual operations on any of the document object models, generating visual instructions for logical data, executing the visual instructions, and reading logical data from the virtual DOM corresponding to the document object model, for example, reading the virtual DOM corresponding to the document object model. data attribute data. Display the read logical data on the business display page. Optionally, you can set a logical data display area on the business display page. Domain displays the logical data of the selected document object model in the display area. Optionally, display the logical data of the selected document object model in the form of a pop-up window or a floating window. In this embodiment, the display method of the logical data of the document object model is not limited. It can be visually displayed on the business display page, and there is no limitation on this.
在上述实施例的基础上,在步骤S130之前,还可以包括接收可视化指令,以进入可视化模式,即执行步骤S130,在可视化模式可显示文档对象模型的可视化标识和逻辑数据。在步骤S130之后,还可以包括接收取消可视化指令,以退出可视化模式,避免可视化模式对其他操作的影响。Based on the above embodiment, before step S130, it may also include receiving a visualization instruction to enter the visualization mode, that is, executing step S130. In the visualization mode, the visual identification and logical data of the document object model may be displayed. After step S130, it may also include receiving a cancellation instruction to exit the visualization mode to avoid the impact of the visualization mode on other operations.
在一些实施例中,业务显示页面中可以是设置有可视化切换控件,该可视化切换控件可以是由一个或两个控件实现。可视化切换控件设置为实现可视化模式的进入和退出。In some embodiments, the business display page may be provided with a visual switching control, and the visual switching control may be implemented by one or two controls. The visualization switch control is set to realize the entry and exit of the visualization mode.
本实施例的提供的技术方案,通过将包含逻辑数据的预编译数据更新各组件的原始数据,并通过各组件的预编译数据进行页面渲染,对渲染得到的业务显示页面中各文档对象模型设置可视化标识,通过该可视化标识可直观的在业务显示页面中确定存在逻辑数据的文档对象模型,同时业务显示页面中各文档对象模型具有逻辑数据的显示功能,在文档对象模型被触发的情况下,可将对应的逻辑数据进行可视化显示,无需对前端业务逻辑文件源代码进行查询,可在业务显示页面实现逻辑数据的查询,简化了逻辑数据的查询方式,提高了逻辑数据的查询效率,尤其是在多人协作开发或者新人接手项目的情况下,便于快速查看开发进度和逻辑数据的编辑方式。The technical solution provided by this embodiment is to update the original data of each component with pre-compiled data containing logical data, and perform page rendering through the pre-compiled data of each component, so as to set the document object model of each document in the rendered business display page. Visual identification, through which the document object model with logical data can be intuitively determined in the business display page. At the same time, each document object model in the business display page has the display function of logical data. When the document object model is triggered, The corresponding logical data can be visually displayed without querying the source code of the front-end business logic file. Logical data query can be realized on the business display page, which simplifies the query method of logical data and improves the query efficiency of logical data, especially When multiple people collaborate on development or new people take over the project, it is convenient to quickly check the development progress and the editing method of logical data.
在上述实施例中,对逻辑数据的可视化显示依赖于对原始数据的预编译处理,在一些实施例中,客户端获取前端业务逻辑文件的源代码,对该源代码进行预编译处理,得到预编译数据。在一些实施例中,客户端将前端业务逻辑文件的源代码发送至服务端,服务端对源代码进行预编译处理,得到预编译数据。服务端计算能力强,可提高预编译过程的效率。
In the above embodiments, the visual display of logical data relies on the pre-compilation process of the original data. In some embodiments, the client obtains the source code of the front-end business logic file, pre-compiles the source code, and obtains the pre-compile process. Compile data. In some embodiments, the client sends the source code of the front-end business logic file to the server, and the server pre-compiles the source code to obtain pre-compiled data. The server has strong computing power, which can improve the efficiency of the pre-compilation process.
示例性的,参见图3,图3是本申请实施例提供的另一种前端业务逻辑的可视化处理方法的流程图。该方法包括以下步骤:For example, see FIG. 3 , which is a flow chart of another visual processing method of front-end business logic provided by an embodiment of the present application. The method includes the following steps:
S210、将前端业务逻辑文件的源代码发送至服务端,以使服务端对前端业务逻辑文件的源代码进行预编译处理。S210. Send the source code of the front-end business logic file to the server, so that the server pre-compiles the source code of the front-end business logic file.
S220、向服务端发送预编译数据请求,并接收服务端反馈的预编译数据。S220: Send a precompiled data request to the server, and receive the precompiled data fed back by the server.
S230、基于所述组件对应的预编译数据更新所述组件中的原始数据,并对更新后的多个组件进行渲染,得到业务显示页面。S230. Update the original data in the component based on the precompiled data corresponding to the component, and render the updated multiple components to obtain a business display page.
S240、对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。S240. Set a visual identifier for the document object model obtained by rendering the business display page by the update component, wherein when the document object model corresponding to the visual identifier is selected, it triggers the display of the component corresponding to the document object model. logical data.
预编译数据在客户端和服务端的生成过程相同,其中,预编译数据的生成方式包括:获取前端业务逻辑文件的源代码,将所述源代码中的第一代码部分转换为第一语法树,所述第一语法树中包括指令类逻辑节点和计算属性逻辑节点;分别提取所述指令类逻辑节点和所述计算属性逻辑节点的逻辑数据,并生成对应的预编译数据。The generation process of precompiled data is the same on the client and server. The generation method of precompiled data includes: obtaining the source code of the front-end business logic file, converting the first code part in the source code into the first syntax tree, The first syntax tree includes instruction type logical nodes and computational attribute logical nodes; logical data of the instruction type logical nodes and the computational attribute logical nodes are extracted respectively, and corresponding precompiled data is generated.
本实施例中的前端应用为Vue框架的前端应用,相应的,对前端业务逻辑文件的源代码的预编译过程即将源代码的模板部分template和控制部分script中涉及到逻辑控制部分的信息通过对象字符串的形式写到渲染函数(即render函数)中,得到预编译数据。模板部分和控制部分都涉及到前端的业务逻辑:模板部分中包括使用v-if、v-show、v-for等指令来进行元素的挂载、显示、循环等指令类逻辑;控制部分中包括利用计算属性computed来对模板渲染所需要的数据进行控制的计算属性逻辑,即模板部分中还包括依赖于计算属性逻辑的渲染数据。The front-end application in this embodiment is the front-end application of the Vue framework. Correspondingly, the pre-compilation process of the source code of the front-end business logic file is to pass the information related to the logic control part in the template part template and control part script of the source code through the object Write the string form into the rendering function (i.e. render function) to get the precompiled data. Both the template part and the control part involve the front-end business logic: the template part includes the use of v-if, v-show, v-for and other instructions to mount, display, loop and other instruction logic of elements; the control part includes Computed attribute logic is used to control the data required for template rendering by using the computed attribute. That is, the template part also includes rendering data that depends on the calculated attribute logic.
由于控制部分script本身就是纯JavaScript代码,因此这部分无须额外编译,相应的,源代码中的第一代码部分为模板部分template。将模板部分template转换为第一语法树,该第一语法树中包括多个节点,所述多个节点包括指令类逻
辑节点和计算属性逻辑节点。Since the control part script itself is pure JavaScript code, this part does not require additional compilation. Correspondingly, the first code part in the source code is the template part. Convert the template part template into a first syntax tree. The first syntax tree includes a plurality of nodes, and the plurality of nodes include instruction class logic. Edit nodes and computed attribute logical nodes.
模板部分中指令类逻辑包括直接使用v-if去控制元素挂载、直接使用v-show控制元素是否展现、以及使用v-if、v-else-if、v-else的嵌套逻辑。相应的,对于指令类逻辑节点,每个节点对应一个el对象,解析el对象上的逻辑信息,以得到每个指令类逻辑节点的逻辑数据。The instruction logic in the template part includes directly using v-if to control element mounting, directly using v-show to control whether elements are displayed, and using v-if, v-else-if, and v-else nested logic. Correspondingly, for instruction type logical nodes, each node corresponds to an el object, and the logical information on the el object is parsed to obtain the logical data of each instruction type logical node.
在一些实施例中,提取所述指令类逻辑节点的逻辑数据,包括:遍历所述第一语法树中的指令类逻辑节点,在所述指令类逻辑节点的节点对象中包括指令类标识的情况下,读取所述节点对象中的指令类逻辑数据。In some embodiments, extracting the logical data of the instruction type logical node includes: traversing the instruction type logical node in the first syntax tree, and when the node object of the instruction type logical node includes an instruction class identifier. Next, read the instruction type logical data in the node object.
可选的,第一语法树中节点可存在指令类逻辑节点和计算属性逻辑节点的区分,遍历指令类逻辑节点,得到指令类逻辑节点的指令类逻辑数据。可选的,第一语法树中节点不存在指令类逻辑节点和计算属性逻辑节点的区分,遍历第一语法树中的节点,通过判断是否存在指令类标识,确定节点是否为指令类逻辑节点,并在节点对象中存在指令类标识时,得到指令类逻辑节点的指令类逻辑数据。Optionally, the nodes in the first syntax tree may be distinguished between instruction type logical nodes and computational attribute logical nodes, and the instruction type logical nodes are traversed to obtain instruction type logical data of the instruction type logical nodes. Optionally, the nodes in the first syntax tree do not have a distinction between instruction type logical nodes and computed attribute logical nodes. The nodes in the first syntax tree are traversed, and whether the nodes are instruction type logical nodes is determined by determining whether there is an instruction class identifier. And when the instruction class identifier exists in the node object, the instruction class logical data of the instruction class logical node is obtained.
示例性的,指令类标识可以包括但不限于el.if和el.show。相应的,读取所述节点对象中的指令类逻辑数据,包括:若所述节点对象的指令类标识包括el.if,则基于所述节点对象、所述节点对象的父节点对象、所述节点对象的兄弟节点对象的逻辑数据,得到所述节点对象的指令类逻辑数据;若所述节点对象的指令类标识包括el.show,则读取V-show元素中的表达式为所述节点对象的指令类逻辑数据。For example, instruction class identifiers may include but are not limited to el.if and el.show. Correspondingly, reading the instruction class logical data in the node object includes: if the instruction class identifier of the node object includes el.if, then based on the node object, the parent node object of the node object, and the The logical data of the sibling node object of the node object is obtained to obtain the instruction type logical data of the node object; if the instruction type identifier of the node object includes el.show, the expression in the V-show element is read as the node The instruction-type logical data of the object.
在节点对象即el对象中包括指令类标识el.if的情况下,确定该节点对象的父节点是否存在if属性,以及确定该节点对象是否存在el.elseif、el.else的兄弟节点。在父节点不存在if属性,以及不存在el.elseif、el.else的兄弟节点的情况下,提取el对象中的逻辑信息,并将提取的逻辑信息确定为节点的指令类逻辑数据。在父节点存在if属性的情况下,提取父节点if属性中的逻辑信息,在节点对象存在el.elseif和/或el.else的兄弟节点的情况下,提取兄弟节点el.elseif和
/或el.else中的逻辑信息。将提取的父节点的逻辑信息和/或兄弟节点的逻辑数据取非后,与el对象中的逻辑信息进行拼接,得到该节点的指令类逻辑数据。When the node object, that is, the el object, includes the instruction class identifier el.if, it is determined whether the parent node of the node object has an if attribute, and whether the node object has sibling nodes of el.elseif and el.else. When the parent node does not have an if attribute and there are no sibling nodes of el.elseif and el.else, the logical information in the el object is extracted, and the extracted logical information is determined as the instruction type logical data of the node. When the parent node has an if attribute, extract the logical information in the parent node's if attribute. When the node object has el.elseif and/or el.else's sibling nodes, extract the sibling nodes el.elseif and el.elseif. /or logical information in el.else. After negating the extracted logical information of the parent node and/or the logical data of the sibling nodes, they are spliced with the logical information in the el object to obtain the instruction type logical data of the node.
在节点对象即el对象中包括指令类标识el.show的情况下,读取V-show元素中的表达式为所述节点对象的指令类逻辑数据。When the node object, that is, the el object, includes the instruction class identifier el.show, the expression in the V-show element is read as the instruction class logical data of the node object.
在一些实施例中,提取所述计算属性逻辑节点的逻辑数据,包括:遍历所述第一语法树中的计算属性逻辑节点,在所述计算属性逻辑节点的节点信息在预设匹配数据中匹配成功的情况下,读取所述计算属性逻辑节点的属性名作为逻辑数据。其中,预设匹配数据是对控制部分script进行解析处理得到的计算属性逻辑的信息汇总。在第一语法树中任一节点的节点信息在预设匹配数据中匹配成功的情况下,表明依赖于控制部分script中的计算属性逻辑,可读取对应的计算属性逻辑数据。In some embodiments, extracting the logical data of the computed attribute logical node includes: traversing the computed attribute logical node in the first syntax tree, and matching the node information of the computed attribute logical node in the preset matching data. If successful, read the attribute name of the calculated attribute logical node as logical data. Among them, the preset matching data is a summary of the information of the calculated attribute logic obtained by parsing the control part script. When the node information of any node in the first syntax tree is successfully matched in the preset matching data, it indicates that the corresponding calculated attribute logic data can be read depending on the calculated attribute logic in the control part script.
可选的,计算属性逻辑节点的节点信息包括组件属性的属性名或者文本元素的元素内容。在节点对象对应组件的情况下,读取节点对象的组件属性(例如attrs属性),将组件属性的属性名在预设匹配数据中进行匹配,在匹配成功的情况下,表明该节点对象依赖于计算属性逻辑,可将匹配到的属性名作为计算属性逻辑数据。在节点对象对应文本元素的情况下,读取文本元素的元素内容,将文本元素的元素内容在预设匹配数据中进行匹配,在匹配成功的情况下,表明该节点对象依赖于计算属性逻辑,可将节点信息匹配到的属性名作为计算属性逻辑数据。Optionally, the node information of the calculated attribute logical node includes the attribute name of the component attribute or the element content of the text element. When the node object corresponds to a component, read the component attributes of the node object (such as the attrs attribute), and match the attribute names of the component attributes in the preset matching data. If the matching is successful, it indicates that the node object depends on Computed attribute logic can use the matched attribute name as calculated attribute logic data. When the node object corresponds to a text element, read the element content of the text element and match the element content of the text element in the preset matching data. If the match is successful, it indicates that the node object relies on calculated attribute logic. The attribute name matched to the node information can be used as calculated attribute logical data.
在上述实施例的基础上,预设匹配数据是基于前端业务逻辑文件的源代码中控制部分script生成的,其中,预设匹配数据的生成方法包括:将所述源代码中的第二代码部分转换为第二语法树,遍历所述第二语法树中的节点对象,在任一所述节点对象的对应函数中包括特定语句块的情况下,基于所述节点对象的计算属性名和对应函数生成预设匹配数据,即computedmap。On the basis of the above embodiment, the preset matching data is generated based on the control part script in the source code of the front-end business logic file, wherein the method for generating the preset matching data includes: converting the second code part in the source code Convert to a second syntax tree, traverse the node objects in the second syntax tree, and when the corresponding function of any node object includes a specific statement block, generate a prediction based on the calculated attribute name and corresponding function of the node object. Assume matching data, namely computedmap.
在前端业务逻辑文件的源代码中截取第二代码部分,即控制部分script,执行第二代码部分,生成一个js对象,即computed对象,该computed对象中包
括computed函数。computed对象中包括键值对,key为计算属性名,value为computed函数。遍历computed对象,通过babel工具进行抽象语法树分析,得到第二语法树。Intercept the second code part, that is, the control part script, from the source code of the front-end business logic file, execute the second code part, and generate a js object, that is, the computed object, which contains Include computed function. The computed object includes key-value pairs, where key is the computed attribute name and value is the computed function. Traverse the computed object, perform abstract syntax tree analysis through the babel tool, and obtain the second syntax tree.
遍历第二语法树中的节点对象,在任一节点对象的computed函数中包括Switch语句SwitchStatement、ifelse语句IfStatement、三元表达式ConditionalExpression等的特定语句块时,基于节点对象的计算属性名生成预设匹配数据。示例性的,将包含特定语句块的节点对象的计算属性名作为key值,true作为value值,生成预设匹配数据。Traverse the node objects in the second syntax tree. When the computed function of any node object includes a specific statement block such as Switch statement SwitchStatement, ifelse statement IfStatement, ternary expression ConditionalExpression, etc., generate a preset match based on the calculated attribute name of the node object. data. For example, the calculated attribute name of the node object containing a specific statement block is used as the key value, and true is used as the value value to generate preset matching data.
通过上述实施例的方式,得到前端业务逻辑文件中的逻辑数据,基于各逻辑数据生成对应的预编译数据。示例性的,可以是创建初始函数,将得到的逻辑数据添加到初始函数的预设字段处,得到预编译数据。本实施例中,预编译数据可以是重编译的render函数,该render函数可以是_c函数,该_c函数的第一个参数即为元素的标签名,第二个参数为一个数据或者是一个对象,如果是对象则表示标签的一些属性数据,如一些静态样式,类名,元素id等,这些数据会被完整地保留在组件的虚拟DOM中对象的data属性中。本实施例中,对于任一对象节点,创建_c函数,将该对象节点的标签名设置在_c函数的第一个参数位置,将该对象节点的逻辑数据设置在_c函数的第二个参数位置,得到对应的预编译数据。Through the above embodiment, the logical data in the front-end business logic file is obtained, and corresponding precompiled data is generated based on each logical data. For example, an initial function may be created, and the obtained logical data may be added to a preset field of the initial function to obtain precompiled data. In this embodiment, the precompiled data may be a recompiled render function, and the render function may be a _c function. The first parameter of the _c function is the tag name of the element, and the second parameter is a piece of data or a An object. If it is an object, it represents some attribute data of the tag, such as some static styles, class names, element ids, etc. These data will be completely retained in the data attribute of the object in the virtual DOM of the component. In this embodiment, for any object node, create a _c function, set the label name of the object node in the first parameter position of the _c function, and set the logical data of the object node in the second parameter position of the _c function. parameter position to obtain the corresponding precompiled data.
本实施例提供的技术方案,通过对源代码进行预编译处理,得到能够实现逻辑数据可视化显示的预编译数据。在预编译过程中,通过对源代码进行抽象语法树分析,得到源代码对应的抽象语法树,并基于抽象语法树实现对指令类逻辑数据和计算属性逻辑数据的提取,通过预设的编译方式以及上述逻辑数据得到对应的预编译数据,为逻辑数据的可视化显示提取数据基础。The technical solution provided by this embodiment is to pre-compile the source code to obtain pre-compiled data that can realize the visual display of logical data. In the pre-compilation process, through abstract syntax tree analysis of the source code, the abstract syntax tree corresponding to the source code is obtained, and based on the abstract syntax tree, the instruction type logical data and computational attribute logical data are extracted, and through the preset compilation method And the above logical data obtains corresponding precompiled data to extract the data basis for the visual display of logical data.
在上述实施例的基础上,本申请实施例还提供了一种前端业务逻辑的可视化处理装置,参见图4,图4是本申请实施例提供的一种前端业务逻辑的可视化
处理装置的结构示意图。该装置包括:On the basis of the above embodiments, embodiments of the present application also provide a visual processing device for front-end business logic. See Figure 4. Figure 4 is a visualization of front-end business logic provided by embodiments of the present application. Structural diagram of the processing device. The device includes:
预编译数据获取模块310,设置为获取前端业务逻辑文件的预编译数据,其中,所述预编译数据中包括组件的逻辑数据;The precompiled data acquisition module 310 is configured to obtain precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;
数据更新模块320,设置为基于所述组件对应的预编译数据更新所述组件中的原始数据;The data update module 320 is configured to update the original data in the component based on the precompiled data corresponding to the component;
页面渲染模块330,设置为对更新后的多个组件进行渲染,得到业务显示页面;The page rendering module 330 is configured to render the updated multiple components to obtain a business display page;
可视化处理模块340,设置为对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。The visualization processing module 340 is configured to set a visual identifier for the document object model obtained by the update component when rendering the business display page, wherein the document object model corresponding to the visual identifier triggers the display of the document when selected. The object model corresponds to the logical data of the component.
可选的,可视化处理模块340设置为:对所述更新组件在对所述业务显示页面渲染得到的文档对象模型设置遮罩层;和/或,Optionally, the visualization processing module 340 is configured to: set a mask layer on the document object model obtained by rendering the business display page by the update component; and/or,
在所述更新组件在对所述业务显示页面渲染得到的文档对象模型的预设位置处设置预设标记。The update component sets a preset mark at a preset position of the document object model obtained by rendering the business display page.
可选的,该装置还包括:Optionally, the device also includes:
逻辑数据显示模块,设置为在检测到对任一所述文档对象模型的可视化操作的情况下,读取所述文档对象模型对应组件的逻辑数据,并基于预设窗口进行显示。The logical data display module is configured to read the logical data of the corresponding component of the document object model and display it based on a preset window when a visual operation on any of the document object models is detected.
可选的,该装置还包括:Optionally, the device also includes:
路径汇总数据获取模块,设置为获取所述预编译数据的路径汇总数据;The path summary data acquisition module is configured to obtain the path summary data of the precompiled data;
数据更新模块320设置为:在组件执行钩子函数时,获取所述组件的当前路径数据,在组件的当前路径数据在所述路径汇总数据中匹配成功的情况下,基于所述组件对应的预编译数据更新所述组件中的原始数据。The data update module 320 is configured to: when the component executes the hook function, obtain the current path data of the component, and when the current path data of the component is successfully matched in the path summary data, based on the precompilation corresponding to the component Data updates the original data in said component.
可选的,页面渲染模块330设置为:Optionally, the page rendering module 330 is set to:
获取前端业务中各组件的预编码数据,执行所述预编码数据,得到各组件实例,所述组件实例中包括对应的至少一个虚拟文档对象模型;
Obtain the precoding data of each component in the front-end business, execute the precoding data, and obtain each component instance, and the component instance includes at least one corresponding virtual document object model;
遍历所述组件实例中各虚拟文档对象模型,渲染得到业务显示页面中的各文档对象模型。Each virtual document object model in the component instance is traversed, and each document object model in the business display page is rendered.
可选的,该装置还包括:预编译数据生成模块,预编译数据生成模块包括:Optionally, the device also includes: a precompiled data generation module. The precompiled data generation module includes:
第一语法树生成子模块,设置为获取前端业务逻辑文件的源代码,将所述源代码中的第一代码部分转换为第一语法树,所述第一语法树中包括指令类逻辑节点和计算属性逻辑节点;The first syntax tree generation submodule is configured to obtain the source code of the front-end business logic file, and convert the first code part in the source code into a first syntax tree. The first syntax tree includes instruction class logical nodes and Computed attribute logical node;
逻辑数据获取子模块,设置为分别提取所述指令类逻辑节点和所述计算属性逻辑节点的逻辑数据;The logical data acquisition submodule is configured to respectively extract the logical data of the instruction type logical node and the computational attribute logical node;
数据编译子模块,设置为生成对应的预编译数据。The data compilation submodule is set to generate corresponding precompiled data.
可选的,逻辑数据获取子模块设置为:遍历所述第一语法树中的各指令类逻辑节点,在所述指令类逻辑节点的节点对象中包括指令类标识的情况下,读取所述节点对象中的指令类逻辑数据。Optionally, the logical data acquisition sub-module is configured to: traverse each instruction class logical node in the first syntax tree, and when the node object of the instruction class logical node includes an instruction class identifier, read the instruction class identifier. Instruction-type logical data in node objects.
可选的,逻辑数据获取子模块设置为:Optional, the logical data acquisition submodule is set to:
若所述节点对象的指令类标识包括el.if,则基于所述节点对象、所述节点对象的父节点对象、所述节点对象的兄弟节点对象的逻辑数据,得到所述节点对象的指令类逻辑数据;If the instruction class identifier of the node object includes el.if, then the instruction class of the node object is obtained based on the logical data of the node object, the parent node object of the node object, and the sibling node object of the node object. logical data;
若所述节点对象的指令类标识包括el.show,则读取V-show元素中的表达式为所述节点对象的指令类逻辑数据。If the instruction class identifier of the node object includes el.show, the expression in the V-show element is read as the instruction class logical data of the node object.
可选的,逻辑数据获取子模块设置为:Optional, the logical data acquisition submodule is set to:
遍历所述第一语法树中的各计算属性逻辑节点,在所述计算属性逻辑节点的节点信息在预设匹配数据中匹配成功的情况下,读取所述计算属性逻辑节点的属性名作为逻辑数据。Traverse each calculated attribute logical node in the first syntax tree, and when the node information of the calculated attribute logical node is successfully matched in the preset matching data, read the attribute name of the calculated attribute logical node as the logical data.
可选的,所述计算属性逻辑节点的节点信息包括组件属性的属性名或者文本元素的元素内容。Optionally, the node information of the calculated attribute logical node includes the attribute name of the component attribute or the element content of the text element.
可选的,预编译数据生成模块还包括:Optionally, the precompiled data generation module also includes:
预设匹配数据生成子模块,设置为将所述源代码中的第二代码部分转换为
第二语法树,遍历所述第二语法树中各节点对象,在任一所述节点对象的对应函数中包括特定语句块的情况下,基于所述节点对象的计算属性名和对应函数生成预设匹配数据。The preset matching data generation sub-module is configured to convert the second code part in the source code into The second syntax tree traverses each node object in the second syntax tree, and when the corresponding function of any node object includes a specific statement block, generates a preset match based on the calculated attribute name of the node object and the corresponding function. data.
本申请实施例所提供的前端业务逻辑的可视化处理装置可执行本申请任意实施例所提供的前端业务逻辑的可视化处理方法,具备执行前端业务逻辑的可视化处理方法相应的功能模块。The visual processing device for front-end business logic provided by the embodiments of this application can execute the visual processing method of front-end business logic provided by any embodiment of this application, and has corresponding functional modules for executing the visual processing method of front-end business logic.
在上述实施例的基础上,本申请实施例还提供了一种前端业务逻辑的可视化系统,参见图5,图5是本申请实施例提供的一种前端业务逻辑的可视化系统的结构示意图。该前端业务逻辑的可视化系统包括服务端410和客户端420,其中,所述客户端包括可视化插件421和处理器422;Based on the above embodiments, embodiments of the present application also provide a front-end business logic visualization system. See Figure 5 , which is a schematic structural diagram of a front-end business logic visualization system provided by embodiments of the present application. The front-end business logic visualization system includes a server 410 and a client 420, where the client includes a visualization plug-in 421 and a processor 422;
其中,可视化插件421设置为将前端业务逻辑文件的源代码发生至服务端410,以及向服务端410发送数据请求,并接收服务器410反馈的预编译数据;Among them, the visualization plug-in 421 is configured to generate the source code of the front-end business logic file to the server 410, send a data request to the server 410, and receive the precompiled data fed back by the server 410;
服务端410设置为对前端业务逻辑文件的源代码进行预编译处理,得到预编译数据,其中,预编译数据中包括组件的逻辑数据;The server 410 is configured to precompile the source code of the front-end business logic file to obtain precompiled data, where the precompiled data includes the logical data of the component;
可视化插件421设置为基于组件对应的预编译数据更新组件中的原始数据,并将更新后的组件数据发送至处理器422,以及在接收到可视化指令的情况下,向处理器422发送触发指令;The visualization plug-in 421 is configured to update the original data in the component based on the precompiled data corresponding to the component, and send the updated component data to the processor 422, and when receiving the visualization instruction, send a trigger instruction to the processor 422;
处理器422设置为对更新后的多个组件进行渲染,得到业务显示页面,以及在接收到触发指令的情况下,对更新组件在对业务显示页面渲染得到的文档对象模型设置可视化标识,其中,可视化标识在被选择的情况下,触发显示文档对象模型对应组件的逻辑数据。The processor 422 is configured to render the updated multiple components to obtain a business display page, and upon receiving a trigger instruction, set a visual identifier for the document object model obtained by rendering the business display page with the updated component, wherein, When the visual identifier is selected, it triggers the display of logical data of the corresponding component of the document object model.
本实施例中,通过服务端进行源代码的预编译处理,基于服务端的强大算力,提高预编译处理的处理效率。同时在客户端设置可视化插件,用于基于包含逻辑数据的预编译数据对原始数据进行替换,以使得处理器基于更新后的预编译数据进行页面渲染。无需对客户端的处理器进行二次开发,通过注入可视
化插件的方式实现,降低实现成本。In this embodiment, the source code is pre-compiled through the server, and the processing efficiency of the pre-compilation is improved based on the powerful computing power of the server. At the same time, a visualization plug-in is set on the client to replace the original data based on precompiled data containing logical data, so that the processor renders the page based on the updated precompiled data. There is no need to carry out secondary development of the client's processor, by injecting visual Implemented in the form of plug-ins to reduce implementation costs.
可视化插件可接收输入的可视化指令,或者检测用户输入的可视化操作,向处理器发送可视化触发信号,以使得处理器进入可视化模式,以及可视化插件可接收输入的取消可视化指令,或者检测用户输入的可视化退出操作,向处理器发送可视化退出触发信号,以使得处理器退出可视化模式,以满足操作用户的不同需求。The visualization plug-in can receive an input visualization instruction, or detect a user-input visualization operation, send a visualization trigger signal to the processor so that the processor enters the visualization mode, and the visualization plug-in can receive an input cancellation visualization instruction, or detect a user-input visualization To exit the operation, send a visual exit trigger signal to the processor so that the processor exits the visualization mode to meet the different needs of operating users.
在上述实施例的基础上,本申请实施例提供的一种前端业务逻辑的可视化处理的可选实例,参见图6,图6是本申请实施例提供的另一种前端业务逻辑的可视化处理方法的流程示意图。图6中服务端执行对源代码的预编译处理,得到预编译数据(即编译结果)发送至客户端,客户端预先注入的插件(即可视化插件)通过接收预编译数据,基于预编译数据中的新渲染函数替代原本的渲染函数,客户端的处理器进行逻辑数据的可视化处理,获取组件实例,遍历组件实例中的各虚拟dom对象,并在对应的真实dom增加浮窗,通过浮窗显示真实dom对应的逻辑数据。Based on the above embodiments, embodiments of the present application provide an optional example of visual processing of front-end business logic. See Figure 6. Figure 6 is another method of visual processing of front-end business logic provided by embodiments of the present application. process diagram. In Figure 6, the server performs pre-compilation processing of the source code, and obtains pre-compiled data (i.e., compilation results) and sends it to the client. The plug-in (i.e., visualization plug-in) pre-injected by the client receives the pre-compiled data and generates data based on the pre-compiled data. The new rendering function replaces the original rendering function. The client's processor performs visual processing of logical data, obtains component instances, traverses each virtual DOM object in the component instance, and adds a floating window to the corresponding real DOM, and displays the real DOM through the floating window. Logical data corresponding to dom.
服务端对源代码进行预编译处理的过程可以是:在各.vue文件的源代码中分别截取模板部分template和控制部分script,通过对控制部分script进行处理,得到预设匹配数据,即computedMap。示例性的,将获取的script部分打到内存中成为一个js对象,然后取该对象的computed值;遍历computed对象,该对象的key为计算属性名,value是一个函数,将函数序列化,然后利用babel工具进行抽象语法树分析;深度遍历解析后的语法树对象,如果存在SwitchStatement、IfStatement、ConditionalExpression语句块,则将对应的计算属性key值加入computedMap中,value值设置为true,表示该计算属性中具有计算逻辑。参见图7,图7是本申请实施例提供的抽象语法树解析示意图。The process of precompiling the source code on the server side can be as follows: intercepting the template part and the control part script respectively from the source code of each .vue file, and processing the control part script to obtain the preset matching data, that is, computedMap. For example, the obtained script part is copied into the memory to become a js object, and then the computed value of the object is obtained; the computed object is traversed, the key of the object is the calculated attribute name, the value is a function, the function is serialized, and then Use the babel tool to perform abstract syntax tree analysis; deeply traverse the parsed syntax tree object. If there are SwitchStatement, IfStatement, and ConditionalExpression statement blocks, add the corresponding calculated attribute key value to the computedMap, and set the value value to true to indicate the calculated attribute. There is calculation logic in it. Refer to Figure 7, which is a schematic diagram of abstract syntax tree parsing provided by an embodiment of the present application.
模板部分template的逻辑主要是三种指令类:直接使用v-if去控制元素挂载、直接使用v-show控制元素是否展现、以及使用v-if、v-else-if、v-else的嵌套逻辑;以及依赖计算属性的部分。将模板部分template转换为抽象语法树,按照
层级关系生成编译后的代码,每个节点都对应一个el对象。参见图8,图8是本申请实施例提供的一种指令类逻辑数据的生成示意图。判断每一个元素(即节点)的el对象(即节点对象)是否存在指令类标识el.if,若是,确定该el对象的父节点的if属性是否存在,若存在,则将el对象的if逻辑信息和el对象父节点的if逻辑信息拼接;判断el对象否存在兄弟节点el.elseif或者el.else,若是,则将各兄弟节点的el.elseif或者el.else的表达式(即逻辑信息)取非后,拼接在el对象的逻辑信息之后,或者拼接在el对象的if逻辑信息和el对象父节点的if逻辑信息的拼接信息之后,得到el对象的逻辑数据。在el对象中不存在指令类标识el.if,判断el.directives中是否包括show标识,若是,则将V-show的表达式(即逻辑信息)作为逻辑数据。The logic of the template part mainly consists of three instruction types: directly using v-if to control element mounting, directly using v-show to control whether elements are displayed, and using v-if, v-else-if, and v-else for embedding. set of logic; and the parts that rely on computed properties. Convert the template part template into an abstract syntax tree according to The hierarchical relationship generates compiled code, and each node corresponds to an el object. Referring to Figure 8, Figure 8 is a schematic diagram of the generation of instruction type logical data provided by an embodiment of the present application. Determine whether the el object (i.e. node object) of each element (i.e. node) exists the instruction class identifier el.if. If so, determine whether the if attribute of the parent node of the el object exists. If it exists, change the if logic of the el object. The information is spliced with the if logical information of the parent node of the el object; it is judged whether the el object has sibling nodes el.elseif or el.else. If so, the el.elseif or el.else expression (i.e. logical information) of each sibling node is After negation, it is spliced after the logical information of the el object, or after the splicing information of the if logical information of the el object and the if logical information of the parent node of the el object, to obtain the logical data of the el object. There is no instruction class identifier el.if in the el object, and it is judged whether the show identifier is included in el.directives. If so, the V-show expression (ie, logical information) is used as logical data.
对于模板部分template中依赖计算属性的部分,获取el中的attrs属性,如果该对象中存在匹配到comptuedMap中的属性名,则在data后拼接:data+=`computed:${属性名},`;如果el是文本元素,并且其元素内容中匹配到comptuedMap中的属性名,则在data后拼接:data+=`computed:${属性名},`。在匹配成功的情况下,将comptuedMap中匹配到的计算属性名作为逻辑数据。For the part of the template part that relies on calculated attributes, get the attrs attribute in el. If there is an attribute name matching the computedMap in the object, splice it after data: data+=`computed:${attribute name},`; If el is a text element and its element content matches the attribute name in computedMap, then splice it after data: data+=`computed:${attribute name},`. If the match is successful, the calculated attribute name matched in computedMap will be used as logical data.
将el对象的标签名作为_c函数的第一个参数,将el对象的逻辑数据作为第二个参数,得到新的渲染函数,进一步得到预编译数据。Use the label name of the el object as the first parameter of the _c function, and use the logical data of the el object as the second parameter to obtain a new rendering function and further obtain precompiled data.
可视化插件接管渲染阶段,参见图9,图9是本申请实施例提供的一种渲染阶段的示意图。Vue插件(即可视化插件)注入,在检测到组件执行create钩子函数的情况下,获取组件的_file属性,即组件的当前路径数据。将_file属性在renderMap中进行匹配,renderMap存储render函数与其路径的对应关系,若file属性在renderMap中匹配成功,则将renderMap中的新的渲染函数(预编译数据中的渲染函数)替换组件本身的render函数。并在数据更新完成后,触发处理器进行组件渲染,生成真实dom。The visualization plug-in takes over the rendering phase, see Figure 9. Figure 9 is a schematic diagram of a rendering phase provided by an embodiment of the present application. Vue plug-in (that is, visualization plug-in) injection, when detecting that the component executes the create hook function, obtains the _file attribute of the component, that is, the current path data of the component. Match the _file attribute in renderMap. renderMap stores the correspondence between the render function and its path. If the file attribute is successfully matched in renderMap, replace the component itself with the new rendering function in renderMap (the rendering function in the precompiled data). render function. And after the data update is completed, the processor is triggered to render the component and generate the real DOM.
在渲染过程中,将逻辑数据注入到每个虚拟DOM的data中,每一个虚拟DOM对应着页面上的一个真实DOM,可以准确地获取到真实DOM的元素位
置。可视化阶段从当前页面的根节点对应的根组件实例开始,递归编译子组件中_vnode对象中data中带有元标记的节点,随后在这些节点后追加一个绝对布局的遮罩层,实现对于具有逻辑控制元素的可视化,同时逻辑详情也记录在逻辑数据中,可以在逻辑数据中获取查看实现逻辑。During the rendering process, logical data is injected into the data of each virtual DOM. Each virtual DOM corresponds to a real DOM on the page, and the element bits of the real DOM can be accurately obtained. Set. The visualization phase starts from the root component instance corresponding to the root node of the current page, recursively compiles the nodes with meta tags in the data in the _vnode object in the sub-component, and then appends an absolute layout mask layer after these nodes to implement the The logic control elements are visualized, and the logic details are also recorded in the logic data. The implementation logic can be obtained and viewed in the logic data.
图10示出了可以用来实施本申请的实施例的电子设备10的结构示意图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备(如头盔、眼镜、手表等)和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本申请的实现。FIG. 10 shows a schematic structural diagram of an electronic device 10 that can be used to implement embodiments of the present application. Electronic devices are intended to refer to various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (eg, helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are examples only and are not intended to limit the implementation of the present application as described and/or claimed herein.
如图10所示,电子设备10包括至少一个处理器11,以及与至少一个处理器11通信连接的存储器,如只读存储器(Read-Only Memory,ROM)12、随机访问存储器(Random Access Memory,RAM)13等,其中,存储器存储有可被至少一个处理器执行的计算机程序,处理器11可以根据存储在只读存储器(ROM)12中的计算机程序或者从存储单元18加载到随机访问存储器(RAM)13中的计算机程序,来执行各种适当的动作和处理。在RAM 13中,还可存储电子设备10操作所需的各种程序和数据。处理器11、ROM 12以及RAM 13通过总线14彼此相连。输入/输出(Input/Output,I/O)接口15也连接至总线14。As shown in Figure 10, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (Read-Only Memory, ROM) 12, a random access memory (Random Access Memory, RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can be loaded into the random access memory (RAM) according to the computer program stored in the read-only memory (ROM) 12 or from the storage unit 18. A computer program in RAM) 13 to perform various appropriate actions and processes. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via the bus 14. An input/output (I/O) interface 15 is also connected to the bus 14 .
电子设备10中的多个部件连接至I/O接口15,包括:输入单元16,例如键盘、鼠标等;输出单元17,例如各种类型的显示器、扬声器等;存储单元18,例如磁盘、光盘等;以及通信单元19,例如网卡、调制解调器、无线通信收发机等。通信单元19允许电子设备10通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc. etc.; and communication unit 19, such as network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices through computer networks such as the Internet and/or various telecommunications networks.
处理器11可以是各种具有处理和计算能力的通用和/或专用处理组件。处理
器11的一些示例包括但不限于中央处理单元(Central Processing Unit,CPU)、图形处理单元(Graphics Processing Unit,GPU)、各种专用的人工智能(Artificial Intelligence,AI)计算芯片、各种运行机器学习模型算法的处理器、数字信号处理器(Digital Signal Processing,DSP)、以及任何适当的处理器、控制器、微控制器等。处理器11执行上文所描述的各个方法和处理,例如前端业务逻辑的可视化处理方法。Processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. deal with Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (Artificial Intelligence, AI) computing chips, various running machines Processor of learning model algorithm, digital signal processor (Digital Signal Processing, DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes various methods and processes described above, such as the visual processing method of front-end business logic.
在一些实施例中,前端业务逻辑的可视化处理方法可被实现为计算机程序,其被有形地包含于计算机可读存储介质,例如存储单元18。在一些实施例中,计算机程序的部分或者全部可以经由ROM 12和/或通信单元19而被载入和/或安装到电子设备10上。当计算机程序加载到RAM 13并由处理器11执行时,可以执行上文描述的前端业务逻辑的可视化处理方法的一个或多个步骤。备选地,在其他实施例中,处理器11可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行前端业务逻辑的可视化处理方法。In some embodiments, the visual processing method of front-end business logic can be implemented as a computer program, which is tangibly included in a computer-readable storage medium, such as the storage unit 18 . In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the visual processing method of the front-end business logic described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the visual processing method of the front-end business logic in any other suitable manner (eg, by means of firmware).
本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(Field Programmable Gate Array,FPGA)、专用集成电路(Application Specific Integrated Circuit,ASIC)、专用标准产品(Application Specific Standard Parts,ASSP)、芯片上系统的系统(System on Chip,SOC)、负载可编程逻辑设备(Complex Programmable Logic Device,CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above may be implemented in digital electronic circuit systems, integrated circuit systems, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Parts (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), computer hardware, firmware, software, and/or they implemented in a combination. These various embodiments may include implementation in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor The processor, which may be a special purpose or general purpose programmable processor, may 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. An output device.
用于实施本申请的方法的计算机程序可以采用一个或多个编程语言的任何组合来编写。这些计算机程序可以提供给通用计算机、专用计算机或其他可编
程数据处理装置的处理器,使得计算机程序当由处理器执行时使流程图和/或框图中所规定的功能/操作被实施。计算机程序可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。Computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided for general-purpose computers, special-purpose computers, or other programmable The computer program, when executed by the processor, causes the functions/operations specified in the flowcharts and/or block diagrams to be implemented. A computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
在本申请的上下文中,计算机可读存储介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的计算机程序。计算机可读存储介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。备选地,计算机可读存储介质可以是机器可读信号介质。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM(Erasable Programmable Read-Only Memory)或快闪存储器)、光纤、便捷式紧凑盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of this application, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. Computer-readable storage media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, laptop disks, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM (Erasable Programmable Read-Only Memory) or flash memory), optical fiber, portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical storage device, magnetic storage device, or the above content Any suitable combination.
为了提供与用户的交互,可以在电子设备上实施此处描述的系统和技术,该电子设备具有:用于向用户显示信息的显示装置(例如,CRT(Cathode Ray Tube,阴极射线管)或者LCD(Liquid Crystal Display,液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给电子设备。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。In order 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., CRT (Cathode Ray Tube, cathode ray tube) or LCD) for displaying information to the user (Liquid Crystal Display, LCD monitor); and a keyboard and pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds 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 may be provided in any form, including Acoustic input, voice input or tactile input) to receive input from the user.
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和
技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(Local Area Network,LAN)、广域网(Wide Area Network,WAN)、区块链网络和互联网。The systems and techniques described herein may be implemented in a computing system that includes back-end 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 front-end components (e.g., A user's computer with a graphical user interface or web browser through which the user can interact with the systems and systems described herein technology implementations interact), or in a computing system that includes any combination of such backend components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (eg, a communications network). Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN), blockchain network, and the Internet.
计算系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与虚拟专用服务器(Virtual Private Server,VPS)服务中,存在的管理难度大,业务扩展性弱的缺陷。Computing systems may include clients and servers. Clients and servers are generally remote from each other and typically interact over a communications network. The relationship of client and server is created by computer programs running on corresponding computers and having a client-server relationship with each other. The server can be a cloud server, also known as cloud computing server or cloud host. It is a host product in the cloud computing service system to solve the problems that exist in traditional physical host and virtual private server (VPS) services. It has the disadvantages of difficult management and weak business scalability.
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本申请中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本申请的技术方案所期望的结果,本文在此不进行限制。It should be understood that various forms of the process shown above may be used, with steps reordered, added or deleted. For example, each step described in this application can be executed in parallel, sequentially, or in a different order. As long as the desired results of the technical solution of this application can be achieved, there is no limitation here.
上述具体实施方式,并不构成对本申请保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本申请的精神和原则之内所作的修改、等同替换和改进等,均应包含在本申请保护范围之内。The above-mentioned specific embodiments do not constitute a limitation on the scope of protection of the present application. It will be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions are possible depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application shall be included in the protection scope of this application.
注意,上述仅为本申请的可选实施例及所运用技术原理。本领域技术人员会理解,本申请不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本申请的保护范围。因此,虽然通过以上实施例对本申请进行了较为详细的说明,但是本申请不仅仅限于以上实施例,在不脱离本申请构思的情况下,还可以包括更多其他等效实施例,而本申请的范围由所附的权利要求范围决定。
Note that the above are only optional embodiments and the technical principles used in this application. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present application, and the present application The scope is determined by the scope of the appended claims.
Claims (15)
- 一种前端业务逻辑的可视化处理方法,包括:A visual processing method for front-end business logic, including:获取前端业务逻辑文件的预编译数据,其中,所述预编译数据中包括组件的逻辑数据;Obtain the precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;基于所述组件对应的预编译数据更新所述组件中的原始数据,并对更新后的多个组件进行渲染,得到业务显示页面;Update the original data in the component based on the precompiled data corresponding to the component, and render the updated multiple components to obtain a business display page;对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。Set a visual identifier for the document object model rendered by the update component on the business display page, where, when the document object model corresponding to the visual identifier is selected, it triggers the display of the logical data of the corresponding component of the document object model. .
- 根据权利要求1所述的方法,其中,对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,包括以下至少之一:The method according to claim 1, wherein setting a visual identifier for the document object model obtained by rendering the business display page by the update component includes at least one of the following:对所述更新组件在对所述业务显示页面渲染得到的文档对象模型设置遮罩层;Set a mask layer on the document object model obtained by rendering the business display page by the update component;在所述更新组件在对所述业务显示页面渲染得到的文档对象模型的预设位置处设置预设标记。The update component sets a preset mark at a preset position of the document object model obtained by rendering the business display page.
- 根据权利要求1所述的方法,还包括:The method of claim 1, further comprising:响应于检测到对任一所述文档对象模型的可视化操作,读取所述文档对象模型对应组件的逻辑数据,并基于预设窗口进行显示。In response to detecting a visual operation on any of the document object models, read the logical data of the corresponding component of the document object model and display it based on a preset window.
- 根据权利要求1所述的方法,还包括:The method of claim 1, further comprising:获取所述预编译数据的路径汇总数据;Obtain the path summary data of the precompiled data;所述基于所述组件对应的预编译数据更新所述组件中的原始数据,包括:The updating of the original data in the component based on the precompiled data corresponding to the component includes:在所述组件执行钩子函数时,获取所述组件的当前路径数据,响应于所述组件的当前路径数据在所述路径汇总数据中匹配成功,基于所述组件对应的预编译数据更新所述组件中的原始数据。When the component executes the hook function, the current path data of the component is obtained. In response to the current path data of the component being successfully matched in the path summary data, the component is updated based on the precompiled data corresponding to the component. original data in .
- 根据权利要求1所述的方法,其中,所述对更新后的多个组件进行渲染,得到业务显示页面,包括:The method according to claim 1, wherein rendering the updated multiple components to obtain a business display page includes:获取前端业务中组件的预编码数据,执行所述预编码数据,得到组件实例, 所述组件实例中包括对应的至少一个虚拟文档对象模型;Obtain the precoding data of the component in the front-end business, execute the precoding data to obtain the component instance, The component instance includes at least one corresponding virtual document object model;遍历所述组件实例中的虚拟文档对象模型,渲染得到业务显示页面中的文档对象模型。The virtual document object model in the component instance is traversed, and the document object model in the business display page is obtained by rendering.
- 根据权利要求1所述的方法,其中,所述预编译数据的生成方式包括:The method according to claim 1, wherein the method of generating the precompiled data includes:获取前端业务逻辑文件的源代码,将所述源代码中的第一代码部分转换为第一语法树,所述第一语法树中包括指令类逻辑节点和计算属性逻辑节点;Obtain the source code of the front-end business logic file, and convert the first code part in the source code into a first syntax tree. The first syntax tree includes instruction type logical nodes and calculated attribute logical nodes;分别提取所述指令类逻辑节点和所述计算属性逻辑节点的逻辑数据,并生成对应的预编译数据。Extract the logical data of the instruction type logical node and the computational attribute logical node respectively, and generate corresponding precompiled data.
- 根据权利要求6所述的方法,其中,所述提取所述指令类逻辑节点的逻辑数据,包括:The method according to claim 6, wherein the extracting the logical data of the instruction type logical node includes:遍历所述第一语法树中的指令类逻辑节点,响应于所述指令类逻辑节点的节点对象中包括指令类标识,读取所述节点对象中的指令类逻辑数据。Traverse the instruction class logical nodes in the first syntax tree, and in response to the instruction class identifier included in the node object of the instruction class logical node, read the instruction class logic data in the node object.
- 根据权利要求7所述的方法,其中,所述读取所述节点对象中的指令类逻辑数据,包括:The method according to claim 7, wherein reading the instruction type logical data in the node object includes:响应于所述节点对象的指令类标识包括el.if,基于所述节点对象、所述节点对象的父节点对象、所述节点对象的兄弟节点对象的逻辑数据,得到所述节点对象的指令类逻辑数据;In response to the instruction class identifier of the node object including el.if, based on the logical data of the node object, the parent node object of the node object, and the sibling node object of the node object, the instruction class of the node object is obtained logical data;响应于所述节点对象的指令类标识包括el.show,读取V-show元素中的表达式为所述节点对象的指令类逻辑数据。In response to the instruction class identifier of the node object including el.show, the expression in the V-show element is read as the instruction class logical data of the node object.
- 根据权利要求6所述的方法,其中,所述提取所述计算属性逻辑节点的逻辑数据,包括:The method according to claim 6, wherein the extracting the logical data of the calculated attribute logical node includes:遍历所述第一语法树中的计算属性逻辑节点,响应于所述计算属性逻辑节点的节点信息在预设匹配数据中匹配成功,读取所述计算属性逻辑节点的属性名作为逻辑数据。Traverse the computed attribute logical nodes in the first syntax tree, and in response to the node information of the computed attribute logical node matching successfully in the preset matching data, read the attribute name of the computed attribute logical node as logical data.
- 根据权利要求9所述的方法,其中,所述计算属性逻辑节点的节点信息包括组件属性的属性名或者文本元素的元素内容。 The method according to claim 9, wherein the node information of the calculated attribute logical node includes an attribute name of a component attribute or an element content of a text element.
- 根据权利要求9所述的方法,其中,所述预设匹配数据的生成方法包括:The method according to claim 9, wherein the method for generating the preset matching data includes:将所述源代码中的第二代码部分转换为第二语法树,遍历所述第二语法树中的节点对象,响应于任一所述节点对象的对应函数中包括特定语句块,基于所述节点对象的计算属性名和对应函数生成预设匹配数据。Convert the second code part in the source code into a second syntax tree, traverse the node objects in the second syntax tree, and in response to the corresponding function of any node object including a specific statement block, based on the The calculated attribute name of the node object and the corresponding function generate preset matching data.
- 一种前端业务逻辑的可视化处理装置,包括:A visual processing device for front-end business logic, including:预编译数据获取模块,设置为获取前端业务逻辑文件的预编译数据,其中,所述预编译数据中包括组件的逻辑数据;The precompiled data acquisition module is configured to obtain the precompiled data of the front-end business logic file, where the precompiled data includes the logical data of the component;数据更新模块,设置为基于所述组件对应的预编译数据更新所述组件中的原始数据;A data update module configured to update the original data in the component based on the precompiled data corresponding to the component;页面渲染模块,设置为对更新后的多个组件进行渲染,得到业务显示页面;The page rendering module is set to render multiple updated components to obtain a business display page;可视化处理模块,设置为对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。The visualization processing module is configured to set a visual identifier for the document object model obtained by rendering the business display page by the update component, wherein the document object model corresponding to the visual identifier triggers the display of the document object when selected. The model corresponds to the logical data of the component.
- 一种前端业务逻辑的可视化系统,包括服务端和客户端,其中,所述客户端包括可视化插件和处理器;A front-end business logic visualization system, including a server and a client, wherein the client includes a visualization plug-in and a processor;所述可视化插件设置为将前端业务逻辑文件的源代码发生至所述服务端,以及向服务端发送数据请求,并接收所述服务器反馈的预编译数据;The visualization plug-in is configured to send the source code of the front-end business logic file to the server, send a data request to the server, and receive precompiled data fed back by the server;所述服务端设置为对前端业务逻辑文件的源代码进行预编译处理,得到预编译数据,其中,所述预编译数据中包括组件的逻辑数据;The server is configured to precompile the source code of the front-end business logic file to obtain precompiled data, wherein the precompiled data includes the logical data of the component;所述可视化插件还设置为基于所述组件对应的预编译数据更新所述组件中的原始数据,并将更新后的组件数据发送至所述处理器,以及在接收到可视化指令的情况下,向所述处理器发送触发指令;The visualization plug-in is also configured to update the original data in the component based on the precompiled data corresponding to the component, send the updated component data to the processor, and upon receiving a visual instruction, send The processor sends a trigger instruction;所述处理器设置为对更新后的多个组件进行渲染,得到业务显示页面,以及在接收到触发指令的情况下,对更新组件在对所述业务显示页面渲染得到的文档对象模型设置可视化标识,其中,所述可视化标识对应的文档对象模型在 被选择的情况下,触发显示所述文档对象模型对应组件的逻辑数据。The processor is configured to render a plurality of updated components to obtain a business display page, and upon receiving a trigger instruction, set a visual identifier for the document object model obtained by rendering the business display page on the updated component. , where the document object model corresponding to the visual identification is in When selected, the logical data of the corresponding component of the document object model is triggered to be displayed.
- 一种电子设备,包括:An electronic device including:至少一个处理器;以及at least one processor; and与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-11中任一项所述的前端业务逻辑的可视化处理方法。The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor, so that the at least one processor can perform any one of claims 1-11 The visual processing method of front-end business logic.
- 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现权利要求1-11中任一项所述的前端业务逻辑的可视化处理方法。 A computer-readable storage medium that stores computer instructions, and the computer instructions are used to enable the processor to implement the visual processing of the front-end business logic described in any one of claims 1-11 when executed. method.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211059031.5A CN117667052A (en) | 2022-08-30 | 2022-08-30 | Visual processing method, device and system for front-end business logic |
CN202211059031.5 | 2022-08-30 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2024046313A1 true WO2024046313A1 (en) | 2024-03-07 |
Family
ID=90075817
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/115511 WO2024046313A1 (en) | 2022-08-30 | 2023-08-29 | Visual processing method, apparatus, and system for front-end service logic |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN117667052A (en) |
WO (1) | WO2024046313A1 (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118051687A (en) * | 2024-04-16 | 2024-05-17 | 太平金融科技服务(上海)有限公司 | Page response method and device, electronic equipment and storage medium |
CN118708181A (en) * | 2024-08-27 | 2024-09-27 | 青岛诺亚信息技术有限公司 | Rapid development platform and method based on data model and front-end configuration model |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103744832A (en) * | 2013-12-27 | 2014-04-23 | 华为技术有限公司 | Data multiplexing method and device |
CN108052365A (en) * | 2017-12-19 | 2018-05-18 | 深圳市四格互联信息技术有限公司 | The component generation method and device of user interface |
CN112099891A (en) * | 2020-09-10 | 2020-12-18 | 亚信科技(南京)有限公司 | Popup window display method and device, electronic equipment and computer readable storage medium |
CN113742014A (en) * | 2021-08-11 | 2021-12-03 | 深圳Tcl新技术有限公司 | Interface rendering method and device, electronic equipment and storage medium |
-
2022
- 2022-08-30 CN CN202211059031.5A patent/CN117667052A/en active Pending
-
2023
- 2023-08-29 WO PCT/CN2023/115511 patent/WO2024046313A1/en unknown
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103744832A (en) * | 2013-12-27 | 2014-04-23 | 华为技术有限公司 | Data multiplexing method and device |
CN108052365A (en) * | 2017-12-19 | 2018-05-18 | 深圳市四格互联信息技术有限公司 | The component generation method and device of user interface |
CN112099891A (en) * | 2020-09-10 | 2020-12-18 | 亚信科技(南京)有限公司 | Popup window display method and device, electronic equipment and computer readable storage medium |
CN113742014A (en) * | 2021-08-11 | 2021-12-03 | 深圳Tcl新技术有限公司 | Interface rendering method and device, electronic equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118051687A (en) * | 2024-04-16 | 2024-05-17 | 太平金融科技服务(上海)有限公司 | Page response method and device, electronic equipment and storage medium |
CN118708181A (en) * | 2024-08-27 | 2024-09-27 | 青岛诺亚信息技术有限公司 | Rapid development platform and method based on data model and front-end configuration model |
Also Published As
Publication number | Publication date |
---|---|
CN117667052A (en) | 2024-03-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10983660B2 (en) | Software robots for programmatically controlling computer programs to perform tasks | |
WO2024046313A1 (en) | Visual processing method, apparatus, and system for front-end service logic | |
US10042834B2 (en) | Dynamic field extraction of data | |
US10942708B2 (en) | Generating web API specification from online documentation | |
US10169471B2 (en) | Generating and executing query language statements from natural language | |
US9087296B2 (en) | Navigable semantic network that processes a specification to and uses a set of declaritive statements to produce a semantic network model | |
US9792264B2 (en) | Inheritance of rules across hierarchical levels | |
US11816456B2 (en) | Notebook for navigating code using machine learning and flow analysis | |
US20120131556A1 (en) | Xpath-based selection assistance of gui elements during manual test script authoring for xml-based applications | |
US9892191B2 (en) | Complex query handling | |
US20160306736A1 (en) | Translation verification testing | |
US11573790B2 (en) | Generation of knowledge graphs based on repositories of code | |
US10592304B2 (en) | Suggesting application programming interfaces based on feature and context analysis | |
CN113656533A (en) | Tree control processing method and device and electronic equipment | |
CN112506854A (en) | Method, device, equipment and medium for storing page template file and generating page | |
CN112970011A (en) | Recording pedigrees in query optimization | |
WO2021129812A1 (en) | Method and system for running artificial intelligence application, and device | |
CN115964042A (en) | Menu generation method and device, storage medium and electronic equipment | |
US20240202100A1 (en) | System, method, and graphical user interface for temporal presentation and navigation of code path data | |
US20220318386A1 (en) | Generation of a causality tree representation of threat analysis report data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23859343 Country of ref document: EP Kind code of ref document: A1 |