{"id":19428015,"url":"https://github.com/hellof2e/dora","last_synced_at":"2025-04-24T17:31:54.033Z","repository":{"id":182281188,"uuid":"668190497","full_name":"hellof2e/dora","owner":"hellof2e","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-04T07:24:10.000Z","size":4579,"stargazers_count":35,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"release/0.0.1","last_synced_at":"2025-04-03T09:04:38.668Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellof2e.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-19T08:29:43.000Z","updated_at":"2025-02-14T08:24:27.000Z","dependencies_parsed_at":"2023-07-19T12:17:46.233Z","dependency_job_id":null,"html_url":"https://github.com/hellof2e/dora","commit_stats":null,"previous_names":["hellof2e/dora"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellof2e%2Fdora","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellof2e%2Fdora/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellof2e%2Fdora/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellof2e%2Fdora/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellof2e","download_url":"https://codeload.github.com/hellof2e/dora/tar.gz/refs/heads/release/0.0.1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250674393,"owners_count":21469214,"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-10T14:13:32.276Z","updated_at":"2025-04-24T17:31:52.803Z","avatar_url":"https://github.com/hellof2e.png","language":"JavaScript","readme":"\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://ant.design\"\u003e\n    \u003cimage src='./docs/圆角-tmpq_5tz_14.png' width='200px' /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eDora\u003c/h1\u003e\n\n# Taro小程序微前端集成框架\nDora是一个哈啰出行的开源的Taro小程序微前端集成框架，具有把多页业务拆分并集成编译的与通讯的能力，解耦了业务与业务，降低了总体的复杂度与多业务线合作难度\n\n\n## 集成编译\nDora具有集成编译功能，app与在subapp中添加以下config既可以运行，会自动集成各业务线的路由, 可以参考demo仓库\n\n## 事件通讯\nDora使用事件通讯来解耦业务线与业务线之间的关系，在subapp的config中可以定义事件来监听整个app的运行周期与自定义事件\n```\n  componentDidShow () {\n    DoraEvent.emit({\n      eventName : 'app:componentDidShow',\n      args : {},\n    });\n  }\n```\n```\n  event : {\n    'app:componentDidShow' : (arg) =\u003e {\n      console.log('subapp 启动');\n      console.log('持续检测用户当前订单是否偏离导航，触发安全机制。');\n    },\n    'app:componentDidHide' : (arg) =\u003e {\n      console.log('subapp 启动');\n      console.log('推入后台暂停检测');\n    },\n  },\n```\n在小程序componentDidShow时候就会打印\n\u003cimage src='./docs/event.png' \u003e\n\n## 子父通讯与桥接\nDora使用ctx来桥接父与子仓库的通讯\n\n### setCtx\n```\nimport useCtx from '../../../../../src/export/useCtx';\n\nsetCtx({\n  moduleA: ()=\u003e{\n    return '我来自父app'\n  }\n})\n```\n\n### useCtx\n```\n\u003cView className='index'\u003e\n  我是subapp的页面\n  \u003cView \u003e\n    {useCtx().moduleA()}\n  \u003c/View\u003e\n\u003c/View\u003e\n```\n\n## 版本控制\n### Dora update\n`Dora update`\n把所有subapp的版本切换为父应用中的版本\n### Dora publish\n`Dora publish`\n把当前目录publish到父仓库中去，请确定你拥有父仓库与子仓库的push权限\n\n## demo\nhttps://github.com/hellof2e/DoraAppExample 父应用demo\nhttps://github.com/hellof2e/DoraSubappExample 子应用demo\n\n\n\n# 如何使用\n## 安装\n$ npm i -g  @hellobikefe/dora\n\n\n## 指令\n```\n命令\nOptions:\n  -V, --version     output the version number\n  -h, --help        display help for command\nCommands:\n  publish           发布子应用代码至父应用\n  update [options]  更新子应用\n  help [command]    display help for command\n```\n\n## 接入\n### config.json \u0026 config.ts/js\n配置config.json在父应用与子应用中，子应用包含路由和event，父config记录子应用tag path等。在项目初始化的时候可以手动clone子仓库到想要的目录，随后在子应用根目录执行dora publish\n```\n//父亲仓库config.json\n{\n  \"apps\": {\n    \"doraSubappExample\": {\n      \"configPath\": \"./src/doraSubappExample/config.ts\",\n      \"path\": \"./src\",\n      \"repository\": \"git@github.com:gjc9620/dora-subapp-example.git\",\n      \"subAppName\": \"doraSubappExample\", \n      \"tag\": \"1.0.0-release/1.0.0-1689675708545\"\n    }\n  }\n}\n```\n子仓库可以参考 此[配置](https://github.com/hellof2e/doraAppExample/blob/23df5ef592b8c9dab8fa19d15f76ed516fd263fb/src/app.config.ts#L38)\n\n## package.json\n在接入的子仓库的package.json中编写subappname属性\n```\n{\n  \"version\": \"1.0.0\",\n  \"subAppName\": \"doraSubappExample\"\n}\n```\n\n## babel\n增加babel插件 执行npm i babel-plugin-macros@3.1.0，随后在config/index中添加如下代码\n```\nconst macros = (chain) =\u003e chain.merge({\n  module : {\n    rule : {\n      myloader : {\n        test : /(node_modules|src).*\\.(ts|tsx|js|jsx)$/,\n        use : [{\n          loader : 'babel-loader',\n          options : {\n            plugins : [\n              'macros',\n            ],\n          },\n        }],\n      },\n    },\n  },\n});\n\n//增加\nwebpackChain(chain) {\n  macros(chain)\n},\n```\n\n这里配置就完成了\n具体可以参考这2个仓库\n父应用demo(https://github.com/hellof2e/doraAppExample)   \u003cbr/\u003e\n子应用demo(https://github.com/hellof2e/doraSubappExample)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellof2e%2Fdora","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellof2e%2Fdora","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellof2e%2Fdora/lists"}