CN118012421A - Applet conversion method, device, equipment and storage medium - Google Patents

Applet conversion method, device, equipment and storage medium Download PDF

Info

Publication number
CN118012421A
CN118012421A CN202410179983.3A CN202410179983A CN118012421A CN 118012421 A CN118012421 A CN 118012421A CN 202410179983 A CN202410179983 A CN 202410179983A CN 118012421 A CN118012421 A CN 118012421A
Authority
CN
China
Prior art keywords
file
type
files
target
converted
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
CN202410179983.3A
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.)
China United Network Communications Group Co Ltd
Unicom Digital Technology Co Ltd
China Unicom Heilongjiang Industrial Internet Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Unicom Digital Technology Co Ltd
China Unicom Heilongjiang Industrial Internet 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 China United Network Communications Group Co Ltd, Unicom Digital Technology Co Ltd, China Unicom Heilongjiang Industrial Internet Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202410179983.3A priority Critical patent/CN118012421A/en
Publication of CN118012421A publication Critical patent/CN118012421A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The application provides an applet conversion method, device, equipment and storage medium. The method comprises the following steps: acquiring a target item in an applet, wherein the target item is an item to be converted from a first instant messaging APP to a second instant messaging APP; reading and traversing the target item through JavaScript to obtain a target file to be processed and other files; determining the type of a file to be processed of a target file, wherein the file type comprises a acss type file, a axml type file, a js type file and a json type file; according to the type of the target file to be processed, calling conversion methods corresponding to different file types in the index. Js file in JavaScript to process, and obtaining a converted target file; and obtaining the converted project according to the converted target file and other files. The method of the application improves the conversion efficiency of the original codes in different instant messaging APP.

Description

Applet conversion method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer software technologies, and in particular, to a method, an apparatus, a device, and a storage medium for applet conversion.
Background
Various small program third party applications which are mounted on the instant messaging APP are developed according to project requirements, and the code delivery is involved, so that the development is carried out by using the official original language and api of the instant messaging APP, and the main stream multi-terminal code conversion in the prior art mainly comprises unicloud, apicloud and the like, namely, the code is written according to the specific requirements of the product to be converted into application programs such as h5 and loadable small programs, and a mutual conversion method does not exist among the application programs. For projects requiring development using instant messaging APP official native language and api, such codes are the same in the effects exhibited by themselves, and if conversion of the native code is not considered, code rewriting is required, which takes a lot of time to develop the developed functions.
Therefore, the existing method has the problem that conversion efficiency in different instant messaging APPs is low by using the native code.
Disclosure of Invention
The application provides a small program conversion method, device, equipment and storage medium, which are used for solving the technical problem of low conversion efficiency in different instant messaging APP by using a native code.
In a first aspect, the present application provides an applet conversion method, comprising:
Acquiring a target item in an applet, wherein the target item is an item to be converted from a first instant messaging APP to a second instant messaging APP;
Reading and traversing the target item through JavaScript to obtain a target file to be processed and other files;
Determining the type of a file to be processed of a target file, wherein the file type comprises a acss type file, a axml type file, a js type file and a json type file;
according to the type of the target file to be processed, calling conversion methods corresponding to different file types in the index. Js file in JavaScript to process, and obtaining a converted target file;
And obtaining the converted project according to the converted target file and other files.
In the embodiment of the application, before the target item in the applet is acquired, the method further comprises the following steps:
Configuring a methods file, an util file, a config file and an index.js file;
the file conversion method in the methods file, the file conversion method in the util file, the file conversion method in the config file, and the fs module and path module in the JavaScript are introduced into the index.
In the embodiment of the application, target files and other files to be processed are obtained by reading and traversing target items through JavaScript, which comprises the following steps:
reading a target item through an fs module and a path module in JavaScript;
And traversing the target item by using nodes.js in the JavaScript, determining other files when the files in the target item belong to jumpNames files and WHITENAMES files, and determining the target files to be processed when the files in the target item do not belong to jumpNames files and WHITENAMES files.
In the embodiment of the application, determining the type of the target file to be processed comprises the following steps:
Judging whether the target file is a folder or a file;
if the target file is a folder, creating a same-level folder, and determining the file type of the file in the folder;
if the target file is a file, determining the file type of the file.
In the embodiment of the application, when the file type is acss types, a conversion method corresponding to different file types in an index. Js file in JavaScript is called for processing, and the method comprises the following steps:
Creating wxss postfix files according to the same name of the same stage;
Converting acss in acss type file code to wxss;
And (3) multiplying the numerical value in front of the rem unit by a first set coefficient and splicing rpx units, or multiplying the numerical value in front of the rem unit by a second set coefficient and splicing the rem unit, wherein the first set coefficient and the second set coefficient are conversion coefficients of measurement units of different instant messaging APP, and the first set coefficient and the second set coefficient are different numerical values.
In the embodiment of the application, when the file type is axml types, a conversion method corresponding to different file types in an index. Js file in JavaScript is called for processing, and the method comprises the following steps:
Creating wxml postfix files according to the same name of the same stage;
Axml in axml type file code was replaced with wxml, onTap with bindtap, onBlur with bindblur, formType with form-type, a: replaced with wx: onSubmit is replaced with bindsubmit,' with quotation marks, ${ } with string concatenation.
In the embodiment of the application, when the file type is js type, a conversion method corresponding to different file types in an index. Js file in JavaScript is called for processing, and the method comprises the following steps:
Creating a js suffix file according to the same name of the same stage;
For an app.js file in js type files, introducing codes of planB.js into the app.js file, wherein planB.js is a file conversion method in an util file introduced into an index.js file;
For non-app.js files in js-type files, dd. is replaced with wx. and the dataset rear portion becomes the lowercase re-splice dataset front portion.
In the embodiment of the application, when the file type is json type, a conversion method corresponding to different file types in an index. Js file in JavaScript is called for processing, and the method comprises the following steps:
creating a file of json suffix according to the same name of the same stage;
Traversing and replacing keys in the app.json file for the app.json file in the json file type;
For non-app.json files in json file types, defaultTitle is replaced with navigationBarTitleText.
9. The method of claim 1, wherein deriving the converted item from the converted file and the other files comprises:
Filtering jumpNames files in other files to obtain an initial file;
copying WHITENAMES files in the initial file to obtain other files after processing;
and combining the converted target file and other processed files to obtain the converted item.
In a second aspect, the present application provides an applet conversion apparatus comprising:
the acquisition module is used for acquiring target items in the applet, wherein the target items are items to be converted from the first instant messaging APP to the second instant messaging APP;
The reading module is used for reading and traversing the target item through JavaScript to obtain a target file and other files;
The judging module is used for reading and traversing the target item through JavaScript to obtain a target file to be processed and other files;
The conversion module is used for determining the type of a file to be processed of the target file, wherein the file type comprises a acss type file, a axml type file, a js type file and a json type file;
And the generation module is used for obtaining the converted item according to the converted target file and other files.
In a third aspect, the present application provides an electronic device comprising: a processor, a memory communicatively coupled to the processor; the memory stores computer-executable instructions; the processor executes computer-executable instructions stored in the memory to perform the applet conversion method of the application.
In a fourth aspect, the present application provides a computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the applet conversion method of the application.
According to the method for converting the small program, the target files to be processed and other files in the target items are determined by reading and traversing the target items through JavaScript, the conversion methods corresponding to different file types are called from index. Js files according to acss types of files, axml types of files, js types of files and json types of files in the target files, the converted target files are obtained, regular dynamic matching, replacement and modification of codes are achieved, filtering processing is conducted on jumpNames files in other files, copying processing is conducted on WHITENAMES files, other files after processing are obtained, finally converted target files and other files are combined to obtain converted items, conversion efficiency of the small program among different instant messaging APPs is improved, and labor cost and time cost are greatly saved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic view of a scenario of an applet conversion method according to an embodiment of the present application;
FIG. 2 is a flow chart of an applet conversion method according to an embodiment of the application;
FIG. 3 is a flowchart illustrating another method for applet conversion according to an embodiment of the present application;
Fig. 4 is a schematic structural diagram of an applet converting apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Specific embodiments of the present application have been shown by way of the above drawings and will be described in more detail below. The drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but rather to illustrate the inventive concepts to those skilled in the art by reference to the specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with aspects of the application as detailed in the accompanying claims.
In the prior art, various applet third party applications which are mounted on an instant messaging APP are developed according to project requirements, and the code delivery of the applet is realized, so that the development is required by using the original language and api of the instant messaging APP, the third party application of the instant messaging APP has relatively fixed use scene, and when the applet is required to be loaded on other instant messaging APP, the applet cannot be used, and the code of the applet needs to be converted to adapt to other instant messaging APP. The main multi-terminal code conversion in the prior art mainly comprises unicloud, apicloud and the like, and codes are written according to the specific requirements of the product to be converted into h5, loadable applets and other application programs. Since specific codes need to be written according to the requirements of unicloud and apicloud products, and no mutual conversion method exists among the applications, for the project which is developed by one instant messaging APP, the project which wants to convert the native codes into another instant messaging APP is not available.
In order to solve the above problems, an embodiment of the present application provides a method for converting an applet, where the method classifies applets loaded into different instant messaging APPs, and invokes a method for processing a method file, a util file, a config file, and an index. Js file in JavaScript by using JavaScript programming language, so as to classify a target item, including filtering unnecessary files, copying files that do not need to be modified, replacing a required file suffix, regenerating, and writing a master file in a global configuration file, thereby implementing conversion of the target item of the applet between different instant messaging APPs.
The application provides a small program conversion method, which aims to solve the technical problems in the prior art.
The following describes the technical scheme of the present application and how the technical scheme of the present application solves the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 1 is a schematic view of a scenario of an applet conversion method according to an embodiment of the present application. As shown in fig. 1, the execution body of the applet conversion method provided in the embodiment of the present application is applet development equipment, such as a computer, and adopts JavaScript programming language.
Fig. 2 is a flow chart of an applet conversion method according to an embodiment of the application. As shown in fig. 2, an applet conversion method includes:
S201, acquiring a target item in an applet, wherein the target item is an item to be converted from a first instant messaging APP to a second instant messaging APP.
The JavaScript is a lightweight, interpreted or just-in-time compiled programming language with function priority.
The target item refers to an item which is developed in the first instant messaging APP and needs to be converted into a second instant messaging APP by adopting a native language and api (ApplicationProgrammingInterface, application program interface).
Prior to obtaining the target items in the applet, file configurations may be performed, which files are used to implement the execution of the applet, including methods files, util files, config files, and index.
The methods files refer to code blocks or functions for storing some files that can respond to events or call directly, and in the embodiment of the present application, the methods files include conversion methods of different types of files, for example, a acss type file conversion method, a axml type file conversion method, a js type file conversion method, and a json type file conversion method.
In the embodiment of the application, the util file mainly comprises two types, namely a planB.js file which is designed according to different instant messaging APP differences, a method which needs to be rewritten is arranged, the method comprises modification of key of parameters, modification of return values, and the other type is a common method for processing various types of files.
The config file refers to all configuration information of the application program, and is used for managing an instance, an environment, debug information and other parameters, and in the embodiment of the present application, the config file includes a WHITENAMES file, a jumpNames file, a default name prefix of an input item, and the like.
The index. Js file, i.e. the main logic file, refers to the function responsible for defining and exporting each function, class and variable in the module, and processing the calls required by other modules.
In order to realize that the developed applet can be converted in different instant messaging software, a file conversion method in a methods file, a file conversion method in an util file, a file conversion method in a config file, and an fs module and a path module in JavaScript can be introduced into an index.
S202, reading and traversing the target item through JavaScript to obtain a target file to be processed and other files.
The target file refers to a file which needs to be converted in the target item, and other files refer to files which do not need to be converted in the target item.
In the embodiment of the application, as the original language and api among different instant messaging APP have a plurality of similarities, the files in the target project are divided into the files needing to be converted and the files not needing to be converted by summarizing the similarities and differences of the target project, the files needing to be converted are classified, the conversion methods applicable to the differences of various files are analyzed and summarized, including the replacement of objects, the rewriting of the methods, the replacement and modification by adopting regular dynamic matching of specific codes, and the like, the processing of the target files by the original language and api of the instant messaging APP is realized, and compared with the development of developed functions which take a large amount of time to rewrite codes, the conversion efficiency among different instant messaging APP is greatly improved.
The embodiment of the application also provides a method for reading and traversing the target item through JavaScript, which can comprise the following steps:
reading a target item through an fs module and a path module in JavaScript;
And traversing the target item by using nodes.js in the JavaScript, determining other files when the files in the target item belong to jumpNames files and WHITENAMES files, and determining the target files to be processed when the files in the target item do not belong to jumpNames files and WHITENAMES files.
The fs module (file system module) refers to one of the modules commonly used in node. Js, and is used for operating a file system, and functions and methods provided by the module can perform operations such as reading, writing, copying, deleting and the like of a file, and also support operations such as creating, traversing, modifying and the like of a directory.
The path module refers to one of the modules commonly used in nodes, js, and is used for providing a series of methods and attributes to meet the processing requirements of users on paths.
In the embodiment of the application, a node. Js is utilized to traverse a recursion target item according to a file path, and the target files in the target item are determined to be files in non-jumpNames and WHITENAMES, and the conversion method is to call a conversion method in an index. Js file for conversion; and determining that other files in the target item are files jumpNames and WHITENAMES, and because similarities exist among different instant messaging APPs, directly filtering the files in jumpNames and copying the files in WHITENAMES.
S203, determining the type of the file to be processed of the target file, wherein the file type comprises a acss type file, a axml type file, a js type file and a json type file.
The file type to be processed of the target file refers to the file type of the file to be converted in the target project; the file type may be generally identified by a file extension and an application associated with the file.
It should be noted that if the target file is a folder, a peer folder may be created and a file type of a file in the folder may be determined; if the target file is a file, the file type of the file can be directly determined.
When the target file is a folder, creating a same-level folder of the target file in the second instant messaging APP according to the rule of the target file in the first instant messaging APP, continuously judging the file type of the file in the folder, and converting according to conversion methods corresponding to different file types; when the target file is a file, the file type of the file is directly judged, and then the file is converted according to a conversion method corresponding to the file type, wherein the file type is mainly divided into acss type files, axml type files, js type files and json type files.
S204, according to the type of the file to be processed of the target file, calling conversion methods corresponding to different file types in the index. Js file in the JavaScript to process, and obtaining the converted target file.
In consideration of multiple levels of target items and multiple complexities of file types, firstly, the conversion methods and modules of files of different types are introduced into index. Js main logic, so that target files in subsequent target items are converted according to file types by using corresponding methods, wherein the conversion methods comprise a conversion method of files in methods files, a conversion method of files in util files and a conversion method of files in config files.
For different types of files, different conversion modes can be used for processing, for example: if the file type is acss types, a conversion method corresponding to the acss type in the index. Js file in JavaScript can be called for processing; if the file type is json type, a conversion method corresponding to the json type in the index. Js file in JavaScript can be called for processing. Therefore, the target file classification is processed by accurately matching the conversion methods corresponding to different file types, so that the code conversion efficiency between different instant messaging APP is further improved.
S205, obtaining the converted item according to the converted target file and other files.
Converting the target file according to the file type and a processing method corresponding to the file type to obtain a converted file; adding the copied files of other files and the converted files of the target file to a target directory to obtain a converted item, wherein the target directory refers to a directory in the files needing to be converted in the first instant messaging APP applet; finally, the converted item is obtained by combining the converted file and other files, so that recompilation of the target item among different instant messaging APPs is realized, and new items conforming to the item structures and file types of the different instant messaging APPs are generated.
In summary, the method for converting the applet provided by the application is used for summarizing and summarizing the conversion methods of acss types of files, axml types of files, js types of files and json types of files in the target file, adopting the conversion methods corresponding to different file types for the target file of the target project, filtering the files which do not need to be processed, copying the files which do not need to be modified, and writing the global configuration file into the main file, thereby realizing the applet conversion between different instant messaging APPs based on the native language.
On the basis of the above embodiment, the present embodiment further provides an implementation manner of calling, according to a type of a file to be processed of the target file, conversion methods corresponding to different file types in the index. Js file in JavaScript to perform processing.
Fig. 3 is a flowchart of another applet conversion method according to an embodiment of the present application. As shown in fig. 3, the method comprises the steps of:
S301, when the file type is acss types, calling a conversion method corresponding to a acss type file in an index. Js file in JavaScript to process, wherein the conversion method comprises the following steps:
Creating wxss postfix files according to the same name of the same stage;
Converting acss in acss type file code to wxss;
And (3) multiplying the numerical value in front of the rem unit by a first set coefficient and splicing rpx units, or multiplying the numerical value in front of the rem unit by a second set coefficient and splicing the rem unit, wherein the first set coefficient and the second set coefficient are conversion coefficients of measurement units of different instant messaging APP, and the first set coefficient and the second set coefficient are different numerical values.
In the case where there are differences in measurement units in different instant messaging APPs, when a file of acss types is converted, conversion coefficients of different measurement units need to be analyzed, for example, when a measurement unit of css in a first instant messaging APP is rem (fontsizeoftherootelement) and a measurement unit of css in a second instant messaging APP is rpx (responsivepixel), transcoding needs to be performed, where a measurement unit rem is defined as a unit of font size relative to a root element, and a measurement unit rpx can be adaptive according to a screen width.
When different measurement units are adopted, the corresponding conversion coefficients are different, and when a unit rem of the first instant messaging APP is converted into a unit rpx of the second instant messaging APP, a numerical value in front of the rem unit needs to be multiplied by a first setting coefficient 100 to splice the units rpx, for example, the code in the first instant messaging APP is 2rem, and the code in the second instant messaging APP is 200rpx; when reserving the unit rem of the first instant messaging APP, the rem unit needs to be spliced again by multiplying the previous value of the rem unit in the first instant messaging APP by the second set coefficient 100/32, i.e. 3.125, for example, the code in the first instant messaging APP is 2rem, and the code in the second instant messaging APP is 6.25rem.
S302, when the file type is axml types, calling a conversion method corresponding to the axml type in the index. Js file in JavaScript to process, wherein the method comprises the following steps:
Creating wxml postfix files according to the same name of the same stage;
Axml in axml type file code was replaced with wxml, onTap with bindtap, onBlur with bindblur, formType with form-type, a: replaced with wx: onSubmit is replaced with bindsubmit,' with quotation marks, ${ } with string concatenation.
The method comprises the steps of replacing ' with quotation marks, for example, replacing '2131' in a first instant messaging APP with '2131' in a second instant messaging APP, and replacing '2131' in the second instant messaging APP in order to avoid repetition of single quotation marks and realize accurate identification, wherein a return value is required to be added in the second instant messaging APP, so that the second instant messaging APP is replaced with '2131 '; the character string is spliced by replacing ${ }, for example, 'gao $ { mingzi }' haha 'in the first instant messaging APP, and' gao '+ mingzi +' \ haha \in the second instant messaging APP.
S303, when the file type is js type, calling a conversion method corresponding to js type in an index. Js file in JavaScript to process, wherein the method comprises the following steps:
Creating a js suffix file according to the same name of the same stage;
For an app.js file in js type files, introducing codes of planB.js into the app.js file, wherein planB.js is a file conversion method in an util file introduced into an index.js file;
For non-app.js files in js-type files, dd. is replaced with wx. and the dataset rear portion becomes the lowercase re-splice dataset front portion.
Firstly, creating a js suffix file in the converted target file according to the same name of the file in the first instant messaging APP. Secondly, if the file in the js type is an app.js file, adding a code for introducing the playb.js into the file, for example, when getStorageSync in the first instant messaging APP is replaced by $ getStorageSync, the conversion of the parameter and the return value is needed, that is, rewriting getStorageSync to remove the key in the parameter, and wrapping the date layer; if the js type file is a non-app.js file, on one hand, dd. in the first instant messaging APP is replaced by wx. in the second instant messaging APP, and on the other hand, getStorageSync, getStorage, chooseImage, uploadFile, showToast, showLading are replaced by etStorageSync, getStorage, chooseImage, uploadFile, showToast, showLading with special symbols, for example, getStorageSync in the first instant messaging APP is replaced by $ getStorageSync in the second instant messaging APP, and some special symbols are used to ensure that no conflict with the existing method in the project occurs. Finally, considering that the case requirements of the attributes in the datasets in different instant messaging APPs are not strict, for example, when the datasets in the second instant messaging APP must be lower case and the datasets in the first instant messaging APP are not required, the latter part of the datasets is changed into the front part of the lower case re-spliced datasets in the second instant messaging APP.
S304, when the file type is json type, calling a conversion method corresponding to the json type in the index. Js file in JavaScript to process, wherein the method comprises the following steps:
creating a file of json suffix according to the same name of the same stage;
Traversing and replacing keys in the app.json file for the app.json file in the json file type;
For non-app.json files in json file types, defaultTitle is replaced with navigationBarTitleText.
Creating a json suffix file in the converted target file according to the same name of the file in the first instant messaging APP, and changing defaultTitle to navigationBarTitleText if the file in the json type is a non-app.json file; if the file in the Json type is an app.json file, when the first instant messaging APP is converted to the second instant messaging APP, the functions in the app.json file are basically the same, but only the codes are different, so that the key is replaced by a CHANGEKEY4Json method.
The CHANGEKEY-4 Json method refers to traversing all keys of an app.json file in the Json file type, and replacing the keys one by one.
On the basis of the above embodiment, the method further includes, after processing the target file according to the conversion methods corresponding to different file types to obtain the converted target file:
and filtering jumpNames files in other files to obtain an initial file.
And copying WHITENAMES files in the initial file to obtain other files after processing.
And combining the converted target file and other processed files to obtain the converted item.
In summary, according to the other applet conversion method provided by the application, some unnecessary files are filtered and some files which do not need to be modified are copied through the recursion circulation of the whole item, some file suffixes need to be replaced and regenerated, some global configuration files are written into the planB.js files, and some simple replacement method can not modify details such as parameters, default values, return values and the like through the recompilation method, so that recompilation into new items which accord with different instant messaging APP is realized, compared with manual modification, time cost is saved, and conversion efficiency of the items among different instant messaging APP is improved. Fig. 4 is a schematic structural diagram of an applet converting apparatus according to an embodiment of the present application, and as shown in fig. 4, the applet converting apparatus 400 includes: an acquisition module 401, a reading module 402, a judging module 403, a conversion module 404 and a generating module 405.
The obtaining module 401 is configured to obtain a target item in the applet, where the target item is an item to be converted from the first instant messaging APP to the second instant messaging APP.
And the reading module 402 is used for reading and traversing the target item through JavaScript to obtain a target file and other files.
And the judging module 403 is configured to read and traverse the target item through JavaScript to obtain a target file to be processed and other files.
The conversion module 404 is configured to determine a type of a file to be processed of the target file, where the file type includes a file of acss types, a file of axml types, a file of js types, and a file of json types.
The generating module 405 is configured to obtain a converted item according to the converted target file and other files.
In this embodiment of the present application, the obtaining module 401 further includes:
Configuring a methods file, an util file, a config file and an index.js file;
the file conversion method in the methods file, the file conversion method in the util file, the file conversion method in the config file, and the fs module and path module in the JavaScript are introduced into the index.
Wherein, in the embodiment of the present application, the reading module 402 further includes:
reading a target item through an fs module and a path module in JavaScript;
And traversing the target item by using nodes.js in the JavaScript, determining other files when the files in the target item belong to jumpNames files and WHITENAMES files, and determining the target files to be processed when the files in the target item do not belong to jumpNames files and WHITENAMES files.
In this embodiment of the present application, the determining module 403 further includes:
Judging whether the target file is a folder or a file;
if the target file is a folder, creating a same-level folder, and determining the file type of the file in the folder;
if the target file is a file, determining the file type of the file.
Wherein, in the embodiment of the present application, the conversion module 404 further includes:
Creating wxss postfix files according to the same name of the same stage;
Converting acss in acss type file code to wxss;
And (3) multiplying the numerical value in front of the rem unit by a first set coefficient and splicing rpx units, or multiplying the numerical value in front of the rem unit by a second set coefficient and splicing the rem unit, wherein the first set coefficient and the second set coefficient are conversion coefficients of measurement units of different instant messaging APP, and the first set coefficient and the second set coefficient are different numerical values.
Wherein, in the embodiment of the present application, the conversion module 404 further includes:
Creating wxml postfix files according to the same name of the same stage;
Axml in axml type file code was replaced with wxml, onTap with bindtap, onBlur with bindblur, formType with form-type, a: replaced with wx: onSubmit is replaced with bindsubmit,' with quotation marks, ${ } with string concatenation.
Wherein, in the embodiment of the present application, the conversion module 404 further includes:
Creating a js suffix file according to the same name of the same stage;
For an app.js file in js type files, introducing codes of planB.js into the app.js file, wherein planB.js is a file conversion method in an util file introduced into an index.js file;
For non-app.js files in js-type files, dd. is replaced with wx. and the dataset rear portion becomes the lowercase re-splice dataset front portion.
Wherein, in the embodiment of the present application, the conversion module 404 further includes:
creating a file of json suffix according to the same name of the same stage;
Traversing and replacing keys in the app.json file for the app.json file in the json file type;
For non-app.json files in json file types, defaultTitle is replaced with navigationBarTitleText.
In this embodiment of the present application, the generating module 405 further includes:
Filtering jumpNames files in other files to obtain an initial file;
copying WHITENAMES files in the initial file to obtain other files after processing;
and combining the converted target file and other processed files to obtain the converted item.
According to the applet conversion device provided by the embodiment of the application, the target item is acquired through the acquisition module 401, the reading module 402 reads and traverses the target item to obtain the target file and other files and carries out corresponding processing, the target file is determined according to the judgment module 403, the conversion module 404 carries out code conversion by adopting conversion methods corresponding to different file types, the other files are filtered and copied, and further the converted item is obtained according to the converted target file and other files through the generation module 405, so that the item conversion between different instant messaging APPs through the original codes is realized, the conversion efficiency between different instant messaging APPs is improved, and the labor and time cost is saved.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the electronic device 500 includes:
the electronic device 500 may include one or more processing cores 'processors 501, one or more computer-readable storage media's memory 502, communication components 503, and the like. The processor 501, the memory 502, and the communication unit 503 are connected via a bus 504.
In a specific implementation, at least one processor 501 executes computer-executable instructions stored in memory 502, causing at least one processor 501 to perform a message processing method as described above.
The specific implementation process of the processor 501 may refer to the above-mentioned method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
In the embodiment shown in fig. 5, it should be understood that the processor may be a Central Processing Unit (CPU), other general purpose processors, digital Signal Processors (DSP), application Specific Integrated Circuits (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present application may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in a processor for execution.
The memory may include high-speed memory (RandomAccessMemory, RAM) or may also include Non-volatile memory (Non-volatileMemory, NVM), such as at least one disk memory.
The bus may be an industry standard architecture (IndustryStandardArchitecture, ISA) bus, an external device interconnect (PeripheralComponent, PCI) bus, or an extended industry standard architecture (ExtendedIndustryStandardArchitecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or to one type of bus.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (12)

1. A method of applet conversion, comprising:
acquiring a target item in an applet, wherein the target item is an item to be converted from a first instant messaging APP to a second instant messaging APP;
Reading and traversing the target item through JavaScript to obtain a target file to be processed and other files;
Determining the type of a file to be processed of the target file, wherein the file type comprises a acss type file, a axml type file, a js type file and a json type file;
According to the type of the target file to be processed, calling conversion methods corresponding to different file types in the index. Js file in the JavaScript to process the target file to obtain a converted target file;
And obtaining the converted item according to the converted target file and the other files.
2. The method of claim 1, wherein prior to the acquiring the target item in the applet, the method further comprises:
Configuring a methods file, an util file, a config file and an index.js file;
And introducing a file conversion method in the methods file, a file conversion method in the util file, a file conversion method in the config file, and an fs module and a path module in the JavaScript into the index.
3. The method according to claim 1 or 2, wherein the reading and traversing the target item by the JavaScript results in a target file and other files to be processed, comprising:
reading the target item through an fs module and a path module in the JavaScript;
and traversing the target item by using node.js in the JavaScript, determining the target item as the other files when the files in the target item belong to jumpNames files and WHITENAMES files, and determining the target item as the target file to be processed when the files in the target item do not belong to jumpNames files and WHITENAMES files.
4. A method according to claim 3, wherein said determining the type of file to be processed for said target file comprises:
judging whether the target file is a folder or a file;
If the target file is a folder, creating a same-level folder, and determining the file type of the file in the folder;
and if the target file is a file, determining the file type of the file.
5. The method of claim 1, wherein when the file type is the acss type, calling a conversion method corresponding to a different file type in an index. Js file in the JavaScript to process, including:
Creating wxss postfix files according to the same name of the same stage;
converting. acss in the acss type of file code to. wxss;
and multiplying the numerical value before the rem unit by a first set coefficient and splicing rpx units, or multiplying the numerical value before the rem unit by a second set coefficient and splicing rem units, wherein the first set coefficient and the second set coefficient are conversion coefficients of measurement units of different instant messaging APP, and the first set coefficient and the second set coefficient are different numerical values.
6. The method of claim 1, wherein when the file type is the axml type, calling a conversion method corresponding to a different file type in an index. Js file in the JavaScript to process, including:
Creating wxml postfix files according to the same name of the same stage;
Axml in the axml type file code was replaced with wxml, onTap with bindtap, onBlur with bindblur, formType with form-type, a: replaced with wx: onSubmit is replaced with bindsubmit,' with quotation marks, ${ } with string concatenation.
7. The method of claim 1, wherein when the file type is js type, invoking the conversion method corresponding to a different file type in the index. Js file in the JavaScript for processing, comprising:
Creating a js suffix file according to the same name of the same stage;
For an app.js file in the js type file, introducing a code of a planB.js into the app.js file, wherein the planB.js is a file conversion method in an util file introduced into an index.js file;
for non-app.js files in the js-type file, dd. is replaced with wx. and the dataset rear portion becomes the lower case re-splice dataset front portion.
8. The method of claim 1, wherein when the file type is the json type, calling a conversion method corresponding to a different file type in an index. Js file in the JavaScript to process, including:
creating a file of json suffix according to the same name of the same stage;
traversing and replacing keys in the app.json file for the app.json file in the json file type;
for non-app.json files in the json file type, defaultTitle is replaced with navigationBarTitleText.
9. The method of claim 1, wherein the obtaining the converted item from the converted file and the other files comprises:
filtering jumpNames files in the other files to obtain an initial file;
copying WHITENAMES files in the initial file to obtain the other files after processing;
And combining the converted target file and the processed other files to obtain a converted item.
10. An applet conversion apparatus, comprising:
The acquisition module is used for acquiring target items in the applet, wherein the target items are items to be converted from the first instant messaging APP to the second instant messaging APP;
the reading module is used for reading and traversing the target item through JavaScript to obtain a target file and other files;
The judging module is used for reading and traversing the target item through JavaScript to obtain a target file to be processed and other files;
the conversion module is used for determining the type of the file to be processed of the target file, wherein the file type comprises a acss type file, a axml type file, a js type file and a json type file;
and the generation module is used for obtaining the converted item according to the converted target file and other files.
11. An electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
The memory stores computer-executable instructions;
The processor executes computer-executable instructions stored in the memory to implement the method of any one of claims 1 to 9.
12. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1 to 9.
CN202410179983.3A 2024-02-18 2024-02-18 Applet conversion method, device, equipment and storage medium Pending CN118012421A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410179983.3A CN118012421A (en) 2024-02-18 2024-02-18 Applet conversion method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410179983.3A CN118012421A (en) 2024-02-18 2024-02-18 Applet conversion method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN118012421A true CN118012421A (en) 2024-05-10

Family

ID=90945976

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410179983.3A Pending CN118012421A (en) 2024-02-18 2024-02-18 Applet conversion method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN118012421A (en)

Similar Documents

Publication Publication Date Title
WO2021037050A1 (en) Code change method and device
CN110262783B (en) Interface generation method and device and terminal equipment
CN111176717B (en) Method and device for generating installation package and electronic equipment
CN111736884A (en) Componentization method and system
CN111124382A (en) Attribute assignment method and device in Java and server
CN112328241B (en) Method and device for creating Android library module dependency relationship in application program development
CN110941443B (en) Method and device for modifying file name in SDK (software development kit) and electronic equipment
CN117234582A (en) Project code processing method and device, electronic equipment and storage medium
CN112631644A (en) Method and device for modifying initial formula of Flutter constructor
CN110688320B (en) Global variable detection method and device and terminal equipment
CN109840078B (en) Method and device for collaboratively editing hierarchical metadata
CN118012421A (en) Applet conversion method, device, equipment and storage medium
CN111444456B (en) Style editing method and device and electronic equipment
CN114911541A (en) Configuration information processing method and device, electronic equipment and storage medium
CN114449063A (en) Message processing method, device and equipment
CN107239270B (en) Code processing method and device
CN111552510B (en) File construction method and device, electronic equipment and computer readable storage medium
CN114237407A (en) Font icon processing method and device and computer readable storage medium
CN113760237A (en) Compiling address updating method and device, terminal equipment and readable storage medium
CN112925523A (en) Object comparison method, device, equipment and computer readable medium
CN110825450B (en) APP configuration modification method and device, electronic equipment and storage medium
CN114579135B (en) Installation package generation method and device
CN116483324A (en) Multi-terminal parallel development method, device, equipment, medium and product of low-code platform
CN117271004A (en) Document report generation method, device, equipment and storage medium
CN109214760B (en) Method and device for processing diagram in mail

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