Ember-Pusher 项目教程
ember-pusherA proper Ember / Pusher integration.项目地址:https://gitcode.com/gh_mirrors/em/ember-pusher
1. 项目的目录结构及介绍
Ember-Pusher 项目的目录结构如下:
ember-pusher/
├── app/
│ ├── controllers/
│ ├── helpers/
│ ├── initializers/
│ ├── models/
│ ├── routes/
│ ├── serializers/
│ ├── services/
│ ├── templates/
│ └── views/
├── config/
│ ├── environment.js
│ └── optional-features.json
├── ember-cli-build.js
├── package.json
├── public/
│ ├── assets/
│ ├── images/
│ └── index.html
├── tests/
│ ├── integration/
│ ├── unit/
│ └── test-helper.js
├── vendor/
└── README.md
目录介绍:
- app/: 包含应用程序的主要代码,如控制器、模型、路由等。
- config/: 包含配置文件,如
environment.js
用于配置环境变量。 - ember-cli-build.js: 构建配置文件。
- package.json: 项目的依赖和脚本。
- public/: 静态资源文件,如图片和样式文件。
- tests/: 测试代码。
- vendor/: 第三方库和工具。
- README.md: 项目说明文档。
2. 项目的启动文件介绍
项目的启动文件主要是 app/app.js
和 config/environment.js
。
app/app.js
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver,
});
loadInitializers(App, config.modulePrefix);
export default App;
介绍:
- Application: 定义应用程序的主类。
- Resolver: 解析器,用于解析模块路径。
- loadInitializers: 加载初始化器。
- config: 导入配置文件。
3. 项目的配置文件介绍
项目的配置文件主要是 config/environment.js
。
config/environment.js
'use strict';
module.exports = function(environment) {
let ENV = {
modulePrefix: 'ember-pusher',
environment,
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
}
if (environment === 'production') {
// here you can enable a production-specific feature
}
return ENV;
};
介绍:
- environment: 定义不同的环境配置,如开发、测试和生产环境。
- modulePrefix: 模块前缀。
- rootURL: 根URL。
- locationType: 位置
ember-pusherA proper Ember / Pusher integration.项目地址:https://gitcode.com/gh_mirrors/em/ember-pusher