Information injection method and device and storage medium

By obtaining the configuration file of the front-end construction tool and using the information injection function, the information to be injected is written into the web page entrance file, the problem of how to inject information into the web page entrance file is solved, and automated and efficient information injection is achieved.

CN120029664APending Publication Date: 2025-05-23PIPECHINA SOUTH CHINA CO +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510197227.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

When using front-end construction tools to compile front-end projects, how to write the information to be injected into the web page entry file becomes a technical challenge.

Method used

By responsive to the configuration operation, the configuration file of the front-end construction tool is obtained and the information to be injected is written to the entry file of the destination web page according to the configuration file. The specific steps include obtaining the information injection function in the configuration file, and writing the information to be injected into the entrance file through the function.

Benefits of technology

It realizes the automatic writing of information to be injected into the web page entrance file, improving the efficiency and accuracy of information injection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029664A_ABST
    Figure CN120029664A_ABST
Patent Text Reader

Abstract

The invention discloses an information injection method and device and a storage medium, relates to the technical field of information processing, and aims to solve the problem of writing to-be-injected information into a webpage entry file. The method comprises the steps that in response to configuration operation, a configuration file of a front-end construction tool is obtained, the configuration file comprises information to be injected, and the front-end construction tool is used for generating an entry file of a target webpage; and writing the to-be-injected information into an entry file of the target webpage according to the configuration file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing technology, and in particular to an information injection method, device and storage medium. Background Art

[0002] Currently, when front-end construction tools are used to compile front-end projects, injecting user-expected information into the compiled web page entry file has become a normal practice. Therefore, how to write the information to be injected into the web page entry file has become a technical problem to be solved. Summary of the invention

[0003] The purpose of the present application is to provide an information injection method, device and storage medium, aiming to solve the problem of writing the information to be injected into the web page entry file.

[0004] In order to achieve the above objectives, this application adopts the following technical solutions:

[0005] In a first aspect, the present application provides an information injection method, the method comprising: in response to a configuration operation, obtaining a configuration file of a front-end construction tool, the configuration file including information to be injected, the front-end construction tool being used to generate an entry file of a target web page; according to the configuration file, writing the information to be injected into the entry file of the target web page.

[0006] The information injection method provided in the embodiment of the present application can automatically write the information to be injected into the entry file of the target web page according to the configuration file through the front-end construction tool.

[0007] In a possible implementation, the information to be injected is written into the entry file of the target web page according to the configuration file, including: obtaining an information injection function through the configuration file, the information injection function is used to modify the entry file of the web page; and writing the information to be injected into the entry file of the target web page through the information injection function.

[0008] In a possible implementation, obtaining an information injection function through a configuration file includes: obtaining a hook function in the configuration file, the hook function being used to modify information of a web page; and adjusting parameters of the hook function according to information to be injected to obtain the information injection function.

[0009] In a possible implementation, the method further includes: obtaining source code of the target webpage; and compiling the source code of the target webpage using a front-end construction tool to obtain an entry file of the target webpage.

[0010] In one possible implementation, the configuration file includes display parameters of the information to be injected on the target web page. According to the configuration file, the information to be injected is written into the entry file of the target web page, including: in response to a construction operation, according to the display parameters, the information to be injected is written into the entry file of the target web page.

[0011] In a possible implementation, after writing the information to be injected into the entry file of the target webpage, the method further includes: displaying the target webpage; and displaying the information to be injected in response to a viewing operation on the target webpage.

[0012] In a possible implementation, the front-end construction tool includes Vite, and the information to be injected includes version information and development information of the target web page.

[0013] In a second aspect, the present application provides an information injection device, which includes: a communication unit and a processing unit; the communication unit is used to obtain a configuration file of a front-end construction tool in response to a configuration operation, the configuration file includes information to be injected, and the front-end construction tool is used to generate an entry file of a target web page; the processing unit is used to write the information to be injected into the entry file of the target web page according to the configuration file.

[0014] In a possible implementation, the communication unit is also used to obtain an information injection function through a configuration file, and the information injection function is used to modify the entry file of the web page; the processing unit is also used to write the information to be injected into the entry file of the target web page through the information injection function.

[0015] In a possible implementation, the communication unit is further used to obtain a hook function in a configuration file, where the hook function is used to modify information on a web page; the processing unit is further used to adjust parameters of the hook function according to the information to be injected to obtain an information injection function.

[0016] In a possible implementation, the communication unit is further used to obtain the source code of the target web page; the processing unit is further used to compile the source code of the target web page through a front-end construction tool to obtain an entry file of the target web page.

[0017] In a possible implementation, the configuration file includes display parameters of the information to be injected on the target web page, and the processing unit is further used to write the information to be injected into the entry file of the target web page in response to the construction operation according to the display parameters.

[0018] In a possible implementation, after the information to be injected is written into the entry file of the target webpage, the processing unit is further configured to display the information to be injected in response to a viewing operation on the target webpage.

[0019] In a possible implementation, the front-end construction tool includes Vite, and the information to be injected includes version information and development information of the target web page.

[0020] In a third aspect, the present application provides an information injection device, comprising: a processor and a communication interface; the communication interface and the processor are coupled, and the processor is used to run a computer program or instructions to implement the information injection method described in the first aspect and any possible implementation method of the first aspect.

[0021] In a fourth aspect, the present application provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a terminal, the terminal executes the information injection method described in the first aspect and any possible implementation of the first aspect.

[0022] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when the computer program product is run on an information injection device, enables the information injection device to perform the information injection method as described in the first aspect and any possible implementation of the first aspect.

[0023] In a sixth aspect, the present application provides a chip, the chip comprising a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a computer program or instructions to implement the information injection method described in the first aspect and any possible implementation method of the first aspect.

[0024] Specifically, the chip provided in the present application also includes a memory for storing computer programs or instructions. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments 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 drawings can be obtained based on these drawings without paying any creative work.

[0026] Figure 1 A schematic diagram of the composition of an information injection device provided in an embodiment of the present application;

[0027] Figure 2 A flowchart of an information injection method provided in an embodiment of the present application;

[0028] Figure 3 A flowchart of an information injection method provided in an embodiment of the present application;

[0029] Figure 4 A flowchart of an information injection method provided in an embodiment of the present application;

[0030] Figure 5 A schematic diagram of a complete hook calling sequence of Vite provided in an embodiment of the present application;

[0031] Figure 6 A flowchart of an information injection method provided in an embodiment of the present application;

[0032] Figure 7 A schematic diagram of a target page provided in an embodiment of the present application;

[0033] Figure 8 A schematic diagram of the structure of an information injection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0035] In the description of this application, it should be understood that the terms "upper", "lower", "left", "right", "front", "back", "inside", "outside", etc. indicate directions or positional relationships based on the directions or relative positional relationships shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as a limitation on this application. Unless otherwise specified, the above-mentioned directional description can be flexibly set in the process of actual application under the condition that the relative positional relationship shown in the accompanying drawings is met.

[0036] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise specified, "plurality" means two or more.

[0037] In the present application, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, article or device including the element.

[0038] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0039] In the description of this specification, specific features, structures, materials or characteristics may be combined in an appropriate manner in any one or more embodiments or examples.

[0040] Currently, when using front-end building tools to compile front-end projects, it is necessary to inject the information expected by the user into the compiled web page entry file (i.e., index.html file). Therefore, how to write the information to be injected into the web page entry file becomes a technical problem to be solved.

[0041] In view of this, an embodiment of the present application provides an information injection method, the method comprising: in response to a configuration operation, obtaining a configuration file of a front-end construction tool, and writing the information to be injected into an entry file of a target web page according to the configuration file. That is, the information injection method provided in the embodiment of the present application can automatically write the information to be injected into the entry file of a target web page according to the configuration file through a front-end construction tool.

[0042] For example, Figure 1 A schematic diagram of the composition of an information injection device 10 provided in an embodiment of the present application, the information injection device 10 may include a processor 101 and a bus 102.

[0043] Furthermore, the information injection device 10 may also include a communication interface 103 and a memory 104 . The processor 101 , the memory 104 and the communication interface 103 may be connected via a bus 102 .

[0044] The processor 101 is a central processing unit (CPU), a general processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 101 may also be other devices with processing functions, such as circuits, devices, or software modules, without limitation.

[0045] The bus 102 is used to transmit information between the components included in the information injection device 10 .

[0046] The communication interface 103 is used to communicate with other devices or other communication networks. The other communication networks may be Ethernet, radio access network (RAN), wireless local area network (WLAN), etc. The communication interface 103 may be a module, a circuit, a communication interface or any device capable of realizing communication.

[0047] The memory 104 is used to store instructions, where the instructions may be computer programs.

[0048] The memory 104 may be a read-only memory (ROM) or other types of static storage devices that can store static information and / or instructions, or a random access memory (RAM) or other types of dynamic storage devices that can store information and / or instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, etc., without limitation.

[0049] It should be noted that the memory 104 can exist independently of the processor 101, or can be integrated with the processor 101. The memory 104 can be used to store instructions or program codes or some data, etc. The memory 104 can be located in the information injection device 10, or can be located outside the information injection device 10, without limitation. The processor 101 is used to execute the instructions stored in the memory 104 to implement the information injection method provided in the following embodiments of the present application.

[0050] In an example, the processor 101 may include one or more CPUs, for example, CPU0 and CPU1 (not shown in the figure).

[0051] As an optional implementation, the information injection device 10 includes multiple processors.

[0052] As an optional implementation, the information injection device 10 further includes an output device and an input device. Exemplarily, the input device is a keyboard, a mouse, a microphone, a joystick, and the like, and the output device is a display screen, a speaker, and the like.

[0053] It should be noted that the information injection device 10 can be a desktop computer, a portable computer, a network server, a mobile phone, a tablet computer, a wireless terminal, an embedded device, a chip system or a Figure 1 In addition, Figure 1 The composition shown in the Figure 1 The limitations of each device in Figure 1 In addition to the parts shown, Figure 1 The various devices in the drawings may include more or fewer components than shown, or combine certain components, or arrange the components differently.

[0054] In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.

[0055] In addition, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation. The message name or parameter name in the message exchanged between the various devices in the embodiments of the present application is only an example, and other names can also be used in the specific implementation without limitation.

[0056] The information injection method provided by the embodiment of the present application is described below in conjunction with the accompanying drawings. Among them, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation. The message name or parameter name in the message exchanged between the various devices in the embodiment of the present application is only an example, and other names can also be used in the specific implementation without limitation. The actions involved in the various embodiments of the present application are only an example, and other names can also be used in the specific implementation, such as: "included in" in the embodiment of the present application can also be replaced by "carried on" or "carried in", etc.

[0057] like Figure 2 As shown, the embodiment of the present application proposes an information injection method, which includes:

[0058] S201. In response to a configuration operation, obtain a configuration file of a front-end building tool.

[0059] The configuration file includes information to be injected. The information to be injected refers to information that needs to be written into the entry file of the target web page. The front-end construction tool is used to generate the entry file of the target web page.

[0060] In a possible implementation, in response to a configuration operation by a user, a storage location of a configuration file of a front-end construction tool is located, and content of the configuration file is obtained.

[0061] Furthermore, after obtaining the configuration file of the front-end building tool, the configuration items in the configuration file can be modified or new configuration items can be added to the configuration file according to user needs. For example, if the port number of the development server needs to be modified, the port attribute under the server configuration item in the configuration file can be located and the value of the port attribute can be changed to the desired port number.

[0062] Exemplarily, the front-end building tool may include Vite. Vite can provide faster cold start speed, more efficient hot update and intelligent on-demand compilation and packaging. Vite is used to package the code and resources under development into an optimized format suitable for deployment in a production environment.

[0063] Exemplarily, the information to be injected may include version information and development information of the target web page, wherein the development information may be web page release time, web page release personnel, web page release branch or web page environment type.

[0064] S202. According to the configuration file, the information to be injected is written into the entry file of the target web page.

[0065] In a possible implementation, an information injection function is imported into the configuration file, and the information to be injected defined in the configuration file is written into the entry file of the target web page through the information injection function. Figure 4 The described embodiments are not described in detail here.

[0066] Furthermore, the configuration file may include display parameters of the information to be injected on the target web page. In the case where the configuration file includes display parameters of the information to be injected on the target web page, in response to a build command input by a user (e.g., npm run build), the information to be injected is written into the entry file of the target web page according to the display parameters in the configuration file.

[0067] Exemplarily, the above display parameters may include the font of the information to be injected and / or the color of the information to be injected.

[0068] In the information injection method provided by the present application, in response to the configuration operation, the configuration file of the front-end construction tool is obtained, and the information to be injected is written into the entry file of the target web page according to the configuration file. In other words, the information injection method provided by the embodiment of the present application can automatically write the information to be injected into the entry file of the target web page according to the configuration file through the front-end construction tool.

[0069] Optionally, before S202, the source code of the target webpage may be obtained so as to compile the source code of the target webpage to obtain the entry file of the target webpage. Figure 3 As shown, the information injection method described in the embodiment of the present application may also include the following steps.

[0070] S301, obtaining the source code of the target web page.

[0071] The source code of the target web page refers to the code and resources of the front-end project in the development environment.

[0072] Exemplarily, the source code of the above-mentioned target web page may include hypertext markup language (HTML) files, cascading style sheets (CSS) files, JavaScript files, Vue component files, etc., which are project source codes written by developers.

[0073] S302: compile the source code of the target webpage through a front-end construction tool to obtain an entry file of the target webpage.

[0074] In one possible implementation, the source code of the target web page is migrated to the corresponding directory of the Vite project, and the development server is started in the root directory of the Vite project. Vite compresses, obfuscates, and splits the source code of the target web page to generate all compiled static resource files, which include the entry file of the target web page.

[0075] It should be noted that since the source code of the target web page cannot work if it is directly placed in the web container, it is necessary to use Vite to compile the source code of the target web page to generate a file that can be recognized by the web browser.

[0076] In one embodiment, Figure 4 As shown, the above S202 can be specifically determined through the following S401 to S402.

[0077] S401. Obtain information injection function through configuration file.

[0078] Among them, the information injection function is used to modify the entry file of the web page.

[0079] In a possible implementation, a hook function is obtained through a configuration file, the input of which is a parameter html, which is the content of the entry file of the target web page. The information to be injected is defined as a variable, and the input parameter html of the hook function is adjusted according to the variable to obtain an information injection function.

[0080] It should be noted that Vite uses the front-end module compilation tool rollup at the bottom layer. Vite and rollup define external hooks. Hooks provide developers with a way to insert custom logic at different stages of the Vite build process.

[0081] For example, Figure 5 A schematic diagram of a complete hook calling sequence of Vite provided in an embodiment of the present application. Figure 5 As shown in the figure, Vite's compilation process includes three stages: parsing configuration stage, building stage and output stage. The complete hook calling sequence of Vite is: config→options→configServer→buildStart→resolveld→load→transform→buildEnd→outputoptions→renderStart→augmentChunkHash→renderChunk→generateBundle→transformIndexHtml→writeBundle→closeBundle. Among them, config, configServer and transformIndexHtml are Vite-specific hooks, and the rest are rollup hooks.

[0082] Combination Figure 5 The hook function in the above information injection function is transformIndexHtml, which is used to modify the information of the web page. The embodiment of the present application writes the information to be injected into the entry file of the target web page by calling the transformIndexHtml hook function.

[0083] Exemplarily, the code of the above information injection function can be as follows:

[0084]

[0085]

[0086] Among them, the above comment vite-plugin-injection-data.js represents the file name. The first line of code represents the export of the default function vitePluginInjectionData, the input of which is the configuration object config. The second line of code represents the return of a plug-in object. The third line of code represents the plug-in name. The fourth line of code represents the definition of the transformIndexHtml hook function, the input of which is the parameter html, which is the content of the web page entry file in string format. The fifth line of code represents the use of the JSON.stringify method to convert the config.injects object into a JSON string, and the config.injects object is the information to be injected. The sixth line of code represents adding the converted JSON string to the end of html and adding a comment mark in front. The seventh line of code represents returning the modified html.

[0087] S402: Write the information to be injected into the entry file of the target web page through the information injection function.

[0088] In a possible implementation, an information injection function is imported into a configuration file, and the information to be injected is written into an entry file of a target web page through the information injection function.

[0089] Exemplarily, the code of the above configuration file may include the following content:

[0090]

[0091]

[0092] Among them, the above comment vite.config.js indicates the file name. The vite.config.js file is the configuration file of the Vite project, which is used to define the configuration items of the project. The first line of code indicates that the defineConfig function is imported from the 'vite' package, which is used to define the Vite configuration object. The second line of code indicates that the vue plug-in is imported from the '@vitejs / plugin-vue' package, which is used to support .vue files in the Vite project. The third line of code indicates that the injectionPluginData plug-in (i.e., the information injection function) is imported from the 'vite-plugin-injection-data' file. The fourth line of code indicates that the Vite configuration object is defined and exported by default using the defineConfig function. The fifth and sixth lines of code indicate that the plug-ins are configured in the plugins array of the Vite configuration object, including the vue plug-in and the injectionPluginData plug-in. The seventh line of code indicates that a configuration object is passed to the injectionPluginData plug-in, which includes the injects attribute, which is used to specify the information to be injected. The information to be injected is the time of the current running code and the fixed version number.

[0093] It should be noted that the '. / vite-plugin-injection-data' in the third line of code above means that the 'vite-plugin-injection-data' file is stored in the same directory as the vite.config.js file. Of course, the 'vite-plugin-injection-data' file and the vite.config.js file can also be in different directories. For example, the 'vite-plugin-injection-data' file is stored in a subdirectory of the vite.config.js file, or the 'vite-plugin-injection-data' file is stored in the node package manager (NPM) repository.

[0094] It is understandable that when it is necessary to write the information to be injected into the web page entry file of different front-end projects, the information to be injected can be written into the web page entry file by importing the information injection function in the configuration file without modifying the information injection function, thereby improving the efficiency of information injection. In addition, when the information to be injected changes, it is only necessary to modify the injects attribute in the seventh line of code in the above configuration file.

[0095] Furthermore, after S202, the entry file of the target webpage where the information to be injected is written needs to be deployed to the production environment so as to display the target webpage, and then the information to be injected can be displayed through the target webpage. Figure 6 As shown, the information injection method described in the embodiment of the present application may also include the following steps.

[0096] S601: Display the target web page.

[0097] In one possible implementation, a server of a production environment (i.e., an environment actually accessed and used by end users) is connected, and an entry file of a target webpage with information to be injected is uploaded to the server. The server is configured accordingly and the environment variables of the production environment are set to obtain a successfully deployed target webpage. In response to a user's request to access the target webpage, the target webpage is displayed.

[0098] S602: In response to a viewing operation on a target webpage, display information to be injected.

[0099] In a possible implementation, in response to a user's operation of viewing a webpage source code on a target webpage, the target page is displayed, and the target page includes the information to be injected.

[0100] For example, Figure 7 A schematic diagram of a target page provided in an embodiment of the present application. Figure 7 As shown, the last line of the page "<!--{"time":"Sun Sep 22 2024 07:13:58GMT+0800(China Standard Time)", "version":"2024-09-21"}-->" is the information to be injected.

[0101] It is understandable that through the target page, the user can quickly view the information to be injected, which facilitates the understanding of the relevant information of the target web page.

[0102] It is understandable that the above-mentioned information injection method can be implemented by an information injection device. In order to realize the above-mentioned functions, the information injection device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the modules and algorithm steps of each example described in the embodiments disclosed herein, the embodiments disclosed in this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments disclosed in this application.

[0103] The embodiments disclosed in the present application can divide the functional modules according to the information injection device generated by the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiments disclosed in the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.

[0104] Figure 8 This is a schematic diagram of the structure of an information injection device provided in an embodiment of the present application. Figure 8 As shown, the information injection device 80 can be used to perform Figure 2-Figure 4 as well as Figure 6 The information injection method shown. The information injection device 80 includes: a communication unit 801 and a processing unit 802.

[0105] The communication unit 801 is used to obtain a configuration file of a front-end construction tool in response to a configuration operation. The configuration file includes information to be injected. The front-end construction tool is used to generate an entry file of a target web page. The processing unit 802 is used to write the information to be injected into the entry file of the target web page according to the configuration file.

[0106] In a possible implementation, the communication unit 801 is also used to obtain an information injection function through a configuration file, and the information injection function is used to modify the entry file of a web page; the processing unit 802 is also used to write the information to be injected into the entry file of the target web page through the information injection function.

[0107] In a possible implementation, the communication unit 801 is further used to obtain a hook function in a configuration file, where the hook function is used to modify information on a web page; the processing unit 802 is further used to adjust parameters of the hook function according to the information to be injected to obtain an information injection function.

[0108] In a possible implementation, the communication unit 801 is further used to obtain the source code of the target webpage; the processing unit 802 is further used to compile the source code of the target webpage through a front-end construction tool to obtain an entry file of the target webpage.

[0109] In a possible implementation, the configuration file includes display parameters of the information to be injected on the target web page, and the processing unit 802 is further configured to write the information to be injected into the entry file of the target web page according to the display parameters in response to the construction operation.

[0110] In a possible implementation, after the information to be injected is written into the entry file of the target webpage, the processing unit 802 is further configured to display the information to be injected in response to a viewing operation on the target webpage.

[0111] In a possible implementation, the front-end construction tool includes Vite, and the information to be injected includes version information and development information of the target web page.

[0112] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0113] The present disclosure also provides a computer-readable storage medium having instructions stored thereon. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the information injection method provided by the above-mentioned embodiment of the present disclosure.

[0114] The embodiments of the present disclosure also provide a computer program product including instructions, which, when executed on an electronic device, enables the electronic device to execute the information injection method provided by the embodiments of the present disclosure.

[0115] Among them, the computer readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a register, a hard disk, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application-specific integrated circuit (ASIC). In the embodiments of the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program, which may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0116] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. An information injection method, characterized in that: The method comprises: In response to the configuration operation, a configuration file of a front-end construction tool is obtained, the configuration file including the information to be injected, and the front-end construction tool is used to generate an entry file of a target web page; According to the configuration file, the information to be injected is written into the entry file of the target webpage.

2. The method according to claim 1, characterized in that The step of writing the information to be injected into the entry file of the target webpage according to the configuration file comprises: Obtaining an information injection function through the configuration file, wherein the information injection function is used to modify an entry file of a web page; The information to be injected is written into the entry file of the target web page through the information injection function.

3. The method according to claim 2, characterized in that The step of obtaining the information injection function through the configuration file includes: Obtaining a hook function in the configuration file, wherein the hook function is used to modify information of a web page; According to the information to be injected, the parameters of the hook function are adjusted to obtain the information injection function.

4. The method according to claim 1, characterized in that: The method further comprises: Obtaining the source code of the target webpage; The source code of the target webpage is compiled by the front-end construction tool to obtain the entry file of the target webpage.

5. The method according to claim 1, characterized in that The configuration file includes display parameters of the information to be injected on the target webpage, and the step of writing the information to be injected into the entry file of the target webpage according to the configuration file includes: In response to the construction operation, the information to be injected is written into the entry file of the target web page according to the display parameters.

6. The method according to any one of claims 1 to 5, characterized in that After writing the information to be injected into the entry file of the target webpage, the method further includes: Displaying the target web page; In response to a viewing operation on the target webpage, the information to be injected is displayed.

7. The method according to any one of claims 1 to 5, characterized in that The front-end construction tool includes Vite, and the information to be injected includes version information and development information of the target webpage.

8. An information injection device, characterized in that: The device comprises: a communication unit and a processing unit; The communication unit is used to obtain a configuration file of a front-end construction tool in response to a configuration operation, wherein the configuration file includes information to be injected, and the front-end construction tool is used to generate an entry file of a target webpage; The processing unit is used to write the information to be injected into the entry file of the target web page according to the configuration file.

9. An information injection device, characterized in that: include: Memory and processor; The memory is coupled to the processor; The memory is used to store instructions executable by the processor; When the processor executes the instruction, the information injection method according to any one of claims 1 to 7 is performed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is enabled to execute the information injection method according to any one of claims 1 to 7.

11. A computer program product, characterized in that The computer program product comprises computer program instructions, and when the computer program instructions are executed by a processor, the information injection method according to any one of claims 1 to 7 is implemented.