CN113568605A - Method, device and system for configuring constrained route - Google Patents

Method, device and system for configuring constrained route Download PDF

Info

Publication number
CN113568605A
CN113568605A CN202110748430.1A CN202110748430A CN113568605A CN 113568605 A CN113568605 A CN 113568605A CN 202110748430 A CN202110748430 A CN 202110748430A CN 113568605 A CN113568605 A CN 113568605A
Authority
CN
China
Prior art keywords
page
path
routing
module
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.)
Granted
Application number
CN202110748430.1A
Other languages
Chinese (zh)
Other versions
CN113568605B (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

Images

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, provides a method, a device, a system and a medium for appointed route configuration aiming at the defects of poor flexibility, low efficiency, high cost and the like of the existing front-end development, and aims to solve the technical problems of reducing the complexity of developing a front-end route, even maintaining the flexibility, improving the efficiency and the like. To this end, the method includes setting a contract; traversing all index pages below the pages folder; acquiring default routing information; defining a first routing path processing function; processing the page path information; defining a second routing path processing function; sequentially calling a second function to process the page path information; delete "-" in the path information of the page; acquiring a predefined page layout parameter; and respectively setting a plurality of attributes of the modules variable 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 constrained route
Technical Field
The invention relates to the field of front-end development, in particular to a method, a device and a system for agreed route configuration and a computer readable medium.
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. Different technical frameworks are configured with a specified route in advance, and then the page is matched with the route when the page is accessed, and then the page is presented. Therefore, in some middle-platform projects, as the number of page pages increases, each new page addition needs to be manually configured to access the new page, so that for project developers, the same content is always configured repeatedly, and a large amount of repeated work exists. In addition, developers who newly join a team need to understand the configuration specification in advance, and thus, a great deal of cumbersome work also exists. When a module is completed by cooperation of multiple persons, the traditional mode is difficult to clearly split the service, so that code conflict is often solved, and the efficiency is reduced. To overcome this problem, a concept of "contract over configuration" is proposed in the backend framework Egg. The developers need to follow the same set of convention to carry out application development, the learning cost of the developers can be reduced by adopting the mode inside the team, the number of software developers who need to make decisions is reduced, and the developers can flow and are more flexible.
Based on this idea, a promissory routing scheme needs to be implemented in front-end development as well.
Disclosure of Invention
In order to solve the above problems, the present invention provides a method, an apparatus, a system and a computer readable medium for conventional route configuration, which aims to solve the technical problem of how to effectively reduce the complexity of developing a front-end route, and further solve the technical problem of how to maintain the flexibility of a team during front-end development and further improve the efficiency during front-end development.
In order to solve the above technical problem, a first aspect of the present invention provides an agreed routing configuration method, including the following steps: appointing a page module corresponding to the routing configuration to be named as a folder name where page pages are located; when naming files in a folder, carrying out uniform naming processing on the folder names through a defined function; 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 various folders are not repeated.
According to a preferred embodiment of the present invention, when naming a file in a folder, a unified naming process is performed on the folder name through a defined function, which specifically includes: traversing all index page pages under a folder where the page pages are located, and storing page path information of all the page pages into a file variable; acquiring default routing information and storing the default routing information into module variables; defining a first routing path processing function for carrying out uniform naming processing on names of folders when the files are named; processing the page path information of all the page pages stored in the file files 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 if so, returning to not process the page path information; if not, the page path information of all the page pages stored in the file files variable is uniformly named by sequentially calling a defined second routing path processing function; 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 uniform naming processing on the name of the folder and then stores the processing result in a routing path variable; deleting the ". multidot" in each page path information, and storing the ". multidot" in a file path variable filePath.
According to a preferred embodiment of the present invention, the traversal operation may be completed using a require. And/or the first path routing function replaces the first regular expression in the folder name with a second regular expression; and/or the processing performed by the second path routing function specifically includes: and dividing the page path information according to the '/' and then removing the '. and' index.
According to a preferred embodiment of the present invention, the replacing specifically comprises: replace "-" in the folder name with "_".
According to a preferred embodiment of the present invention, 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 specifically includes: acquiring a preset layout current path layout parameter of the page through analysis and storing the preset layout current path layout parameter into a layout variable; and respectively setting a plurality of attributes stored in the module variables for use in generating a routing configuration table.
According to a preferred embodiment of the present invention, the plurality of attributes of the module variable are at least one or more of the following: a path attribute, an import attribute, a layout attribute, and an exact attribute; and/or, the setting the plurality of attributes stored in the module variables respectively for use in generating a routing configuration table specifically includes: splicing the PATH parameters and the routing PATHs into a complete routing PATH, importing a file PATH under a pages directory as a reference module, if the preset layout parameter sets layout ═ user', directly needing no menu directory, and determining whether the routing is strictly matched according to user exact information and PATH information.
In order to solve the above technical problem, a second aspect of the present invention provides an agreed routing configuration apparatus, including: the appointment setting module is used for appointing a page module corresponding to the routing configuration to be named as a folder name where the pages are located; the name processing module is used for carrying out uniform naming processing on the folder names through a defined function when the files in the folder 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 so as to be used when a routing configuration table is generated; wherein the names of the various folders are not repeated.
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 the page path information of all the page pages into a file files variable; the default routing information storage module is used for acquiring default routing information and storing the default routing information into module variables; the first routing path processing function definition module is used for defining a first routing path processing function and is used for carrying out uniform naming processing on names of folders when the files are named; the first page path information processing module is used for processing the page path information of all the page pages stored in the file files 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 if so, returning to not process the page path information; a second routing path processing function defining module, configured to define a second routing path processing function, and perform uniform naming processing on the page path information of all the page pages stored in the file files variable; the second page path information processing module is used for carrying out uniform naming processing on the page path information of all the page pages stored in the file files variable by sequentially calling the second routing path processing function if the first page path information processing module judges whether the page path information is the page path information of all the page pages stored in the file files variable, sending a processing result to the first routing path processing function by the second routing path processing function, and storing the processing result into the routing path variable after the uniform naming processing is carried out on the names of the folders by the first routing path processing function; a third page path information processing module, configured to delete the "·" in each piece of page path information, and store the "·" in a file path variable filePath; the configuration and use module specifically comprises: the page layout parameter storage module is used for acquiring a preset page layout current path layout parameter through analysis and storing the preset page layout current path layout parameter into a layout variable; and the module attribute setting module is used for respectively setting a plurality of attributes stored in the module variables for use in generating a routing configuration table.
According to a preferred embodiment of the present invention, the traversal operation may be completed using a require. And/or the first path routing function replaces the first regular expression in the folder name with a second regular expression, or replaces "-" in the folder name with "_"; and/or the processing performed by the second path routing function specifically includes: removing the page path information according to the '/' after segmentation '. and ' index.jsx '; and/or the plurality of attributes in the module variables are at least one or more of the following: a path attribute, an import attribute, a layout attribute, and an exact attribute; and/or, the setting the plurality of attributes stored in the module variables respectively for use in generating a routing configuration table specifically includes: splicing the PATH parameters and the routing PATHs into a complete routing PATH, importing a file PATH under a pages directory as a reference module, if the preset layout parameter sets layout ═ user', directly needing no menu directory, and determining whether the routing is strictly matched according to user exact information and PATH information. In order to solve the above technical problem, a third aspect of the present invention provides an agreed routing configuration system, including: a memory for storing computer executable instructions; data processing apparatus for reading a computer executable program in said memory to perform the method steps of said 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.
The invention does not need to carry out route configuration on each developed page one by one, so developers only need to pay attention to own codes, can automatically read the file directory and automatically generate the front-end route according to the file naming standard during development, and can uniformly configure the route by uniformly processing the route naming, thereby effectively saving the workload of the developers, keeping the flexibility of the realization of the front-end development, leading the code logic to be simpler and easier to maintain, being beneficial to reducing the complexity during the development of the front-end route and improving the efficiency.
Drawings
In order to make the technical problems solved by the present invention, the technical means adopted and the technical effects obtained more clear, the following will describe in detail the embodiments of the present invention with reference to the accompanying drawings. It should be noted, however, that the drawings described below are only illustrations of exemplary embodiments of the invention, from which other embodiments can be derived by those skilled in the art without inventive step.
FIG. 1 is a flow diagram for one embodiment of a contracted route configuration method, in accordance with the present invention;
fig. 2 is a schematic main flow chart of implementation of a provisioning routing procedure in an embodiment of the provisioning routing configuration method according to the present invention.
Fig. 3 is a main structural block diagram of an implementation of a provisioning routing procedure in an embodiment of a provisioning routing configuration apparatus according to the present invention.
FIG. 4 is a block diagram of an architectural framework for an embodiment of a promissory routing configuration system according to 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 of the invention may be embodied in many specific forms, and should not be construed as limited to the embodiments set forth herein. 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, properties, effects or other characteristics described in a certain embodiment may be combined in any suitable manner in one or more other embodiments, while still complying with the technical idea of the invention.
In describing particular embodiments, specific details of structures, properties, effects, or other features are set forth in order to provide a thorough understanding of the embodiments by one skilled in the art. However, it is not excluded that a person skilled in the art may implement the invention in a specific case without the above-described structures, performances, effects or other features.
The flow chart in the drawings is only an exemplary flow demonstration, and does not represent that all the contents, operations and steps in the flow chart are necessarily included in the scheme of the invention, nor does it represent that the execution is necessarily performed in the order shown in the drawings. For example, some operations/steps in the flowcharts may be divided, some operations/steps may be combined or partially combined, and the like, and the execution order 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. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The same reference numerals denote the same or similar elements, components, or parts throughout the drawings, and thus, a repetitive description thereof may be omitted hereinafter. It will be further understood that, although the terms first, second, third, etc. may be used herein to describe various elements, components, or sections, these elements, components, or sections should not be limited by these terms. That is, these phrases are used only to distinguish one from another. For example, a first device may also be referred to as a second device without departing from the spirit of the present invention. Furthermore, the term "and/or", "and/or" is intended to include all combinations of any one or more of the listed items.
In one embodiment of the technical scheme of the agreed route configuration provided by the invention, a front-end agreed route configuration method is provided, the method follows agreement during development, only needs to name according to a file naming specification, can automatically read a file directory when generating a project, and further automatically generates a front-end route.
Specifically, in one embodiment of the method, a convention is mainly set during development, and each new page can be developed in a mode according to parameters and attributes by traversing an index page, acquiring default routing information, defining a routing path processing function and page processing path information, removing specific symbols in the page path information, acquiring page layout parameters and setting attributes, so that the method is simple, convenient, efficient and easy to maintain, and effectively reduces the complexity of a development stage.
[ example 1 ]
The following describes implementation of the technical solution of the present invention with reference to a flowchart of an embodiment of an agreed route configuration method according to the present invention shown in fig. 1.
An embodiment of the method comprises the steps of: s1, setting convention, namely naming the page module corresponding to the routing configuration as a folder name where the page pages are located; s2, when naming the files in the folder, carrying out uniform naming processing on the folder names through a defined function; s3, 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; wherein the names of the various folders are not repeated. And determining the actual front-end route of the newly added page by the route configuration table, and matching the route with the corresponding route and accessing the page when accessing the newly added page.
Further, the route is typically generated by loading all pages (whether new or old) in this embodiment. For example:
at S1, a convention may be preset to default the name of the page module/page routing module to the name of the folder in which the page resides. Wherein the names of the various folders are not repeated.
Then at S2, the files in the folder are named and the folder names are uniformly named. The method comprises the following steps:
s2a, firstly, traversing all index pages under the folder where the pages are located, storing the page path information of all the pages into file variables (files variables), and further obtaining default routing information and storing the default routing information into module variables (modules variables).
S2b, defining a first routing path processing function (first function for short), and naming the names of the folders of the files uniformly when the files are named.
S2c, processing the path information of all the pages under the folder where the pages in the files variable are stored, judging whether the path information of each page in the files variable is an index (such as index. jsx) file under the files 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 the second function for short) to perform uniform naming processing on the page path information of all the pages under the folder where the pages stored in the files variable are located in sequence, sending the uniformly named processing result to the first function (namely turning to S2b to perform uniform processing on the name of the folder), and storing the processing result in the routing path variable.
S2e, deletes the specific symbol (e.g., ") in each page path information, and stores the symbol in the file path variable filePath.
Wherein the names of the various folders are not repeated.
S3, acquiring predefined page layout parameters and setting attributes of module variables of the page module, specifically for example:
and S3a, acquiring a predefined layout parameter of the page and saving the parameter into a layout variable.
And S3b, setting the path attribute, import attribute, layout attribute, exact attribute and the like of the modules variable for storing the routing information respectively, and using the path attribute, the import attribute, the layout attribute, the exact attribute and the like when a new page is added and a routing configuration table needs to be generated.
Finally, the page module is output (as the default module).
When the routing configuration table is generated, module pushing is performed, and the routing configuration table can be configured according to the attribute every time a page is newly added.
[ example 2 ]
Further, with reference to the main flow diagram for implementing the configuration-agreed routing procedure in an embodiment of the technical solution according to the present invention shown in fig. 2, the implementation process of the present invention is described from the process of route configuration developed by the front end of practical application.
Loading all pages generates a routing configuration. Specifically, for example, the method may include the following steps:
s101: and setting convention, wherein a convention page routing module is named as a folder name of a page, and folders of the modules cannot be renamed.
The method specifically comprises the following steps: appointing the names of the page modules corresponding to the routing configuration to be generated, defaulting to the names of the folders where 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 the page path information of all the pages into files variable constfiles.
Wherein the pages are a page component directory of a front end engineering project source file. The traversal operation may be completed using a require.
The requirement.
Context (directory, usesbDirectories, regExp), wherein:
a directory: a description is given of the directory that needs to be retrieved,
usesbdirectories: whether or not to retrieve a sub-directory,
regExp-regular expression that matches a file, typically the file name.
In the embodiment of the present invention, all operations that require unified batch processing may be completed using a require.
In a particular embodiment, the index page is an index.
S103: and acquiring default routing information and storing the default routing information to modules variables.
S104: a first routing path processing function is defined.
In one embodiment, the first routing path processing function performs uniform 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 present invention, and the first function may be a getPath function.
Further, in one particular embodiment, the first function uses regular expressions to uniformly name the names of folders.
For example, the first function may replace a first regular expression in a folder name with a second regular expression, e.g., replace "-" with "_".
For example, the first function may add a predetermined character, such as "v 2/" in the address bar in a unified manner.
For example, the first function may delete a predetermined character such as "v 2/" in the address bar in a unified manner.
Of course, the above-mentioned unified routing naming is only exemplary, and those skilled in the art may set other naming modes according to the actual situation, and the present invention is not limited thereto.
In this embodiment of the present invention, an example will be specifically described in which the first function replaces "-" in the folder name with "_" at the time of naming.
S105: processing the path information of all the pages stored in the files variable under the pages folder, mainly judging whether the path information of each page in the files variable is an index (such as 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 processing function performs uniform naming processing on the page path information of all the pages stored in the pages folder in the files variable. The second path routing processing function is abbreviated as a second function, and the second function may be a PathArr function.
And the second function divides the page path information according to the '/' and then removes the '. and' index.
S107: and calling the second function to sequentially process the page path information of all the pages, sending the processing result to the first function by the second function, carrying out uniform naming processing on the names of the folders by the first function, and then storing the processing result into a routing path variable.
In this example, the second function divides the page path information of all pages according to "/" and then removes "-" and "index.
S108: deleting the ". quadrature" in the path information of the page, and storing the ". quadrature" in a file path variable filePath.
S109: and acquiring a predefined layout parameter of the page, and storing the layout parameter into a layout variable.
Specific examples thereof include: the operation may be accomplished using the resolution of the Tools module to obtain the current path parameters, such as the getParameterByName method.
S110: and respectively setting a path attribute, an import attribute, a layout attribute and an exact attribute of the modules variable for use in generating a routing configuration table.
The setting of the PATH attribute means that the PATH parameter and the PATH variable of the routing PATH are spliced into a complete routing PATH, and the PATH attribute of the module is set.
The setting of the import attribute means that a file path filePath under the pages directory is imported as a reference module, and the import attribute of the 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 user Layout definition. If the predefined layout parameter layout ═ user', then the menu directory is not directly needed.
The setting of the exact attribute refers to determining whether the route is strictly matched according to the usereexact information and the path information to set the exact attribute of the module.
Specifically, for example, the PATH parameter and the routing PATH are first 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 the menu directory is not needed directly, and it is decided whether the route exactly matches according to the usereexact information and the path information. If the exact attribute is true, it indicates exact match, the path and location are required to be completely matched, and it is required to compare whether the matched route is consistent with the matching route, if the exact attribute is false, all sub-routes will directly return to the same page, so as to achieve the effect of not requiring menu directory. And storing the information into modules variables for generating a routing configuration table.
An example of the generation of the routing configuration table in the practical application scenario is as follows: processing all index pages under a predefined directory by traversing all the index pages, and then generating a routing configuration table:
route configuration table config [ { path:, import: > import ('), layout: false, exact } [ ]
For example:
[{path:path1,import:()=>import('path1'),layout:false,exact:true},
{path:path2,import:()=>import('path2'),layout:false,exact:true}
]
part of the code configuring the constrained routing may be as follows:
Figure BDA0003145122360000111
Figure BDA0003145122360000121
in the embodiment of the present invention, the constrained front-end routing is mainly implemented based on the read front-end JS framework, but those skilled in the art may also implement the constrained front-end routing of the present application using other frameworks according to the actual situation, for example, Vue, Angular, and the like, which is not limited in the present invention.
The constrained routing mode can automatically read files in the page directory, automatically generate routes according to file names, and if the files contain a plurality of single times, replace the single times with underlining lines to form paths, developers can automatically generate route configuration objects without paying attention to route configuration. And a uniform entry of the route can be realized.
[ example 3 ]
The following describes implementation of the technical solution of the present invention with reference to a main structural block diagram of implementation of provisioning routing procedure in an embodiment of a provisioning routing configuration apparatus according to the present invention shown in fig. 3. An embodiment of the apparatus may correspond to the method of embodiment 2.
As shown in fig. 3, the apparatus includes an agreement setting module 201, a page information storage module 202, a default routing information storage module 203, a first routing path processing function definition module 204, a first page path information processing module 205, a second routing 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 storage module 209, and a modules attribute setting module 210.
In one embodiment, the appointment setting module 201 may be configured to set an appointment, for example, an appointment page routing module routes a folder name named as a page, and each module folder cannot rename.
The method specifically comprises the following steps: appointing the names of the page modules corresponding to the routing configuration to be generated, defaulting to the names of the folders where 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 folder names can be uniformly named through a defined function. Specific examples thereof include:
the page information saving module 202 may be configured to traverse all index pages below the pages folder, and save the page path information of all the pages to the files variable const files.
Wherein the pages are a page component directory of a front end engineering project source file. The traversal operation may be completed using a require.
The requirement.
Context (directory, usesbDirectories, regExp), wherein:
a directory: a description is given of the directory that needs to be retrieved,
usesbdirectories: whether or not to retrieve a sub-directory,
regExp-regular expression that matches a file, typically the file name.
In the embodiment of the present invention, all operations that require unified batch processing may be completed using a require.
In a particular embodiment, the index page is an index.
The default routing information saving module 203 may be configured to obtain default routing information and save the default routing information to modules variables.
The first routing path processing function defining module 204 may be configured to define a first routing path processing function.
In one embodiment, the first routing path processing function performs uniform 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 present invention, and the first function may be a getPath function.
Further, in one particular embodiment, the first function uses regular expressions to uniformly name the names of folders.
For example, the first function may replace a first regular expression in a folder name with a second regular expression, e.g., replace "-" with "_".
For example, the first function may add a predetermined character, such as "v 2/" in the address bar in a unified manner.
For example, the first function may delete a predetermined character such as "v 2/" in the address bar in a unified manner.
Of course, the above-mentioned unified routing naming is only exemplary, and those skilled in the art may set other naming modes according to the actual situation, and the present invention is not limited thereto.
In this embodiment of the present invention, an example will be specifically described in which the first function replaces "-" in the folder name with "_" at the time of naming.
The first page path information processing module 205 may be configured to process the path information of all the pages in the pages folder stored in the files variable, mainly determine whether the path information of each page in the files variable is an index (e.g., index. jsx) file in the pages folder, and if so, return to not process the path information.
A second routing path processing function definition module 206 may be used to define a second routing path processing function.
In one embodiment, the second path routing processing function performs uniform naming processing on the page path information of all the pages stored in the pages folder in the files variable. The second path routing processing function is abbreviated as a second function, and the second function may be a PathArr function.
And the second function divides the page path information according to the '/' and then removes the '. and' index.
The second page path information processing module 207 may be configured to call the second function to sequentially process the page path information of all the pages. The second function sends the processing result to the first routing path processing function definition module 204, and the first function performs uniform naming processing on the name of the folder, and then stores the processing result in the routing path variable.
In this example, the second function divides the page path information of all pages according to "/" and then removes "-" and "index.
The third page path information processing module 208 may be configured to delete the "·" in the path information of the page, and store the ". multidot..
In one embodiment, when generating the routing configuration table, parameters, attributes, and the like need to be acquired and set (configuration using module), specifically, for example:
the page layout parameter storage module 209 may be configured to obtain a predefined page layout parameter and store the predefined page layout parameter in the layout variable.
Specific examples thereof include: the operation may be accomplished using the resolution of the Tools module to obtain the current path parameters, 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.
The setting of the PATH attribute means that the PATH parameter and the PATH variable of the routing PATH are spliced into a complete routing PATH, and the PATH attribute of the module is set.
The setting of the import attribute means that a file path filePath under the pages directory is imported as a reference module, and the import attribute of the 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 user Layout definition. If the predefined layout parameter layout ═ user', then the menu directory is not directly needed.
The setting of the exact attribute refers to determining whether the route is strictly matched according to the usereexact information and the path information to set the exact attribute of the module.
Specifically, for example, the PATH parameter and the routing PATH are first 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 the menu directory is not needed directly, and it is decided whether the route exactly matches according to the usereexact information and the path information. If the exact attribute is true, it indicates exact match, the path and location are required to be completely matched, and it is required to compare whether the matched route is consistent with the matching route, if the exact attribute is false, all sub-routes will directly return to the same page, so as to achieve the effect of not requiring menu directory. And storing the information into modules variables for generating a routing configuration table.
An example of the generation of the routing configuration table in the practical application scenario is as follows: processing all index pages under a predefined directory by traversing all the index pages, and then generating a routing configuration table:
route configuration table config [ { path:, import: > import ('), layout: false, exact } [ ]
For example:
[{path:path1,import:()=>import('path1'),layout:false,exact:true},
{path:path2,import:()=>import('path2'),layout:false,exact:true}
]
part of the code configuring the constrained routing may be as follows:
Figure BDA0003145122360000161
Figure BDA0003145122360000171
[ example 4 ]
Fig. 4 is a schematic structural framework diagram of an embodiment of the agreed routing configuration system according to the present invention, and as shown in fig. 4, the system 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 execute the agreed 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 invention can be a local memory, and can also be a distributed storage system, such as a cloud storage system. The data processor includes at least one device having digital information processing capability, such as a CPU, GPU, multi-processor 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 can be seen 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 considered supplementary to, and not limiting to, the embodiments of the method or apparatus/system described above, merely as an illustrative illustration of one local system situation, and should not bring any limitations to the function 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 the 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 apparatus), at least one storage unit 220 (i.e., an example of a specific memory), a bus 230 connecting 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 a computer readable program, which may be a code of a source program or a read-only program. 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 a random access memory unit (RAM)2201 and/or a cache memory unit 2202, and may further include a read only memory unit (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 of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 230 may be 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.), enable a user to interact with the system 200 via the external devices 300, and/or enable the system 200 to communicate with one or more other data processing devices (e.g., router, modem, etc.). Such communication may occur via input/output (I/O) interfaces 250, and may also occur via network adapter 260 with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network such as the Internet). The network adapter 260 may communicate with other modules of the electronic device 200 via the bus 230. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in the electronic device 200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
[ example 5 ]
In particular, a computer readable medium is also included, which stores one or more programs, wherein the one or more programs, when executed by a processor, implement the embodiment steps related to the method of the present invention in the aforementioned embodiments 1 and 2. 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.
Those skilled in the art will appreciate that all or part of the steps for implementing the above-described embodiments are implemented as programs executed by data processing apparatuses (including computers), i.e., computer programs. When the computer program is executed, the method provided by the invention can be realized. Also, 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. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: 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 any suitable combination of the foregoing, such as a storage array comprised of a plurality of storage media, e.g., a magnetic disk or tape storage array. The computer program, when executed by one or more data processing devices, enables the computer-readable medium to implement the above-described methods of the present invention. Further, the storage medium is not limited to a centralized storage, but may be a distributed storage, such as a cloud storage based on cloud computing. It should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes described in a single embodiment or with reference to a single figure, for the purpose of streamlining the disclosure and aiding in the understanding of various aspects of the invention by those skilled in the art. However, the present invention should not be construed such that the features included in the exemplary embodiments are all the essential technical features of the patent claims.
Further, those skilled in the art will readily appreciate that the exemplary embodiments of the present invention described herein may be implemented by software, or by a combination of software and hardware as necessary. Therefore, the technical solution according to the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a computer readable medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to make a data processing device (which can be a personal computer, a server, or a network device, etc.) execute the above method according to the present invention. The computer readable medium may comprise a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable storage medium may also be any readable medium that is not a readable storage medium and 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 for aspects 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 and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, 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., through the internet using an internet service provider).
Thus, the present invention may be embodied as a method, system, electronic device, 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 a Digital Signal Processor (DSP).
It should be understood that the modules, units, components, and the like included in the device of one embodiment of the present invention may be adaptively changed to be provided in a device different from that of the embodiment. The different modules, units or components comprised by the apparatus of an embodiment 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 in the embodiments of the present invention may be implemented in hardware, or may be implemented in software running on one or more processors, or a combination thereof.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention and are not intended to limit the present invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
In summary, the present invention can be implemented as 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 a Digital Signal Processor (DSP).
While the foregoing embodiments have described the objects, aspects and advantages of the present invention in further detail, it should be understood that the present invention is not inherently related to any particular computer, virtual machine or electronic device, and various general-purpose machines may be used to implement the present invention. The invention is not to be considered as limited to the specific embodiments thereof, but is to be understood as being modified in all respects, all changes and equivalents that come within the spirit and scope of the invention.

Claims (10)

1. A method for provisioning routing, the method comprising the steps of:
appointing a page module corresponding to the routing configuration to be named as a folder name where page pages are located;
when naming files in a folder, carrying out uniform naming processing on the folder names through a defined function;
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 various folders are not repeated.
2. The method according to claim 1, wherein when naming a file in a folder, the uniform naming process is performed on the folder name through a defined function, and specifically comprises:
traversing all index page pages under a folder where the page pages are located, and storing page path information of all the page pages into a file variable;
acquiring default routing information and storing the default routing information into module variables;
defining a first routing path processing function for carrying out uniform naming processing on names of folders when the files are named;
processing the page path information of all the page pages stored in the file files 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 if so, returning to not process the page path information;
if not, the second routing path processing function defined is called in sequence to carry out uniform naming processing on the page path information of all the page pages stored in the file files 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 carries out uniform naming processing on the name of the folder and stores the processing result into the routing path variable;
deleting the ". multidot" in each page path information, and storing the ". multidot" in a file path variable filePath.
3. The method of claim 2,
the traversal operation may be completed using a require.
And/or the presence of a gas in the gas,
the first path routing function replaces a first regular expression in the folder name with a second regular expression or replaces "-" in the folder name with "_";
and/or the presence of a gas in the gas,
the processing performed by the second path routing function specifically includes: and dividing the page path information according to the '/' and then removing the '. and' index.
4. The method according to any one of claims 1 to 3, wherein 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 specifically comprises:
acquiring a preset layout current path layout parameter of the page through analysis and storing the preset layout current path layout parameter into a layout variable;
and respectively setting a plurality of attributes stored in the module variables for use in generating a routing configuration table.
5. The method of claim 4,
the plurality of attributes in the module variables are at least one or more of: a path attribute, an import attribute, a layout attribute, and an exact attribute;
and/or the presence of a gas in the gas,
the setting of the plurality of attributes stored in the module variables respectively for use in generating a routing configuration table specifically includes: splicing the PATH parameters and the routing PATHs into a complete routing PATH, importing a file PATH under a pages directory as a reference module, if the preset layout parameter sets layout ═ user', directly needing no menu directory, and determining whether the routing is strictly matched according to user exact information and PATH information.
6. An agreed upon route configuration device, comprising:
the appointment setting module is used for appointing a page module corresponding to the routing configuration to be named as a folder name where the pages are located;
the name processing module is used for carrying out uniform naming processing on the folder names through a defined function when the files in the folder 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 so as to be used when a routing configuration table is generated;
wherein the names of the various folders are not repeated.
7. The apparatus of claim 6,
the name processing module specifically comprises:
the page information storage module is used for traversing all index page pages below a folder where the page pages are located and storing the page path information of all the page pages into a file files variable;
the default routing information storage module is used for acquiring default routing information and storing the default routing information into module variables;
the first routing path processing function definition module is used for defining a first routing path processing function and is used for carrying out uniform naming processing on names of folders when the files are named;
the first page path information processing module is used for processing the page path information of all the page pages stored in the file files 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 if so, returning to not process the page path information;
a second routing path processing function defining module, configured to define a second routing path processing function, and perform uniform naming processing on the page path information of all the page pages stored in the file files variable;
the second page path information processing module is used for carrying out uniform naming processing on the page path information of all the page pages stored in the file files variable by sequentially calling the second routing path processing function if the first page path information processing module judges whether the page path information is the page path information of all the page pages stored in the file files variable, sending a processing result to the first routing path processing function by the second routing path processing function, and storing the processing result into the routing path variable after the uniform naming processing is carried out on the names of the folders by the first routing path processing function;
a third page path information processing module, configured to delete the "·" in each piece of page path information, and store the "·" in a file path variable filePath;
the configuration and use module specifically comprises:
the page layout parameter storage module is used for acquiring a preset page layout current path layout parameter through analysis and storing the preset page layout current path layout parameter into a layout variable;
and the module attribute setting module is used for respectively setting a plurality of attributes stored in the module variables for use in generating a routing configuration table.
8. The apparatus of claim 7, wherein:
the traversal operation may be completed using a require.
And/or the presence of a gas in the gas,
the first path routing function replaces a first regular expression in the folder name with a second regular expression, or replaces "-" in the folder name with "_";
and/or the presence of a gas in the gas,
the processing performed by the second path routing function specifically includes: removing the page path information according to the '/' after segmentation '. and ' index.jsx ';
and/or the presence of a gas in the gas,
the plurality of attributes in the module variables are at least one or more of: a path attribute, an import attribute, a layout attribute, and an exact attribute;
and/or the presence of a gas in the gas,
the setting of the plurality of attributes stored in the module variables respectively for use in generating a routing configuration table specifically includes: splicing the PATH parameters and the routing PATHs into a complete routing PATH, importing a file PATH under a pages directory as a reference module, if the preset layout parameter sets layout ═ user', directly needing no menu directory, and determining whether the routing is strictly matched according to user exact information and PATH information.
9. A promissory routing configuration system, comprising:
a memory for storing a computer executable program;
data processing apparatus for reading a computer executable program in said memory to perform the route configuration method of any of claims 1 to 5.
10. A computer-readable medium storing a computer-readable program for executing the route configuration method according to any one of claims 1 to 5.
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 true CN113568605A (en) 2021-10-29
CN113568605B 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)

Cited By (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
CN117112021A (en) * 2023-10-24 2023-11-24 腾讯科技(深圳)有限公司 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

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
果冻~: "umijs介绍及基本用法、配置式路由、约定式路由、路由传参等", Retrieved from the Internet <URL:https://blog.csdn.net/weixin_48653480/article/details/109011777> *

Cited By (3)

* 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
CN117112021A (en) * 2023-10-24 2023-11-24 腾讯科技(深圳)有限公司 Route configuration generation method, device, equipment and computer readable storage medium
CN117112021B (en) * 2023-10-24 2024-01-26 腾讯科技(深圳)有限公司 Route configuration generation method, device, equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN113568605B (en) 2024-02-09

Similar Documents

Publication Publication Date Title
WO2020119485A1 (en) Page display method and device, apparatus, and storage medium
US8661023B1 (en) Optimizing search query logic to speed retrieval
CN107943691B (en) Method and device for automatically generating function test page of intelligent contract
US20180295194A1 (en) Techniques for supporting remote micro-services as native functions in spreadsheet applications
US11048885B2 (en) Cognitive translation service integrated with context-sensitive derivations for determining program-integrated information relationships
CN113568605A (en) Method, device and system for configuring constrained route
US20160034272A1 (en) Managing a catalog of scripts
CN111626028A (en) Report generation method, device and equipment based on function analysis and computer medium
CN110975293A (en) Method, device, server and medium for establishing resource reference relation table
CN109726217A (en) A kind of database operation method, device, equipment and storage medium
US20140181786A1 (en) Generating debugging extension source code utilizing debugging information
CN112035443A (en) Big data execution method, system, equipment and storage medium based on Linux platform
CN113419789A (en) Method and device for generating data model script
US20140157227A1 (en) Method and system for preserving restful web service structure in a client consuming the restful web service
CN111078228A (en) Method and device for converting webpage into small program, server and storage medium
CN114356962A (en) Data query method and device, electronic equipment and storage medium
CN110888876A (en) Method and device for generating database script, storage medium and computer equipment
CN111221888A (en) Big data analysis system and method
CN112988163A (en) Intelligent programming language adaptation method and device, electronic equipment and medium
CN117008920A (en) Engine system, request processing method and device, computer equipment and storage medium
US9201937B2 (en) Rapid provisioning of information for business analytics
CN114153547B (en) Management page display method and device
CN111221860A (en) Mixed query optimization method and device based on big data
CN113760969A (en) Data query method and device based on elastic search
CN115563183B (en) Query method, query device and program product

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