Applet generation method, device, equipment and storage mediumTechnical Field
The embodiment of the invention relates to the technical field of computers, in particular to a small program generating method, a device, equipment and a storage medium.
Background
An applet is an application that can be used without download and installation. For users, the small program can save the use time cost and the storage space of the mobile terminal; for developers, applets can save development and promotion costs. Meanwhile, the small program is used as an important component of a large-scale internet platform product, and has a wide development prospect in the future.
In using applets, there may be a need for: 1. there is a customization requirement for the style of the applet (such as position, background map, color matching, font size, etc.); 2. the applet may present different data at each impression. In the existing applet development process, if the above requirements are met, a new applet generally needs to be developed again, so that the applet development period is long, and a large amount of redundancy exists in the development process.
Disclosure of Invention
Embodiments of the present invention provide an applet generating method, apparatus, device, and storage medium, which can shorten a development cycle of a program and facilitate change of the applet.
In a first aspect, an embodiment of the present invention provides an applet generating method, where the applet generating method includes:
determining a target configuration template of a target applet, wherein the target configuration template comprises a target data model configuration file, a target view and a business logic script file of the target applet;
acquiring configuration information corresponding to the target configuration template;
generating the target applet based on the target configuration template and the configuration parameters.
In a second aspect, an embodiment of the present invention further provides an applet generating apparatus, where the applet generating apparatus includes:
the target configuration template determining module is used for determining a target configuration template of a target applet, wherein the target configuration template comprises a target data model configuration file of the target applet, a target view and a service logic script file;
the configuration information acquisition module is used for acquiring the configuration information corresponding to the target configuration template;
and the target applet generating module is used for generating the target applet based on the target configuration template and the configuration parameters.
In a third aspect, an embodiment of the present invention further provides a computer device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the applet generation method as described above.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the applet generating method as described above.
The method comprises the steps that a target configuration template of a target small program is determined, wherein the target configuration template comprises a target data model configuration file of the target small program, a target view and a service logic script file; acquiring configuration information corresponding to a target configuration template; and generating a target applet based on the target configuration template and the configuration parameters, decoupling the configuration template of the target applet, and dividing the configuration template into a data model configuration file, a view and a service logic script file, so that the development cycle of the applet can be shortened, and the applet can be conveniently changed.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart of an applet generating method in one embodiment of the present invention;
FIG. 2a is a block diagram of an applet in a second embodiment of the present invention;
FIG. 2b is a flowchart of an applet generating method in the second embodiment of the present invention;
FIG. 2c is a schematic diagram of a configuration interface according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an applet generating apparatus in a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device in the fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of an applet generating method according to an embodiment of the present invention, where the method may be applied to a case where an applet needs to be generated, and the method may be executed by an applet generating apparatus, where the apparatus may be implemented in a software and/or hardware manner, and the apparatus may be configured in a computer device. As shown in fig. 1, the method may include the steps of:
s110, determining a target configuration template of the target small program, wherein the target configuration template comprises a target data model configuration file, a target view and a business logic script file of the target small program.
The applet can be used without downloading and installing, and when the applet is used, a user can obtain the applet by scanning a two-dimensional code or searching and the like, or the applet can be automatically launched when the fact that the applet launching condition is met is detected. The configuration template of the applet may be a program code corresponding to the data model of the applet, the view of the applet and the business logic of the applet, the program code preferably being derived based on the idea of decoupling the data model, the view and the business logic of the applet.
The configuration file is a computer file which can be used for configuring parameters and initial settings for a computer program, namely files for carrying out different configurations on different objects, the view can comprise a logic view, a development view (also called a module view or an implementation view) and a process view (or a process view), and the like.
It should be noted that the same data model may correspond to a plurality of different views and business logic, and thus, the same data model configuration file may correspond to a plurality of different view and business logic script files.
Preferably, before determining the target configuration template of the target applet, preset configuration templates corresponding to the preset applets are preset in the applet configuration template database based on the idea of decoupling the data model, the view and the service logic of the applet, wherein the preset configuration templates include preset data model configuration files of the preset applets, preset view script files and service logic script files.
In this embodiment, the target configuration template of the target applet may be determined according to the actual requirements input by the user, for example, if the actual requirements of the user include, but are not limited to, the type, style, and presented data of the target applet, the target configuration template of the target applet may be determined according to at least one of the target type, target style, or target presented data of the target applet. The type of the applet may include, but is not limited to, e-commerce, presentation, and appointment, the style of the applet may include, but is not limited to, background, color scheme, text content, and text size, and the presented data may include, but is not limited to, video, picture, or text. And determining the target configuration template of the target applet according to the unique identifier corresponding to the target configuration template input by the user. The target applet's target profile may also be determined from the known data model, view, and business logic entered by the user.
In this embodiment, preferably, according to the condition for determining the target configuration template input by the user, it may be determined whether the configuration template database includes the target data model configuration file, and then it is determined whether the configuration template database includes the target view and the service logic script file, or it may be determined whether the configuration template database includes the target data model configuration file and the target view and the service logic script file.
Preferably, determining the target configuration template of the target applet comprises:
determining whether a configuration template database comprises a target data model configuration file and a target view and service logic script file:
and if the target data model configuration file, the target view and the service logic script file are determined to be included, acquiring the target data model configuration file, the target view and the service logic script file from the configuration template database, and taking the target data model configuration file, the target view and the service logic script file as a target configuration template. Preferably, determining the target configuration template of the target applet further comprises:
if the target data model configuration file is determined to be included, acquiring the target data model configuration file from a configuration template database, generating a target view and a service logic script file according to the received view and service logic data of the target applet, and taking the target data model configuration file and the target view and service logic script file as a target configuration template;
when the configuration template data only includes the target data model configuration file but does not include the target view and the service logic script file, the target view and the service logic script file can be generated according to the view and the service logic data of the target applet input by the user, and the target configuration file of the target view, the service logic script file and the target data in the configuration template data is used as the target configuration template.
And if the fact that the target data model configuration file, the target view and the service logic script file are not included is determined, generating the target data model configuration file according to the type data of the received target small program, generating the target view and the service logic script file according to the view and the service logic data of the received target small program, and taking the target data model configuration file, the target view and the service logic script file as a target configuration template.
Preferably, the target data model configuration file is a JSON configuration file, and the JSON configuration file is used for configuring a UI component having an uploading function or an inputting function.
The JSON configuration file in this embodiment may be a configuration file conforming to the JSON Schema standard, and the configuration file may preferably be a configuration file in the form of a JSON character string. Illustratively, the JSON configuration file may configure content such as a material website in the configuration information required by the generated applet, and may also configure a UI component having an upload function or an input function to achieve the purpose of configuring corresponding material in the configuration information required by the generated applet. Illustratively, the configuration information required to generate the applet includes a target picture that is stored locally rather than at a corresponding storage location in the server, at which time the picture needs to be uploaded to the corresponding storage location in the server. Based on the above requirement, the JSON configuration file can be used to configure a target picture having an upload function, and the target picture is uploaded to a corresponding storage location in the server from the local via the UI component, for example, the UI component may be a button having an upload function.
And S120, acquiring configuration information corresponding to the target configuration template.
Preferably, the target configuration template is a configuration template without page configuration, and accordingly, the target configuration template can be configured to generate a final target applet. For example, the configuration information corresponding to the target configuration template may be obtained by receiving data input by a user. The configuration information may be data corresponding to the final presentation form of the target applet, for example, data for determining the page style of the target applet, and the like. For example, the configuration information may be, but is not limited to, a numerical value (e.g., a color value, a gray value, etc.) or a web address, etc.
Preferably, the obtaining of the configuration information corresponding to the target configuration template includes: generating a configuration interface corresponding to the configuration information based on the target data model configuration file; and acquiring configuration information through a configuration interface.
The configuration interface may be an interface that is presented to the user and used for the user to input corresponding configuration information. The configuration interface can comprise an input box, an upload button, corresponding text description and the like.
And S130, generating the target applet based on the target configuration template and the configuration parameters.
In this embodiment, the target applet includes two parts, namely a target configuration template and configuration parameters.
Preferably, the generating the target applet based on the target configuration template and the configuration parameters comprises: filling the configuration information into a target data model configuration file to obtain a configured target data model configuration file; and taking the configured target data model configuration file, the target view and the service logic script file as a target applet.
In the applet generating method provided by this embodiment, a target configuration template of a target applet is determined, where the target configuration template includes a target data model configuration file, a target view and a service logic script file of the target applet; acquiring configuration information corresponding to a target configuration template; and generating a target applet based on the target configuration template and the configuration parameters, decoupling the configuration template of the target applet, and dividing the configuration template into a data model configuration file, a view and a service logic script file, so that the development cycle of the applet can be shortened, and the applet can be conveniently changed.
On the basis of the foregoing embodiments, further, after generating the target applet based on the target configuration template and the configuration parameters, the method further includes: determining the release condition of the target applet; and when the launching condition is determined to be met, launching the target applet.
The releasing condition may include a releasing action, a releasing position, releasing time and the like, wherein the releasing action may be to release the target applet when the corresponding action is satisfied, the releasing position may be an interface position where the target applet is displayed, and the releasing time may be a total display duration of the target applet. Taking the target applet as the video applet for example, the release action may be that the video is played to half, the release position may be the middle of the interface, and the release time may be 10 s. Taking the target applet as the WeChat applet as an example, the release action may be that a two-dimensional code scanning request is received, the release position may be the whole display interface, and the release time may be set until the user closes the target applet interface.
When the target applet is launched, the target applet can be rendered by using the target view and the service logic script file based on the configured target data model configuration file, and a final display form of the target applet is generated in a display interface.
Example two
Fig. 2a is a block diagram of an applet according to a second embodiment of the present invention, where the applet in this embodiment provides a preferred embodiment based on the above embodiment, as shown in fig. 2a, the applet includes a data modelJSON configuration file 210, a view and service logic Lua script file 220 having a one-to-many relationship with the data modelJSON configuration file 210, and one data modelJSON configuration file 210 and one view and service logic Lua script file 220 together form aconfiguration template 230 of the applet, where theconfiguration template 230 cannot form a complete applet, and in order to enable the applet to be delivered and used, correspondingconfiguration information 240 needs to be configured based on the data modelJSON configuration file 210, and theconfiguration template 230 and theconfiguration information 240 together form afinal applet 250.
Fig. 2b is a flowchart of an applet generating method according to a second embodiment of the present invention, where as shown in fig. 2b, a user selects a configuration template from a configuration template database according to a requirement, if the configuration template database includes a target configuration template, a configuration interface is generated according to the target configuration template, and the user inputs configuration information based on the configuration interface to generate a final target applet. If the configuration template database only comprises the data model configuration file in the target configuration template and does not comprise the view and service logic script file, the view and service logic script file can be generated according to the view and service logic data input by the user to obtain the target configuration template, the configuration interface is generated according to the target configuration template, and the user inputs configuration information based on the configuration interface to generate the final target applet. If the configuration template database does not include the data model configuration file, the view and service logic script file in the target configuration template, the data model configuration file can be generated according to the data model input by the user, the view and service logic script file can be generated according to the view and service logic data input by the user to obtain the target configuration template, a configuration interface is generated according to the target configuration template, and the user inputs configuration information based on the configuration interface to generate a final target applet. After the final target applet is generated, the target applet can be launched by setting launching conditions according to launching data input by a user. Before generating the view and service logic script file according to the view and service logic data input by the user, a configuration interface may be generated according to the data model configuration file, preset configuration information is filled in the configuration interface to generate a debugging configuration interface, and the view and service logic script file is generated based on the debugging configuration interface, so that the view and service logic script file can identify the data model configuration file to generate the configuration interface.
By way of example, the following is a simple example of a data model JSON configuration file:
as can be seen from the above example, the JSON configuration file is a JSON string configuration file, and is represented in the form of a key-value. type and properties are used to define the type of JSON property. required is the constraint on the necessity of the property in the property field, wherein creationame is the name of the project applet material as a mandatory item, and properties defines the name and type of each property. The uiSchema processing rule is a custom part of a JSON Schema standard, and the purpose of uploading videos and pictures can be achieved by using the uiSchema to replace the ui component. When a picture is set in a group of objects, the hierarchy of the object needs to be set, as in the above example, the purpose of uploading the picture can be achieved by setting the value of ui: widget in the object attribute to imgBtn, and if a video needs to be uploaded, the value of ui: widget can be set to videoBtn.
Based on the above example, a configuration interface can be generated, and fig. 2c is a schematic diagram of a configuration interface provided by the second embodiment of the present invention, as shown in fig. 2c, 200 corresponds to "creativeName" in the above example, { "ui: placeholder": please input a material name "}, 201 corresponds to" ui: widget ": imgBtn" in the above example, 202 corresponds to "ui: help": that "picture size is 100PX wide, 135PX" in the above example, 203 corresponds to "creativeName" in the above example, { "title": material name "," type ":" max L ength ":30}, 204 corresponds to" hotEdit ": type": object ": hotspot edit", 205 corresponds to "animation": type ": item {" type ": 5:" elementary: "pictures": item: "in the above example, and" picture ": item {" type: "1:": item:.
Corresponding to the above example, when the applet is launched, the mobile terminal may obtain the following data:
after the mobile terminal acquires the data, the data is filled into a data model configuration file, and view rendering is performed by using a view and a service logic script file to generate a final applet display form.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an applet generating apparatus in a third embodiment of the present invention. As shown in fig. 3, the applet generating apparatus includes:
a target configurationtemplate determining module 310, configured to determine a target configuration template of the target applet, where the target configuration template includes a target data model configuration file of the target applet, and a target view and service logic script file;
a configurationinformation obtaining module 320, configured to obtain configuration information corresponding to the target configuration template;
and a targetapplet generating module 330 for generating a target applet based on the target configuration template and the configuration parameters.
In the applet generating apparatus provided in this embodiment, a target configuration template of a target applet is determined by using a target configuration template determining module, where the target configuration template includes a target data model configuration file of the target applet and a target view and service logic script file; acquiring configuration information corresponding to a target configuration template by using a configuration information acquisition module; the target applet generating module is used for generating the target applet based on the target configuration template and the configuration parameters, the configuration template of the target applet is decoupled and divided into a data model configuration file, a view and a service logic script file, the development period of the applet can be shortened, and the applet can be conveniently changed.
On the basis of the foregoing technical solution, further, the target configurationtemplate determining module 310 may be specifically configured to:
determining whether a configuration template database comprises a target data model configuration file and a target view and service logic script file:
and if the target data model configuration file, the target view and the service logic script file are determined to be included, acquiring the target data model configuration file, the target view and the service logic script file from the configuration template database, and taking the target data model configuration file, the target view and the service logic script file as a target configuration template.
On the basis of the foregoing technical solution, further, the target configurationtemplate determining module 310 may be specifically configured to:
if the target data model configuration file is determined to be included, acquiring the target data model configuration file from a configuration template database, generating a target view and a service logic script file according to the received view and service logic data of the target applet, and taking the target data model configuration file and the target view and service logic script file as a target configuration template;
and if the fact that the target data model configuration file, the target view and the service logic script file are not included is determined, generating the target data model configuration file according to the type data of the received target small program, generating the target view and the service logic script file according to the view and the service logic data of the received target small program, and taking the target data model configuration file, the target view and the service logic script file as a target configuration template.
On the basis of the technical scheme, the target data model configuration file is a JSON configuration file, and the JSON configuration file is used for configuring a UI component with an uploading function or an inputting function.
On the basis of the foregoing technical solution, further, the configurationinformation obtaining module 320 may specifically include:
the configuration interface generating unit is used for generating a configuration interface corresponding to the configuration information based on the target data model configuration file;
and the configuration information acquisition unit is used for acquiring the configuration information through the configuration interface.
On the basis of the foregoing technical solution, further, the targetapplet generating module 330 may specifically include:
the target data model configuration file determination unit is used for filling the configuration information into the target data model configuration file to obtain the target data model configuration file with the configuration completed;
and the target applet generating unit is used for taking the configured target data model configuration file and the target view and service logic script file as the target applet.
On the basis of the above technical solution, further, the applet generating device may further include a launch condition determining module, configured to determine a launch condition of the target applet after the target applet is generated based on the target configuration template and the configuration parameters; and when the launching condition is determined to be met, launching the target applet.
The applet generating device provided by the embodiment of the invention can execute the applet generating method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 4 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention. FIG. 4 illustrates a block diagram of anexemplary computer device 412 suitable for use in implementing embodiments of the present invention. Thecomputer device 412 shown in FIG. 4 is only one example and should not impose any limitations on the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 4,computer device 412 is in the form of a general purpose computing device. Components ofcomputer device 412 may include, but are not limited to: one ormore processors 416, amemory 428, and abus 418 that couples the various system components (including thememory 428 and the processors 416). In addition, thecomputer device 412 includes a laser transmitter (not shown in fig. 4) disposed at a reference point within the reference coordinate system for transmitting the outgoing laser light.
Bus 418 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 412 typically includes a variety of computer system readable media. Such media can be any available media that is accessible bycomputer device 412 and includes both volatile and nonvolatile media, removable and non-removable media.
Memory 428 can include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)430 and/orcache memory 432. Thecomputer device 412 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only,storage 434 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected tobus 418 by one or more data media interfaces.Memory 428 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 440 having a set (at least one) ofprogram modules 442 may be stored, for instance, inmemory 428,such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Theprogram modules 442 generally perform the functions and/or methodologies of the described embodiments of the invention.
Thecomputer device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing device,display 424, etc., where thedisplay 424 may be configurable or not as desired), one or more devices that enable a user to interact with thecomputer device 412, and/or any device (e.g., network card, modem, etc.) that enables thecomputer device 412 to communicate with one or more other computing devices.
Theprocessor 416 executes various functional applications and data processing, for example, implementing the applet generating method provided by the embodiments of the present invention, by executing the programs stored in thememory 428.
EXAMPLE five
An embodiment five of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a applet generating method provided in an embodiment of the present invention, including:
determining a target configuration template of the target applet, wherein the target configuration template comprises a target data model configuration file of the target applet, a target view and a service logic script file;
acquiring configuration information corresponding to a target configuration template;
and generating the target applet based on the target configuration template and the configuration parameters.
Of course, the computer-readable storage medium provided in the embodiments of the present invention, on which the computer program is stored, is not limited to executing the method operations described above, and may also execute the relevant operations in the small program generation method based on the computer device provided in any embodiment of the present invention.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer 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 computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, 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. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer 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 computer readable signal medium may also be any computer readable medium that is not a computer 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 computer readable 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.
Computer 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, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.