File updating method and system and electronic equipment
Through dynamic loading and hot update of the GIS 3D engine, the problems of complexity and high cost of the GIS 3D engine update process are solved, and simplified update process and efficient resource management are achieved.
Patent Information
- Application Number
- CN202411044462.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-29
AI Technical Summary
The existing GIS 3D engine update process has long links, high costs and complex operations, which affects platform stability and increases operation and maintenance costs.
By dynamically loading files and performing hot updates, the web application automatically reads the version number of the GIS 3D engine during runtime, assembles the resource address according to the cloud-edge environment, and uses script tags to insert the resource address into the HTML page to complete the dynamic loading of the GIS 3D engine and Initialize and simplify the update process.
It reduces the complexity and cost of update operations, improves the convenience and efficiency of file update processes, simplifies the operation process, and realizes visual update of resource files.
Smart Images

Figure CN119045845A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of multimedia processing technology, and in particular to a file updating method, system and electronic equipment. Background Art
[0002] GIS (Geographic Information System) 3D engine is widely used in the field of digital twins and has become an indispensable core part of building digital twin systems. In the digital twin business, both the code editing environment and the integrated management platform of digital twins are highly dependent on the technical support provided by the GIS 3D engine. With the continuous delivery of digital twin projects and the continuous update of versions, the frequency of new version releases of GIS 3D engines is gradually increasing.
[0003] Currently, GIS 3D engines are integrated into various web applications in the form of NPM (Node Package Manager) packages. When a new version of GIS 3D engine is released, multiple steps need to be performed to update the GIS 3D engine.
[0004] However, the existing GIS 3D engine update process has a long update link, high update cost, and complex operation. Summary of the invention
[0005] The purpose of this application is to provide a file update method, system and electronic device, which can improve the convenience and efficiency of the file update process.
[0006] To achieve the above-mentioned purpose, the present application provides a file update method on the one hand, which includes: determining whether an initial resource version number is cached locally, if the initial resource version number is not cached locally, the web application sends a version number access request to a remote configuration center according to its own category to obtain a target resource version number fed back by the remote configuration center, wherein the categories include cloud applications and edge applications, and the remote configuration center includes a cloud configuration center and an edge server; generating a target resource address based on the target resource version number, creating a script tag, and adding the target resource address to the script tag to load and execute the target resource file corresponding to the target resource address; mounting the application programming interface exposed after the target resource file is loaded into a global variable, and initializing the application programming interface through the attribute value in the global variable, so as to create a unique instance for external business calls based on the initialized application programming interface.
[0007] To achieve the above-mentioned purpose, the present application also provides a file update system on the other hand, which includes: a web application module, which is used to determine whether the initial resource version number is cached locally. If the initial resource version number is not cached locally, the web application module sends a version number access request to the remote configuration center according to its own category to obtain the target resource version number fed back by the remote configuration center, wherein the categories include cloud applications and edge applications, and the remote configuration center includes a cloud configuration center and an edge server; a target resource address is generated based on the target resource version number, a script tag is created, and the target resource address is added to the script tag to load and execute the target resource file corresponding to the target resource address; the application programming interface exposed after the target resource file is loaded is mounted into a global variable, and the application programming interface is initialized through the attribute value in the global variable, based on A unique instance is created for external business calls in the initialized application programming interface; a version distribution center is used to encapsulate resource files corresponding to each version number according to preset specifications, and upload each encapsulated resource file to a storage cluster; a resource storage address of each resource file in the storage cluster is recorded, and a mapping relationship between the resource storage address and the version number is established; a storage cluster is used to store each resource file; a cloud configuration center is used to configure the version number information and resource library information corresponding to each resource file according to preset rules based on each resource file stored in the storage cluster, wherein the resource library information at least includes the resource storage address corresponding to the version number; an edge server is used to update the local cache data according to the version number information and the resource library information fed back by the cloud configuration center, and convert the resource storage address into an edge resource address.
[0008] To achieve the above-mentioned purpose, the present application also provides an electronic device on the other hand, which includes a memory and a processor, and the memory is used to store a computer program. When the computer program is executed by the processor, the above-mentioned file updating method is implemented.
[0009] It can be seen from this that the technical solution provided by the present application is that the cloud web application or the edge web application will first read the local configuration at runtime to determine whether there is an initial resource version number locally. If there is no initial resource version number, the web application will automatically send a version number access request to the cloud configuration center or the edge server according to its own cloud edge attributes, thereby obtaining the target resource version number fed back by the cloud configuration center or the edge server, and the target resource version number is mapped to the target resource file (such as a GIS 3D engine). When the web application receives the target resource version number, it can convert the target resource version number into the target resource address according to the cloud edge environment. After that, the web application can introduce the above-mentioned target resource address through a script tag and insert it into the head tag of the HTML page to complete the dynamic loading of the target resource file. When the target resource file is loaded, by mounting the exposed application programming interface to a global variable, the user can directly initialize the application programming interface in the browser window, thereby creating a unique instance for external business calls, and then completing the update deployment of the target resource file. The solution of the present application can realize the visualization operation of the update process by mounting the resource file on the global variable. The user can intuitively view the resource version number of the current environment, as well as the source of the version number and other information. The update operation is simple and intuitive. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in 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 creative work.
[0011] Figure 1 is a flowchart of the file updating method in the first implementation mode of the present application;
[0012] Figure 2 is a system architecture diagram of a file update system in an implementation manner of the present application;
[0013] Figure 3 This is a flow chart of a method for updating a file in a cloud application in the second implementation mode of the present application;
[0014] Figure 4 This is a flow chart of a file update method for edge applications in implementation mode 3 of the present application;
[0015] Figure 5 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0016] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0017] GIS 3D engine has a very wide range of applications in the field of digital twins. GIS 3D engine has become a core component for building digital twin systems. In the business process of digital twins, both the code editing environment and the integrated management platform are highly dependent on the technical support provided by the GIS 3D engine. The GIS 3D engine is integrated into these platforms and works with other components to form a complete system to meet specific business needs. With the continuous delivery of digital twin projects and the continuous iteration of versions, the update frequency of the GIS 3D engine is also gradually increasing.
[0018] Currently, GIS 3D engines are usually integrated into various web applications in the form of NPM packages. When a new version of the GIS 3D engine is released, the following steps need to be performed to implement the update: First, the dependent version of the GIS 3D engine needs to be manually updated in the web application and all new dependencies need to be installed correctly; then, the application is built on the deployment platform and the updated application is pushed to the edge server. After that, the edge server updates its image to implement the update of the GIS3D engine in the online environment.
[0019] However, the existing GIS 3D engine update process has the following problems:
[0020] Long update link and high cost: The entire update process includes multiple steps such as manually upgrading the version number, installing dependencies, building applications, pushing updates to edge servers, and updating edge server images, which will extend the update cycle and increase time costs. At the same time, frequent version iterations and build push operations also increase operation and maintenance costs.
[0021] Impact on platform stability: Each update of the GIS 3D engine requires a version update of the platform application. In some cases, even if the platform application has no business logic changes, it still needs to be updated again, which may affect the stability of the platform.
[0022] High update operation requirements: Operators must have a deep understanding of business processes and clearly understand the dependencies of the GIS 3D engine in different projects. They also need to be proficient in the relevant operations of NPM package upgrades. These requirements significantly increase the usage threshold for operators.
[0023] Therefore, how to simplify the update process of resource files, reduce the complexity and cost of update operations, and ultimately improve the convenience and efficiency of the file update process has become a topic that urgently needs to be solved in this field.
[0024] The present application provides a file update method, system and electronic device that can dynamically load files and perform hot updates on loaded files. Taking the GIS 3D engine as an example, the web application can automatically read the version number of the GIS 3D engine at runtime, and automatically assemble the resource address of the GIS 3D engine according to the cloud edge environment, and then use the script tag to insert the above resource address into the head tag of the HTML page, thereby completing the dynamic loading of the GIS 3D engine. After the GIS 3D engine is loaded and executed, the web application can complete the initialization process of the engine by obtaining the attribute values exposed by the resource file on the global variables, thereby creating a unique instance for external business calls, and finally completing the update deployment of the GIS 3D engine.
[0025] Figure 1 This is a flowchart of a file updating method in an implementation manner of the present application. Figure 2 This is a system architecture diagram of the file update system in the implementation mode of this application. Figure 3 This is a flow chart of the file update method for cloud applications. Figure 4 Flowchart of the file update method for edge applications. The file update system includes a version distribution center, a storage cluster, a remote configuration center, and a web application deployed in the cloud or at the edge, wherein the remote configuration center includes a cloud configuration center and an edge server. The version distribution center is used to perform testing, package software code, publish software version numbers to the outside, upload code resources to the storage cluster, and other operations. The storage cluster is used to store information such as the name, code file, version number, etc. of the code resource, and its type can be a CDN (Content Delivery Network) cluster or a distributed storage cluster. The cloud configuration center can exchange information with the storage cluster, and configure resource version numbers, resource files, and other information according to the content released by the version distribution center. The edge server can exchange information with the cloud configuration center and the storage cluster, and synchronize its own storage information based on the configuration information of the cloud configuration center.
[0026] S101: Determine whether the initial resource version number is cached locally. If the initial resource version number is not cached locally, the web application sends a version number access request to the remote configuration center according to its own category to obtain the target resource version number fed back by the remote configuration center, wherein the categories include cloud applications and edge applications, and the remote configuration center includes a cloud configuration center and an edge server.
[0027] In this embodiment, when the web application is running, the web application will check its internal cache to determine whether the initial resource version number is cached locally. If the web application does not cache the initial resource version number, the web application will send a version number access request to the remote configuration center according to its own category to obtain the target resource version number fed back by the remote configuration center.
[0028] According to the deployment location of web applications, this application divides web applications into cloud applications and edge applications. Specifically, if a web application is deployed in a cloud data center, then the web application is a cloud application, and the cloud application can directly access the storage cluster through the network; if a web application is deployed on a network edge device (such as a remote terminal unit, a smart phone, a tablet computer, and other edge computing node devices), then the web application is an edge application, and the edge application can usually only exchange data with the edge server, and it cannot directly access the storage cluster.
[0029] In this embodiment, when the web application determines that the initial resource version number is not cached locally, if the web application's own category is a cloud application, the web application will send the above version number access request to the cloud configuration center. When the cloud configuration center receives the version number access request, the cloud configuration center will feed back the target resource version number stored to the above web application, and the user can use the above target resource version number as the update object. If the web application's own category is an edge application, the web application will send the above version number access request to the edge server. When the edge server receives the version number access request, the edge server will feed back the resource version number list stored to the above web application. In this way, the user can select a resource version number (i.e., the target resource version number) from the resource version number list as the update object according to actual needs.
[0030] In an achievable implementation, before the web application determines whether the initial resource version number is cached locally (i.e., before running the web application), the version distribution center needs to encapsulate the resource files corresponding to each version number according to the preset specification, and upload the encapsulated resource files to the storage cluster. Afterwards, the version distribution center or the storage cluster will generate corresponding resource storage addresses for each resource file according to the preset rules based on the storage location of each resource file. At the same time, the storage cluster will also record the resource storage address of each resource file, and establish a mapping relationship between the resource storage address and the version number, so that the subsequent web application or edge server can find the corresponding resource storage address according to the version number, and then download the corresponding resource file according to the resource storage address.
[0031] Taking the GIS 3D engine as an example, the GIS 3D engine may release multiple versions, and each version may have different functions. After the GIS 3D engine is released, for any version of the GIS 3D engine, the developer can encapsulate the source code of the GIS3D engine according to the UMD specification and upload the encapsulated resource files to the storage cluster. After receiving the above resource files, the storage cluster will store them and record the resource storage address of each resource file in the storage cluster, where the resource storage address is associated with the version number. For example: assuming that the version number of a GIS 3D engine is 0.1.178, the resource storage address of this version of the GIS 3D engine can be constructed as https: / / xxxxxx / xxx-gis3d / v0.1.178 / index.js. If the version number of a GIS3D engine is 0.1.179, the resource storage address of this version of the GIS 3D engine can be constructed as https: / / xxxxxx / xxx-gis3d / v0.1.179 / index.js.
[0032] In an achievable implementation, after the storage cluster establishes a mapping relationship between the resource storage address and the version number, the cloud configuration center can configure the version number information and resource library information corresponding to each resource file stored in the storage cluster according to preset rules, wherein the resource library information at least includes the resource storage address corresponding to the version number. Specifically, the cloud configuration center can send a request to the version distribution center to obtain the resource version number, resource file and other information uploaded by the version distribution center to the storage cluster.
[0033] In actual scenarios, the network environment of edge applications and cloud applications is very different. For example, in edge scenarios, edge applications may not be able to access the public network, which means that edge applications cannot access the storage cluster, so the resource files called by edge applications can only be stored in the edge server. In response to the above situation, the version distribution center will feedback the relevant information of these resource files that are only used by edge applications to the cloud configuration center to facilitate the subsequent synchronization of the edge server and the cloud configuration center. After obtaining the relevant information fed back by the version distribution center, the cloud configuration center can know which resource files are stored in the storage cluster and which resource files are only for edge applications to call. For resource files that are only called by edge applications, the cloud configuration center will configure the version number and resource library, while for resource files that are called by cloud applications, the cloud configuration center can only configure the version number.
[0034] The configuration operations of the cloud configuration center can be implemented in the following ways:
[0035]
[0036]
[0037] When the cloud configuration center completes the configuration operation, the edge server can update the local cache data according to the version number information and resource library information fed back by the cloud configuration center, and download the corresponding resource file to the specified location of the local storage device according to the resource storage address fed back by the cloud configuration center. Correspondingly, the resource storage address of the resource file is converted to an edge resource address. Specifically, after the edge server downloads the corresponding resource file from the storage cluster using a certain resource storage address, it will store the resource file in the specified location of the local storage device. Based on the actual storage address of the resource file at the edge, the edge server will generate an edge storage address, which is the edge resource address of the above-mentioned resource file. In this way, the edge application can find the corresponding resource file in the edge server according to the above-mentioned edge resource address.
[0038] For example:
[0039]
[0040]
[0041] Obviously, for any resource file, its resource storage address and edge resource address can be linked through the version number, and the edge web application can use the version number to query the corresponding edge resource address, and then download the corresponding resource file from the edge server according to the edge resource address.
[0042] S102: Generate a target resource address based on the target resource version number, create a script tag, and add the target resource address to the script tag to load and execute the target resource file corresponding to the target resource address.
[0043] In this embodiment, to realize dynamic loading of resource files, after the web application obtains the target resource version number, the web application can generate the target resource address based on the target resource version number, create a script tag, and then add the target resource address to the script tag. In this way, when the browser parses the script tag, the browser will suspend the parsing of the HTML document according to the attributes of the script tag, and then obtain the corresponding target resource file from the storage cluster or edge server according to the target resource address, and finally load and execute the target resource file.
[0044] It should be noted that when the web application generates the target resource address based on the target resource version number, the generation rule it adopts is the same as the generation rule of the resource storage address, so as to ensure that for the target resource file, the target resource address generated by the web application is the same as the resource storage address of the target resource file, so that the cloud web application can directly download the target resource file from the storage cluster according to the target resource address. In actual applications, the resource storage address can be generated by the version distribution center or by the scheduling center of the storage cluster, and this application does not limit this.
[0045] For the target resource files stored in the storage cluster (i.e., the resource files called by the cloud web application), when the cloud web application generates the target resource address based on the target resource version number, it can adopt the following generation rule: https: / / xxxxxx / xxx-gis3d / v${version} / index.js, where version is the version field configured by asyncFileVersion of the cloud configuration center.
[0046] For the target resource file stored in the edge server (i.e., the resource file called by the edge web application), the edge server has converted the resource storage address of the target resource file into the edge resource address when updating the local cache data according to the version number information and resource library information fed back by the cloud configuration center, and the edge web application can use the version number to query the corresponding edge resource address. Therefore, when the edge web application receives the target resource version number fed back by the edge server, it can find the edge resource address corresponding to the target resource version number, and then download the target resource file from the edge server.
[0047] In an achievable implementation, if the web application is a cloud application, and the web application determines during runtime that the local cache has an initial resource version number, then the web application will generate a target resource address based on the initial resource version number. At this time, the target resource address generated by the web application based on the initial resource version number is the same as the resource storage address corresponding to the initial resource version number, so as to ensure that the target resource file downloaded by the web application from the storage cluster is the resource file corresponding to the initial resource version number.
[0048] Furthermore, if the web application is an edge application, and the web application determines that the initial resource version number is cached locally during operation, then after the web application receives the resource version number list fed back by the edge server, it can compare the initial resource version number with the version number information in the above resource version number list, and then determine whether there is version number information matching the initial resource version number in the edge server. If there is a version number in the resource version number list that is the same as the above initial resource version number, it means that there is version number information matching the initial resource version number in the edge server, and then the web application will generate a target resource address based on the above initial resource version number, wherein the target resource address generated by the web application is the same as the edge resource address corresponding to the initial resource version number, so as to ensure that the target resource file downloaded by the above web application from the edge server is the resource file corresponding to the initial resource version number.
[0049] If the resource version number list does not contain the same version number as the initial resource version number, it means that the edge server does not have the version number information that matches the initial resource version number, which means that the web application cannot download the corresponding resource file from the edge server. To prevent the system from failing to run due to the lack of necessary resource files, the web application can use the address of the locally stored initial resource file as the target resource address. In this way, when the web application runs, it can load and execute the initial resource file to ensure that the entire system can run stably. At this time, the initial resource file is the target resource file.
[0050] In an achievable implementation, creating a script tag and adding the target resource address in the script tag can be achieved in the following way: First, use the file asynchronous loader to dynamically create the script tag. Then, write the target resource address in the link attribute of the script tag, and output the script tag to the header metadata area of the web page source code file. Specifically, you can use requirejs or system.js to dynamically create a script tag, and then set the src attribute of the script tag to point to the URL of the target resource file (that is, the target resource address), and finally output the created script tag to the head part of the HTML (HyperText Markup Language) document to ensure that the target resource file has been loaded before the relevant JavaScript script is executed. For example, you can use script.src = 'https: / / xxxxxx / xxx-gis3d / v0.1.178 / index.js' to set the src attribute, and the final output effect is <script type="text javascript"crossorigin="anonymous"src="https: xxxxxx xxx-gis3d v0.1.178 index.js">< / script> .
[0051] S103: Mounting the application programming interface exposed after the target resource file is loaded into a global variable, and initializing the application programming interface through the attribute value in the global variable, so as to create a unique instance for external business call based on the initialized application programming interface.
[0052] In this implementation, when the target resource file is loaded, the exposed application programming interface can be mounted on the global variable to access the above application programming interface through the global variable. For example, if the attribute value of the application programming interface of the target resource file is ['@xxx / xxx-gis3d'], the above application programming interface can be accessed through window['@xxx / xxx-gis3d'], and its implementation code is as follows:
[0053] window['@xxx / xxx-gis3d'].xxxGIS
[0054] {}i
[0055] Application:(...)
[0056] TwinEntityTagEditorModeType:(...)
[0057] ViewerComponent:(...)
[0058] editControlsMode:(...)
[0059] utils:(...)
[0060] get Application:()=>Da
[0061] get TwinEntityTagEditorModeType:()=>y0
[0062] get ViewerComponent:()=>Ri
[0063] get editControlsMode:()=>iie
[0064] get utils:()=>rie
[0065] [[Prototype]]:Object
[0066] After accessing the API of the target resource file, the attribute values exposed on the global variables of the target resource file can be further obtained to complete the initialization of the API, and then create a unique instance for external business calls based on the initialized API. Specifically, the web application can access the attribute values of the API through window['@xxx / xxx-gis3d'], and then use the attribute values to perform initialization operations such as calling initialization methods, setting configuration options, and registering event listeners to complete the initialization of the API.
[0067] After the initialization of the application programming interface is completed, the web application can use the initialized application programming interface to create a unique instance in singleton mode, and export the created unique instance through the export keyword for external business calls. In this way, different external businesses can import and use the same SDK API singleton and use the functions it provides without having to repeatedly create a singleton object in each file.
[0068] It can be seen from this that the technical solution provided by the present application is that the cloud web application or the edge web application will first read the local configuration at runtime to determine whether there is an initial resource version number locally. If there is no initial resource version number, the web application will automatically send a version number access request to the cloud configuration center or the edge server according to its own cloud edge attributes, thereby obtaining the target resource version number fed back by the cloud configuration center or the edge server, and the target resource version number is mapped to the target resource file (such as a GIS 3D engine). When the web application receives the target resource version number, it can convert the target resource version number into the target resource address according to the cloud edge environment. After that, the web application can introduce the above-mentioned target resource address through a script tag and insert it into the head tag of the HTML page to complete the dynamic loading of the target resource file. When the target resource file is loaded, by mounting the exposed application programming interface to a global variable, the user can directly initialize the application programming interface in the browser window, thereby creating a unique instance for external business calls, and then completing the update deployment of the target resource file. The solution of the present application can realize the visualization operation of the update process by mounting the resource file on the window object. The user can intuitively view the resource version number of the current environment, as well as the source of the version number and other information. The update operation is simple and intuitive.
[0069] The present application also provides a file update system, which includes:
[0070] A web application module is used to determine whether an initial resource version number is cached locally. If the initial resource version number is not cached locally, the web application module sends a version number access request to a remote configuration center according to its own category to obtain a target resource version number fed back by the remote configuration center, wherein the categories include cloud applications and edge applications, and the remote configuration center includes a cloud configuration center and an edge server; a target resource address is generated based on the target resource version number, a script tag is created, and the target resource address is added to the script tag to load and execute a target resource file corresponding to the target resource address; an application programming interface exposed after the target resource file is loaded is mounted into a global variable, and the application programming interface is initialized through the attribute value in the global variable to create a unique instance for external business calls based on the initialized application programming interface;
[0071] The version issuing center is used to encapsulate the resource files corresponding to each version number according to the preset specification, and upload the encapsulated resource files to the storage cluster; record the resource storage address of each resource file in the storage cluster, and establish a mapping relationship between the resource storage address and the version number;
[0072] A storage cluster, used to store each of the resource files;
[0073] A cloud configuration center, configured to configure the version number information and resource library information corresponding to each resource file according to preset rules based on each resource file stored in the storage cluster, wherein the resource library information at least includes a resource storage address corresponding to the version number;
[0074] The edge server is used to update the local cache data according to the version number information and the resource library information fed back by the cloud configuration center, and convert the resource storage address into an edge resource address.
[0075] In one embodiment, the web application module sends a version number access request to the remote configuration center according to its own category to obtain the target resource version number fed back by the remote configuration center, including:
[0076] If the web application module is a cloud application, sending the version number access request to the cloud configuration center to obtain the target resource version number fed back by the cloud configuration center;
[0077] If the web application module is an edge application, the version number access request is sent to the edge server to obtain a resource version number list fed back by the edge server, and the target resource version number is selected from the resource version number list.
[0078] In one embodiment, if the web application module is a cloud application and an initial resource version number is cached locally, the target resource address is generated based on the initial resource version number, wherein the target resource address is the same as the resource storage address corresponding to the initial resource version number;
[0079] If the web application module is an edge application and the initial resource version number is cached locally, then based on the version number information fed back by the edge server, it is determined whether there is version number information matching the initial resource version number in the edge server; if so, the target resource address is generated based on the initial resource version number, wherein the target resource address is the same as the edge resource address corresponding to the initial resource version number; if not, the address of the locally stored initial resource file is used as the target resource address.
[0080] See also Figure 5 The present application also provides an electronic device, the electronic device includes a memory and a processor, the memory is used to store a computer program, when the computer program is executed by the processor, the file update method as described above can be implemented. Specifically, at the hardware level, the device may include a processor, an internal bus and a memory. The memory may include a memory and a non-volatile memory. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it. It can be understood by a person skilled in the art that Figure 5 The structure shown is only for illustration and does not limit the structure of the above device. Figure 5 More or fewer components shown in the figure may also include other processing hardware, such as a GPU (Graphics Processing Unit), or an external communication port, etc. Of course, in addition to the software implementation, this application does not exclude other implementations, such as logic devices or a combination of software and hardware, etc.
[0081] In this embodiment, the processor may include a central processing unit (CPU) or a graphics processing unit (GPU), and of course may also include other single-chip microcomputers, logic gate circuits, integrated circuits, etc. with logic processing capabilities, or appropriate combinations thereof. The memory described in this embodiment may be a memory device for storing information. In a digital system, a device that can store binary data may be a memory; in an integrated circuit, a circuit with a storage function without a physical form may also be a memory, such as a RAM, a FIFO, etc.; in a system, a storage device with a physical form may also be called a memory, etc. When implemented, the memory may also be implemented in the form of a cloud storage, and the specific implementation method is not limited in this specification.
[0082] It should be noted that the specific implementation of the electronic device in this specification can refer to the description of the method implementation method, and will not be described in detail here.
[0083] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the file updating method as described above can be implemented.
[0084] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0085] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A file updating method, characterized in that: The method comprises: Determine whether the initial resource version number is cached locally. If the initial resource version number is not cached locally, the web application sends a version number access request to the remote configuration center according to its own category to obtain the target resource version number fed back by the remote configuration center, wherein the categories include cloud applications and edge applications, and the remote configuration center includes a cloud configuration center and an edge server; Generate a target resource address based on the target resource version number, create a script tag, and add the target resource address to the script tag to load and execute the target resource file corresponding to the target resource address; The application programming interface exposed after the target resource file is loaded is mounted into a global variable, and the application programming interface is initialized by the attribute value in the global variable, so as to create a unique instance for external business call based on the initialized application programming interface.
2. The method according to claim 1, characterized in that Before determining whether the initial resource version number is cached locally, the method further includes: Encapsulate the resource files corresponding to each version number according to the preset specification, and upload the encapsulated resource files to the storage cluster; The resource storage address of each resource file in the storage cluster is recorded, and a mapping relationship between the resource storage address and the version number is established.
3. The method according to claim 2, characterized in that After establishing the mapping relationship between the resource storage address and the version number, the method further includes: Based on each of the resource files stored in the storage cluster, the cloud configuration center configures the version number information and resource library information corresponding to each of the resource files according to a preset rule, wherein the resource library information at least includes a resource storage address corresponding to the version number; The edge server updates the local cache data according to the version number information and the resource library information fed back by the cloud configuration center, and converts the resource storage address into an edge resource address.
4. The method according to claim 3, characterized in that The web application sends a version number access request to the remote configuration center according to its own category to obtain the target resource version number fed back by the remote configuration center, including: If the web application is a cloud application, sending the version number access request to the cloud configuration center to obtain the target resource version number fed back by the cloud configuration center; If the web application is an edge application, the version number access request is sent to the edge server to obtain a resource version number list fed back by the edge server, and the target resource version number is selected from the resource version number list.
5. The method according to claim 4, characterized in that If the web application is a cloud application and the local cache has an initial resource version number, the method includes: The target resource address is generated based on the initial resource version number, wherein the target resource address is the same as the resource storage address corresponding to the initial resource version number.
6. The method according to claim 4, characterized in that If the web application is an edge application and the initial resource version number is cached locally, the method includes: According to the version number information fed back by the edge server, determine whether there is version number information matching the initial resource version number in the edge server, and if so, generate the target resource address based on the initial resource version number, wherein the target resource address is the same as the edge resource address corresponding to the initial resource version number; If it does not exist, the address of the initial resource file stored locally is used as the target resource address.
7. The method according to claim 5 or 6, characterized in that: Creating a script tag and adding the target resource address in the script tag includes: Dynamically create said script tag using a file async loader; The target resource address is written into the link attribute of the script tag, and the script tag is output to the header metadata area of the web page source code file.
8. The method according to claim 7, characterized in that Initializing the application programming interface by using the attribute value in the global variable to create a unique instance for external service call based on the initialized application programming interface includes: Acquire the property value exposed by the target resource file on the global variable to complete the initialization of the application programming interface; The initialized application programming interface is used to create a unique instance in singleton mode, and the unique instance is exported through the export keyword for external business calls.
9. A file updating system, characterized in that: The file updating system comprises: A web application module is used to determine whether an initial resource version number is cached locally. If the initial resource version number is not cached locally, the web application module sends a version number access request to a remote configuration center according to its own category to obtain a target resource version number fed back by the remote configuration center, wherein the categories include cloud applications and edge applications, and the remote configuration center includes a cloud configuration center and an edge server; a target resource address is generated based on the target resource version number, a script tag is created, and the target resource address is added to the script tag to load and execute a target resource file corresponding to the target resource address; an application programming interface exposed after the target resource file is loaded is mounted into a global variable, and the application programming interface is initialized through the attribute value in the global variable to create a unique instance for external business calls based on the initialized application programming interface; The version issuing center is used to encapsulate the resource files corresponding to each version number according to the preset specification, and upload the encapsulated resource files to the storage cluster; record the resource storage address of each resource file in the storage cluster, and establish a mapping relationship between the resource storage address and the version number; A storage cluster, used to store each of the resource files; A cloud configuration center, configured to configure the version number information and resource library information corresponding to each resource file according to preset rules based on each resource file stored in the storage cluster, wherein the resource library information at least includes a resource storage address corresponding to the version number; The edge server is used to update the local cache data according to the version number information and the resource library information fed back by the cloud configuration center, and convert the resource storage address into an edge resource address.
10. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 8 is implemented.
