{"id":20064903,"url":"https://github.com/baidu/wx2","last_synced_at":"2025-10-15T04:34:19.744Z","repository":{"id":52468671,"uuid":"314131931","full_name":"baidu/wx2","owner":"baidu","description":"小程序互转工具","archived":false,"fork":false,"pushed_at":"2021-04-28T07:22:57.000Z","size":86,"stargazers_count":122,"open_issues_count":4,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-05T18:35:51.645Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baidu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-19T04:02:53.000Z","updated_at":"2025-02-12T06:39:08.000Z","dependencies_parsed_at":"2022-08-25T22:41:17.853Z","dependency_job_id":null,"html_url":"https://github.com/baidu/wx2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/baidu/wx2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baidu%2Fwx2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baidu%2Fwx2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baidu%2Fwx2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baidu%2Fwx2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baidu","download_url":"https://codeload.github.com/baidu/wx2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baidu%2Fwx2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263986223,"owners_count":23539808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T13:48:10.186Z","updated_at":"2025-10-15T04:34:14.704Z","avatar_url":"https://github.com/baidu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 项目名称\nwx2，微信小程序转换工具\n\n基于已有的原生微信小程序项目，提供零成本平移转换的能力，对小程序间差异进行抹平，提供简单快捷的 API，助力开发者快速互转已有小程序项目。\n\n* 工具会帮你将已有的原生微信小程序转换为目标小程序，目前支持度最好的为百度小程序，其他小程序的能力正在补充中。\n* 工具虽然不能完成100%的转换，但可以帮你节省大量的重复开发成本，随着迭代优化，未来转换率会越来越高\n* 目前只支持转`百度小程序`，后续支持QQ、支付宝、头条等小程序\n\n## 快速开始\n\n### 安装\n\n```\n$ npm i wx2 -g\n```\n\n### 使用\n切换到自己指定的工作目录，执行全局命令`wx2`，并指定转换`目录路径`，和输出`目录路径`\n\n```bash\n// 当前只支持百度小程序，其他小程序后续支持\n$ wx2 \u003c微信小程序文件夹\u003e \u003c目标小程序文件夹\u003e\n```\n\u003e 注： 路径中请包含'/'作为路径标识\n\n### 运行及参数\n使用命令行参数`--target`，简写`-t`\n```\n# 默认，百度小程序\n$ wx2 \u003c微信小程序文件夹\u003e \u003c目标小程序文件夹\u003e --target=swan\n\n# 二次迭代\n$ wx2 \u003c微信小程序文件夹\u003e \u003c目标小程序文件夹\u003e --target=wx\n\n# 当前版本暂不支持，qq小程序\n$ wx2 \u003c微信小程序文件夹\u003e \u003c目标小程序文件夹\u003e --target=qq\n```\n\n#### 日志输出\n```\n// 第三个参数为生成日志的文件夹地址\n$ wx2 \u003c微信小程序文件夹\u003e \u003c目标小程序文件夹\u003e \u003c生成日志的文件夹\u003e -t\n```\n\n#### 自定义转换\n```\n// 第四个参数为生成日志的自定义规则地址\n$ wx2 \u003c微信小程序文件夹\u003e \u003c目标小程序文件夹\u003e \u003c生成日志的文件夹\u003e \u003c自定义规则地址\u003e -t\n```\n\n自定义规则使用方法：\n1、新建自定义规则文件夹（文件夹名自定义），在文件夹下新建wx2.json文件，内部对象用于处理css,js,component,json,view等内置规则，示例如下:\n```\n{\n    \"view\": {\n        \"backets\": [\n            \"s-if\",\n            \"s-elif\",\n            \"s-for\"\n        ]\n    },\n    \"component\": {\n        \"beviors\": {\n            \"swan://form-field\": {\n                \"mapping\": \"wx://form-field\"\n            }\n        }\n    },\n    \"js\": {}\n    \"json\": {\n        \"app.json\": [\"prefetches\"]\n    },\n    \"css\": {}\n}\n```\n\n2、自定义对API处理的插件\n创建过程：需要在自定义规则文件夹下新建api文件夹，并在api下新建plugins文件夹，形如/api/plugins/（代码块的类型）/xxx.js\n代码块类型包括以下:\n'MemberExpression', 'CallExpression', 'ObjectProperty', 'StringLiteral', 'ExpressionStatement', 'ObjectMethod', 'ImportDeclaration', 'VariableDeclaration'\n\n## 测试\n\n### 测试方法\n\n项目通过jest工具进行单元测试，包括测试结果和测试覆盖率。\n```\n// 单元测试\nnpm run jest\n```\n\n## 文档\n\n详细文档参见技术官网：https://pan.baidu.com/union/wx2/home#/\n\n## 维护者\n\nowners: \n* gaofei12@baidu.com\n\ncommitters: \n* zhouyixuan01@baidu.com\n* xujie07@baidu.com\n* wulinfei@baidu.com\n* zhanyongdong@baidu.com\n* dengxiaohong01@baidu.com\n* lijiaxuan02@baidu.com\n* wangshiyuan@baidu.com\n* lijinling03@baidu.com\n* zhangyatao@baidu.com\n\n\n## 反馈\n\nissues贡献： 如在使用中遇到问题，请在 https://github.com/baidu/wx2/issues 新建 issues 反馈问题。\n\n## 讨论\n\n微信扫描二维码，欢迎加入wx2技术交流群(添加下列管理员微信，并备注“wx2”，管理员会邀请您入群)：\n\n\u003cimg src=\"https://staticsns.cdn.bcebos.com/amis/2021-3/1615548842994/jinlin.png\" width = \"150\" height = \"150\" alt=\"lijinling03\" /\u003e\n\u003cimg src=\"https://issuecdn.baidupcs.com/issue/netdisk/ts_ad/help/1605775336.jpg\" width = \"150\" height = \"150\" alt=\"gaofei12\" /\u003e\n\u003cimg src=\"https://issuecdn.baidupcs.com/issue/netdisk/ts_ad/help/1605775338.jpg\" width = \"150\" height = \"150\" alt=\"xujie07\" /\u003e\n\u003cimg src=\"https://issuecdn.baidupcs.com/issue/netdisk/ts_ad/help/1605784743.jpg\" width = \"150\" height = \"150\" alt=\"zhouyixuan01\" /\u003e\n\n\n互转工具百度如流讨论群：3498775\n\n\n\n\n## 版本更新（npm）\n* 1.0.18  支持了微信小程序代码直接对wx赋值或引用的转换情况。\n* 1.0.19  修复了setClipboardData转换问题。\n* 1.0.20  增加LICENSE;支持用户能自定义转换规则，用法见上 ”自定义转换“ 部分。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaidu%2Fwx2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaidu%2Fwx2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaidu%2Fwx2/lists"}