Method, system and device for synchronously updating multiple views, electronic equipment and medium
By listening to the cache database and updating other path information, the data update problem caused by deletion operations in the file system is solved, and data synchronization updates between multiple views and consistency between views and data is achieved.
Patent Information
- Application Number
- CN202411760929.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, when a user deletes directly in the file system or deletes through a terminal, the data will be completely unable to be updated, resulting in inconsistency between the data and interaction.
By listening to the cache database, the path information of the data rendered by each view is stored. When the update operation of the target path information is detected, other path information in the cache database is updated, and the view is re-rendered based on the updated path information.
After deletion operation in the file system, data is updated synchronously between multiple views, so that the rendered view is consistent with the data, avoiding inconsistency between data and interaction.
Smart Images

Figure CN119760016A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, system, apparatus, electronic device, and medium for synchronous updating of multiple views. Background Technology
[0002] In existing integrated development environments, there are often multi-instance application scenarios, meaning multiple instances exist simultaneously. In this model, ensuring the real-time data consistency between different views will result in a more user-friendly and convenient user experience.
[0003] Taking the integrated development environment VS Code as an example, it has the feature of multiple instances, which can open multiple instances at the same time to edit projects or files. All of these data will be saved in the history list data and presented to the user in the form of a list. However, when a file is deleted directly outside of VS Code, the view will not be able to update the data, and a restart is required to refresh the data.
[0004] The above methods, when users delete directly in the file system or through the terminal, will cause the data to be completely unupdable, resulting in inconsistency between the data and the interaction. Summary of the Invention
[0005] This application provides a method, system, apparatus, electronic device, and medium for multi-view synchronous updates to solve the problem in the prior art where data cannot be updated at all when a user deletes directly in the file system or through a terminal, resulting in inconsistency between data and interaction.
[0006] In a first aspect, embodiments of this application provide a method for simultaneous updating of multiple views, including:
[0007] Monitor the cache database, which stores the path information of the data rendered by each view;
[0008] Upon detecting an update operation of the target path information, the other path information in the cache database is updated according to the update operation; the target path information is at least one of the path information, and the other path information is the path information in the cache database other than the target path information;
[0009] The view is re-rendered based on the updated path information from the cached database.
[0010] Optionally, the update operation of the detected target path information includes:
[0011] The system listens for update information sent by the file system to the cache database and updates the target path information accordingly.
[0012] Optionally, re-rendering the view based on the updated path information in the cache database includes:
[0013] Reread the updated data corresponding to the updated path information, and render the view according to the updated data.
[0014] Optionally, before the listening cache database, it also includes:
[0015] Determine if the cache database exists:
[0016] If it exists, send the path information from the cache database to the cache listener and the view;
[0017] If it does not exist, call the initialization interface to create the cache database.
[0018] Secondly, embodiments of this application provide a system for synchronous updating of multiple views, including: a cache database, views, and a cache listener;
[0019] The cache database is used to store the path information of the data rendered by each view, and to update the path information when the files in the file system are updated.
[0020] The cache listener is used to monitor the update operations of the path information in the cache database;
[0021] The cache database is further configured to update other path information in the cache database according to the update operation; the target path information is at least one of the path information, and the other path information is path information in the cache database other than the target path information;
[0022] The view is used to re-render based on the path information of the updated cache database.
[0023] Optionally, each of the views can be configured with a cache listener.
[0024] Optionally, the cache listener listens for path information corresponding to a preset number of recently rendered views.
[0025] Thirdly, embodiments of this application provide a multi-view synchronous update apparatus, comprising:
[0026] The listening module is used to listen to the cache database, which stores the path information of the data rendered by each view;
[0027] An update module is used to update other path information in the cache database according to the update operation when an update operation of target path information is detected; the target path information is at least one of the path information, and the other path information is path information in the cache database other than the target path information;
[0028] The rendering module is used to re-render the view based on the path information in the updated cache database.
[0029] Fourthly, embodiments of this application provide an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0030] The memory is used to store computer programs;
[0031] The processor is configured to execute the program stored in the memory to implement the multi-view synchronous update method described in the first aspect.
[0032] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the multi-view synchronous update method described in the first aspect.
[0033] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application monitors a cache database, which stores path information of the data rendered by each view; when an update operation of the target path information is detected, other path information in the cache database is updated according to the update operation; the target path information is at least one of the path information, and the other path information is the path information in the cache database other than the target path information; the view is re-rendered according to the updated path information in the cache database. Thus, by setting the path information of the data rendered by each view in the cache database, when any path information in the cache database is updated, other path information is updated, achieving synchronous refresh of all path information, making the rendered view consistent with the data. Attached Figure Description
[0034] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 A structural diagram of a system for synchronous updating of multiple views provided in an embodiment of this application;
[0037] Figure 2 A flowchart illustrating a method for synchronous updating of multiple views according to an embodiment of this application;
[0038] Figure 3 A flowchart illustrating a method for synchronous updating of multiple views according to another embodiment of this application;
[0039] Figure 4 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0041] This application provides a system for synchronous updating of multiple views, such as... Figure 1 As shown, the system mainly includes: a cache database, views, and cache listeners;
[0042] The cache database is used to store the path information of the data rendered by each view, and to update the path information when the files in the file system are updated.
[0043] The cache listener is used to monitor the update operations of the path information in the cache database;
[0044] The cache database is further configured to update other path information in the cache database according to the update operation; the target path information is at least one of the path information, and the other path information is path information in the cache database other than the target path information;
[0045] The view is used to re-render based on the path information of the updated cache database.
[0046] The multi-view synchronous update system of this application can be applied as a plugin to the VS Code integrated development environment. VS Code uses Node as its runtime environment, so the plugin running within it also uses Node as one of its basic runtime environments. Therefore, the technology stack used in this invention is implemented using TypeScript. Since VS Code has the feature of multiple view instance windows, the plugin also inherits this feature. The plugin mainly includes a cache database, a cache listener, and a view... Figure 3 Each component. After the plugin is activated, it first checks if a cache database exists. If not, it initializes the cache database to create a blank cache database for subsequent data storage.
[0047] After a view is rendered, it is displayed through a window to enable interaction with the user. If there are multiple views, there will be multiple instance windows.
[0048] The aforementioned view, cache database, and cache listener can communicate with each other through API calls or asynchronous message sending and receiving.
[0049] In an optional embodiment, the cache listener can monitor changes in multiple data simultaneously, for example, it can choose to monitor the path information corresponding to a preset number of recently rendered views.
[0050] The preset quantity can be set based on the actual situation; for example, it can be, but is not limited to, 10 items.
[0051] To ensure data consistency across multiple instance windows, all instances will share a cache database, which mainly records information such as the path of historical files opened through plugins. Each window is a separate running instance, and the threads between windows are independent of each other. Therefore, each window will have a view and a cache listener.
[0052] When a new window is created, a view and a cache listener are registered simultaneously. Both the cache listener and the view call an API to obtain initialization data. This initialization data provides the initial rendering data for the view and the initial listening data required by the cache listener. The cache listener monitors for file renaming, deletion, and modification events in the file system. When these events are detected, the view is refreshed. If the system determines that a file path does not exist in the cache database, it will automatically filter the data to ensure that all data interacted with in the view correctly maps to the content existing in the file system.
[0053] The above solution ensures that, in scenarios with multiple window instances, the historical project data displayed in multiple windows remains consistent, as does the association with the file system.
[0054] Based on the same concept, one embodiment of this application provides a method for simultaneous updating of multiple views. Specific implementation details of this method can be found in the description of the system embodiments section; repeated details will not be elaborated upon. This method can be applied to any type of electronic device, such as terminals and servers. Figure 2 As shown, the method for synchronous updating of multiple views includes:
[0055] Step 201: Listen to the cache database, which stores the path information of the data rendered by each view.
[0056] In some embodiments, the cache database is used to store path information of the rendered data of all views. When a new view is added, its corresponding path information is stored in the cache database.
[0057] One way to monitor the cache database is by setting a cache listener. Changes to the data in the cache database will be detected by the cache listener.
[0058] In one alternative embodiment, before monitoring the cache database, the following is also included:
[0059] Determine if the cache database exists:
[0060] If it exists, send the path information from the cache database to the cache listener and the view;
[0061] If it does not exist, call the initialization interface to create the cache database.
[0062] In some embodiments, after the plugin is activated, it is first determined whether a cache database exists. If no cache database exists, the initialization interface needs to be called to create the cache database, thus establishing a blank cache database for subsequent data storage. If a cache database exists, the data in it can be read and forwarded to the view and cache listener. This allows the cache listener to monitor changes in the data in the cache database, and the view to retrieve the corresponding data according to the path information in the cache database for rendering, thereby enabling interaction with the user.
[0063] Step 202: Upon detecting an update operation of the target path information, update the other path information in the cache database according to the update operation; the target path information is at least one of the path information, and the other path information is the path information in the cache database other than the target path information;
[0064] In some embodiments, if a user performs update operations such as deletion, modification, or renaming on a file in the file system, even if the file's path information is updated, the file system will synchronize the corresponding update operation to the cache database. This allows the cache listener to detect the update operation and then synchronize and update other path information based on the update operation, thereby achieving the goal of timely updating the view.
[0065] In an optional embodiment, detecting an update operation of the target path information includes:
[0066] The system listens for update information sent by the file system to the cache database and updates the target path information accordingly.
[0067] In some embodiments, after an update operation occurs in the file system, the update operation is synchronized to the cache database. Based on this, when an update operation occurs in the file system, the corresponding update information is sent to the cache database, causing the cache database to update the target path information according to the update information. The update information may include deletion, modification, or renaming of the target path information.
[0068] Step 203: Re-render the view based on the updated path information in the cache database.
[0069] In some embodiments, after an update operation is detected and a synchronous update is completed, the view is re-rendered according to the updated data, so that the view can be updated without restarting.
[0070] In an optional embodiment, re-rendering the view based on the updated path information in the cached database includes:
[0071] Reread the updated data corresponding to the updated path information, and render the view according to the updated data.
[0072] In some embodiments, changes in path information can cause inconsistencies between the data rendered by the view and the data corresponding to the actual path information. Therefore, after the path information in the cache database is updated, the view can be re-rendered according to the updated data corresponding to the updated path information to achieve real-time updates of the view.
[0073] In one specific embodiment, the method for multi-view synchronous update of this application is described in [reference needed]. Figure 3 The specific process includes:
[0074] First, activate the plugin;
[0075] Second, the plugin checks if the cache database exists; if it exists, it proceeds to step four; otherwise, it proceeds to step three.
[0076] Third, initialize the cache database;
[0077] Fourth, read cached data;
[0078] Fifth, forward the cached data to the view and listeners, and execute the rendering of view data and the listening of cached data in parallel;
[0079] Sixth, the listener will monitor whether the cached data changes. When a change in the cached data is detected, step seven will be executed.
[0080] Seventh, perform a cache refresh operation, and re-execute step four to read cached data and refresh the view and cache listener.
[0081] By performing the above operations in each window, workspace data synchronization can be achieved between multiple views. Even if the user directly manipulates the file system, the listener will refresh the view, ultimately achieving the effect of workspace data synchronization and updating.
[0082] Based on the same concept, this application provides a device for multi-view synchronous updating. The specific implementation of this device can be found in the description of the method embodiments section, and will not be repeated here. The device mainly includes:
[0083] The listening module is used to listen to the cache database, which stores the path information of the data rendered by each view;
[0084] An update module is used to update other path information in the cache database according to the update operation when an update operation of target path information is detected; the target path information is at least one of the path information, and the other path information is path information in the cache database other than the target path information;
[0085] The rendering module is used to re-render the view based on the path information in the updated cache database.
[0086] Based on the same concept, this application also provides an electronic device, such as... Figure 4 As shown, the electronic device mainly includes a processor 401, a memory 402, and a communication bus 403. The processor 401 and the memory 402 communicate with each other via the communication bus 403. The memory 402 stores programs that can be executed by the processor 401. The processor 401 executes the programs stored in the memory 402 to achieve the following steps:
[0087] Monitor the cache database, which stores the path information of the data rendered by each view;
[0088] Upon detecting an update operation of the target path information, the other path information in the cache database is updated according to the update operation; the target path information is at least one of the path information, and the other path information is the path information in the cache database other than the target path information;
[0089] The view is re-rendered based on the updated path information from the cached database.
[0090] The communication bus 403 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 403 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0091] The memory 402 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor 401.
[0092] The processor 401 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., or a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0093] In another embodiment of this application, a computer-readable storage medium is provided, which stores a computer program that, when run on a computer, causes the computer to perform the multi-view synchronous update method described in the above embodiments.
[0094] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape, etc.), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0095] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0096] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for synchronously updating multiple views, characterized in that: include: Monitor a cache database, where the cache database stores path information of data rendered by each view; When an update operation of the target path information is monitored, updating other path information in the cache database according to the update operation; The target path information is at least one of the path information, and the other path information is the path information in the cache database except the target path information; The view is re-rendered according to the updated path information of the cache database.
2. The method for synchronously updating multiple views according to claim 1, characterized in that: The update operation of the monitored target path information includes: The cache database is monitored to obtain update information sent by the file system, and the target path information is updated according to the update information.
3. The method for synchronously updating multiple views according to claim 1, characterized in that: The re-rendering of the view according to the updated path information of the cache database includes: Re-read the updated data corresponding to the updated path information, and render the view according to the updated data.
4. The method for synchronously updating multiple views according to claim 1, characterized in that: Before monitoring the cache database, the method further includes: Determine whether the cache database exists: If so, sending the path information in the cache database to the cache listener and the view; If it does not exist, call the initialization interface to create the cache database.
5. A system for synchronously updating multiple views, characterized in that: include: Cache database, views and cache listeners; The cache database is used to store the path information of the data rendered by each view, and update the path information when the file in the file system is updated; The cache listener is used to monitor the update operation of the path information in the cache database; The cache database is further used to update other path information in the cache database according to the update operation; the target path information is at least one of the path information, and the other path information is the path information in the cache database except the target path information; The view is used to re-render according to the updated path information of the cache database.
6. The system for synchronously updating multiple views according to claim 5, characterized in that: Each of the views is configured with a cache listener.
7. The system for synchronously updating multiple views according to claim 5, characterized in that: The cache listener listens to the path information corresponding to the preset number of views rendered most recently.
8. A device for synchronously updating multiple views, characterized in that: include: A monitoring module, used to monitor a cache database, wherein the cache database stores path information of data rendered by each view; An updating module, configured to update other path information in the cache database according to the updating operation when an updating operation of the target path information is detected; The target path information is at least one of the path information, and the other path information is the path information in the cache database except the target path information; The rendering module is used to re-render the view according to the updated path information of the cache database.
9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to execute the program stored in the memory to implement the multi-view synchronous updating method according to any one of claims 1 to 4.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for synchronously updating multiple views according to any one of claims 1 to 4 is implemented.