{"id":29926558,"url":"https://github.com/ecomfe/saber-firework","last_synced_at":"2025-08-02T12:42:09.998Z","repository":{"id":11859402,"uuid":"14418323","full_name":"ecomfe/saber-firework","owner":"ecomfe","description":"移动端MVP开发框架","archived":false,"fork":false,"pushed_at":"2016-04-07T09:52:33.000Z","size":270,"stargazers_count":7,"open_issues_count":0,"forks_count":10,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-07-22T05:16:56.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/ecomfe.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2013-11-15T07:55:57.000Z","updated_at":"2017-04-19T08:14:11.000Z","dependencies_parsed_at":"2022-09-14T11:41:28.223Z","dependency_job_id":null,"html_url":"https://github.com/ecomfe/saber-firework","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/ecomfe/saber-firework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-firework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-firework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-firework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-firework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecomfe","download_url":"https://codeload.github.com/ecomfe/saber-firework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-firework/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268392116,"owners_count":24243297,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-08-02T12:41:59.931Z","updated_at":"2025-08-02T12:42:09.954Z","avatar_url":"https://github.com/ecomfe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"saber-firework\n===\n\n![Bower version](https://img.shields.io/bower/v/saber-firework.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/ecomfe/saber-firework.svg?style=flat-square)](https://travis-ci.org/ecomfe/saber-firework) [![License](https://img.shields.io/github/license/ecomfe/saber-firework.svg?style=flat-square)](./LICENSE) [![EFE Mobile Team](https://img.shields.io/badge/EFE-Mobile_Team-blue.svg?style=flat-square)](http://efe.baidu.com)\n\n移动端`SPA`开发框架，基于[MVP](https://github.com/ecomfe/saber-mm)架构，结合[页面转场](https://github.com/ecomfe/saber-viewport)与[路由管理](https://github.com/ecomfe/saber-router)，提供完整的`SPA`解决方案。\n\n## Installation\n\n使用 [edpx-mobile](https://github.com/ecomfe/edpx-mobile) 初始化项目，引入相关模块\n\n```sh\n$ edp mobile init spa\n```\n\n或者通过 [edp](https://github.com/ecomfe/edp) 引入模块：\n\n```sh\n$ edp import saber-firework\n```\n\n## Usage\n\n```js\nvar app = require('saber-firework');\n\n// 加载index配置\napp.load({\n    path: '/index',\n    action: require('./index')\n});\n\n// 启动App\napp.start();\n```\n\n更多内容请参考[使用指南](doc/guide.md)\n\n从 2.0 开始，`saber-firework` 能支持同构的移动端项目了～ 只需要引入同构的插件就能让 `saber-firework` 作为同构项目的浏览器端运行环境来工作：\n\n```js\nvar app = require('saber-firework');\n\n// 引入同构插件\nrequire('saber-firework/extension/isomorphic');\n\n// 欢迎进入同构的世界～\n...\n```\n\n## API\n\n* [Methods](#methods)\n* [Events](#events)\n\n### Methods\n\n#### start(ele[, options])\n\n启动应用\n\n* **ele** `{HTMLElement}` 容器元素\n* **options** `{Object=}` 全局配置信息\n    * `path` `{string=}` 默认路径，默认为 `'/'`\n    * `index` `{string=}` index文件名称，默认为 `''`，如果设置为 `'index'` 则 `'/'` 与 `'/index'` 认为是相同路径\n    * `template` `{string|Array.\u003cstring\u003e=}` 公共模版字符串，预编译的template，主要用于在启动App时提前编译全局公用的 template，比如母版等，默认为空\n    * `templateConfig` `{Object=}` 模版配置信息，具体请参考 [etpl 配置参数](https://github.com/ecomfe/etpl/blob/master/doc/config.md)\n    * `templateData` `{Object=}` 全局模版数据\n    * `Presenter` `{Object=}` 自定义 Presenter 基类\n    * `Model` `{Object=}` 自定义 Model 基类\n    * `View` `{Object=}` 自定义 View 基类\n    * `router` `{Object=}` 路由器，默认为 `hash` 路由\n    * `timeout` `{number=}` 页面加载超时时间，单位ms，超时后框架可以响应其它页面的切换请求，默认为 `300`\n    * `processor` `{Object=}` 附加处理器，作用于特定时刻调整框架行为，具体请参考[附加处理器说明](doc/processor)\n    * `viewport` `{Object=}` 转场相关配置，具体请参考 [saber-viewprot](https://github.com/ecomfe/saber-viewport) 的[全局配置参数说明](https://github.com/ecomfe/saber-viewport#initele-options)，默认为`{ transition: false }` 关闭转场效果\n\n`saber-firework` 由 [saber-mm](https://github.com/ecomfe/saber-mm) 提供 `MVP` 的实现，`Presenter`、`View`、`Model` 相关的配置与 API 请参考 [saber-mm 的说明文档](https://github.com/ecomfe/saber-mm#classes)\n\n#### load(route)\n\n加载路由配置信息\n\n* **route** `{Object|Array.\u003cObject\u003e}` 路由配置信息\n    * **path** `{string}` 请求路径\n    * **action** `{Object|string}` Presenter 配置信息，如果是字符串则表示配置文件的加载地址，会在后续实际访问时进行异步加载\n    * **cached** `{boolean=}` Presenter 缓存设置，缓存的页面在离开时不会被销毁，下次访问会跳过初始化渲染过程\n    * **transition** `{Object=}` 转场参数，具体请参考 [saber-viewprot](https://github.com/ecomfe/saber-viewport) 的[全局配置参数说明](https://github.com/ecomfe/saber-viewport#initele-options)\n\n#### getSyncData(name)\n\n获取后端同步的数据，只针对同构的项目，关于同构的相关信息请参考 [rebas](https://github.com/ecomfe/rebas)\n\n* **name** `{string}` 数据名称\n* _return_ `{*}` 数据内容\n\n#### delCachedAction(path)\n\n删除缓存的Action\n\n* **path** `{string}` 页面路径\n\n#### on(name, fn)\n\n绑定事件\n\n* **name** `{string}` 事件名称，具体请参考[事件说明](#events)\n* **fn** `{Function}` 事件处理函数\n\n### Events\n\n#### beforeload\n\n加载页面前事件，有两个参数，`after`待加载页面信息 与 `before`当前页面信息\n\n* **after** `{Object}`  待加载页面信息\n    * **route** `{Object}` 待加载页面的路由信息\n        * **path** `{string}` 地址\n        * **query** `{Object}` 查询条件\n        * **url** `{string}` 完整 URL\n    * **action** `{Action}` 待加载的 [Presenter 对象](https://github.com/ecomfe/saber-mm/blob/master/doc/presenter.md)\n    * **page** `{Page}` 待加载的 [Page 对象](https://github.com/ecomfe/saber-viewport#page)\n* **before** `{Object}` 当前页面信息\n    * **route** `{Object}` 当前页面的路由信息\n        * **path** `{string}` 地址\n        * **query** `{Object}` 查询条件\n        * **url** `{string}` 完整 URL\n    * **action** `{Action}` 当前的 [Presenter 对象](https://github.com/ecomfe/saber-mm/blob/master/doc/presenter.md)\n    * **page** `{Page}` 当前的 [Page 对象](https://github.com/ecomfe/saber-viewport#page)\n\n#### beforetransition\n\n转场动画开始前事件，参数同 [beforeload](#beforeload)\n\n#### afterload\n\n页面加载完成事件，参数同 [beforeload](#beforeload)\n\n#### error\n\n页面加载失败事件，参数同 [beforeload](#beforeload)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomfe%2Fsaber-firework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecomfe%2Fsaber-firework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomfe%2Fsaber-firework/lists"}