{"id":16440062,"url":"https://github.com/zhuowenli/tbone","last_synced_at":"2025-07-10T11:11:50.143Z","repository":{"id":57170764,"uuid":"271153704","full_name":"zhuowenli/tbone","owner":"zhuowenli","description":"📱 tbone 是一个致力于淘宝小程序和 Web 端同构的解决方案。","archived":false,"fork":false,"pushed_at":"2020-07-20T02:26:55.000Z","size":969,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T19:06:04.193Z","etag":null,"topics":["kbone","miniprogram","taobao-mimiprogram","vue"],"latest_commit_sha":null,"homepage":"https://www.zhuowenli.com/tbone","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/zhuowenli.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-06-10T02:07:55.000Z","updated_at":"2023-08-08T10:16:51.000Z","dependencies_parsed_at":"2022-08-27T13:20:19.827Z","dependency_job_id":null,"html_url":"https://github.com/zhuowenli/tbone","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuowenli%2Ftbone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuowenli%2Ftbone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuowenli%2Ftbone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuowenli%2Ftbone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhuowenli","download_url":"https://codeload.github.com/zhuowenli/tbone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078067,"owners_count":20557274,"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":["kbone","miniprogram","taobao-mimiprogram","vue"],"created_at":"2024-10-11T09:11:04.710Z","updated_at":"2025-03-23T08:31:54.788Z","avatar_url":"https://github.com/zhuowenli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tbone\n\ntbone 是一个致力于[淘宝小程序]和 Web 端同构的解决方案，在 [kbone] 的基础上支持了淘宝、支付宝小程序。\n\n## 简介\n\n[淘宝小程序]和[支付宝小程序]的底层模型和 Web 端不同，我们想直接把 Web 端的代码挪到小程序环境内执行是不可能的。tbone 的诞生就是为了解决这个问题，它实现了一个适配器，在适配层里模拟出了浏览器环境，让 Web 端的代码可以不做什么改动便可运行在小程序里。\n\n由于 tbone 小程序运行时方案与 [kbone] 同源，因此此处可以直接查看 [kbone] 对于[运行时方案原理的解释](https://wechat-miniprogram.github.io/kbone/docs/guide/principle.html) 。tbone 小程序运行时方案上层通过 [@zhuowenli/mp-webpack-plugin] 进行小程序代码的编译。底层上使用 [@zhuowenli/miniapp-render] 和 [@zhuowenli/miniapp-element] 进行适配。\n\n使用该方案的优点是开发者可以自如地使用任何语法而不会再受到限制，缺点是性能上存在一定的损耗。因此，何时启用运行时方案，取决于你对小程序的性能要求有多高。\n\n## 使用\n\n为了可以让开发者可以更自由地进行项目的搭建，以下提供了三种方式，任选其一即可：\n\n### 使用 tbone-cli 快速开发\n\n对于新项目，可以使用 `tbone-cli` 来创建项目，首先安装 `tbone-cli`:\n\n```bash\nnpm install -g tbone-cli\n```\n\n创建项目：\n\n```bash\ntbone init my-app\n```\n\n进入项目，按照 README.md 的指引进行开发：\n\n```bash\n// 开发小程序端\nnpm run mp\n\n// 开发 Web 端\nnpm run web\n\n// 构建 Web 端\nnpm run build\n```\n\n\u003e PS：项目基于 webpack 构建，关于 webpack 方面的配置可以[点此查看](https://webpack.js.org/configuration/)，而关于小程序构建相关的详细配置细节可以[参考此文档](https://wechat-miniprogram.github.io/kbone/docs/guide/tutorial.html)。\n\n\u003c!-- ### 使用模板快速开发\n\n除了使用 tbone-cli 外，也可以直接将现有模板 clone 下来，然后在模板基础上进行开发改造：\n\n* [Vue 项目模板](https://github.com/zhuowenli/tbone-template-vue)\n* [React 项目模板](https://github.com/zhuowenli/tbone-template-react)\n\n项目 clone 下来后，按照项目中 README.md 的指引进行开发。 --\u003e\n\n### 手动配置开发\n\n此方案基于 webpack 构建实现，如果你不想要使用官方提供的模板，想要更灵活地搭建自己的项目，又或者是想对已有的项目进行改造，则需要自己补充对应配置来实现 tbone 项目的构建。\n\n一般需要补充两个配置：\n\n* 构建到小程序代码的[webpack 配置](https://webpack.js.org/configuration/)\n* 使用 webpack 构建中使用到的特殊插件 [@zhuowenli/mp-webpack-plugin 配置](https://wechat-miniprogram.github.io/kbone/docs/config/)\n\n[点此可以查看](https://wechat-miniprogram.github.io/kbone/docs/guide/tutorial.html)具体配置方式和操作流程。\n\n## 文档\n\n更为详细的说明和指引，可点击[查看文档](https://wechat-miniprogram.github.io/kbone/docs/)。\n\n## TODOS\n\n* [ ] 云函数适配\n* [ ] 原生 select 组件适配\n* [ ] 原生 canvas 组件适配\n* [ ] Echarts 适配\n\n## License\n\n[MIT](./LICENSE)\n\n[淘宝小程序]: https://miniapp.open.taobao.com/docV3.htm?docId=117200\u0026docType=1\n[支付宝小程序]: https://opendocs.alipay.com/mini/developer\n[kbone]: https://github.com/Tencent/kbone\n[@zhuowenli/mp-webpack-plugin]: https://www.npmjs.com/package/@zhuowenli/mp-webpack-plugin\n[@zhuowenli/miniapp-render]: https://www.npmjs.com/package/@zhuowenli/miniapp-render\n[@zhuowenli/miniapp-element]: https://www.npmjs.com/package/@zhuowenli/miniapp-element\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhuowenli%2Ftbone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhuowenli%2Ftbone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhuowenli%2Ftbone/lists"}