CN109298883A - A kind of automatically generate component file method and electronic equipment under teaching platform - Google Patents

A kind of automatically generate component file method and electronic equipment under teaching platform Download PDF

Info

Publication number
CN109298883A
CN109298883A CN201810968111.XA CN201810968111A CN109298883A CN 109298883 A CN109298883 A CN 109298883A CN 201810968111 A CN201810968111 A CN 201810968111A CN 109298883 A CN109298883 A CN 109298883A
Authority
CN
China
Prior art keywords
file
under
npm
command
generates
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.)
Pending
Application number
CN201810968111.XA
Other languages
Chinese (zh)
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.)
Shenzhen Dianmao Technology Co Ltd
Original Assignee
Shenzhen Dianmao 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 Shenzhen Dianmao Technology Co Ltd filed Critical Shenzhen Dianmao Technology Co Ltd
Priority to CN201810968111.XA priority Critical patent/CN109298883A/en
Publication of CN109298883A publication Critical patent/CN109298883A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Library & Information Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The present invention discloses the method and electronic equipment for automatically generating component file under a kind of teaching platform, and method is comprising steps of A, setting automatically generate the script of react component, and the script is published to npm in the form of npm packet;B, global installation npm packet;C, it is executed under the target directory of project and generates file command;D, js file is automatically generated according to command parameter, the js file includes react life cycle function code.Through the invention, without addition component file manually and many identical assemblies codes of duplication, development efficiency is improved.And npm can be published to and carry out trustship, it can be general between disparity items.

Description

A kind of automatically generate component file method and electronic equipment under teaching platform
Technical field
The present invention relates to the sides for automatically generating component file under field of computer technology more particularly to a kind of teaching platform Method and electronic equipment.
Background technique
In the prior art, although project scaffold can be supported to automatically generate project directory, a foot is write every time It requires to write many duplicate codes when this document.
A usual component file includes js code and corresponding model code file, and it is non-to require manual adding procedure every time Normal cumbersome, low efficiency.
Therefore, the existing technology needs to be improved and developed.
Summary of the invention
In view of above-mentioned deficiencies of the prior art, the purpose of the present invention is to provide automatically generate group under a kind of teaching platform The method and electronic equipment of part file, it is intended to the problems such as solving cumbersome component file adding procedure in the prior art, low efficiency.
Technical scheme is as follows:
A kind of automatically generate component file method under teaching platform, wherein comprising steps of
A, setting automatically generates the script of react component, and the script is published to npm in the form of npm packet;
B, global installation npm packet;
C, it is executed under the target directory of project and generates file command;
D, js file is automatically generated according to command parameter, the js file includes react life cycle function code.
The method for automatically generating component file under the teaching platform, wherein the step D is specifically included:
Judge whether the command parameter includes pattern file parameters;
If the command parameter includes pattern file parameters, js file and model code file are automatically generated, if institute Stating command parameter includes pattern file parameters, then only generates js file.
The method for automatically generating component file under the teaching platform, wherein the step C is specifically included:
Under the target directory of project, order line is opened, executes and generates file command;
Judge under target directory whether existing js file, if then prompt is renamed, if otherwise entering step D.
The method for automatically generating component file under the teaching platform, wherein the step A is specifically included:
Definition generates file command, generates the script of react component.
The method for automatically generating component file under the teaching platform, wherein in the step D, utilize node.js Module for reading and writing creation component file folder, and the component file folder in be written js file.
The method for automatically generating component file under the teaching platform, wherein the react life cycle function generation Code is for initializing life cycle function.
A kind of electronic equipment, wherein include:
Processor is adapted for carrying out each instruction, and
Equipment is stored, is suitable for storing a plurality of instruction, described instruction is suitable for being loaded and being executed by processor:
The script for automatically generating react component is set, and the script is published to npm in the form of npm packet;
Overall situation installation npm packet;
It is executed under the target directory of project and generates file command;
Js file is automatically generated according to command parameter, the js file includes react life cycle function code.
The electronic equipment, wherein described to automatically generate js file according to command parameter, the js file includes The step of react life cycle function code, specifically includes:
Judge whether the command parameter includes pattern file parameters;
If the command parameter includes pattern file parameters, js file and model code file are automatically generated, if institute Stating command parameter includes pattern file parameters, then only generates js file.
A kind of non-volatile computer readable storage medium storing program for executing, wherein the non-volatile computer readable storage medium storing program for executing is deposited Computer executable instructions are contained, when which is executed by one or more processors, may make described one A or multiple processors execute the method for automatically generating component file under the teaching platform.
A kind of computer program product, wherein the computer program product can including being stored in non-volatile computer The computer program on storage medium is read, computer program includes program instruction, when program instruction is executed by processor, makes institute State the method for automatically generating component file under the processor execution teaching platform.
The utility model has the advantages that through the invention, without addition component file manually and many identical assemblies codes are replicated, Improve development efficiency.And npm can be published to and carry out trustship, it can be general between disparity items.
Detailed description of the invention
Fig. 1 is the process signal of the method preferred embodiment for automatically generating component file under a kind of teaching platform of the present invention Figure.
Fig. 2 is the structural block diagram of a kind of electronic equipment preferred embodiment of the present invention.
Specific embodiment
The present invention provides the method and electronic equipment for automatically generating component file under a kind of teaching platform, to make the present invention Purpose, technical solution and effect it is clearer, clear, the present invention is described in more detail below.It should be appreciated that this place The specific embodiment of description is only used to explain the present invention, is not intended to limit the present invention.
Referring to Fig. 1, Fig. 1 is the method for automatically generating component file under a kind of teaching platform of the present invention, comprising steps of
S1, setting automatically generate the script of react component, and the script is published to npm in the form of npm packet;
S2, global installation npm packet;
S3, generation file command is executed under the target directory of project;
S4, js file is automatically generated according to command parameter, the js file includes react life cycle function code.
Through the invention, without addition component file manually and many identical assemblies codes of duplication, exploitation is improved Efficiency.And npm can be published to and carry out trustship, it can be general between disparity items.
In the step S1, first setting automatically generates the script of react component, then by the script with npm packet Form is published to npm.
Further, the step S1 is specifically included:
Definition generates file command, generates the script of react component.
For example, first definition generates file command are as follows: react-g+ component Name+whether need pattern file+component catalog (being defaulted as current directory).Then it is passed to parameter, obtains incoming component Name and directory information.Regenerate js file.Certainly Aforesaid way is only for example, and script can also be arranged using other modes.
Npm is the packet management tool installed together in company with NodeJS, can solve many problems in the deployment of NodeJS code, Common usage scenario has following several: allowing user to download the third party that others writes from NPM server and wraps to local use. Allow user that order line program that others writes is downloaded and installed from NPM server to local use.User is allowed to compile oneself The packet or order line program write upload to NPM server and use for others.
In the step S2, overall situation installation npm packet.
It is used to that npm packet is installed there are two types of mode: locally-installed and global installation.It installs, takes as which kind of mode is selected Certainly in how using npm packet.
If a certain module is loaded dependent on some packet, and by the require of Node.js, then should be using local Installation, this mode is also the default behavior of npm install order.
If packet need to be used as to a command-line tool, (such as grunt CLI), then should be using global installation.
The overall situation is installed:
Npm packet can be placed on/usr/local under
Operation is such as issued orders: npm install-g grunt-cli
Subsequently into/usr/local/bin catalogue, grunt-cli has been placed on following at this time.
casperchenMacBookPro:bin casperchen$pwd
/usr/local/bin
casperchenMacBookPro:bin casperchen$ll grunt
lrwxr-xr-x 1root admin 39B 8 18 21:43grunt->../lib/node_modules/ grunt-cli/bin/grunt
As it can be seen that the true installation path of global module is at/usr/local/lib/node_modules/ ,/usr/ Executable file under local/bin is soft link.
Furthermore it is possible to directly used in order line, particular by creating soft link at `/usr/local/bin Mode is realized.The overall situation can allow user under any catalogue using this packet after installing this mounting means.
For example, executing the npm packet that npm react-g-save installation automatically generates component file under current project.At this time It needs to create a MyForm component under the src catalogue of current project.
In the step S3, it is executed under the target directory of project and generates file command.
Npm packet above-mentioned thus can be used, thus formation component file.Such as order is opened under project root Row, executes order: react-g MyForm true/src.
Further, the step S3 is specifically included:
Under the target directory of project, order line is opened, executes and generates file command;
Judge under target directory whether existing js file, if then prompt is renamed, if otherwise entering step S4.
That is, the target directory is defined parameter in file generated order, default directory is current directory.
In addition, it is also necessary to judge whether have existed js file under target directory, if had existed, need to carry out weight Name, such as the js file that will be generated is renamed, already present js file can also be renamed.
In the step S4, js file is automatically generated according to command parameter, the js file includes react life cycle Function code.That is formation component file, the component file are index.js file.
Further, the step S4 is specifically included:
Judge whether the command parameter includes pattern file parameters;
If the command parameter includes pattern file parameters, js file and model code file are automatically generated, if institute Stating command parameter includes pattern file parameters, then only generates js file.
The model code file is index.scss file.
In the present invention, the js file comprising react life cycle function code is not only produced, also produces model code File.Specifically determine whether to generate model code file according to whether including pattern file parameters in command parameter, if Command parameter includes pattern file parameters, then not only generates js file, while also generating model code file.If command parameter Not comprising pattern file parameters, then js file is only generated.That is, the pattern file parameters in the command parameter are optional Parameter, correspondingly, model code file is optional file.
Further, in the js file, the react life cycle function code is for initializing life cycle letter Number.Each component also can be created, update and delete in webpage, as lived body.React strict difinition The life cycle of component, life cycle may undergo following three process: loading process (Mount), that is, component The process once rendered in dom tree;Renewal process (Update), when the process that component is rendered again;Uninstall process (Unmount), the process that component is deleted from DOM.Three kinds of different processes, the library react can successively invocation component it is some at Member's function, these functions are known as life cycle function.So to customize a react component, these lifes are actually customized Order periodic function.
Further, it in the step S4, is pressed from both sides using the module for reading and writing creation component file of node.js, and in the component Js file is written in file.
Specifically, it is pressed from both sides using fs module (module for reading and writing) the creation component file of node.js, then in the component file Js file is written in folder.
Script (npm packet) is finished, and the MyForm file of generation can be seen under src catalogue, and contains Index.js file and index.scss file, and life cycle function and pattern have been initialized in index.js file The reference code of file.
The present invention does not have to addition component file manually and replicates many identical assemblies codes, improves development efficiency. Trustship is carried out by being published to npm, it can be general between disparity items.It can expand and automatically generate text for files in different types Part cli.
The present invention also provides a kind of electronic equipment 10, as shown in Figure 2, comprising:
Processor 110 is adapted for carrying out each instruction, and
Equipment 120 is stored, is suitable for storing a plurality of instruction, described instruction is suitable for being loaded and being executed by processor 110:
The script for automatically generating react component is set, and the script is published to npm in the form of npm packet;
Overall situation installation npm packet;
It is executed under the target directory of project and generates file command;
Js file is automatically generated according to command parameter, the js file includes react life cycle function code.
The processor 110 can for general processor, digital signal processor (DSP), specific integrated circuit (ASIC), Field programmable gate array (FPGA), single-chip microcontroller, ARM (Acorn RISC Machine) or other programmable logic device are divided Any combination of vertical door or transistor logic, discrete hardware component or these components.In addition, processor can also be any Conventional processors, microprocessor or state machine.Processor also may be implemented as calculating the combination of equipment, for example, DSP and Wei Chu Manage combination, multi-microprocessor, one or more microprocessors combination DSP core, any other this configuration of device.
It stores equipment 120 and is used as a kind of non-volatile computer readable storage medium storing program for executing, can be used for storing non-volatile software Program, non-volatile computer executable program and module, such as automatically generating under the teaching platform in the embodiment of the present invention The corresponding program instruction of the method for component file.Processor is stored in the non-volatile software journey in storage equipment by operation Sequence, instruction and unit, thereby executing the method for automatically generating component file under teaching platform various function application and Data processing, i.e. realization above method embodiment.
Further, described to automatically generate js file according to command parameter, the js file includes react life cycle function The step of code, specifically includes:
Judge whether the command parameter includes pattern file parameters;
If the command parameter includes pattern file parameters, js file and model code file are automatically generated, if institute Stating command parameter includes pattern file parameters, then only generates js file.
It has been described in detail in the method for particular technique details in front about above-mentioned electronic equipment 10, so it will not be repeated.
The present invention also provides a kind of non-volatile computer readable storage medium storing program for executing, the non-volatile computer readable storage Media storage has computer executable instructions, when which is executed by one or more processors, may make One or more of processors execute the method for automatically generating component file under the teaching platform.
The present invention also provides a kind of computer program product, the computer program product includes being stored in non-volatile meter Computer program on calculation machine readable storage medium storing program for executing, computer program include program instruction, when program instruction is executed by processor When, so that the processor is executed the method for automatically generating component file under the teaching platform.
It should be understood that the application of the present invention is not limited to the above for those of ordinary skills can With improvement or transformation based on the above description, all these modifications and variations all should belong to the guarantor of appended claims of the present invention Protect range.

Claims (10)

1. a kind of method for automatically generating component file under teaching platform, which is characterized in that comprising steps of
A, setting automatically generates the script of react component, and the script is published to npm in the form of npm packet;
B, global installation npm packet;
C, it is executed under the target directory of project and generates file command;
D, js file is automatically generated according to command parameter, the js file includes react life cycle function code.
2. the method for automatically generating component file under teaching platform according to claim 1, which is characterized in that the step Rapid D is specifically included:
Judge whether the command parameter includes pattern file parameters;
If the command parameter includes pattern file parameters, js file and model code file are automatically generated, if the life Enabling parameter includes pattern file parameters, then only generates js file.
3. the method for automatically generating component file under teaching platform according to claim 1, which is characterized in that the step Rapid C is specifically included:
Under the target directory of project, order line is opened, executes and generates file command;
Judge under target directory whether existing js file, if then prompt is renamed, if otherwise entering step D.
4. the method for automatically generating component file under teaching platform according to claim 1, which is characterized in that the step Rapid A is specifically included:
Definition generates file command, generates the script of react component.
5. the method for automatically generating component file under teaching platform according to claim 1, which is characterized in that the step In rapid D, pressed from both sides using the module for reading and writing creation component file of node.js, and js file is written in component file folder.
6. the method for automatically generating component file under teaching platform according to claim 1, which is characterized in that described React life cycle function code is for initializing life cycle function.
7. a kind of electronic equipment characterized by comprising
Processor is adapted for carrying out each instruction, and
Equipment is stored, is suitable for storing a plurality of instruction, described instruction is suitable for being loaded and being executed by processor:
The script for automatically generating react component is set, and the script is published to npm in the form of npm packet;
Overall situation installation npm packet;
It is executed under the target directory of project and generates file command;
Js file is automatically generated according to command parameter, the js file includes react life cycle function code.
8. electronic equipment according to claim 7, which is characterized in that it is described that js file is automatically generated according to command parameter, The step of js file includes react life cycle function code specifically includes:
Judge whether the command parameter includes pattern file parameters;
If the command parameter includes pattern file parameters, js file and model code file are automatically generated, if the life Enabling parameter includes pattern file parameters, then only generates js file.
9. a kind of non-volatile computer readable storage medium storing program for executing, which is characterized in that the non-volatile computer readable storage medium Matter is stored with computer executable instructions, when which is executed by one or more processors, may make institute State the side for automatically generating component file under the one or more processors perform claim requirement described in any item teaching platforms of 1-6 Method.
10. a kind of computer program product, which is characterized in that the computer program product includes being stored in non-volatile calculating Computer program on machine readable storage medium storing program for executing, computer program include program instruction, when program instruction is executed by processor, The processor perform claim is set to require the method for automatically generating component file under the described in any item teaching platforms of 1-6.
CN201810968111.XA 2018-08-23 2018-08-23 A kind of automatically generate component file method and electronic equipment under teaching platform Pending CN109298883A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810968111.XA CN109298883A (en) 2018-08-23 2018-08-23 A kind of automatically generate component file method and electronic equipment under teaching platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810968111.XA CN109298883A (en) 2018-08-23 2018-08-23 A kind of automatically generate component file method and electronic equipment under teaching platform

Publications (1)

Publication Number Publication Date
CN109298883A true CN109298883A (en) 2019-02-01

Family

ID=65165575

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810968111.XA Pending CN109298883A (en) 2018-08-23 2018-08-23 A kind of automatically generate component file method and electronic equipment under teaching platform

Country Status (1)

Country Link
CN (1) CN109298883A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110297647A (en) * 2019-05-29 2019-10-01 福建天泉教育科技有限公司 A kind of front end engineering updates the method and terminal of npm packet
CN111221524A (en) * 2019-12-29 2020-06-02 南京云帐房网络科技有限公司 Method and system for generating front-end module by one key

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843869A (en) * 2017-01-16 2017-06-13 百融(北京)金融信息服务股份有限公司 A kind of front end Development Engineering system and method
US20180081693A1 (en) * 2016-09-22 2018-03-22 Groupon, Inc. Mobile service applications

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180081693A1 (en) * 2016-09-22 2018-03-22 Groupon, Inc. Mobile service applications
CN106843869A (en) * 2017-01-16 2017-06-13 百融(北京)金融信息服务股份有限公司 A kind of front end Development Engineering system and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
仅此而已001: "从零开始写一个npm包,一键生成react组件(偷懒==提高效率)", 《HTTPS://BLOG.CSDN.NET/WEIXIN_41042393/ARTICLE/DETAILS/81561593》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110297647A (en) * 2019-05-29 2019-10-01 福建天泉教育科技有限公司 A kind of front end engineering updates the method and terminal of npm packet
CN110297647B (en) * 2019-05-29 2023-12-01 福建天泉教育科技有限公司 Method and terminal for updating npm packet by front-end engineering
CN111221524A (en) * 2019-12-29 2020-06-02 南京云帐房网络科技有限公司 Method and system for generating front-end module by one key
CN111221524B (en) * 2019-12-29 2024-02-09 云帐房网络科技有限公司 Method and system for generating front-end module by one key

Similar Documents

Publication Publication Date Title
CN104793946B (en) Dispositions method and system are applied based on cloud computing platform
US7814476B2 (en) Systems and methods for updating software
US5842024A (en) Method of software installation
US8490082B2 (en) System and method for representing user processes as software packages in a software package management system
US7926051B2 (en) Automatic parallel non-dependent component deployment
EP2245532B1 (en) Method and apparatus for generating virtual software platform based on component model and validating software platform architecture using the platform
US8020146B2 (en) Applying deferred refactoring and API changes in an IDE
EP0707264A2 (en) System and method for determining whether a software package conforms to packaging rules and requirements
US20210232388A1 (en) Software pipeline configuration
CN107506221A (en) Application program updating method, apparatus and equipment
CN100492387C (en) Method and system for software protected development based on Keil C51
CN111985055A (en) Model packaging method and device and electronic equipment
CN104346206A (en) Method and system for recovering installation of unloaded software
CN109298883A (en) A kind of automatically generate component file method and electronic equipment under teaching platform
Chakravarthy et al. Edicts: implementing features with flexible binding times
CN101571801A (en) Service expansion system and method
CN110647326A (en) NuGet program package-based software multiplexing method, device and system
CN104239112A (en) Device driver installation method and device
WO2019024392A1 (en) Dependency package tool verification method, storage medium, electronic device and system
CN111367512B (en) Method and device for creating Android library module dependency relationship in application development
CN114895916A (en) Code deployment method, device, storage medium and electronic equipment
Golemon Extending and Embedding PHP
CN110221821A (en) A kind of project function decoupling method and electronic equipment educated based on programming
CN105446718B (en) Method of managing software and system based on red cap software package manager
Markomanolis et al. Time-Independent Trace Acquisition Framework--A Grid'5000 How-to

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190201