CN113568605B - Method, device and system for configuring defined route - Google Patents

Method, device and system for configuring defined route Download PDF

Info

Publication number
CN113568605B
CN113568605B CN202110748430.1A CN202110748430A CN113568605B CN 113568605 B CN113568605 B CN 113568605B CN 202110748430 A CN202110748430 A CN 202110748430A CN 113568605 B CN113568605 B CN 113568605B
Authority
CN
China
Prior art keywords
page
path
module
routing
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110748430.1A
Other languages
Chinese (zh)
Other versions
CN113568605A (en
Inventor
周飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Qiyue Information Technology Co Ltd
Original Assignee
Shanghai Qiyue Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Qiyue Information Technology Co Ltd filed Critical Shanghai Qiyue Information Technology Co Ltd
Priority to CN202110748430.1A priority Critical patent/CN113568605B/en
Publication of CN113568605A publication Critical patent/CN113568605A/en
Application granted granted Critical
Publication of CN113568605B publication Critical patent/CN113568605B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of front-end development, and provides a method, a device, a system and a medium for contracted route configuration, aiming at solving the problems of how to reduce the complexity in the process of developing front-end routes, and even how to maintain flexibility, improve efficiency and the like, aiming at the defects of poor flexibility, low efficiency, high cost and the like in the existing front-end development. To this end, the method includes setting a contract; traversing all index pages below the pages folder; acquiring default route information; defining a first routing path processing function; processing page path information; defining a second routing path processing function; sequentially calling a second function to process page path information; deleting "." "in path information of the page; acquiring a predefined page layout parameter; the plurality of attributes of the modules variable are respectively set for use in generating a routing configuration table. Therefore, the file directory is automatically read, the front-end route is generated, the complexity of developing the front-end route is reduced, and the efficiency is improved.

Description

Method, device and system for configuring defined route
Technical Field
The present invention relates to the field of front-end development, and in particular, to a method, an apparatus, a system, and a computer readable medium for provisioning routing configuration.
Background
Both fact and Vue are now popular front-end technology frameworks that introduce the concept of routing to the front-end during the front-end single page period. The different technical frameworks will all pre-configure the specified routes and then match to the respective routes when the page is accessed before the page is presented. Therefore, in some middle-platform projects, as page pages increase, each time a new page needs to be manually configured, the new page can be accessed, so that the same content is always configured repeatedly for project developers, and a great deal of repeated work exists. In addition, developers of new joining teams need to understand the specifications of the configuration in advance, which also has a great deal of troublesome work. When a plurality of persons cooperate to complete a module, the traditional mode is difficult to split the service clearly, so that code conflict can be solved frequently, and the efficiency is reduced. To overcome this problem, a concept of "contract preferred configuration (convention over configuration)" is proposed in the back-end framework Egg. The developers need to follow the same set of conventions to carry out application development, the learning cost of the developers can be reduced by adopting the mode in the team, the number of decisions needed by the software developers is reduced, and the developers can flow and are more flexible.
Based on this idea, a contracted routing scheme needs to be implemented in the front-end development as well.
Disclosure of Invention
In order to solve the problems, the invention provides a method, a device, a system and a computer readable medium for configuration of a contracted route, which aim to solve the technical problem of how to effectively reduce the complexity in developing front-end routes, and further solve the technical problem of how to maintain the flexibility of a team in front-end development and further solve the problem of improving the efficiency in front-end development.
In order to solve the above technical problems, a first aspect of the present invention provides a method for provisioning routing configuration, the method comprising the following steps: the appointed page module corresponding to the route configuration is named as the name of a folder where the page pages are located; when naming files in the folder, uniformly naming the names of the folders through defined functions; acquiring predefined page layout parameters and setting a plurality of attributes in module variables of a page module for use in generating a routing configuration table; wherein the names of the respective folders do not repeat.
According to a preferred embodiment of the present invention, when naming files in a folder, unified naming is performed on the folder names through defined functions, which specifically includes: traversing all index page pages below a folder where the page pages are located, and storing page path information of all the page pages into file variables; obtaining default route information and storing the default route information into module variables; defining a first routing path processing function for carrying out unified naming processing on names of folders in file naming; processing the page path information of all the page pages stored in the file variable, judging whether the page path information of each page in the file variable is an index file under the folder where the page pages are located, and if so, returning to not process the page path information; if not, calling a defined second routing path processing function in turn to perform unified naming processing on the page path information of all the page pages stored in the file variable; the second routing path processing function sends the processing result to the first routing path processing function, and the first routing path processing function performs unified naming processing on names of folders and then saves the processing result to a routing path variable; deleting the 'in each page path information, and storing the' in a file path variable file path.
According to a preferred embodiment of the invention, the traversing operation may be accomplished using a request. And/or the first path routing function replaces the first regular expression in the folder name with the second regular expression; and/or the processing performed by the second path routing function specifically includes: the page path information is removed according to "/" after segmentation "," and "index. Jsx".
According to a preferred embodiment of the invention, the substitution is in particular: the "-" in the folder name is replaced with "_".
According to a preferred embodiment of the present invention, the method for obtaining the predefined page layout parameters and setting the plurality of attributes in the module variables of the page module for use in generating the routing configuration table specifically includes: obtaining a predefined page layout current path layout parameter through analysis and storing the predefined page layout current path layout parameter into a layout variable; the plurality of attributes stored in the module variables are respectively set for use in generating a routing configuration table.
According to a preferred embodiment of the invention, the plurality of attributes in the module variable are at least one or more of the following: a path attribute, an import attribute, a layout attribute, an exact attribute; and/or, the setting the plurality of attributes stored in the module variables for use in generating a routing configuration table specifically includes: and splicing the PATH parameter and the routing PATH into a complete routing PATH, importing a file PATH under the pages directory as a reference module, and if a predefined layout parameter is set to be layout= = = 'user', directly without a menu directory, determining whether the routing is strictly matched according to userExact information and PATH information.
In order to solve the above technical problem, a second aspect of the present invention provides a device for provisioning routing configuration, including: the provisioning setting module is used for provisioning the name of the folder where the page pages are located, which is the page module corresponding to the routing configuration; the name processing module is used for carrying out unified naming processing on the names of the folders through defined functions when the files in the folders are named; the configuration using module is used for acquiring predefined page layout parameters and setting a plurality of attributes in module variables of the page module for use in generating a route configuration table; wherein the names of the respective folders do not repeat.
According to a preferred embodiment of the present invention, the name processing module specifically includes: the page information storage module is used for traversing all index page pages below a folder where the page pages are located and storing page path information of all the page pages into file variables; the default route information storage module is used for acquiring default route information and storing the default route information into a module variable; the first routing path processing function definition module is used for defining a first routing path processing function and carrying out unified naming processing on names of folders in file naming; the first page path information processing module is used for processing the page path information of all page pages stored in the file variable, judging whether the page path information of each page in the file variable is an index file under a folder where the page pages are located, and returning to not process the page path information if the page path information is an index file under the folder where the page pages are located; the second routing path processing function definition module is used for defining a second routing path processing function and carrying out unified naming processing on the page path information of all the page pages stored in the file variable; the second routing path information processing module is used for carrying out unified naming processing on the page path information of all the page pages stored in the file variable by calling the second routing path processing function in turn if the first routing path information processing module judges that the first routing path information processing module does not exist; the third page path information processing module is used for deleting the 'in each page path information and storing the' in a file path variable file path; the configuration and use module specifically comprises: the page layout parameter storage module is used for acquiring a predefined page layout current path layout parameter through analysis and storing the predefined page layout current path layout parameter into a layout variable; and the module attribute setting module is used for setting a plurality of attributes stored in the module variables respectively for use in generating a routing configuration table.
According to a preferred embodiment of the invention, the traversing operation may be accomplished using a request. And/or the first path routing function replaces the first regular expression in the folder name with the second regular expression, or replaces the "-" in the folder name with "_"; and/or the processing performed by the second path routing function specifically includes: dividing the page path information according to "/" and then removing "," and "index. Jsx"; and/or the plurality of attributes in the module variable are at least one or more of: a path attribute, an import attribute, a layout attribute, an exact attribute; and/or, the setting the plurality of attributes stored in the module variables for use in generating a routing configuration table specifically includes: and splicing the PATH parameter and the routing PATH into a complete routing PATH, importing a file PATH under the pages directory as a reference module, and if a predefined layout parameter is set to be layout= = = 'user', directly without a menu directory, determining whether the routing is strictly matched according to userExact information and PATH information. In order to solve the above technical problem, a third aspect of the present invention provides a system for provisioning routing configuration, including: a memory for storing computer executable instructions; data processing means for reading the computer executable program in the memory to perform the method steps of the first aspect.
In order to solve the above technical problem, a fourth aspect of the present invention proposes a computer readable storage medium storing one or more programs which, when executed by a processor, implement the method steps of the first aspect.
Because the invention does not need to carry out route configuration on each developed page one by one, a developer only needs to pay attention to own codes, and can automatically read file catalogues and automatically generate front-end routes according to file naming standards during development, and the mode of uniformly configuring the routes by uniformly processing route naming can effectively save the workload of the developer, keep the flexibility of front-end development realization, ensure that code logic is simpler and easier to maintain, be beneficial to reducing the complexity during development of the front-end routes and improve the efficiency.
Drawings
In order to make the technical problems solved by the present invention, the technical means adopted and the technical effects achieved more clear, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted, however, that the drawings described below are merely illustrative of exemplary embodiments of the present invention and that other embodiments of the drawings may be derived from these drawings by those skilled in the art without undue effort.
FIG. 1 is a flow chart of one embodiment of a method of promissory routing configuration in accordance with the present invention;
fig. 2 is a schematic flow diagram of a configuration of an implementation of a routing program for provisioning a routing contract in one embodiment of a routing provisioning method in accordance with the present invention.
Fig. 3 is a block diagram of the main structure of an implementation of a configuration routing program in one embodiment of a routing provisioning apparatus according to the present invention.
Fig. 4 is a schematic diagram of a structural framework of an embodiment of a promissory routing configuration system in accordance with the present invention.
Fig. 5 is a block diagram of a more specific embodiment of the system according to the invention.
FIG. 6 is a schematic diagram of one embodiment of a computer readable medium of the present invention.
Detailed Description
Exemplary embodiments of the present invention will now be described more fully hereinafter with reference to the accompanying drawings, in which exemplary embodiments are shown, although the exemplary embodiments may be practiced in various specific ways. Rather, these exemplary embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the invention to those skilled in the art.
The structures, capabilities, effects, or other features described in a particular embodiment may be incorporated in one or more other embodiments in any suitable manner without departing from the spirit of the present invention.
In describing particular embodiments, specific details of construction, performance, effects, or other features are set forth in order to provide a thorough understanding of the embodiments by those skilled in the art. It is not excluded, however, that one skilled in the art may implement the present invention in a particular situation in a solution that does not include the structures, properties, effects, or other characteristics described above.
The flow diagrams in the figures are merely exemplary flow illustrations and do not represent that all of the elements, operations, and steps in the flow diagrams must be included in the aspects of the present invention, nor that the steps must be performed in the order shown in the figures. For example, some operations/steps in the flowcharts may be decomposed, some operations/steps may be combined or partially combined, etc., and the order of execution shown in the flowcharts may be changed according to actual situations without departing from the gist of the present invention.
The block diagrams in the figures generally represent functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The same reference numerals in the drawings denote the same or similar elements, components or portions, and thus repeated descriptions of the same or similar elements, components or portions may be omitted hereinafter. It will be further understood that, although the terms first, second, third, etc. may be used herein to describe various devices, elements, components or portions, these devices, elements, components or portions should not be limited by these terms. That is, these phrases are merely intended to distinguish one from the other. For example, a first device may also be referred to as a second device without departing from the spirit of the invention. Furthermore, the term "and/or," "and/or" is meant to include all combinations of any one or more of the items listed.
In one embodiment of the technical scheme of the contracted route configuration, the invention provides a front-end contracted route configuration method, which is characterized in that the method follows a contract in development, only needs to name according to file naming standards, and can automatically read file catalogues in project generation, thereby automatically generating a front-end route.
Specifically, in one embodiment of the method, a contract is set mainly during development, and by traversing an index page, acquiring default route information, defining a route path processing function and page processing path information, removing specific symbols in the page path information, acquiring page layout parameters and setting attributes, each new page can be developed in a modeling mode according to the parameters and the attributes, and the method is simple, convenient, efficient, easy to maintain and capable of effectively reducing complexity of a development stage.
[ example 1 ]
The implementation of the technical solution of the present invention will be described below with reference to a flowchart of an embodiment of the method for provisioning routing configuration according to the present invention shown in fig. 1.
An embodiment of the method comprises the steps of: s1, setting a convention, namely naming the page module corresponding to the routing configuration as the name of a folder where page pages are located; s2, when naming files in the folder, carrying out unified naming processing on the names of the folders through defined functions; s3, acquiring predefined page layout parameters and setting a plurality of attributes in module variables of the page module for use in generating a routing configuration table; wherein the names of the respective folders do not repeat. The routing configuration table determines the front-end route of the actual newly added page, and the corresponding route can be matched and the page can be accessed when the newly added page is accessed.
Further, the routes are specifically generated in this embodiment, typically by loading all page pages (whether new or old pages). For example:
in S1, a convention may be preset to default the naming of the page module/page routing module to the name of the folder in which the page is located. Wherein the names of the respective folders do not repeat.
And then, naming the files in the folder and uniformly naming the names of the folders in S2. The method comprises the following steps:
s2a, traversing all index pages under a folder where the pages are located, storing page path information of all the pages into file variables (file variables), and further obtaining default route information and storing the default route information into module variables (module variables).
S2b, defining a first routing path processing function (first function for short), and carrying out unified naming processing on names of folders of the files when the files are named.
S2c, processing the path information of all pages in the folder where the pages stored in the file variable are located, judging whether the path information of each page in the file variable is an index (e.g. index. Jsx) file in the page folder, and if so, returning to not process the path information.
If not, turning to S2d, calling a defined second routing path processing function (called second function for short), sequentially carrying out unified naming processing on page path information of all pages under the folder where the pages stored in the file variable are located, sending a processing result of unified naming to the first function (namely turning to S2b to carry out unified processing on names of the folder), and storing the processing result in a routing path variable.
And S2e, deleting a specific symbol (such as "") in each page path information, and storing the specific symbol in a file path variable file path.
Wherein the names of the respective folders do not repeat.
S3, acquiring predefined page layout parameters and setting the attribute of the module variable of the page module, specifically for example:
s3a, acquiring a predefined page layout parameter and saving the page layout parameter into a layout variable.
And S3b, setting the path attribute, the import attribute, the layout attribute, the exact attribute and the like of the modules variable for storing the routing information respectively so as to be used when a new page is added and a routing configuration table needs to be generated.
Finally, the page module (as the default module) is output.
When the route configuration table is generated, for example, module pushing is performed, and the route configuration table can be configured according to the attribute when one page is newly added.
[ example 2 ]
The implementation process of the present invention will be further described with reference to a main flow diagram of an implementation of a routing configuration procedure configured in an embodiment of the technical solution according to the present invention shown in fig. 2, from a process of route configuration developed by a front end of an actual application.
All pages are loaded to generate a routing configuration. Specifically, for example, the steps may be as follows:
S101: the convention is set, the convention page routing module is named as the name of the folder where the page is located, and the folders of the modules cannot be renamed.
The method specifically comprises the following steps: the naming of the page modules corresponding to the routing configuration to be generated is agreed, the default is the names of the folders in which the pages are located, and the names of the modules cannot be repeated.
S102: and traversing all index pages below the pages folder, and storing page path information of all pages to file variable postfiles.
Wherein the pages are page component directories of the front-end engineering project source file. The traversal operation may be completed using a required content module and provided to the content files.
The request.
A request.context (directors, usesubdirectors, regExp), wherein:
directors: a description is given of the directory that needs to be retrieved,
usescubdirectories: whether or not to retrieve a sub-directory,
regExp, a regular expression matching a file, is typically a file name.
In the embodiment of the present invention, all operations requiring unified batch processing may be completed by using a request.
In a specific embodiment, the index page is an index. Jsx file or an index. Js file.
S103: and obtaining default route information and storing the default route information into modules variables.
S104: a first routing path processing function is defined.
In one embodiment, the first routing path processing function performs unified naming processing on names of folders when naming files. The first routing path processing function is abbreviated as a first function in this embodiment of the invention, which may be a getPath function.
Further, in a particular embodiment, the first function uses a regular expression to uniformly name the names of the folders.
For example, the first function may replace a first regular expression in the folder name with a second regular expression, e.g., replace "-" with "_".
For example, the first function may add a preset character, such as "v2/", in the address bar.
For example, the first function may uniformly delete a preset character, such as "v2/", in the address bar.
Of course, the unified processing route naming is merely exemplary, and those skilled in the art may set other naming manners according to actual situations, which is not limited by the present invention.
In this embodiment of the present invention, description will be made specifically taking the case that the first function replaces "-" in the folder name with "_" when named.
S105: and processing the path information of all pages under the pages folder stored in the file variable, wherein the processing mainly comprises judging whether the path information of each page in the file variable is an index (e.g. index. Jsx) file under the pages folder, and if so, returning to not process the path information.
S106: a second routing path processing function is defined.
In one embodiment, the second path routing function performs unified naming processing on the page path information of all the pages under the pages folder stored in the file variable. The second path routing processing function is simply referred to as a second function, which may be a PathArr function.
The second function removes the page path information according to "/" split "," and "index. Jsx".
S107: and calling the second function to process the page path information of all pages in sequence, sending the processing result to the first function by the second function, uniformly naming names of folders by the first function, and storing the processing result in a routing path variable.
In this example, the second function cuts out the page path information of all pages according to "/" after division "," and "index. Jsx", and the first function replaces the name "-" of the folder with "_" and then splices and saves the same to the path variable with "/".
S108: deleting the 'in the path information of the page, and storing the' in a file path variable file path.
S109: the predefined page layout parameters are acquired and saved into layout variables.
Specific examples are: the operation may be accomplished using a resolution acquisition current path parameter of Tools module such as the getParameterByName method.
S110: and setting the path attribute, the import attribute, the layout attribute and the exact attribute of the modules variable respectively for use in generating a route configuration table.
Setting the PATH attribute refers to splicing PATH parameters and routing PATH variables into a complete routing PATH, and setting the PATH attribute of a module.
The setting of the import attribute refers to the fact that a file path filePath under the pages directory is introduced as a reference module, and the import attribute of a module is set.
The setting of the Layout attribute refers to setting the Layout attribute of the module according to the Layout parameter and the Layout definition of the user. The menu directory is not directly needed if the predefined layout parameter layout= = = = 'user'.
The setting of the exact attribute means that whether the route is strictly matched is determined according to userExact information and path information to set the exact attribute of the module.
Specifically, for example, the PATH parameter and the routing PATH are spliced into a complete routing PATH, and then a file PATH under the pages directory is imported as a reference module. If the predefined layout parameter sets layout= = = = 'user', then no menu directory is needed directly, and it is decided whether this route is exactly matched according to userExact information and path information. If the exact attribute is true, the required path and location. Path name must be completely matched, and if the matched route is consistent with the matched route, if the exact attribute is false, all sub-routes can directly return to the same page, so that the effect of not needing menu catalogue is achieved. By saving the above information to modules variables, a routing configuration table is generated.
An example of route configuration table generation in an actual application scenario: and generating a route configuration table after processing all index pages under a predefined directory by traversing the index pages:
routing configuration table config= [ { path:, report: () = > report (':') layout: false, exact: true } ]
For example:
[{path:path1,import:()=>import('path1'),layout:false,exact:true},
{path:path2,import:()=>import('path2'),layout:false,exact:true}
]
the partial code for configuring the routing may be as follows:
In the embodiment of the invention, the predetermined front-end routing is mainly realized based on the fact that the frame of the front-end JS is developed, but a person skilled in the art can also use other frames to realize the predetermined front-end routing of the present application according to actual situations, for example, vue, angular, etc., and the invention is not limited thereto.
The contracted routing mode can automatically read the file under the page directory, automatically generate a route according to the file name, and automatically generate a router configuration object if the file contains a plurality of single paths and the underscores are replaced by paths without concerning the routing configuration. And a unified entry for routing can be implemented.
[ example 3 ]
The implementation of the technical solution of the present invention will be described below with reference to a main structural block diagram of an implementation of a routing program configured in one embodiment of the routing configuration device according to the present invention shown in fig. 3. An embodiment of the device may correspond to the method of embodiment 2.
As shown in fig. 3, the apparatus includes a contract setting module 201, a page information saving module 202, a default route information saving module 203, a first route path processing function definition module 204, a first page path information processing module 205, a second route path processing function definition module 206, a second page path information processing module 207, a third page path information processing module 208, a page layout parameter saving module 209, and a modules attribute setting module 210.
In one embodiment, the contract setting module 201 may be configured to set a contract, for example, the contract page routing module routes a name of a folder where a page is located, and the folders of the modules cannot be renamed.
The method specifically comprises the following steps: the naming of the page modules corresponding to the routing configuration to be generated is agreed, the default is the names of the folders in which the pages are located, and the names of the modules cannot be repeated.
In one embodiment, names are processed (name processing module), and when files in a folder are named, the names of the folder can be uniformly named through defined functions. Specific examples are:
the page information saving module 202 may be configured to traverse all index pages under the pages folder, and save the page path information of all the pages to the file variable const files.
Wherein the pages are page component directories of the front-end engineering project source file. The traversal operation may be completed using a required content module and provided to the content files.
The request.
A request.context (directors, usesubdirectors, regExp), wherein:
directors: a description is given of the directory that needs to be retrieved,
usescubdirectories: whether or not to retrieve a sub-directory,
regExp, a regular expression matching a file, is typically a file name.
In the embodiment of the present invention, all operations requiring unified batch processing may be completed by using a request.
In a specific embodiment, the index page is an index. Jsx file or an index. Js file.
The default route information storage module 203 may be configured to obtain default route information and store the default route information in modules variables.
The first routing path processing function definition module 204 may be configured to define a first routing path processing function.
In one embodiment, the first routing path processing function performs unified naming processing on names of folders when naming files. The first routing path processing function is abbreviated as a first function in this embodiment of the invention, which may be a getPath function.
Further, in a particular embodiment, the first function uses a regular expression to uniformly name the names of the folders.
For example, the first function may replace a first regular expression in the folder name with a second regular expression, e.g., replace "-" with "_".
For example, the first function may add a preset character, such as "v2/", in the address bar.
For example, the first function may uniformly delete a preset character, such as "v2/", in the address bar.
Of course, the unified processing route naming is merely exemplary, and those skilled in the art may set other naming manners according to actual situations, which is not limited by the present invention.
In this embodiment of the present invention, description will be made specifically taking the case that the first function replaces "-" in the folder name with "_" when named.
The first page path information processing module 205 may be configured to process path information of all the pages under the pages folder stored in the file variable, mainly determine whether the path information of each page in the file variable is an index (e.g. index. Jsx) file under the pages folder, and if yes, return that the path information is not processed.
The second routing path processing function definition module 206 may be configured to define a second routing path processing function.
In one embodiment, the second path routing function performs unified naming processing on the page path information of all the pages under the pages folder stored in the file variable. The second path routing processing function is simply referred to as a second function, which may be a PathArr function.
The second function removes the page path information according to "/" split "," and "index. Jsx".
The second page path information processing module 207 may be configured to call the second function to process the page path information of all the pages in sequence. The second function sends the processing result to the first routing path processing function definition module 204, and the first function performs unified naming processing on the names of the folders, and then saves the processing result to the routing path variable.
In this example, the second function cuts out the page path information of all pages according to "/" after division "," and "index. Jsx", and the first function replaces the name "-" of the folder with "_" and then splices and saves the same to the path variable with "/".
The third page path information processing module 208 may be configured to delete "." in the path information of the page, and store the deleted "." in the file path variable file path.
In one embodiment, when the routing configuration table is generated, parameters, attributes, and the like need to be acquired and set (configuration using module), specifically for example:
the page layout parameter saving module 209 may be configured to obtain a predefined page layout parameter, and save the predefined page layout parameter into a layout variable.
Specific examples are: the operation may be accomplished using a resolution acquisition current path parameter of Tools module such as the getParameterByName method.
The modules attribute setting module 210 may be configured to set a path attribute, an import attribute, a layout attribute, and an exact attribute of the modules variable respectively, for use in generating a routing configuration table.
Setting the PATH attribute refers to splicing PATH parameters and routing PATH variables into a complete routing PATH, and setting the PATH attribute of a module.
The setting of the import attribute refers to the fact that a file path filePath under the pages directory is introduced as a reference module, and the import attribute of a module is set.
The setting of the Layout attribute refers to setting the Layout attribute of the module according to the Layout parameter and the Layout definition of the user. The menu directory is not directly needed if the predefined layout parameter layout= = = = 'user'.
The setting of the exact attribute means that whether the route is strictly matched is determined according to userExact information and path information to set the exact attribute of the module.
Specifically, for example, the PATH parameter and the routing PATH are spliced into a complete routing PATH, and then a file PATH under the pages directory is imported as a reference module. If the predefined layout parameter sets layout= = = = 'user', then no menu directory is needed directly, and it is decided whether this route is exactly matched according to userExact information and path information. If the exact attribute is true, the required path and location. Path name must be completely matched, and if the matched route is consistent with the matched route, if the exact attribute is false, all sub-routes can directly return to the same page, so that the effect of not needing menu catalogue is achieved. By saving the above information to modules variables, a routing configuration table is generated.
An example of route configuration table generation in an actual application scenario: and generating a route configuration table after processing all index pages under a predefined directory by traversing the index pages:
routing configuration table config= [ { path:, report: () = > report (':') layout: false, exact: true } ]
For example:
[{path:path1,import:()=>import('path1'),layout:false,exact:true},
{path:path2,import:()=>import('path2'),layout:false,exact:true}
]
the partial code for configuring the routing may be as follows:
[ example 4 ]
Fig. 4 is a schematic structural diagram of an embodiment of the promissory routing configuration system according to the present invention, as shown in fig. 4, which includes a memory for storing a computer executable program (or instructions, etc.), and a data processing device for reading the computer executable program (or instructions, etc.) in the memory to perform the aforementioned promissory routing configuration method, such as the method in embodiment 1. In this embodiment, the system may be a local system or a distributed system. The memory of the present invention may be a local memory or a distributed storage system, such as a cloud storage system. While a data processor includes at least one device having digital information processing capabilities, such as a CPU, GPU, multiprocessor system, or cloud processor.
An example of the structure of a local system is described in detail below with reference to fig. 5. The system may be regarded as an implementation in physical form for the method and apparatus embodiments of the invention described above. The details described in this embodiment of the system of the present invention should be regarded as supplementary to the above-described embodiments of the method or apparatus/system, not as limiting, but merely as an exemplary illustration of a local system condition, and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
As shown in fig. 5, the local system 200 of the exemplary embodiment is in the form of a general purpose data processing device. The components of example 200 of the system may include, but are not limited to: at least one processing unit 270 (i.e., an example of a specific data processing device), at least one storage unit 220 (i.e., an example of a specific memory), a bus 230 connecting the different system components (including the storage unit 220 and the processing unit 270), a display unit 240, and the like.
The storage unit 220 stores therein a computer readable program, which may be a source program or code of a program that is read only. The program may be executed by the processing unit 270 such that the processing unit 270 performs the steps of various embodiments of the present invention. For example, the processing unit 270 may perform the steps of the method of the foregoing embodiment 1.
The memory unit 220 may include readable media in the form of volatile memory units, such as Random Access Memory (RAM) 2201 and/or cache memory 2202, and may further include Read Only Memory (ROM) 2203. The storage unit 220 may also include a program/utility 2204 having a set (at least one) of program modules 2205, such program modules 2205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
Bus 230 may be a bus representing one or more of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The local system 200 may also communicate with one or more external devices 300 (e.g., keyboard, display, network device, bluetooth device, etc.), such that a user can interact with the system 200 via the external devices 300, and/or such that the system 200 can communicate with one or more other data processing devices (e.g., routers, modems, etc.). Such communication may occur through an input/output (I/O) interface 250, and may also occur through a network adapter 260 to one or more networks, such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet. Network adapter 260 may communicate with other modules of electronic device 200 via bus 230. It should be appreciated that although not shown, other hardware and/or software modules may be used in electronic device 200, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
[ example 5 ]
Specifically, a computer readable medium storing one or more programs is also included, wherein the embodiment steps of the methods of embodiments 1 and 2 described above involving the present invention are implemented when the one or more programs are executed by a processor. FIG. 6 is a schematic diagram of one embodiment of a computer readable medium of the present invention. The computer program may be stored on one or more computer readable media, which may be local or distributed, such as cloud storage, etc.
Those skilled in the art will appreciate that all or part of the steps implementing the above-described embodiments are implemented as a program, i.e., a computer program, executed by a data processing apparatus (including a computer). The above-described method provided by the present invention can be implemented when the computer program is executed. Furthermore, the computer program may be stored in a computer readable storage medium, i.e., a computer readable medium, which may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a magnetic disk, an optical disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or a storage array of any suitable combination of the foregoing, such as a plurality of storage media, for example, a magnetic disk or tape storage array. The computer program, when executed by one or more data processing apparatus, enables the computer readable medium to carry out the above-described methods of the present invention. Further, the storage medium is not limited to the centralized storage, but may be a distributed storage, such as cloud storage based on cloud computing. It should be appreciated that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes described in the context of a single embodiment or with reference to a single figure in order to streamline the invention and aid those skilled in the art in understanding the various aspects of the invention. The present invention should not, however, be construed as including features that are essential to the patent claims in the exemplary embodiments.
Further, those skilled in the art will readily appreciate that the exemplary embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present invention may be embodied in the form of a software product, which may be stored in a computer readable medium (which may be a CD-ROM, a usb disk, a mobile hard disk, etc.) or on a network, comprising several instructions to cause a data processing device (which may be a personal computer, a server, or a network device, etc.) to perform the above-described method according to the present invention. The computer readable medium may include a data signal propagated in baseband or as part of a carrier wave, with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable storage medium may also be any readable medium that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing. Program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
Thus, the present invention may be embodied in methods, systems, electronic devices, or computer readable media that execute computer programs. Some or all of the functions of the present invention may be implemented in practice using a general purpose data processing device such as a microprocessor or Digital Signal Processor (DSP).
It should be understood that modules, units, components, etc. included in the apparatus of one embodiment of the present invention may be adaptively changed to arrange them in an apparatus different from the embodiment. The different modules, units or components comprised by the apparatus of the embodiments may be combined into one module, unit or component or they may be divided into a plurality of sub-modules, sub-units or sub-components. The modules, units, or components of embodiments of the invention may be implemented in hardware, in software running on one or more processors, or in a combination thereof.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the invention thereto, but to limit the invention thereto, and any modifications, equivalents, improvements and equivalents thereof may be made without departing from the spirit and principles of the invention.
In summary, the present invention may be implemented in a method, apparatus, system, or computer readable medium that executes a computer program. Some or all of the functions of the present invention may be implemented in practice using a general purpose data processing device such as a microprocessor or Digital Signal Processor (DSP).
The above-described specific embodiments further describe the objects, technical solutions and advantageous effects of the present invention in detail, and it should be understood that the present invention is not inherently related to any particular computer, virtual device or electronic apparatus, and various general-purpose devices may also implement the present invention. The foregoing description of the embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.

Claims (9)

1. A method for provisioning routing configuration, the method comprising the steps of:
the appointed page module corresponding to the route configuration is named as the name of a folder where the page pages are located;
when naming files in a folder, carrying out unified naming processing on the folder names through defined functions, wherein the unified naming processing comprises the following steps:
Traversing all index page pages below a folder where the page pages are located, and storing page path information of all the page pages into file variables;
obtaining default route information and storing the default route information into module variables;
defining a first routing path processing function for carrying out unified naming processing on names of folders in file naming;
processing the page path information of all the page pages stored in the file variable, and judging whether the page path information of each page in the file variable is an index file under the folder where the page pages are located; if yes, returning to not process the page path information;
if not, the defined second routing path processing function is sequentially called to perform unified naming processing on the page path information of all the page pages stored in the file variable, the second routing path processing function sends a processing result to the first routing path processing function, and the first routing path processing function performs unified naming processing on names of folders and then stores the processing result into the routing path variable;
Deleting the 'in each page path information, and storing the' in a file path variable file path;
acquiring predefined page layout parameters and setting a plurality of attributes in module variables of a page module for use in generating a routing configuration table;
wherein the names of the respective folders do not repeat.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the traversal operation may be completed using a required. And/or the number of the groups of groups,
the first path routing function replaces a first regular expression in the folder name with a second regular expression or replaces a "-" in the folder name with "_j"; and/or the number of the groups of groups,
the processing performed by the second path routing function specifically includes: the page path information is removed according to "/" after segmentation "," and "index. Jsx".
3. The method according to claim 1 or 2, characterized by obtaining predefined page layout parameters and setting a plurality of attributes in module variables of the page module for use in generating a routing configuration table, in particular comprising:
obtaining a predefined page layout current path layout parameter through analysis and storing the predefined page layout current path layout parameter into a layout variable;
The plurality of attributes stored in the module variables are respectively set for use in generating a routing configuration table.
4. The method of claim 3, wherein the step of,
the plurality of attributes in the module variable are at least one or more of: a path attribute, an import attribute, a layout attribute, an exact attribute; and/or the number of the groups of groups,
the setting of the plurality of attributes stored in the module variables for use in generating a routing configuration table specifically includes: and splicing the PATH parameter and the routing PATH into a complete routing PATH, importing a file PATH under the pages directory as a reference module, and if a predefined layout parameter is set to be layout= = = 'user', directly without a menu directory, determining whether the routing is strictly matched according to userExact information and PATH information.
5. A contracted routing configuration device, comprising:
the provisioning setting module is used for provisioning the name of the folder where the page pages are located, which is the page module corresponding to the routing configuration;
the name processing module is used for carrying out unified naming processing on the names of the folders through defined functions when the files in the folders are named, and specifically comprises the following steps:
The page information storage module is used for traversing all index page pages below a folder where the page pages are located and storing page path information of all the page pages into file variables;
the default route information storage module is used for acquiring default route information and storing the default route information into a module variable;
the first routing path processing function definition module is used for defining a first routing path processing function and carrying out unified naming processing on names of folders in file naming;
the first page path information processing module is used for processing the page path information of all page pages stored in the file variable, judging whether the page path information of each page in the file variable is an index file under a folder where the page pages are located, and returning to not process the page path information if the page path information is an index file under the folder where the page pages are located;
the second routing path processing function definition module is used for defining a second routing path processing function and carrying out unified naming processing on the page path information of all the page pages stored in the file variable;
the second routing path information processing module is used for carrying out unified naming processing on the page path information of all the page pages stored in the file variable by calling the second routing path processing function in turn if the first routing path information processing module judges that the first routing path information processing module does not exist;
The third page path information processing module is used for deleting the 'in each page path information and storing the' in a file path variable file path;
the configuration using module is used for acquiring predefined page layout parameters and setting a plurality of attributes in module variables of the page module for use in generating a route configuration table;
wherein the names of the respective folders do not repeat.
6. The device according to claim 5, wherein the configuration using module specifically comprises:
the page layout parameter storage module is used for acquiring a predefined page layout current path layout parameter through analysis and storing the predefined page layout current path layout parameter into a layout variable;
and the module attribute setting module is used for setting a plurality of attributes stored in the module variables respectively for use in generating a routing configuration table.
7. The apparatus according to claim 6, wherein:
the traversal operation may be completed using a required. And/or the number of the groups of groups,
the first path routing function replaces a first regular expression in the folder name with a second regular expression, or replaces a "-" in the folder name with "_j"; and/or the number of the groups of groups,
The processing performed by the second path routing function specifically includes: dividing the page path information according to "/" and then removing "," and "index. Jsx"; and/or the number of the groups of groups,
the plurality of attributes in the module variable are at least one or more of: a path attribute, an import attribute, a layout attribute, an exact attribute; and/or the number of the groups of groups,
the setting of the plurality of attributes stored in the module variables for use in generating a routing configuration table specifically includes: and splicing the PATH parameter and the routing PATH into a complete routing PATH, importing a file PATH under the pages directory as a reference module, and if a predefined layout parameter is set to be layout= = = 'user', directly without a menu directory, determining whether the routing is strictly matched according to userExact information and PATH information.
8. A contracted routing configuration system, comprising:
a memory for storing a computer executable program;
data processing means for reading the computer executable program in the memory to perform the route configuration method of any one of claims 1 to 4.
9. A computer readable medium storing a computer readable program for executing the route configuration method according to any one of claims 1 to 4.
CN202110748430.1A 2021-07-02 2021-07-02 Method, device and system for configuring defined route Active CN113568605B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110748430.1A CN113568605B (en) 2021-07-02 2021-07-02 Method, device and system for configuring defined route

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110748430.1A CN113568605B (en) 2021-07-02 2021-07-02 Method, device and system for configuring defined route

Publications (2)

Publication Number Publication Date
CN113568605A CN113568605A (en) 2021-10-29
CN113568605B true CN113568605B (en) 2024-02-09

Family

ID=78163443

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110748430.1A Active CN113568605B (en) 2021-07-02 2021-07-02 Method, device and system for configuring defined route

Country Status (1)

Country Link
CN (1) CN113568605B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114268538A (en) * 2021-12-08 2022-04-01 马上消费金融股份有限公司 Configuration method and device of front-end route
CN117112021B (en) * 2023-10-24 2024-01-26 腾讯科技(深圳)有限公司 Route configuration generation method, device, equipment and computer readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108390773A (en) * 2018-02-02 2018-08-10 上海汉得信息技术股份有限公司 A kind of method and apparatus of dynamic routing for scaffold
CN109739479A (en) * 2018-10-29 2019-05-10 深圳壹账通智能科技有限公司 A kind of front end structure method for implanting and device
CN110502232A (en) * 2018-05-16 2019-11-26 杭州海康威视系统技术有限公司 The routing address configuration method and configuration device of page application
CN111273898A (en) * 2020-02-25 2020-06-12 安徽以萨数据技术有限公司 Web front-end code automatic construction method, system and storage medium
CN111443908A (en) * 2020-03-19 2020-07-24 深圳市震有软件科技有限公司 vue method, device, equipment and medium for realizing route interaction of multiple independent pages

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108390773A (en) * 2018-02-02 2018-08-10 上海汉得信息技术股份有限公司 A kind of method and apparatus of dynamic routing for scaffold
CN110502232A (en) * 2018-05-16 2019-11-26 杭州海康威视系统技术有限公司 The routing address configuration method and configuration device of page application
CN109739479A (en) * 2018-10-29 2019-05-10 深圳壹账通智能科技有限公司 A kind of front end structure method for implanting and device
CN111273898A (en) * 2020-02-25 2020-06-12 安徽以萨数据技术有限公司 Web front-end code automatic construction method, system and storage medium
CN111443908A (en) * 2020-03-19 2020-07-24 深圳市震有软件科技有限公司 vue method, device, equipment and medium for realizing route interaction of multiple independent pages

Also Published As

Publication number Publication date
CN113568605A (en) 2021-10-29

Similar Documents

Publication Publication Date Title
CN113568605B (en) Method, device and system for configuring defined route
CN105335137A (en) Method and device used for processing source file
CN113283613B (en) Deep learning model generation method, optimization method, device, equipment and medium
CN113312377A (en) Automatic-association SQL query statement processing method and device and electronic equipment
CN104375875A (en) Method for compiler optimization of applications and compiler
CN113419789A (en) Method and device for generating data model script
CN112988163B (en) Intelligent adaptation method, intelligent adaptation device, intelligent adaptation electronic equipment and intelligent adaptation medium for programming language
CN114153473A (en) Module integration method, device, storage medium and electronic equipment
US10169725B2 (en) Change-request analysis
CN111221852A (en) Mixed query processing method and device based on big data
CN117008920A (en) Engine system, request processing method and device, computer equipment and storage medium
WO2023160327A1 (en) Container image management
US20160350090A1 (en) Information processing apparatus, method of compiling, and storage medium
US11182272B2 (en) Application state monitoring
CN115167822A (en) Branch code merging method, device, equipment and storage medium
CN113901025A (en) Database management method, device, equipment and storage medium
CN111752912B (en) Data processing method and device
CN110471708B (en) Method and device for acquiring configuration items based on reusable components
CN112988583A (en) Method and device for testing syntax compatibility of database
CN111176718A (en) Script online method and device, storage medium and electronic equipment
CN112988778A (en) Method and device for processing database query script
CN113590088B (en) Method and device for automatically analyzing use condition of component and electronic equipment
CN115563183B (en) Query method, query device and program product
CN111273956B (en) Program module loading method, device, equipment and storage medium
US11662989B2 (en) Pointer alignment computation in program code according to code pattern analyses

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant