Routing file updating method and device, computer equipment and storage medium
By scanning and listening to the local file system, obtaining routing path changes and generating routing tree objects, the problem of low efficiency in routing file updates in the existing technology is solved, and the effect of efficient update and automatic generation of routing tree objects is achieved.
Patent Information
- Application Number
- CN202411731863.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, real-time update of routing files is not supported, and the routing tree object cannot be automatically generated when updating the routing file. Usually, it is necessary to manually name the route name and then generate the routing tree object, resulting in inefficient updates.
By scanning and listening to the local file system, we obtain the target file directory and target file path array with changes in the routing path, generate the target routing tree object based on the array, and update the routing file of the local file system.
It realizes efficient update of routing files, automatically generates routing tree objects without manual naming, saves human and material resources, and improves the efficiency of routing file updates.
Smart Images

Figure CN119645936A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a routing file updating method, device, computer equipment and storage medium. Background Art
[0002] With the development of computer technology, local file systems can perform automated routing to meet the needs of opening, switching and jumping pages of computer devices. Since local files in the local file system may be added or deleted, the routing path of the local files may change. At this time, it is necessary to update the routing file in the local file system accordingly. The updated routing file can record the changes in the routing path of the local files in the local file system so that the automated routing can proceed smoothly. However, the prior art generally does not support real-time updating of routing files, and the prior art cannot automatically generate routing tree objects when updating routing files. It is usually necessary to manually name the routing names that constitute the routing tree objects before generating the routing tree objects, which is time-consuming and labor-intensive, and reduces the updating efficiency of the routing files.
[0003] Therefore, how to efficiently update routing files is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present invention provide a routing file updating method, device, computer equipment and storage medium to solve the problem of how to update the routing file efficiently.
[0005] A routing file updating method, comprising: Scanning the local file system to determine at least one local file directory corresponding to the local file system; Monitor all the local file directories to obtain the target file directories with routing path changes and the target file path arrays corresponding to the target file directories; Generate a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory; Based on the target routing tree object corresponding to the target file directory, the routing file of the local file system is updated.
[0006] Preferably, monitoring all the local file directories to obtain the target file directories with routing path changes and the target file path arrays corresponding to the target file directories include: Monitor all the local file directories to obtain the target file directory with routing path changes and the original file path array corresponding to the target file directory; The original file path array corresponding to the target file directory is cleaned to obtain the target file path array corresponding to the target file directory.
[0007] Preferably, monitoring all the local file directories to obtain the target file directory with routing path changes and the original file path array corresponding to the target file directory includes: Monitor the file status of all the local file directories to determine the file status of each local file in the local file directory; If the file status corresponding to the local file in the local file directory is in a changed state, the local file directory corresponding to the local file is determined as the target file directory.
[0008] Preferably, the cleaning of the original file path array corresponding to the target file directory to obtain the target file path array corresponding to the target file directory includes: Classifying the original file path array corresponding to the target file directory to determine an initial index file path array and an initial non-index file path array; According to the file path lengths of the initial non-index file paths in the initial non-index file path array, the initial non-index file paths are sorted to obtain a target non-index file path array; The target non-index file path array is concatenated with the initial index file path array to obtain a target file path array corresponding to the target file directory.
[0009] Preferably, generating a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory includes: According to the target file path array corresponding to the target file directory, obtain the file name and file extension corresponding to the target file directory; A target routing tree object corresponding to the target file directory is generated according to the target file directory and the file name and file extension corresponding to the target file directory.
[0010] Preferably, generating a target routing tree object corresponding to the target file directory according to the target file directory and the file name and file extension corresponding to the target file directory includes: According to the file extension corresponding to the target file directory, the file name corresponding to the target file directory is concatenated to obtain the routing path and routing name corresponding to the target file directory; Read the index file in the target file directory to obtain target metadata; The routing path, the routing name and the target metadata are concatenated to generate a target routing tree object corresponding to the target file directory.
[0011] Preferably, after generating the target routing tree object corresponding to the target file directory, the routing file updating method further includes: Obtain the current number of the target routing tree objects; If the current number reaches a preset number threshold, executing the target routing tree object corresponding to the target file directory to update the routing file of the local file system; If the current number does not reach the preset number threshold, the scanning of the local file system is repeated to determine at least one local file directory corresponding to the local file system.
[0012] A routing file updating device, comprising: A local file system scanning module, used to scan the local file system and determine at least one local file directory corresponding to the local file system; A local file directory monitoring module is used to monitor all the local file directories, obtain the target file directory with routing path changes and the target file path array corresponding to the target file directory; A target routing tree object generation module, used to generate a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory; The routing file updating module updates the routing file of the local file system based on the target routing tree object corresponding to the target file directory.
[0013] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned routing file updating method when executing the computer program.
[0014] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the routing file updating method is implemented.
[0015] The above-mentioned routing file updating method, device, computer equipment and storage medium monitor all local file directories, obtain the target file directory with routing path changes, and determine the target file path array corresponding to the target file directory, which can determine the target file directory with routing changes and the target file path array corresponding to all target file directories in real time, which is relatively efficient, and is convenient for the subsequent real-time generation of the target routing tree object corresponding to the target file directory according to the target file path array, which can improve the generation efficiency of the target routing tree object. According to the target file path array corresponding to the target file directory, the purpose of automatically generating the target routing tree object corresponding to the target file directory can be achieved, without the need to manually name the target routing tree object, which not only saves manpower and material resources, but also can generate the target routing tree object more efficiently, which is convenient for the subsequent update of the routing file of the local file system based on the target routing tree object corresponding to the target file directory, and improves the update efficiency of the routing file. Finally, the target routing tree object corresponding to the target file directory is written into the routing file in the local file system, which can achieve the purpose of more efficiently updating the routing file of the local file system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0017] Figure 1 is a flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 2 is another flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 3 is another flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 4 is another flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 5 is another flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 6 is another flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 7 is another flow chart of a method for updating a routing file in one embodiment of the present invention; Figure 8 is a schematic diagram of a routing file updating device in one embodiment of the present invention; Fig. 9is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] The routing file updating method provided by the embodiment of the present invention is used to achieve the purpose of efficiently updating the routing file. The routing file updating method provided by the embodiment of the present invention runs independently in the form of a plug-in, does not invade the code, can achieve code reuse, and save development resources.
[0020] In one embodiment, if Figure 1 As shown, a routing file update method is provided, which is applied in Fig. 9 The computer device is taken as an example to illustrate, including the following steps: S101: Scan the local file system to determine at least one local file directory corresponding to the local file system; S102: Monitor all local file directories to obtain target file directories with routing path changes and target file path arrays corresponding to the target file directories; S103: Generate a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory; S104: Based on the target routing tree object corresponding to the target file directory, update the routing file of the local file system.
[0021] Among them, the local file system refers to a system for storing local files, which is used to help computer devices implement dynamic routing. The local file directory refers to the directory corresponding to the local files stored in the local file system, and the directory is related to its storage path. As an example, the local file system can be nested for storage, so each local file corresponds to a directory, which is the local file directory corresponding to the local file. For example, for the local file demo2.vue, if the local file demo2.vue is stored in the directory m1, the local file directory corresponding to the local file demo2.vue is m1 / demo2.vue, and if the local file demo2.vue is stored in the directory m1 / a, the local file directory corresponding to the local file demo2.vue is m1 / a / demo2.vue.
[0022] Among them, local files refer to files stored in the local file system, including routing files and ordinary files. Routing files refer to files that store routing paths corresponding to ordinary files, and are used to implement dynamic routing of ordinary files through pointers. Routing paths refer to paths for routing ordinary files determined based on local file directories. Ordinary files refer to functional files used to help computer devices implement specific functions. For example, ordinary files include functional files that help computer devices implement functions such as opening, jumping, and deleting pages. Understandably, each local file system is equipped with a routing file and several functional ordinary files. The routing file stores the paths of all functional ordinary files, and is used to point to functional ordinary files through pointers to implement dynamic routing, helping computer devices implement functions such as opening, jumping, and deleting pages.
[0023] As an example, in step S101, the computer device performs a real-time scan on the local file system to determine the local file directories corresponding to all local files in the local file system. For example, the computer device performs a real-time scan on the local file system and obtains a local file demo1.vue. The local file is in the first-level directory m1 and under the second-level directory a. The local file directory corresponding to the local file demo1.vue is / m1 / a / demo1.vue; for example, another local file is index.vue, and the local file is under the first-level directory m2. The local file directory corresponding to the local file index.vue is / m2 / index.vue; for another example, another local file demo2.vue is directly used as the first-level directory, and the local file directory corresponding to the local file demo2.vue is / demo2.vue. Determine the local file directory corresponding to each local file in the local file system in the above manner. Among them, the first-level directory is the highest-level directory in the local file system. The second-level directory is a subdirectory of the first-level directory. Understandably, each local file system includes several first-level directories, each first-level directory includes several second-level directories, and so on, the local file system may include multiple levels of directories. In this example, the local file system is scanned to determine at least one local file directory corresponding to the local file system, so that subsequent monitoring of the local file directory is feasible.
[0024] The routing path change refers to the situation where the routing path corresponding to the local file changes. For example, if the local file is deleted, added and / or renamed, the local file directory will change, and then the routing path will change. Specifically, it may be that the ordinary files in the local file are deleted, added and / or renamed, resulting in the change of the local file directory corresponding to the ordinary files, and then the routing path changes.
[0025] The target file directory refers to the local file directory after the routing path changes. The file corresponding to the target file directory is the target file. The target file is the local file whose routing path changes. The target file path array refers to the array of routing paths corresponding to the target files determined according to all target file directories in the local file system.
[0026] As an example, in step S102, the computer device monitors the local file directory corresponding to each local file in real time, determines the local file directory with routing path changes, uses the local file directory with routing path changes as the target file directory, uses the local file with routing path changes as the target file, and determines the target file path array according to the target file directory. In this example, the computer device performs splicing and combination processing on all target file directories to obtain the target file path array. In this example, all local file directories are monitored to obtain the target file directory with routing path changes, and the target file path array corresponding to the target file directory is determined. This method can determine the target file directory with routing changes and the target file path array corresponding to all target file directories in real time, which is more efficient and convenient for the subsequent real-time generation of the target routing tree object corresponding to the target file directory according to the target file path array, and can improve the generation efficiency of the target routing tree object.
[0027] The target routing tree object refers to the tree structure corresponding to the target file directory generated according to the target file path array. It can be understood that by processing the routing path corresponding to each target file in the target file path array, the routing tree object corresponding to each target file can be obtained, and the routing tree object is the target routing tree object corresponding to the target file.
[0028] As an example, in step S103, after obtaining the target file path array corresponding to the target file directory, the computer device processes the routing path corresponding to each target file directory in the target file path array to generate a target routing tree object corresponding to each target file directory. In this example, the computer device splices the routing path corresponding to each target file directory to obtain the target routing tree object corresponding to each target file directory. In this example, according to the target file path array corresponding to the target file directory, the purpose of automatically generating the target routing tree object corresponding to the target file directory can be achieved, without manually naming the target routing tree object, which not only saves manpower and material resources, but also can generate the target routing tree object more efficiently, which is convenient for the subsequent update of the routing file of the local file system based on the target routing tree object corresponding to the target file directory. Efficiency, improve the update efficiency of the routing file.
[0029] As an example, in step S104, after obtaining the target routing tree object corresponding to each target file directory, the computer device writes the target routing tree object corresponding to each target file directory into the corresponding position in the routing file of the local file system, and completes the updating of the routing file in the local file system. In this example, the computer device establishes the route.js file as the routing file, converts the target routing tree object corresponding to each target file directory into the corresponding string form, obtains the target routing tree object converted into the string form, and outputs the target routing tree object converted into the string form into the route.js file to implement the updating of the routing file. In this example, directly writing the target routing tree object corresponding to the target file directory into the routing file in the local file system can achieve the purpose of more efficiently updating the routing file of the local file system.
[0030] In this embodiment, all local file directories are monitored, the target file directories with routing path changes are obtained, and the target file path array corresponding to the target file directory is determined. The target file directory with routing changes and the target file path array corresponding to all target file directories can be determined in real time, which is relatively efficient. It is convenient for the subsequent real-time generation of the target routing tree object corresponding to the target file directory according to the target file path array, and the generation efficiency of the target routing tree object can be improved. According to the target file path array corresponding to the target file directory, the purpose of automatically generating the target routing tree object corresponding to the target file directory can be achieved, and there is no need to manually name the target routing tree object, which not only saves manpower and material resources, but also can generate the target routing tree object more efficiently, which is convenient for the subsequent update of the routing file of the local file system based on the target routing tree object corresponding to the target file directory. Improve the update efficiency of the routing file. Finally, the target routing tree object corresponding to the target file directory is written into the routing file in the local file system, which can achieve the purpose of more efficiently updating the routing file of the local file system.
[0031] In one embodiment, if Figure 2 As shown, step S102, i.e. monitoring all local file directories, obtaining the target file directory with routing path changes and the target file path array corresponding to the target file directory, includes: S201: Monitor all local file directories to obtain the target file directory with routing path changes and the original file path array corresponding to the target file directory; S202: Clean the original file path array corresponding to the target file directory to obtain the target file path array corresponding to the target file directory.
[0032] The original file path array refers to an array obtained by directly concatenating the routing paths corresponding to each target file directory.
[0033] As an example, in step S201, the computer device monitors the local file directory in the local file system in real time, determines the local file directory with the routing path change, and determines the local file directory with the routing path change as the target file directory. Understandably, the file corresponding to the target file directory is the target file. When dynamic routing is performed through the routing file, the target file directory is usually used as the routing path to route the target file. This method does not require a complex routing method and is more convenient and quick.
[0034] For example, if the local file directory corresponding to the local file changes from / m1 / a / demo1.vue to / m1 / a, it indicates that the local file has been deleted and the routing path of the local file directory has changed; for example, if the local file directory changes from / m1 / a / demo2.vue to / m1 / a / demo3.vue, it indicates that the local file has been renamed and the routing path of the local file directory has changed; for another example, if the local file directory changes from / m2 / demo4.vue to / m2 / demo4.vue and / m2 / demo5.vue, it indicates that the local file has been added and the routing path of the local file directory has changed. The computer device determines the local file directory after the above routing path change as the target file directory, and splices the above target file directories to obtain the original file path array. Among them, each target file directory is used as the routing path of the target file, so the original file path array includes the routing path of each target file.
[0035] In this example, if the local file system has the above-mentioned local file deletion, renaming and addition, the target file directory after the routing path change and the index file corresponding to each target file directory (that is, the file with the underlying file name index.vue) are spliced. For example, if the first-level directory is m1, the index file corresponding to the target file directory with the first-level directory m1 is / m1 / index.vue. If the first-level directory is m1, the index file corresponding to the target file directory with the first-level directory m1 is / m2 / index.vue. The target file directory and the index file corresponding to each target file directory are spliced to obtain the original file path array corresponding to the target file directory: [' / m1 / a', ' / m1 / a / demo3.vue', ' / m1 / index.vue', ' / m2 / demo5.vue', ' / m2 / index.vue']. Among them, each first-level directory corresponding to the target file directory corresponds to an index file, which is used to store the target file directory under the first-level directory. In this example, by monitoring all local file directories, the target file directory with routing path changes and the original file path array corresponding to the target file directory can be obtained in real time, so that the subsequent generation of the target file path array is real-time, more efficient and convenient.
[0036] As an example, in step S202, after obtaining the original file path array corresponding to each target file directory, the computer device cleans the original file path array according to the preset cleaning rule to obtain the target file path array corresponding to the target file directory. In this example, the preset cleaning rule can be to sort the target file directories in the original file path array according to the length of the routing path corresponding to the target file directory to obtain the target file path array. In this example, the original file path array is cleaned to obtain the target file path array, so that it is feasible to generate the target routing tree object according to the target file path array later.
[0037] In this embodiment, all local file directories are monitored, and the target file directory with routing path changes and the original file path array corresponding to the target file directory can be obtained in real time, so that the subsequent generation of the target file path array is real-time, more efficient and convenient. The original file path array is cleaned to obtain the target file path array, so that the subsequent generation of the target routing tree object according to the target file path array is practical.
[0038] In one embodiment, if Figure 3 As shown, step S201, i.e. monitoring all local file directories, obtaining the target file directory with routing path changes and the original file path array corresponding to the target file directory, includes: S301: monitoring the file status of all local file directories to determine the file status of each local file in the local file directory; S302: If the file status of a local file corresponding to a local file in the local file directory is in a changed status, the local file directory corresponding to the local file is determined as the target file directory.
[0039] Among them, the file status refers to the status of whether the local file corresponding to the local file directory has changed. The file status includes the unchanged state and the changed state of the local file. It can be understood that if there is no file change such as deletion, addition and / or renaming of the local file, the file status of the local file is unchanged. If there is a file change such as deletion, addition and / or renaming of the local file, the file status of the local file is a changed state.
[0040] As an example, in step S301, the computer device monitors the file status of all local file directories to determine the file status of each local file in the local file directory. In this example, the computer device monitors the file status of the local files corresponding to each local file directory to determine whether there are file changes such as deletion, addition and / or renaming of the local files. If there are local files that have the above file changes, the local file status is determined to be a changed state. In this example, the file status of all local file directories is monitored to determine the file status of each local file, so that the target file directory can be determined in real time according to the file status of the local files.
[0041] As an example, in step S302, when the computer device determines that the file status corresponding to the local file in the local file directory is a changing state, the local file directory corresponding to the local file is determined as the target file directory. Understandably, if the local file corresponding to the local file directory is in a changing state, it indicates that there are file changes such as deletion, addition and / or renaming of the local file, that is, the routing path of the local file will also change. Therefore, it is necessary to update the routing path corresponding to the local file in the changing state in the routing file. Since the routing path refers to the path for routing the local file determined according to the local file directory, it is necessary to determine the local file directory corresponding to the local file as the target file directory to facilitate the subsequent update of the routing file. In this example, if the file status corresponding to the local file in the local file directory is a changing state, the local file directory corresponding to the local file is determined as the target file directory to facilitate the update of the routing file.
[0042] In this embodiment, the file status of all local file directories is monitored to determine the file status of each local file, so that the target file directory can be determined in real time according to the file status of the local file. When the file status corresponding to a local file in the local file directory is in a changing state, the local file directory corresponding to the local file is determined as the target file directory, so that the target file directory can be processed and the routing file can be updated.
[0043] In one embodiment, if Figure 4 As shown, step S202, that is, cleaning the original file path array corresponding to the target file directory to obtain the target file path array corresponding to the target file directory, includes: S401: Classify the original file path array corresponding to the target file directory to determine an initial index file path array and an initial non-index file path array; S402: sorting the initial non-index file paths according to the file path lengths of the initial non-index file paths in the initial non-index file path array to obtain a target non-index file path array; S403: Concatenate the target non-index file path array with the initial index file path array to obtain a target file path array corresponding to the target file directory.
[0044] Among them, the initial index file path array refers to an array composed of routing paths corresponding to index files in the original file path array. Among them, the initial index file path array includes the initial index file path corresponding to each index file, and the initial index file path refers to the routing path corresponding to the index file in the original file path array. The initial non-index file path array refers to an array composed of routing paths corresponding to target files other than index files in the original file path array. Among them, the initial non-index file path array includes the initial non-index file path corresponding to each non-index file, and the initial non-index file path refers to the routing path corresponding to the non-index file in the original file path array. It can be understood that there is an index file and several non-index files under the first-level directory corresponding to the target file directory. The index file stores the corresponding file directories of all non-index files under the corresponding first-level directory, and the non-index files are nested and stored under the first-level directory. The routing path corresponding to the non-index file is the target file directory corresponding to the non-index file, and the routing path corresponding to the index file is the target file directory corresponding to the index file. Therefore, the index file is used to determine the target file directory of the non-index file corresponding to the target file under the first-level directory where the index file is located.
[0045] As an example, in step S401, the computer device classifies the original file path array corresponding to the target file directory, and uses the routing paths corresponding to the index files in all target files in the original file path array as the initial index file path, and uses the routing paths corresponding to the non-index files in the target files as the initial non-index file path. For example, for the original file path array [' / m1 / a', ' / m1 / a / demo3.vue', ' / m1 / index.vue', ' / m2 / demo5.vue', ' / m2 / index.vue'] of step S201, ' / m1 / index.vue' and ' / m2 / index.vue' are the routing paths corresponding to the index files. ' / m1 / a', ' / m1 / a / demo3.vue' and ' / m2 / demo5.vue' are the routing paths corresponding to the non-index files. The original file path array is classified to determine that the initial index file paths are ' / m1 / index.vue' and ' / m2 / index.vue', and the initial non-index file paths are ' / m1 / a', ' / m1 / a / demo3.vue', and ' / m2 / demo5.vue'. The computer device forms an initial index file path array according to the initial index file paths ' / m1 / index.vue' and ' / m2 / index.vue': [' / m1 / index.vue', ' / m2 / index.vue'], and forms an initial non-index file path array according to the initial non-index file paths: [' / m1 / a', ' / m1 / a / demo3.vue', ' / m2 / demo5.vue']. In this example, the initial index file path and the initial non-index file path are determined to facilitate the subsequent determination of the target index file path according to the initial index file path.
[0046] Among them, the file path length refers to the length of the routing path corresponding to the initial non-index file path. It can be understood that the more subdirectories the non-index files are located in, the longer the corresponding file path length will be. For example, for the initial non-index file path / m1 / a / demo3.vue corresponding to the non-index file demo3.vue and the initial non-index file path / m2 / demo5.vue corresponding to the non-index file demo5.vue, since / demo5.vue is directly stored under the first-level directory m2 and demo3.vue is stored under the second-level directory a, the file path length of demo3.vue is greater than the file path length of demo5.vue. The target non-index file path array refers to the array obtained after sorting the initial non-index file paths in the initial non-index file path array according to the file path length.
[0047] As an example, in step S402, after obtaining the initial non-indexed file path array, the computer device determines the file path length corresponding to the initial non-indexed file path in the initial non-indexed file path array, and sorts the initial non-indexed file paths in the initial non-indexed file path array according to the file path length corresponding to the initial non-indexed file path, to obtain a target non-indexed file path array. For example, for the initial non-indexed file path array in step S401: [' / m1 / a', ' / m1 / a / demo3.vue', ' / m2 / demo5.vue'], the initial non-indexed file paths therein are sorted in the order of the file path length corresponding to the initial non-indexed file paths from small to large, to obtain a target non-indexed file path array: [' / m1 / a', ' / m2 / demo5.vue', ' / m1 / a / demo3.vue']. In this example, the initial non-indexed file paths are sorted according to the file path lengths corresponding to the initial non-indexed file paths in the initial non-indexed file path array to obtain a target non-indexed file path array, which facilitates the subsequent direct concatenation of the target non-indexed file path array with the initial indexed file path to obtain a target file path array, thereby improving the generation efficiency of the target file path array.
[0048] As an example, in step S403, the computer device concatenates the target non-index file path array obtained by processing with the initial index file path to obtain a target file path array corresponding to the target file directory. For example, the target non-index file path array [' / m1 / a', ' / m2 / demo5.vue', ' / m1 / a / demo3.vue'] obtained in step S402 and the initial index file path array [' / m1 / index.vue', ' / m2 / index.vue'] obtained in step S401 are concatenated to obtain a target file path array corresponding to the target file directory: [' / m1 / a', ' / m2 / demo5.vue', ' / m1 / a / demo3.vue', ' / m1 / index.vue', ' / m2 / index.vue']. In this example, the target non-index file path array is concatenated with the initial index file path to obtain the target file path array corresponding to the target file directory, thereby cleaning the original file path array and making it feasible to subsequently generate a target routing tree object based on the target file path array.
[0049] In this embodiment, the initial index file path and the initial non-index file path are determined, and the initial non-index file paths are sorted according to the file path lengths corresponding to the initial non-index file paths in the initial non-index file path array to obtain a target non-index file path array, so that the target non-index file path array and the initial index file path can be directly spliced to obtain a target file path array, thereby improving the generation efficiency of the target file path array. The target non-index file path array is spliced with the initial index file path to obtain a target file path array corresponding to the target file directory, so as to clean the original file path array and make it feasible to generate a target routing tree object according to the target file path array.
[0050] In one embodiment, if Figure 5 As shown, step S103, that is, generating a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory, includes: S501: Obtain the file name and file extension corresponding to the target file directory according to the target file path array corresponding to the target file directory; S502: Generate a target routing tree object corresponding to the target file directory according to the target file directory and the file name and file extension corresponding to the target file directory.
[0051] Among them, the file name refers to the name of the target file corresponding to the target file directory, which can be a combination of the names of the directories at all levels corresponding to the target file. The file extension refers to the suffix of the target file in the target file directory, which is used to indicate that the target routing tree object is stopped from being generated. Understandably, the file extension is not a component of the target routing tree object, so the file extension can be used to indicate that the target routing tree object is stopped from being generated. In particular, due to the particularity of the index file, the underlying directory name of the index file does not participate in the subsequent process of generating the target routing tree object. Therefore, for the index file, its file extension includes not only the suffix of the index file, but also the underlying directory name of the index file. For non-index files, its file name includes the underlying directory name of the non-index file, and its file extension only includes the suffix of the non-index file. For example, for a non-index file in the target file, its target file directory is / m2 / demo5.vue, its file names are m2 and demo5, and its file extension is vue, where demo5 is the underlying directory name of the non-index file whose target file directory is / m2 / demo5.vue. For the index file in the target file, its target file directory is / m1 / index.vue, its file name is m1, and the file extensions are index and vue, where index is the underlying directory name of the index file whose target file directory is / m1 / index.vue.
[0052] As an example, in step S501, after the computer device obtains the target file path array corresponding to the target file directory, the file name and file extension in the target file directory are further obtained in the target file path array. For example, for the non-index file / m2 / demo5.vue in the target file, the computer device determines that its file name is m2 and demo5, and the file extension is vue. For the index file / m1 / index.vue in the target file, the computer device determines that its file name is m1, and the file extension is index and vue. In this example, according to the target file path array, the file name and file extension corresponding to the target file directory are directly obtained, without the need for manual participation in the naming of the file name and file extension, saving manpower and material resources, being more efficient and convenient, and making it feasible to subsequently generate the target routing tree object corresponding to the target file directory according to the file name and file extension corresponding to the target file directory.
[0053] As an example, in step S502, the computer device generates a target routing tree object corresponding to the target file directory according to each target file directory and the file name and file extension corresponding to each target file directory. For example, the computer device traverses the file name corresponding to the target file directory until the file extension is traversed, and the traversal is completed, and the obtained file name is spliced to generate the target routing tree object corresponding to the target file directory. In this example, the target routing tree object corresponding to the target file directory is directly generated according to the target file directory and the file name and file extension corresponding to the target file directory, without manually naming the file name and file extension and then generating the target routing tree object, saving manpower and material resources, and improving the generation efficiency of the target routing tree object.
[0054] In this embodiment, according to the target file path array, the file name and file extension corresponding to the target file directory are directly obtained, without manual participation in the naming of the file name and file extension, saving manpower and material resources, and being more efficient and convenient. According to the target file directory and the file name and file extension corresponding to the target file directory, the target routing tree object corresponding to the target file directory is directly generated, without manual naming of the file name and file extension and then generating the target routing tree object, saving manpower and material resources and improving the generation efficiency of the target routing tree object.
[0055] In one embodiment, if Figure 6 As shown, step S502, that is, generating a target routing tree object corresponding to the target file directory according to the target file directory and the file name and file extension corresponding to the target file directory, includes: S601: According to the file extension corresponding to the target file directory, the file name corresponding to the target file directory is concatenated to obtain the routing path and routing name corresponding to the target file directory; S602: Read the index file in the target file directory to obtain target metadata; S603: Concatenate the routing path, routing name and target metadata to generate a target routing tree object corresponding to the target file directory.
[0056] The routing name refers to a component of a target routing tree object determined according to the routing path.
[0057] As an example, in step S601, the computer device traverses each target file directory, obtains the file name in the target file directory, and stops traversing the target file directory until it reaches the file extension in the target file directory, obtains all the file names corresponding to the target file directory, concatenates the traversed file names to obtain the routing path corresponding to the target file directory, and processes the routing path to obtain the routing name corresponding to the target file directory, that is, obtains the routing path and routing name corresponding to the target file directory at the same time, and so on, to obtain the routing path and routing name corresponding to each target file directory.
[0058] For example, for the non-index file / m2 / demo5.vue corresponding to the target file directory, the computer device determines that its file name is m2 and demo5, and the file extension is vue. The target file directory is traversed to obtain the routing path corresponding to the target file directory as m2 / Demo5, remove the connector / in the routing path, and capitalize the first letter of the subdirectory under the first-level directory to obtain the routing name m2Demo5. For the index file / m1 / index.vue in the target file, the computer device determines that its file name is m1, and the file extension is index and vue. The target file directory is traversed to obtain the routing path corresponding to the target file directory as m1, and the routing name is also m1.
[0059] In this example, according to the file extension corresponding to the target file directory, the file name corresponding to the target file directory is spliced, and the routing path and routing name corresponding to the target file directory are directly and automatically obtained, without the need to manually obtain the routing name, which is more efficient and convenient. In addition, by splicing the file name corresponding to the target file directory, the routing name corresponding to the target file directory is directly and automatically obtained, which can avoid the generation of duplicate routing names. By isolating the file directory, the isolation of the routing name is achieved, and there is no need to consider the problem of duplicate routing names, thereby avoiding waste of resources and efficiency.
[0060] The target metadata refers to data written into the index file in the form of annotations, including data information such as the target file directory of non-index files stored in the first-level directory where the index file is located.
[0061] As an example, in step S602, the computer device directly reads the annotation content of the index file in the target file directory, uses the annotation content as the target metadata corresponding to the target file directory, and further obtains the target metadata corresponding to each target file directory. In this example, the target metadata is obtained to facilitate the subsequent generation of the target routing tree object according to the target metadata.
[0062] As an example, in step S603, the computer device concatenates the routing path, routing name and target metadata corresponding to the obtained target file directory to generate a target routing tree object corresponding to the target file directory, and so on, to obtain a target routing tree object corresponding to each target file directory. For example, for the non-index file / m2 / demo5.vue corresponding to the target file directory, the computer device obtains the routing path path corresponding to the target file directory as m2 / Demo5, the routing name as m2Demo5, the target metadata meta as {keepAlive:true,forAliveList:["m2demo5"]}, takes the routing name m2Demo5 as the value of the component component of the target routing tree object, and concatenates the routing path path, the component component, the target metadata meta and the routing name name and their contents to generate the target routing tree object corresponding to the target file directory: "path":"m2 / Demo5","component":"m2Demo5","meta":"{keepAlive:true,forAliveList:["m2demo5"]}","name":"m2Demo5". In this example, the routing path, routing name and target metadata corresponding to the target file directory are concatenated to generate a target routing tree object corresponding to the target file directory without manual intervention, so that the target routing tree object has a high generation efficiency.
[0063] In this embodiment, according to the file extension corresponding to the target file directory, the file name corresponding to the target file directory is spliced, and the routing path and routing name corresponding to the target file directory are directly and automatically obtained, without the need to manually obtain the routing name, which is more efficient and convenient, and can also avoid the generation of duplicate routing names. By isolating the file directory, the isolation of the routing name is achieved, and there is no need to consider the problem of duplicate routing names, thereby avoiding waste of resources and efficiency. The routing path, routing name and target metadata corresponding to the target file directory are spliced to generate a target routing tree object corresponding to the target file directory, without the need for manual participation, so that the target routing tree object has a higher generation efficiency.
[0064] In one embodiment, if Figure 7As shown, after step S103, that is, after generating the target routing tree object corresponding to the target file directory, the routing file updating method further includes: S701: Obtain the current number of target routing tree objects; S702: If the current number reaches a preset number threshold, executing a target routing tree object corresponding to the target file directory to update the routing file of the local file system; S703: If the current number does not reach the preset number threshold, repeatedly scan the local file system to determine at least one local file directory corresponding to the local file system.
[0065] The current number refers to the number of target routing tree objects generated in the local file system.
[0066] As an example, in step S701, the computer device obtains the current number of target routing tree objects in real time, so as to determine whether to update the routing file of the local file system according to the current number of target routing tree objects.
[0067] The preset quantity threshold refers to a preset threshold for determining the current quantity of the target routing tree objects.
[0068] As an example, in step S702, when the computer device determines that the current number of target routing tree objects has reached a preset number threshold, it executes the target routing tree objects corresponding to the target file directory to update the routing file of the local file system, that is, executes step S104. Understandably, when the current number of target routing tree objects reaches the preset number threshold, it indicates that the target routing tree objects can be written into the routing file of the local file system to update the routing file. In this example, when the current number of target routing tree objects reaches the preset number threshold, the target routing tree objects are written into the routing file of the local file system to update the routing file. There is no need to update the routing file immediately after the target routing tree objects are generated, which can reduce the operating pressure of the local file system.
[0069] As an example, in step S703, when the computer device determines that the current number of target routing tree objects does not reach the preset number threshold, it continues to scan the local file system, that is, continues to execute step S101. Understandably, if the current number of target routing tree objects does not reach the preset number threshold, it indicates that the current number of target routing tree objects does not meet the requirements for writing routing files and does not meet the conditions for updating routing files. In this example, when it is determined that the current number does not reach the preset number threshold, continuing to scan the local file system can reduce the number of updates to the routing file and reduce the operating pressure of the local system.
[0070] In this embodiment, if the current number reaches the preset number threshold, the target routing tree object corresponding to the target file directory is executed to update the routing file of the local file system; if the current number does not reach the preset number threshold, the local file system continues to be scanned. This method does not need to update the routing file immediately after generating the target routing tree object, which can reduce the operating pressure of the local system.
[0071] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0072] In one embodiment, a routing file updating device is provided, and the routing file updating device corresponds to the routing file updating method in the above embodiment. Figure 8 As shown, the routing file updating device includes a local file system scanning module 801, a local file directory monitoring module 802, a target routing tree object generating module 803 and a routing file updating module 804. The detailed description of each functional module is as follows: The local file system scanning module 801 is used to scan the local file system and determine at least one local file directory corresponding to the local file system; A local file directory monitoring module 802 is used to monitor all local file directories, obtain a target file directory with a routing path change and a target file path array corresponding to the target file directory; The target routing tree object generation module 803 is used to generate a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory; The routing file updating module 804 updates the routing file of the local file system based on the target routing tree object corresponding to the target file directory.
[0073] In one embodiment, the local file directory monitoring module 802 includes: The original file path array acquisition submodule is used to monitor all local file directories, obtain the target file directory with routing path changes and the original file path array corresponding to the target file directory; The target file path array submodule is used to clean the original file path array corresponding to the target file directory and obtain the target file path array corresponding to the target file directory.
[0074] In one embodiment, the original file path array acquisition submodule includes: A file status determination unit, used to monitor the file status of all local file directories and determine the file status of each local file in the local file directory; The target file directory determining unit is used to determine the local file directory corresponding to the local file as the target file directory if the file status corresponding to the local file in the local file directory is in a changed state.
[0075] In one embodiment, the target file path array submodule includes: An initial path array acquisition unit is used to classify the original file path array corresponding to the target file directory and determine an initial index file path array and an initial non-index file path array; A target non-indexed file path array acquisition unit is used to sort the initial non-indexed file paths according to the file path lengths corresponding to the initial non-indexed file paths in the initial non-indexed file path array to obtain a target non-indexed file path array; The target file path array acquisition unit is used to concatenate the target non-index file path array with the initial index file path array to obtain the target file path array corresponding to the target file directory.
[0076] In one embodiment, the target routing tree object generation module 803 includes: The file name and file extension acquisition submodule is used to obtain the file name and file extension corresponding to the target file directory according to the target file path array corresponding to the target file directory; The target routing tree object generation submodule is used to generate a target routing tree object corresponding to the target file directory according to the target file directory and the file name and file extension corresponding to the target file directory.
[0077] In one embodiment, the target routing tree object generation submodule includes: The routing path and routing name acquisition unit is used to perform concatenation processing on the file name corresponding to the target file directory according to the file extension name corresponding to the target file directory, so as to obtain the routing path and routing name corresponding to the target file directory; A target metadata acquisition unit is used to read the index file in the target file directory to obtain the target metadata; The target routing tree object generation unit is used to perform splicing processing on the routing path, routing name and target metadata to generate a target routing tree object corresponding to the target file directory.
[0078] In one embodiment, the routing file updating device further includes: The current number acquisition module is used to obtain the current number of target routing tree objects; A first judgment module is used to execute a target routing tree object corresponding to a target file directory to update a routing file in a local file system if the current number reaches a preset number threshold; The second judgment module is used to repeatedly scan the local file system if the current number does not reach a preset number threshold, and determine at least one local file directory corresponding to the local file system.
[0079] For the specific definition of the routing file updating device, please refer to the definition of the routing file updating method in the above text, which will not be repeated here. Each module in the above routing file updating device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0080] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data used or generated during the execution of the routing file update method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a routing file update method is implemented.
[0081] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the routing file updating method in the above embodiment is implemented, for example Figure 1 S101-S104 as shown, or Figures 2 to 7 Alternatively, when the processor executes the computer program, the functions of each module / unit in the embodiment of the routing file updating device are realized, for example Figure 8 The functions of the local file system scanning module 801, the local file directory monitoring module 802, the target routing tree object generating module 803 and the routing file updating module 804 are not described here in detail to avoid repetition.
[0082] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the routing file updating method in the above embodiment is implemented, for example Figure 1 S101-S104 as shown, or Figures 2 to 7Alternatively, when the computer program is executed by the processor, the functions of each module / unit in the above-mentioned routing file updating device are realized, for example, Figure 8 The functions of the local file system scanning module 801, the local file directory monitoring module 802, the target routing tree object generation module 803 and the routing file updating module 804 are not described here to avoid repetition. The computer-readable storage medium may be non-volatile or volatile.
[0083] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0084] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0085] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for updating a routing file, characterized in that: include: Scanning the local file system to determine at least one local file directory corresponding to the local file system; Monitor all the local file directories to obtain the target file directories with routing path changes and the target file path arrays corresponding to the target file directories; Generate a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory; Based on the target routing tree object corresponding to the target file directory, the routing file of the local file system is updated.
2. The method for updating a routing file according to claim 1, wherein: The monitoring of all the local file directories to obtain the target file directory with a routing path change and the target file path array corresponding to the target file directory includes: Monitor all the local file directories to obtain the target file directory with routing path changes and the original file path array corresponding to the target file directory; The original file path array corresponding to the target file directory is cleaned to obtain the target file path array corresponding to the target file directory.
3. The method for updating a routing file according to claim 2, wherein: The monitoring of all the local file directories to obtain the target file directory with a routing path change and the original file path array corresponding to the target file directory includes: Monitor the file status of all the local file directories to determine the file status of each local file in the local file directory; If the file status corresponding to the local file in the local file directory is in a changed state, the local file directory corresponding to the local file is determined as the target file directory.
4. The method for updating a routing file according to claim 2, wherein: The step of cleaning the original file path array corresponding to the target file directory to obtain the target file path array corresponding to the target file directory includes: Classifying the original file path array corresponding to the target file directory to determine an initial index file path array and an initial non-index file path array; According to the file path lengths of the initial non-index file paths in the initial non-index file path array, the initial non-index file paths are sorted to obtain a target non-index file path array; The target non-index file path array is concatenated with the initial index file path array to obtain a target file path array corresponding to the target file directory.
5. The method for updating a routing file according to claim 1, wherein: The step of generating a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory includes: According to the target file path array corresponding to the target file directory, obtain the file name and file extension corresponding to the target file directory; A target routing tree object corresponding to the target file directory is generated according to the target file directory and the file name and file extension corresponding to the target file directory.
6. The method for updating a routing file according to claim 5, wherein: The step of generating a target routing tree object corresponding to the target file directory according to the target file directory and the file name and file extension corresponding to the target file directory comprises: According to the file extension corresponding to the target file directory, the file name corresponding to the target file directory is concatenated to obtain the routing path and routing name corresponding to the target file directory; Read the index file in the target file directory to obtain target metadata; The routing path, the routing name and the target metadata are concatenated to generate a target routing tree object corresponding to the target file directory.
7. The method for updating a routing file according to claim 1, wherein: After generating the target routing tree object corresponding to the target file directory, the routing file updating method further includes: Obtain the current number of the target routing tree objects; If the current number reaches a preset number threshold, executing the target routing tree object corresponding to the target file directory to update the routing file of the local file system; If the current number does not reach the preset number threshold, the scanning of the local file system is repeated to determine at least one local file directory corresponding to the local file system.
8. A routing file updating device, characterized in that: include: A local file system scanning module, used to scan the local file system and determine at least one local file directory corresponding to the local file system; A local file directory monitoring module is used to monitor all the local file directories, obtain the target file directory with routing path changes and the target file path array corresponding to the target file directory; A target routing tree object generation module, used to generate a target routing tree object corresponding to the target file directory according to the target file path array corresponding to the target file directory; The routing file updating module updates the routing file of the local file system based on the target routing tree object corresponding to the target file directory.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the routing file updating method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the routing file updating method according to any one of claims 1 to 7 is implemented.