Global configuration method and device based on Vue technology stack and computer equipment
By using configuration provider components and the provide/inject API for global configuration in the Vue technology stack, the performance overhead caused by verbose code in traditional solutions is solved, achieving lightweight component management and efficient state configuration.
Patent Information
- Application Number
- CN202411145972.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-15
AI Technical Summary
Traditional front-end state management tools based on the Vue technology stack require writing lengthy code, which increases computer performance overhead.
By configuring provider components to obtain user-defined global configuration data, and using Vue.js's provide and inject APIs to perform global configuration in tree components, the system recursively searches upwards for components that have not injected data and retrieves the configuration data, thus achieving lightweight management.
It reduces computer performance overhead, improves the efficiency and reliability of global state management for Vue components, and reduces the possibility of configuration errors.
Smart Images

Figure CN118963860A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a global configuration method, apparatus, computer equipment, computer-readable storage medium, and computer program product based on a Vue technology stack. Background Art
[0002] As the field of computer technology has evolved, so has the technicality and functionality of front-end development. For example, Vue.js is a progressive framework for building user interfaces. As the complexity of front-end development increases, how to effectively manage and share the state and configuration between Vue components has become an issue that needs to be focused on.
[0003] In traditional technologies, common front-end state management methods based on the Vue technology stack include the Vuex state management library, the EventBus event bus implemented through Vue's own technical characteristics, etc., which can help manage global status and configuration.
[0004] However, in traditional solutions, front-end state management tools based on the Vue technology stack usually require writing lengthy codes when performing global configuration and state management, which increases the size of the project code and causes additional performance overhead to the computer. Summary of the invention
[0005] Based on this, it is necessary to provide a global configuration method, device, computer equipment, computer-readable storage medium and computer program product based on the Vue technology stack that can reduce the performance overhead of the computer in response to the above technical problems.
[0006] In the first aspect, the present application provides a global configuration method based on the Vue technology stack, including:
[0007] Based on the created configuration provider component, obtain user-defined global configuration data;
[0008] Calling a preset provide API to inject the global configuration data into a tree component, and globally configuring a first component in the tree component, wherein the first component includes a root component and components associated with the root component;
[0009] Searching for a parent component of a second component in the tree component, and determining whether the parent component has been injected with the global configuration data, wherein the second component is a component that has not been injected with the global configuration data;
[0010] When the target parent component into which the global configuration data has been injected is found, a preset injectapi is called to obtain the global configuration data from the target parent component;
[0011] Based on the global configuration data, the second component is configured.
[0012] In one embodiment, searching for a parent component of a second component in the tree component includes:
[0013] The preset recursive search function in the second component is called to search the parent component of the second component in the tree component by recursive search upward layer by layer.
[0014] In one embodiment, before calling the preset recursive search function in the second component to search for the parent component of the second component in the tree component by recursive search layer by layer, the method further includes:
[0015] Before registering the second component, intercepting a default value of a component property of the second component;
[0016] Based on a preset recursive search function, the default value of the component attribute is modified.
[0017] In one embodiment, determining whether the parent component has been injected with the global configuration data includes:
[0018] Searching for a parent component of a second component in the tree-shaped component, and in the case that the parent component of the second component has not been injected with global configuration data, recursively searching upward layer by layer to find a target parent component in the tree-shaped component that has been injected with the global configuration data;
[0019] If the root component is recursively found and the global configuration data is not injected into the root component, a configuration failure message is generated and pushed.
[0020] In one embodiment, after configuring the second component based on the global configuration data, the method further includes:
[0021] Reading the configuration data injected by the second component, and determining whether the configuration data is consistent with the global configuration data;
[0022] If the configuration data is inconsistent with the global configuration data, a configuration failure prompt message is generated and pushed.
[0023] In the second aspect, the present application also provides a global configuration device based on the Vue technology stack, including:
[0024] The configuration data acquisition module is used to obtain user-defined global configuration data based on the created configuration provider component;
[0025] A configuration data injection module, used to call a preset provide API, inject the global configuration data into the tree component, and globally configure the first component in the tree component, wherein the first component includes a root component and components associated with the root component;
[0026] A component search module, used to search for a parent component of a second component in the tree component, and determine whether the parent component has been injected with the global configuration data, and the second component is a component that has not been injected with the global configuration data;
[0027] A configuration data reading module, configured to, when a target parent component into which the global configuration data has been injected is found, call a preset inject API to obtain the global configuration data from the target parent component;
[0028] A configuration module is used to configure the second component based on the global configuration data.
[0029] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above method embodiment when executing the computer program.
[0030] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the above method embodiment are implemented.
[0031] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps in the above method embodiment when executed by a processor.
[0032] The above-mentioned global configuration method, device, computer equipment, computer-readable storage medium and computer program product based on the Vue technology stack first obtain the user-defined global configuration data based on the created configuration provider component, and then call the provide api to inject the global configuration data into the tree component, and globally configure the root component in the tree component and the components associated with the root component. The second component that has not been injected with the global configuration data can find the parent component of the second component in the tree component, and when the target parent component with the global configuration data is found, call the preset inject api to obtain the global configuration data from the target parent component, and configure the second component based on the global configuration data, so as to achieve global configuration of all components in the tree component. Different from the traditional solution, the configuration provider component in the above solution is itself a Vue component, and the provide api and inject api used in the configuration process are provided by the Vue technology stack itself, so there is no need to introduce additional libraries or write lengthy codes, so as to achieve lightweight management and configuration of the component library of the Vue technology stack and reduce the performance overhead of the computer. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 An application environment diagram of a global configuration method based on the Vue technology stack in one embodiment;
[0035] Figure 2 It is a flowchart of a global configuration method based on the Vue technology stack in one embodiment;
[0036] Figure 3 A schematic flow chart of the steps of searching for global configuration data in one embodiment;
[0037] Figure 4 A schematic flow chart of the steps of searching for global configuration data in another embodiment;
[0038] Figure 5 It is a structural block diagram of a global configuration device based on the Vue technology stack in one embodiment;
[0039] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0041] The global configuration method of the Vue technology stack provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers.
[0042] Specifically, the operator can provide customized global configuration data for the tree component based on the created configuration provider component through the terminal 102, and then the server 104 calls the preset provide API to inject the global configuration data into the tree component, and globally configure the first component in the tree component, wherein the first component includes the root component and the components associated with the root component. For the second component that has not been injected with the global configuration data, the server 104 searches for the parent component of the second component in the tree component, determines whether the parent component has been injected with the global configuration data, and calls the preset inject API when the target parent component that has been injected with the global configuration data is found, obtains the global configuration data from the target parent component, and configures the second component based on the global configuration data.
[0043] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, and tablet computers. The server 104 may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0044] In an exemplary embodiment, Figure 2 As shown in the figure, a global configuration method based on the Vue technology stack is provided, which is applied to Figure 1 Taking the server 104 in the example as an example, the following steps are included:
[0045] S100, obtaining user-defined global configuration data based on the created configuration provider component.
[0046] The configuration provider component is a component in Vue.js that receives user-defined global configuration data. Global configuration data is a set of configuration data defined by the user, which is used to control the behavior and style of each component, including but not limited to the configuration of local components and setting the status of sub-form components.
[0047] Among them, the three modes of "disabeld", "readonly" and "textmode" are mainly configured globally. When a component is set to "disabeld" mode, it means that the component cannot be operated or input by the user; when the component is set to "readonly" mode, it means that the component can display information, but the user cannot modify the component; when the component is set to "textmode", the component can only display information in text form. For example, if the "textmode" mode is set for the specified Input component in the component provided by the configurator, in its subcomponents, the Input components with the "textmode" attribute will be set to textmode mode by default.
[0048] Exemplarily, a Vue component named DConfigProvider may be created through tsx as a configuration provider component, and key properties in the configuration provider component may be defined, thereby allowing it to receive user-defined global configuration data.
[0049] S200, calling the preset provide API, injecting the global configuration data into the tree component, and globally configuring the first component in the tree component.
[0050] Among them, provide api is an api provided by Vue.js, which is used to pass data downward in the tree component. The parent component can provide some dependencies or services to its child components through provide api, thereby allowing data or services to be passed downward in the tree component. Tree component refers to a tree structure generated by multiple components nested in layers in Vue.js. In this tree structure, there are multiple nested and interdependent components. Each component is a node of the tree component, and the hierarchical relationship between the nodes represents the nesting and dependency relationship between the components. The first component includes the root component and the components associated with the root component. The root component is the top-level node of the tree component. Generally speaking, in an instance, there is only one root component, and the other components in the tree component are all subcomponents of the root component.
[0051] For example, through the provide api of Vue.js, global configuration data can be injected into the tree component to globally configure the first component in the tree component. Generally speaking, the global configuration data is injected into the root component of the tree component, and some components in the tree component that are associated with the root component and have nested and dependent relationships can also obtain the global configuration data, so the root component and these components are globally configured first.
[0052] S300, searching for the parent component of the second component in the tree component, and determining whether the parent component has been injected with global configuration data.
[0053] The second component is a component that has not been injected with global configuration data. A parent component is a component that directly contains other components, and the contained components are subcomponents of the parent component. A component can have multiple subcomponents, but only one parent component.
[0054] Continuing with the above steps, after the first component in the tree component is globally configured, there are still some second components in the tree component that have not been globally configured. The second component searches upward for its own parent component and determines whether the global configuration data has been injected into the parent component.
[0055] S400, when a target parent component into which global configuration data has been injected is found, a preset inject api is called to obtain the global configuration data from the target parent component.
[0056] Among them, similar to the provide api, the inject api is also an api provided by Vue.js itself, which is used for components to obtain data from their parent components. For example, a child component receives dependencies or services from the rent payment through the inject api. By providing the provide api and inject api by Vue.js itself, the dependencies between Vue components can be effectively managed and the coupling of the code can be reduced. The target parent component refers to the parent component that has been injected with global configuration data. For example, the parent component of the second component is searched for the parent component of the previous level. The global configuration data has not been injected into the parent component. Therefore, the second component continues to search for the parent component of the parent component of the previous level. If the parent component found at this time has been injected with global configuration data, then the parent component is the target parent component. Further, the inject api provided by Vue.js itself is called to obtain the global configuration data from the target parent component.
[0057] It should be noted that the above configuration process can also be implemented through the Vue state management tool, but it is necessary to introduce other libraries and update the component state through the API specified by the state management tool. This process sometimes requires writing lengthy boilerplate code. For example, the state management tool Vuex needs to provide a large number of actions, mutations, getters and other method codes, which increases the volume of project code and requires additional configuration of the state management tool, increasing the learning cost of the computer. The configuration provider component, provide API and inject API in this embodiment can all be provided by Vue.js itself, and configuration sharing can be achieved without a large amount of complex code.
[0058] S500: Configure the second component based on the global configuration data.
[0059] Following the above steps, for each second component, the second component is globally configured by searching for the parent component and calling the inject API to obtain the global configuration data from the target parent component. For example, the component properties in the second component are updated according to the global configuration data to realize the injection of the global configuration data.
[0060] The above-mentioned global configuration method based on the Vue technology stack first obtains the user-defined global configuration data based on the created configuration provider component, and then calls the provide api to inject the global configuration data into the tree component, and globally configures the root component in the tree component and the components associated with the root component. The second component that has not been injected with the global configuration data can find the parent component of the second component in the tree component, and when the target parent component with the global configuration data is found, call the preset inject api to obtain the global configuration data from the target parent component, and configure the second component based on the global configuration data, so as to achieve global configuration of all components in the tree component. Different from the traditional solution, the configuration provider component in the above solution is itself a Vue component. The provide api and inject api used in the configuration process are both provided by the Vue technology stack itself, so there is no need to introduce additional libraries or write lengthy codes, so as to achieve lightweight management and configuration of the component library of the Vue technology stack and reduce the performance overhead of the computer.
[0061] In one embodiment, S300 includes: calling a preset recursive search function in the second component, searching the parent component of the second component in the tree component by recursive search layer by layer, and determining whether the parent component has been injected with global configuration data.
[0062] In an exemplary embodiment, before registering the second component, the default value of the component attribute of the second component is intercepted, and the default value of the component attribute is modified based on a preset recursive search function. Specifically, the default value in the component attribute of the second component can be intercepted or hijacked by the setDefault method before the second component is registered, and replaced with a predefined recursive search function, in which the operation of recursively reading and returning global configuration data layer by layer is set, so that the default value of the component attribute can be dynamically changed.
[0063] The recursive search function defines the logic of searching for parent components layer by layer. When the recursive search function is called, it will automatically search for the parent component of the second component. If the parent component of the previous level has not been injected with the global configuration data, it will continue to search for the parent component of the parent component until the target parent component that has been injected with the global configuration data is found, or the root component of the tree component is found.
[0064] Exemplarily, taking source as an example, source can be any component in the tree component. The specific way for source to obtain global configuration data is: first determine whether the provided attribute of source itself contains global configuration data. If it does, it means that source is the first component that has been injected with global configuration data, and there is no need to obtain global configuration data through recursive search layer by layer; if it does not contain it, it means that source is the second component that has not been injected with global configuration data, then search for the parent component of the previous level of source. If the parent component does not have global configuration data either, continue to search for the parent component upward until the global configuration data is found and return the global configuration data.
[0065] In this embodiment, the parent component of the second component is searched layer by layer through a recursive search method upward. Even if the global configuration data exists in the parent component of a higher level, the second component can quickly and accurately find the required global configuration data in the tree component. This process does not require the introduction of other libraries or the writing of lengthy codes, thereby reducing the performance overhead of the computer.
[0066] In one embodiment, Figure 3 As shown, determine whether the parent component has been injected with global configuration data, including:
[0067] S310, searching for the parent component of the second component in the tree component.
[0068] S320, when the parent component of the second component has not injected the global configuration data, recursively search upward layer by layer.
[0069] S330, finding out the target parent component into which the global configuration data has been injected in the tree component.
[0070] S340: If the root component is recursively found and the root component has not injected the global configuration data, a configuration failure message is generated and pushed.
[0071] Continuing from the above embodiment, in the process of searching upward layer by layer, there are two possibilities: finding the target parent component in the tree component into which the global configuration data has been injected, or finding the root component of the tree component upward but still failing to find the global configuration data.
[0072] Exemplarily, if the global configuration data is not injected into the parent component of the second component, the recursive search continues upward until the top level of the tree component, that is, the root component, is found. If the global configuration data is not injected into the root component either, it means that an error occurred when the global configuration data was initially injected into the first component of the tree component through the provide API. At this time, a configuration failure message is generated and pushed to the terminal of the relevant manager, for example, the configuration failure message is pushed through a user interface pop-up window or a system log to remind the relevant manager of the global configuration failure.
[0073] In this embodiment, the global configuration data is searched upward layer by layer, and when the root component is recursively searched and the global configuration data is not injected into the root component, the user is notified of the configuration failure, thereby realizing automatic global configuration of components in the tree component. When the global configuration data cannot be found, the relevant management personnel are notified in time to handle it, thereby improving the efficiency of global state management of Vue components.
[0074] In one embodiment, after S500, the method further includes: reading the configuration data injected by the second component, determining whether the configuration data is consistent with the global configuration data, and if the configuration data is inconsistent with the global configuration data, generating and pushing a configuration failure prompt message.
[0075] Continuing with the above embodiment, after configuring the second component based on the global configuration data obtained by recursive search, it is possible to further check whether the configuration data injected into the second component is known to the initial user-defined global configuration data. If the two are found to be inconsistent, a configuration failure message is generated and pushed.
[0076] For example, after the second component completes configuration, the configuration data of the actual application that has been injected into the second component is read, and then the configuration data of the actual application is compared with the user-defined configuration data to determine whether a configuration error occurs. When the two are inconsistent, a configuration failure prompt message is generated in time and pushed to the user or the system, so that when a configuration error occurs, the relevant management personnel can be notified in time for processing.
[0077] In this embodiment, by comparing the configuration data of the actual application with the global configuration data customized by the user, the possibility of configuration errors can be reduced and the efficiency and reliability of Vue global management can be improved.
[0078] In order to make a clearer description of the global configuration method based on the Vue technology stack provided by this application, the following is a specific embodiment and the attached Figure 4 To illustrate, this specific embodiment includes the following steps:
[0079] S401, based on the created configuration provider component, obtain the user-defined global configuration data, call the preset provide API, inject the global configuration data into the tree component, and globally configure the first component in the tree component.
[0080] Exemplarily, a Vue component named DConfigProvider can be created through tsx as a configuration provider component, and key properties in the configuration provider component can be defined to allow it to receive user-defined global configuration data, including but not limited to the configuration of local components and setting the status of sub-form class components.
[0081] Afterwards, through the provide api of Vue.js, the global configuration data can be injected into the root component of the tree component, as well as some components in the tree component that are associated with the root component and have nested and dependent relationships. Therefore, the root component and these components are globally configured first.
[0082] S402, calling the preset recursive search function in the second component, searching the parent component of the second component in the tree component by recursive search layer by layer, and determining whether the parent component has been injected with global configuration data.
[0083] Specifically, through the setDefault method, before the second component is registered, the default value in the component property of the second component is intercepted or hijacked, and replaced with a predefined recursive search function. The recursive search function is set to recursively read and return the global configuration data layer by layer, so as to dynamically change the default value of the component property. When the recursive search function is called, the parent component of the second component will be automatically searched. If the parent component of the parent component has not been injected with the global configuration data, the parent component of the parent component will continue to be searched until the target parent component that has been injected with the global configuration data is found, or the root component of the tree component is found.
[0084] S403, when the parent component of the second component has not injected the global configuration data, recursively search upward layer by layer. If the recursive search reaches the root component and the root component has not injected the global configuration data, a configuration failure message is generated and pushed.
[0085] Continuing with the above steps, if the parent component of the second component has not injected the global configuration data, continue to search recursively upward until the top level of the tree component, that is, the root component, is found. If the root component has not injected the global configuration data, it means that an error occurred when initially injecting the global configuration data into the first component of the tree component through the provide API. At this time, a configuration failure message is generated and pushed to the terminal of the relevant manager, for example, through a user interface pop-up window or system log to remind the relevant manager of the global configuration failure.
[0086] S404, when the target parent component into which the global configuration data has been injected is found, a preset inject API is called to obtain the global configuration data from the target parent component, and the second component is configured based on the global configuration data.
[0087] Among them, the parent component of the second component is searched. If the global configuration data has not been injected into the parent component, the second component continues to search for the parent component of the parent component. If the parent component found at this time has been injected with the global configuration data, then the parent component is the target parent component. Further, the injectapi provided by Vue.js itself is called to obtain the global configuration data from the target parent component.
[0088] S405, reading the configuration data injected by the second component, determining whether the configuration data is consistent with the global configuration data, and if the configuration data is inconsistent with the global configuration data, generating and pushing a configuration failure prompt message.
[0089] After the second component completes the configuration, it reads the configuration data of the actual application that has been injected into the second component, and then compares the configuration data of the actual application with the user-defined configuration data to determine whether a configuration error occurs. When the two are inconsistent, a configuration failure prompt message is generated in time and pushed to the user or system, so that when a configuration error occurs, the relevant management personnel can be notified in time for processing.
[0090] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0091] Based on the same inventive concept, the embodiment of the present application also provides a global configuration device based on the Vue technology stack for implementing the global configuration method based on the Vue technology stack involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more embodiments of the global configuration device based on the Vue technology stack provided below can refer to the limitations of the global configuration method based on the Vue technology stack above, and will not be repeated here.
[0092] In an exemplary embodiment, Figure 5 As shown, a global configuration device 500 based on the Vue technology stack is provided, including: a configuration data acquisition module 510, a configuration data injection module 520, a component search module 530, a configuration data reading module 540 and a configuration module 550, wherein:
[0093] The configuration data acquisition module 510 is used to acquire user-defined global configuration data based on the created configuration provider component.
[0094] The configuration data injection module 520 is used to call the preset provide API to inject the global configuration data into the tree component and perform global configuration on the first component in the tree component. The first component includes the root component and components associated with the root component.
[0095] The component search module 530 is used to search for the parent component of the second component in the tree component, and determine whether the parent component has been injected with global configuration data. The second component is a component that has not been injected with global configuration data.
[0096] The configuration data reading module 540 is used to call a preset inject api to obtain the global configuration data from the target parent component when a target parent component into which the global configuration data has been injected is found.
[0097] The configuration module 550 is used to configure the second component based on the global configuration data.
[0098] In one embodiment, the component search module 530 is further used to call a preset recursive search function in the second component to search for the parent component of the second component in the tree component by recursively searching upward layer by layer.
[0099] In one embodiment, the component search module 530 is further used to intercept the default value of the component property of the second component before registering the second component, and modify the default value of the component property based on a preset recursive search function.
[0100] In one embodiment, the component search module 530 is also used to search for the parent component of the second component in the tree component. If the parent component of the second component has not been injected with global configuration data, the module 530 recursively searches upward layer by layer to find the target parent component in the tree component that has been injected with global configuration data. If the recursive search reaches the root component and the root component has not been injected with global configuration data, a configuration failure message is generated and pushed.
[0101] In one embodiment, the configuration module 550 is also used to read the configuration data injected by the second component, determine whether the configuration data is consistent with the global configuration data, and generate and push a configuration failure prompt message if the configuration data is inconsistent with the global configuration data.
[0102] Each module in the above-mentioned global configuration device based on the Vue technology stack can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0103] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as global configuration data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a global configuration method based on the Vue technology stack is implemented.
[0104] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0105] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiment when executing the computer program.
[0106] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiment are implemented.
[0107] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiment when executed by a processor.
[0108] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0109] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0110] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0111] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A global configuration method based on the Vue technology stack, characterized in that: The method comprises: Based on the created configuration provider component, obtain user-defined global configuration data; Calling a preset provide API to inject the global configuration data into a tree component, and globally configuring a first component in the tree component, wherein the first component includes a root component and components associated with the root component; Searching for a parent component of a second component in the tree component, and determining whether the parent component has been injected with the global configuration data, wherein the second component is a component that has not been injected with the global configuration data; When the target parent component into which the global configuration data has been injected is found, a preset injectapi is called to obtain the global configuration data from the target parent component; Based on the global configuration data, the second component is configured.
2. The method according to claim 1, characterized in that The step of searching for a parent component of a second component in the tree component includes: The preset recursive search function in the second component is called to search the parent component of the second component in the tree component by recursive search upward layer by layer.
3. The method according to claim 2, characterized in that Before calling the preset recursive search function in the second component to search for the parent component of the second component in the tree component by recursive search layer by layer, the method further includes: Before registering the second component, intercepting a default value of a component property of the second component; Based on a preset recursive search function, the default value of the component attribute is modified.
4. The method according to any one of claims 1 to 3, characterized in that: The determining whether the parent component has been injected with the global configuration data includes: Searching for a parent component of a second component in the tree-shaped component, and in the case that the parent component of the second component has not been injected with global configuration data, recursively searching upward layer by layer to find a target parent component in the tree-shaped component that has been injected with the global configuration data; If the root component is recursively found and the global configuration data is not injected into the root component, a configuration failure message is generated and pushed.
5. The method according to any one of claims 1 to 3, characterized in that: After configuring the second component based on the global configuration data, the method further includes: Reading the configuration data injected by the second component, and determining whether the configuration data is consistent with the global configuration data; If the configuration data is inconsistent with the global configuration data, a configuration failure prompt message is generated and pushed.
6. A global configuration device based on the Vue technology stack, characterized in that: The device comprises: The configuration data acquisition module is used to obtain user-defined global configuration data based on the created configuration provider component; A configuration data injection module, used to call a preset provide API, inject the global configuration data into the tree component, and globally configure the first component in the tree component, wherein the first component includes a root component and components associated with the root component; A component search module, used to search for a parent component of a second component in the tree component, and determine whether the parent component has been injected with the global configuration data, and the second component is a component that has not been injected with the global configuration data; A configuration data reading module, configured to, when a target parent component into which the global configuration data has been injected is found, call a preset inject api to obtain the global configuration data from the target parent component; A configuration module is used to configure the second component based on the global configuration data.
7. The device according to claim 6, characterized in that The component search module is also used to call the preset recursive search function in the second component, and search for the parent component of the second component in the tree component by recursive search layer by layer.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
