Cross-platform applet migration method and device, equipment, storage medium and product

By standardizing interface calls and replacing global variables through a cross-platform interface library, the problem of low development efficiency when deploying mini-programs on multiple platforms is solved, achieving efficient and widely compatible cross-platform migration and improving development efficiency.

CN120950200APending Publication Date: 2025-11-14SINA FINANCE MOBILE NETWORK TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510978385.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

In existing technologies, deploying mini-programs on multiple platforms requires developing multiple sets of source code, resulting in low development efficiency and failing to completely resolve issues related to underlying API differences and engineering configuration.

Method used

By providing standardized interface calls through a cross-platform interface library, dynamically determining the interface target, and replacing global variables when the platform changes, code adaptation is achieved, enabling cross-platform migration of mini programs.

Benefits of technology

It improves the development and deployment efficiency of mini-programs, enables more efficient and compatible multi-platform migration, and decouples framework dependencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120950200A_ABST
    Figure CN120950200A_ABST
Patent Text Reader

Abstract

The invention relates to a cross-platform applet migration method and device, equipment, a storage medium and a product, and relates to the technical field of computers. The method comprises the steps of obtaining a first source code of a target applet; the first source code is a source code compiled according to a preset rule and adapted to a first platform; the preset rule indicates that a standard interface call provided by the cross-platform interface library replaces a native interface call of the first platform; the standardized interface call is used for dynamically determining an interface direction based on a platform definition field; under the condition that the application platform indicated by the platform definition field is changed into a second platform, on the basis of a cross-platform interface library, replacing a standardized global variable referenced in the standardized interface call with a global variable of the second platform to obtain a target interface call code; and performing code adaptation operation corresponding to the second platform based on the intermediate source code containing the target interface calling code to obtain a second source code of the target applet migrated to the second platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a cross-platform app migration method, apparatus, device, storage medium, and product. Background Technology

[0002] Currently, with the diversified development of the mini-program ecosystem, major platforms have launched their own mini-program technical specifications, such as differentiated API calling methods, inconsistent file extensions, and unique configuration rules. This situation of multiple platforms coexisting has brought significant challenges to developers.

[0003] In related technologies, the migration of mini-programs can be achieved through specific front-end frameworks. However, this solution depends on specific frameworks and has inherent defects such as performance loss and lagging support for platform features. Furthermore, it cannot completely solve the problems of underlying API differences and engineering configuration adaptation, resulting in low development efficiency. Summary of the Invention

[0004] This application provides a cross-platform mini-program migration method, which can solve the problem of needing to develop multiple sets of source code when deploying mini-programs on multiple platforms, thereby improving the development and deployment efficiency of mini-programs. The technical solution is as follows.

[0005] On the one hand, a cross-platform mini-program migration method is provided, the method including: Obtain the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces of each platform and the standardized interfaces; When the application platform indicated by the platform definition field is changed to the second platform, based on the cross-platform interface library, the standardized global variables referenced in the standardized interface call are replaced with global variables of the second platform to obtain the target interface call code; Based on the intermediate source code containing the target interface call code, a code adaptation operation corresponding to the second platform is performed to obtain the second source code of the target mini-program after migration to the second platform.

[0006] On the other hand, a cross-platform mini-program migration device is provided, the device comprising: The file acquisition module is used to acquire the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces of each platform and the standardized interfaces; The variable substitution module is used to replace the standardized global variables referenced in the standardized interface call with global variables of the second platform based on the cross-platform interface library when the application platform indicated by the platform definition field is changed to the second platform, so as to obtain the target interface call code. The adaptation operation module is used to perform code adaptation operations corresponding to the second platform based on the intermediate source code containing the target interface call code, so as to obtain the second source code of the target mini-program after migration to the second platform.

[0007] In one possible implementation, the variable substitution module includes: The directory generation submodule is used to generate a target mini-program directory corresponding to the second platform; the target mini-program directory is used to provide operational space for cross-platform source code migration. The copy submodule is used to copy the first source code to the target applet directory; The variable substitution submodule is used to parse the first source code in the target mini-program directory, and based on the cross-platform interface library, replace the standardized global variables referenced in the standardized interface call with global variables of the second platform to obtain the target interface call code.

[0008] In one possible implementation, the adaptation module is used to modify the parameters of the global configuration file and page configuration file in the intermediate source code according to the file configuration rules of the second platform, so as to obtain the second source code of the target mini-program after migration to the second platform.

[0009] In one possible implementation, the parameters corresponding to the global configuration file include the mini-program route and route configuration parameters; the parameters corresponding to the page configuration file include view layer tags, event instructions, and the lifecycle hook names of the interaction layer.

[0010] In one possible implementation, the device further includes: The clear module is used to clear the target mini-program directory before copying the first source code to the target mini-program directory.

[0011] In one possible implementation, the preset rule also instructs the nesting of container tags outside of view layer tags, which include text tags or input component tags.

[0012] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the above-described cross-platform applet migration method.

[0013] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, the computer program being loaded and executed by a processor to implement the above-described cross-platform applet migration method.

[0014] On the other hand, a computer program product is provided, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to execute to implement the cross-platform applet migration method provided in the above-described various optional implementations.

[0015] The technical solution provided in this application may include the following beneficial effects: The cross-platform mini-program migration method provided in this application replaces the native interface calls corresponding to the first platform with standardized interface calls from a cross-platform interface library, and dynamically determines the application platform pointed to by the interface based on the platform definition field to obtain the first source code of the target mini-program. When the application platform indicated by the platform definition field is changed to the second platform, the standardized global variables referenced in the standardized interface calls are replaced with global variables of the second platform based on the cross-platform interface library, and code adaptation operations corresponding to the second platform are performed on this basis to obtain the second source code of the target mini-program after migration to the second platform. The above scheme can achieve more efficient and more compatible multi-terminal migration through dynamic interface mapping and automated engineering configuration conversion, decouples framework dependencies, and improves the development and deployment efficiency of mini-programs.

[0016] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] Figure 1 A flowchart illustrating a cross-platform mini-program migration method provided in an exemplary embodiment of this application is shown; Figure 2 A flowchart illustrating a cross-platform mini-program migration method provided in another exemplary embodiment of this application is shown; Figure 3 This illustration shows a schematic diagram of cross-platform development based on SFT_mini_api provided in an exemplary embodiment of this application; Figure 4 This illustration shows a schematic diagram of code migration based on a migration tool provided in an exemplary embodiment of this application; Figure 5 This illustration shows an interactive diagram of cross-platform mini-program migration provided by an exemplary embodiment of this application; Figure 6 A schematic diagram illustrating the mini-program migration process provided in an exemplary embodiment of this application is shown; Figure 7 A block diagram of a cross-platform mini-program migration apparatus provided in an exemplary embodiment of this application is shown; Figure 8 A structural block diagram of a computer device illustrated in an exemplary embodiment of this application is shown; Figure 9 A structural block diagram of a computer device illustrated in an exemplary embodiment of this application is shown. Detailed Implementation

[0019] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0020] This application provides a cross-platform mini-program migration method, which enables mini-programs to be migrated between multiple platforms. Figure 1 This application illustrates a flowchart of a cross-platform mini-program migration method provided by an exemplary embodiment. This method can be executed by a computer device, which can be implemented as a server or a terminal, such as... Figure 1 As shown, the method may include the following steps.

[0021] Step 110: Obtain the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces and standardized interfaces of each platform.

[0022] These preset rules can be based on the syntax and development presets of mini-programs on various platforms. They refer to the specific logic or specifications that must be followed during code compilation or conversion. For example, replacing the original interface call with a standardized interface call provided by a cross-platform interface library, or setting disabled keywords for custom variables during mini-program development. These disabled keywords can be platform-specific keywords, such as tt, ks, my, swan, wx, etc.

[0023] In one possible implementation, the first source code is source code adapted to the first platform that is compiled based on preset rules during the development of the target mini-program; in another possible implementation, the target mini-program is a mini-program that has already been developed. Based on this, the existing source code of the target mini-program is preprocessed according to preset rules to obtain the first source code, so that the first source code conforms to the preset rules and thus adapts to the cross-platform migration requirements.

[0024] Taking the native interface call corresponding to the first platform as wx.request(), during the compilation process according to preset rules, wx.request() is replaced with a standardized interface call, namely SFT_min_sys.request(). This standardized interface call is a platform-independent interface defined in the cross-platform interface library, which dynamically calls the native interface of the corresponding platform through mapping relationships. The platform definition field is a variable in the code used to identify the application platform of the mini-program. It is illustrative. This platform definition field can be SFT_min_var, which is used to indicate which platform's native interface the standardized interface points to. The platform definition field in the first source code indicates that the application platform is the first platform.

[0025] Step 120: If the application platform indicated by the platform definition field is changed to the second platform, based on the cross-platform interface library, replace the standardized global variables referenced in the standardized interface call with the global variables of the second platform to obtain the target interface call code.

[0026] When the platform definition field indicates that the application platform has been changed to the second platform, it means that the mini-program needs to be deployed to the second platform. In this embodiment, the migration and deployment can be carried out based on the first source code of the mini-program adapted to the first platform. In this case, the standardized global variable referenced in the standardized interface call of the first source code is replaced by the global variable of the second platform to obtain the target interface call code corresponding to the second platform. For example, taking the second platform as the global variable and my as the global variable, after the global variable replacement, SFT_min_sys.request() is changed to my.request().

[0027] Step 130: Based on the intermediate source code containing the target interface call code, perform code adaptation operations corresponding to the second platform to obtain the second source code of the target mini-program adapted to the second platform.

[0028] This intermediate source code is the source code that has undergone global variable replacement but is not fully adapted to the second platform. This intermediate source code may still contain specific syntax or parameter configurations of the first platform, and code adaptation operations need to be performed for the second platform, such as syntax compatibility processing, parameter format adjustment, dependency library replacement, etc. The adapted code is then packaged into a second source code that conforms to the specifications of the second platform.

[0029] In summary, the cross-platform mini-program migration method provided in this application replaces the native interface calls corresponding to the first platform with standardized interface calls from a cross-platform interface library, and dynamically determines the application platform pointed to by the interface based on the platform definition field to obtain the first source code of the target mini-program. When the application platform indicated by the platform definition field is changed to the second platform, the standardized global variables referenced in the standardized interface calls are replaced with global variables of the second platform based on the cross-platform interface library, and code adaptation operations corresponding to the second platform are performed on this basis to obtain the second source code of the target mini-program adapted to the second platform. The above scheme can achieve more efficient and more compatible multi-terminal migration through dynamic interface mapping and automated engineering configuration conversion, decouples framework dependencies, and improves the development and deployment efficiency of mini-programs.

[0030] Figure 2 A flowchart illustrating a cross-platform mini-program migration method provided in another exemplary embodiment of this application is shown. This method can be executed by a computer device, which can be implemented as a server or a terminal, such as... Figure 2 As shown, the method may include the following steps.

[0031] Step 210: Obtain the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces and standardized interfaces of each platform.

[0032] In one possible implementation, the predefined rule also instructs the nesting of container tags outside view layer tags. These view layer tags, including text tags or input component tags, serve as standardized encapsulation units for cross-platform user interface rendering. In other words, a container tag is a layout encapsulation unit used to nest basic view layer components, providing a unified layout context and style isolation for internal components, ensuring consistency in cross-platform rendering. For example, for text tags, the following rules must be followed... <view> <text> This is text< / text> < / view> The specifications for input component tags, taking text input as an example, must follow these guidelines. <view> <input value=""这是输入文本框”"> < / view> The specification, through the use of container tags (such as...) <view>Nested view layer tags (such as) <text>or <input> This unifies the user interface rendering behavior across different platforms, avoiding layout inconsistencies or functional abnormalities caused by platform differences. Furthermore, event handlers can be compiled according to the target platform's mini-program specifications. During compilation, container tags can be automatically converted to corresponding native components based on the target platform; for example, on the web, they can be converted to components with specific class names. Converted to WeChat Mini Program <view>In React Native, it is mapped as <view>This conversion not only ensures the consistency of layout behavior, but also eliminates the differences in default styles across different platforms through preset style rules.

[0033] This application embodiment uses the standardized global variable SFT_min_sys provided by the cross-platform interface library to uniformly encapsulate the native APIs of mini-programs on various platforms into the calling form of SFT_min_sys.API, and uses the platform-defined field SFT_min_var to dynamically identify the current running environment of the mini-program, i.e., the application platform. Developers can perform standardized call replacement in the business layer JS. For example, by replacing the original platform API call (e.g., wx.request) with SFT_min_sys.request, the underlying platform interface can be automatically adapted through the cross-platform interface library without modifying the business logic code, thus achieving cross-platform compatibility and unified management.

[0034] In addition, the basic APIs of mini-programs on various platforms may also include routing APIs, such as page navigation (e.g., redirectTo, navigateTo), tab switching (switchTab), and back operation (navigateBack); user authentication APIs, such as the login interface (login); data storage APIs, such as synchronization storage operations (e.g., getStorageSync, setStorageSync), and deletion operations (removeStorageSync); system information APIs, such as getting device parameters (getSystemInfoSync); interactive feedback APIs, such as light prompts (showToast) and modal dialogs (showModal); and network communication APIs, such as core network requests (request). All of the above APIs can be standardized into unified interface calls based on preset rules, such as replacing wx.navigateTo with SFT_min_sys.navigateTo, wx.login with SFT_min_sys.login, and wx.showToast with SFT_min_sys.showToast, etc.

[0035] In one possible implementation, the computer device can introduce the cross-platform interface library as a plugin into the first source code of the first platform. The plugin directory name can be SFT_mini_api. After the plugin is introduced, the interface can be called through the unified SFT_mini_sys global object. In fact, the underlying SFT_mini_api plugin is responsible for automatically routing to the native API implementation of the corresponding platform based on the current platform identifier. Figure 3 This application illustrates a schematic diagram of cross-platform development based on the SFT_mini_api, provided by an exemplary embodiment. Figure 3 As shown, "Sft_mini_sys:wx" indicates that the global variable for this platform is wx, "Sft_mini_var:wx" indicates that the application platform is wx, and "Sft_mini_api" lists a standardized set of cross-platform API interfaces, including common functional modules such as login, storage, canvas, payment (coast), network request, and video. Through a unified API interface layer (SFT_mini_api), native functions of different mini-program platforms can be encapsulated. Developers only need to call these standardized interfaces to achieve cross-platform compatibility, and the underlying layer will automatically map to the corresponding native implementation based on the platform type.

[0036] Step 220: If the application platform indicated by the platform definition field is changed to the second platform, based on the cross-platform interface library, replace the standardized global variables referenced in the standardized interface call with the global variables of the second platform to obtain the target interface call code.

[0037] In one possible implementation, if the target mini-program does not need to be used on the first platform after migration but is used on the second platform, then modifications can be made based on the original first source code. In another possible implementation, if the target mini-program still needs to be deployed on the first platform after migration to the second platform, then after copying the first source code, modifications can be made based on the copied first source code. In this case, the process of generating the second source code can be implemented as follows: Generate a target mini-program directory corresponding to the second platform; the target mini-program directory is used to provide operational space for cross-platform source code migration. Copy the first source code to the target mini-program directory; The first source code in the target mini-program directory is parsed. Based on the cross-platform interface library, the standardized global variables referenced in the standardized interface calls are replaced with global variables from the second platform to obtain the target interface call code.

[0038] In one possible implementation, the computer device can execute system commands to invoke a migration tool (such as iTransfer) to perform a copy operation, completely copying the code, resources, and configuration files of the source mini-program project to the target mini-program directory, providing the original materials for subsequent cross-platform code conversion. The iTransfer tool can intelligently analyze the source code structure of mini-programs on various platforms based on an abstract syntax tree and preset cross-platform compatibility rules, summarizing the current code's cross-platform compatibility and assessing the feasibility of various functions on different platforms, thus providing accurate conversion basis and optimization suggestions for subsequent automated migration. Furthermore, the migration tool reads the cross-platform interface library and, based on the global variables corresponding to the second platform obtained from the cross-platform interface library, changes the SFT_mini_sys variable in the first source code to a global variable of the second platform.

[0039] In one possible implementation, to ensure the accuracy of the generated second source code, it is necessary to ensure that the target mini-program directory is empty before copying the first source code to the target mini-program directory. Therefore, the method also includes: Before copying the first source code to the target mini-program directory, clear the target mini-program directory.

[0040] Furthermore, to ensure the correctness of the migration process input, the computer device can verify the existence of the mini-program before generating the target mini-program directory corresponding to the second platform. If the mini-program exists, subsequent operations can proceed, avoiding failures due to incorrect paths or missing files. After confirming the mini-program's existence, the target mini-program directory is automatically generated via system commands, providing a standardized workspace for subsequent code adaptation and file migration, thereby ensuring the automation and reliability of the migration process. Subsequent code adaptation operations are also performed within the target mini-program directory to ensure that the application of the target mini-program on the first platform is unaffected.

[0041] Step 230: Modify the parameters of the global configuration file and page configuration file in the intermediate source code according to the file configuration rules of the second platform to obtain the second source code of the target mini-program after migration to the second platform.

[0042] The parameters corresponding to the global configuration file include the mini-program route and route configuration parameters; the parameters corresponding to the page configuration file include view layer tags, event instructions, and the lifecycle hook names of the interaction layer.

[0043] Therefore, according to the file configuration rules of the second platform, the parameters of the global configuration file and page configuration file in the intermediate source code are modified, including: The migration tool replaces the view layer tags and event instructions in the intermediate source code corresponding to the second platform. The migration tool replaces the lifecycle hook names of the interaction layer corresponding to the second platform; The target mini-program directory is read by a migration tool, and the global configuration file in the intermediate source code is replaced with the mini-program route and route configuration parameters corresponding to the second platform to obtain the source code corresponding to the second platform, i.e., the second source code. It should be noted that the order of parameter modification by the migration tool is illustrative and is not limited in this embodiment.

[0044] Figure 4 This illustration shows a schematic diagram of code migration based on a migration tool provided in an exemplary embodiment of this application, such as... Figure 4 As shown, code adaptation operations include view layer configuration, such as event and style-related interface settings; system configuration, namely routing configuration implemented through the iTransfer tool and other platform adaptation configurations; and global configuration file configuration, including the Sft_mini_api standardized interface, Sft_mini_sys platform global variables, and Sft_mini_var platform-defined fields. Through the above configuration, the view layer can maintain platform independence, the system configuration can handle differentiated adaptation, and the global configuration file can dynamically determine the runtime environment through platform-defined fields, so that the standardized interface can be automatically mapped to the native implementation of different platforms, realizing cross-platform mini-program migration.

[0045] In summary, the cross-platform mini-program migration method provided in this application replaces the native interface calls corresponding to the first platform with standardized interface calls from a cross-platform interface library, and dynamically determines the application platform pointed to by the interface based on the platform definition field to obtain the first source code of the target mini-program. When the application platform indicated by the platform definition field is changed to the second platform, the standardized global variables referenced in the standardized interface calls are replaced with global variables of the second platform based on the cross-platform interface library, and code adaptation operations corresponding to the second platform are performed on this basis to obtain the second source code of the target mini-program adapted to the second platform. The above scheme can achieve more efficient and more compatible multi-terminal migration through dynamic interface mapping and automated engineering configuration conversion, decouples framework dependencies, and improves the development and deployment efficiency of mini-programs.

[0046] Taking the migration of a target mini-program from the first platform to the second platform as an example, Figure 5 This application illustrates an exemplary embodiment of the cross-platform mini-program migration process, as shown in the diagram. Figure 5 As shown, after developers write code for the first platform according to preset rules, they obtain the first source code. During execution, functional development is performed by calling standardized interfaces provided by the cross-platform interface library (such as SFT_mini_api.request). At this time, the interface library automatically maps to the native API of the current platform (such as tt.request) based on the platform-defined field (SFT_min_var). When migration to the second platform is required, the migration tool dynamically replaces the standardized interface calls with the native API of the second platform (such as wx.request) based on the mapping table in the cross-platform interface library, thus obtaining the second source code. Throughout the process, the cross-platform interface library acts as a bridge, connecting the first source code with the runtime environment of different platforms, ensuring the compatibility and consistency of the code across different platforms, while the migration tool is responsible for the automated adaptation of interface calls, ultimately achieving seamless migration.

[0047] When there are multiple second platforms, based on the first source code developed for the first platform, the source code for each platform can be generated. Figure 6 The illustration shows a schematic diagram of a mini-program migration process provided in an exemplary embodiment of this application, such as... Figure 6 As shown, after developing a mini-program based on the mini-program syntax and preset rules of any platform (i.e., the first platform), and obtaining the first source code corresponding to the first platform, the first source code is parsed, and global variable replacement and code adaptation operations corresponding to each platform are performed through migration tools to obtain the mini-program source code corresponding to each platform. The process of performing global variable replacement and code adaptation operations can be referred to the relevant content of the above embodiments, and will not be repeated here.

[0048] Figure 7 This application shows a block diagram of a cross-platform app migration device provided in an exemplary embodiment. This device can be applied to a computer device to perform tasks such as... Figure 1 or Figure 2 All or part of the steps of any of the illustrated embodiments, such as Figure 7 As shown, the device may include the following modules.

[0049] The file acquisition module 710 is used to acquire the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces of each platform and the standardized interfaces; The variable replacement module 720 is used to replace the standardized global variables referenced in the standardized interface call with global variables of the second platform based on the cross-platform interface library when the application platform indicated by the platform definition field is changed to the second platform, so as to obtain the target interface call code. The adaptation operation module 730 is used to perform code adaptation operations corresponding to the second platform based on the intermediate source code containing the target interface call code, so as to obtain the second source code of the target mini-program after migration to the second platform.

[0050] In one possible implementation, the variable substitution module 720 includes: The directory generation submodule is used to generate a target mini-program directory corresponding to the second platform; the target mini-program directory is used to provide operational space for cross-platform source code migration. The copy submodule is used to copy the first source code to the target applet directory; The variable substitution submodule is used to parse the first source code in the target mini-program directory, and based on the cross-platform interface library, replace the standardized global variables referenced in the standardized interface call with global variables of the second platform to obtain the target interface call code.

[0051] In one possible implementation, the adaptation operation module 730 is used to modify the parameters of the global configuration file and page configuration file in the intermediate source code according to the file configuration rules of the second platform, so as to obtain the second source code of the target mini-program after migration to the second platform.

[0052] In one possible implementation, the parameters corresponding to the global configuration file include the mini-program route and route configuration parameters; the parameters corresponding to the page configuration file include view layer tags, event instructions, and the lifecycle hook names of the interaction layer.

[0053] In one possible implementation, the device further includes: The clear module is used to clear the target mini-program directory before copying the first source code to the target mini-program directory.

[0054] In one possible implementation, the preset rule also instructs the nesting of container tags outside of view layer tags, which include text tags or input component tags.

[0055] In summary, the cross-platform mini-program migration device provided in this application replaces the native interface calls corresponding to the first platform with standardized interface calls from a cross-platform interface library, and dynamically determines the application platform pointed to by the interface based on the platform definition field to obtain the first source code of the target mini-program. When the application platform indicated by the platform definition field is changed to the second platform, the standardized global variables referenced in the standardized interface calls are replaced with global variables of the second platform based on the cross-platform interface library, and code adaptation operations corresponding to the second platform are performed on this basis to obtain the second source code of the target mini-program after migration to the second platform. The above scheme can achieve more efficient and more compatible multi-terminal migration through dynamic interface mapping and automated engineering configuration conversion, decouples framework dependencies, and improves the development and deployment efficiency of mini-programs.

[0056] Figure 8 A structural block diagram of a computer device 800 illustrated in an exemplary embodiment of this application is shown. This computer device can be implemented as a server as described above in this application. The computer device 800 includes a Central Processing Unit (CPU) 801, a system memory 804 including Random Access Memory (RAM) 802 and Read-Only Memory (ROM) 803, and a system bus 805 connecting the system memory 804 and the CPU 801. The computer device 800 also includes a mass storage device 806 for storing an operating system 809, application programs 810, and other program modules 811.

[0057] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage media are not limited to the above-mentioned types. The system memory 804 and mass storage device 806 described above can be collectively referred to as memory.

[0058] According to various embodiments of this application, the computer device 800 can also be connected to a remote computer on a network, such as the Internet. That is, the computer device 800 can be connected to a network 808 via a network interface unit 807 connected to the system bus 805, or the network interface unit 807 can be used to connect to other types of networks or remote computer systems (not shown).

[0059] The memory also includes at least one instruction, at least one program, code set, or instruction set, which are stored in the memory. The central processing unit 801 executes the at least one instruction, at least one program, code set, or instruction set to implement all or part of the steps in the cross-platform applet migration method shown in the above embodiments.

[0060] Figure 9 A structural block diagram of a computer device 900 illustrating an exemplary embodiment of this application is shown. The computer device 900 can be implemented as the aforementioned terminal device, such as a smartphone, tablet computer, laptop computer, desktop computer, etc. The computer device 900 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.

[0061] Typically, computer device 900 includes a processor 901 and a memory 902.

[0062] In some embodiments, the computer device 900 may optionally include a peripheral device interface 903 and at least one peripheral device. The processor 901, memory 902, and peripheral device interface 903 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 903 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 904, a display screen 905, a camera assembly 906, an audio circuit 907, and a power supply 908.

[0063] In some embodiments, the computer device 900 further includes one or more sensors 909. The one or more sensors 909 include, but are not limited to, an accelerometer 910, a gyroscope 911, a pressure sensor 912, an optical sensor 913, and a proximity sensor 914.

[0064] Those skilled in the art will understand that Figure 9 The structure shown does not constitute a limitation on the computer device 900, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0065] In one exemplary embodiment, a computer-readable storage medium is also provided, which stores at least one computer program that is loaded and executed by a processor to implement all or part of the steps in the cross-platform applet migration method described above. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, or optical data storage device, etc.

[0066] In one exemplary embodiment, a computer program product is also provided, comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the above-described actions. Figure 1 or Figure 2 All or part of the steps of the cross-platform mini-program migration method shown in the embodiments.

[0067] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.

[0068] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.< / view> < / view> < / text> < / view>

Claims

1. A cross-platform mini-program migration method, characterized in that, The method includes: Obtain the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces of each platform and the standardized interfaces; When the application platform indicated by the platform definition field is changed to the second platform, based on the cross-platform interface library, the standardized global variables referenced in the standardized interface call are replaced with global variables of the second platform to obtain the target interface call code; Based on the intermediate source code containing the target interface call code, a code adaptation operation corresponding to the second platform is performed to obtain the second source code of the target mini-program after migration to the second platform.

2. The method according to claim 1, characterized in that, The step of replacing the standardized global variables referenced in the standardized interface call with global variables from the second platform based on the cross-platform interface library to obtain the target interface call code includes: Generate a target mini-program directory corresponding to the second platform; the target mini-program directory is used to provide operational space for cross-platform source code migration. Copy the first source code to the target mini-program directory; The first source code in the target mini-program directory is parsed, and based on the cross-platform interface library, the standardized global variables referenced in the standardized interface call are replaced with global variables of the second platform to obtain the target interface call code.

3. The method according to claim 2, characterized in that, The step of performing code adaptation operations based on intermediate source code containing the target interface call code to correspond to the second platform, thereby obtaining the second source code of the target mini-program after migration to the second platform, includes: According to the file configuration rules of the second platform, the parameters of the global configuration file and page configuration file in the intermediate source code are modified to obtain the second source code of the target mini-program after migration to the second platform.

4. The method according to claim 3, characterized in that, The parameters corresponding to the global configuration file include the mini-program route and route configuration parameters; the parameters corresponding to the page configuration file include view layer tags, event instructions, and the lifecycle hook names of the interaction layer.

5. The method according to claim 2, characterized in that, Before copying the first source code to the target mini-program directory, the method further includes: Clear the target mini-program directory.

6. The method according to claim 1, characterized in that, The preset rule also instructs to nest container tags outside view layer tags, the view layer tags including text tags or input component tags, and the container tags being standardized encapsulation units for cross-platform user interface rendering.

7. A cross-platform mini-program migration device, characterized in that, The device includes: The file acquisition module is used to acquire the first source code of the target mini-program; the first source code is source code adapted to the first platform compiled according to preset rules; the preset rules indicate that the native interface calls of the first platform are replaced by standardized interface calls provided by the cross-platform interface library; the standardized interface calls are used to dynamically determine the interface pointer based on the platform definition fields; the cross-platform interface library stores a mapping table between the native interfaces of each platform and the standardized interfaces; The variable substitution module is used to replace the standardized global variables referenced in the standardized interface call with global variables of the second platform based on the cross-platform interface library when the application platform indicated by the platform definition field is changed to the second platform, so as to obtain the target interface call code. The adaptation operation module is used to perform code adaptation operations corresponding to the second platform based on the intermediate source code containing the target interface call code, so as to obtain the second source code of the target mini-program after migration to the second platform.

8. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one computer program, which is loaded and executed by the processor to implement the cross-platform applet migration method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the cross-platform applet migration method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to execute to implement the cross-platform applet migration method as described in any one of claims 1 to 6.