Skip to content

Commit bc9dbb0

Browse files
committed
upgrade ng to 6.0, use ngcli, fixes zkweb-framework#3
1 parent 1b582e0 commit bc9dbb0

File tree

197 files changed

+12578
-991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+12578
-991
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This demo is host on [http://mvvmdemo.zkweb.org](http://mvvmdemo.zkweb.org)<br/>
1111

1212
# Features
1313

14-
- Use AngularJS 4.0 + Webpack 2.0
14+
- Use AngularJS 6.0 + NgCli
1515
- Support automatic generate script form dto and application service
1616
- Support return pre-compressed script bundle
1717
- Support CORS api request
@@ -36,7 +36,9 @@ This demo is host on [http://mvvmdemo.zkweb.org](http://mvvmdemo.zkweb.org)<br/>
3636

3737
# How to start
3838

39-
**Use taobao npm mirror if needed**
39+
**Use taobao npm mirror (optional)**
40+
41+
If you're in china, use taobao registry will make the npm command much happier.
4042

4143
```
4244
npm config set registry http://registry.npm.taobao.org
@@ -47,26 +49,25 @@ npm config set sass_binary_site http://npm.taobao.org/mirrors/node-sass
4749

4850
```
4951
cd src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static
52+
npm install -g @angular/cli
5053
npm install
51-
npm run build
54+
ng build --prod --aot
5255
```
5356

54-
**Modify database configuration"
57+
**Modify database configuration (optional)**
5558

56-
Open `ZKWeb.MVVMDemo.AspNetCore\App_Data\config.json` and modify database configuration.
59+
Open `ZKWeb.MVVMDemo.AspNetCore\App_Data\config.json` and modify database configuration.<br/>
60+
By default it uses sqlite.
5761

5862
**Start website**
5963

60-
Open `ZKWeb.MVVMDemo.sln` with VS2017 and run the project.
61-
62-
**Use webpack-dev-server (optional)**
64+
Open `ZKWeb.MVVMDemo.sln` with visual studio (>= 2017) and run the project.<br/>
65+
If you're using linux, please install libgdiplus by following the instruction on [here](https://github.com/zkweb-framework/ZKWeb.System.Drawing).
6366

64-
If you want more verbose error message and faster recompilation you can use webpack-dev-server, <br/>
65-
Run following command and open `http://127.0.0.1:3000` in your browser.
67+
**Use ng-serve (optional)**
6668

67-
```
68-
npm run dev
69-
```
69+
If you want more verbose error message and faster recompilation you can use ng-serve, <br/>
70+
First, modify `apiUrlBase` in `src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static/index.html`, use the proper api server address, then run `ng serve` under `src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static`.
7071

7172
# Documents
7273

@@ -75,5 +76,5 @@ npm run dev
7576
# LICENSE
7677

7778
LICENSE: MIT LICENSE<br/>
78-
Copyright © 2017 303248153@github<br/>
79+
Copyright © 2017-2018 303248153@github<br/>
7980
If you have any license issue please contact [email protected].<br/>

TODO.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/cn/NgFrontendStruction.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ Angular的前端文件储存在`src\ZKWeb.MVVMPlugins\MVVM.Angular.Website\stati
44

55
![前端项目](img/frontend_struction.jpg)
66

7-
它们的作用如下
7+
TODO: 更新上图(结构还是使用webpack时的结构,现在已经换成了ngcli)
88

9-
- dist: webpack生成的最终前端文件,发布时只需要这个文件夹
9+
它们的作用如下:
10+
11+
- dist: ngcli生成的最终前端文件,发布时只需要这个文件夹
1012
- node_modules: npm安装的库
1113
- src: 前端源代码
14+
- environments: 保存ngcli使用的编译配置
15+
- environment.prod.ts: 生产环境的编译配置 (编译时用--prod选项)
16+
- environment.ts: 开发环境使用的编译配置
1217
- modules: 保存前端模块的文件夹
1318
- admin_base_module: 后台的基础模块,包含导航菜单等,其他后台模块需要引用此模块
1419
- admin_module: 后台主模块,包含后台的路由信息,其他后台模块不能引用此模块
@@ -29,12 +34,15 @@ Angular的前端文件储存在`src\ZKWeb.MVVMPlugins\MVVM.Angular.Website\stati
2934
- index.html: Html主程序文件
3035
- main.ts: Angular主程序文件
3136
- polyfills.ts: 用于引用为旧浏览器提供新功能支持的脚本
37+
- tsconfig.app.json: TypeScript相关配置
38+
- tsconfig.spec.json: TypeScript相关配置
39+
- tslint.json: TypeScript规范设置
3240
- vendor.ts: 用于引用第三方脚本
3341
- .gitignore: git忽略文件,这里用于忽略dist和node_modules
42+
- angular.json: ngcli的配置文件
3443
- package.json: npm库文件,用于指定当前包名称和需要安装哪些包
3544
- tsconfig.json: TypeScript设置
36-
- tslint.json: TypeScript规范设置,使用npm run lint可以检查代码规范
37-
- webpack.config.js: Webpack设置,使用npm run build可以编译和打包前端
45+
- tslint.json: TypeScript规范设置,使用ng lint可以检查代码规范
3846

3947
### **路由的定义**
4048

docs/cn/README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
基于ZKWeb网页框架的MVVM示例
22

3-
这份示例使用了ZKWeb提供的插件系统和AngularJS 4.0编写的模块化前端,支持前后端分离,并且提供了一套基本的后台管理系统
3+
这份示例使用了ZKWeb提供的插件系统和AngularJS 6.0编写的模块化前端,支持前后端分离,并且提供了一套基本的后台管理系统
44

55
这份示例的开源协议是MIT,你可以随意的修改并用于个人或商业用途
66

77
![preview](../preview.jpg)
88

99
### 功能一览
1010

11-
- 使用AngularJS 4.0 + Webpack 2.0
11+
- 使用AngularJS 6.0 + NgCli
1212
- 支持自动生成Api服务和DTO的TypeScript脚本
1313
- 支持返回预压缩好的脚本包
1414
- 支持跨站Api请求
@@ -33,7 +33,7 @@
3333

3434
### 如何开始
3535

36-
**如果你访问官方npm源较慢,可以设置使用淘宝的npm镜像**
36+
**设置使用淘宝的npm镜像 (可选)**
3737

3838
```
3939
npm config set registry http://registry.npm.taobao.org
@@ -44,26 +44,25 @@ npm config set sass_binary_site http://npm.taobao.org/mirrors/node-sass
4444

4545
```
4646
cd src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static
47+
npm install -g @angular/cli
4748
npm install
48-
npm run build
49+
ng build --prod --aot
4950
```
5051

51-
**修改数据库配置**
52+
**修改数据库配置 (可选)**
5253

53-
打开`ZKWeb.MVVMDemo.AspNetCore\App_Data\config.json`并修改到你使用的数据库连接
54+
打开`ZKWeb.MVVMDemo.AspNetCore\App_Data\config.json`并修改到你使用的数据库连接.
55+
如果不修改默认会使用sqlite.
5456

5557
**启动网站**
5658

57-
使用VS2017打开`ZKWeb.MVVMDemo.sln`并启动项目即可
59+
使用VS2017打开`ZKWeb.MVVMDemo.sln`并启动项目即可.<br/>
60+
如果你使用的是linux,请参考[这里](https://github.com/zkweb-framework/ZKWeb.System.Drawing)的步骤安装libgdiplus.
5861

59-
**使用webpack-dev-server (可选)**
62+
**使用ng-serve (可选)**
6063

61-
如果你想要更详细的错误信息和更快的编译速度可以使用webpack-dev-server,<br/>
62-
运行以下命令并在浏览器打开`http://127.0.0.1:3000`.
63-
64-
```
65-
npm run dev
66-
```
64+
如果你想要更详细的错误信息和更快的编译速度可以使用ng-serve,<br/>
65+
首先你需要修改`src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static/index.html`中的`apiUrlBase`, 填写服务端对应的地址, 然后在`src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static`目录下运行`ng serve`命令.
6766

6867
### 更多内容
6968

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
dist-dev
3+
node_modules
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"name": "zkweb-mvvm-demo",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"build": "./node_modules/.bin/webpack --config webpack.config.js --colors --progress",
6+
"watch": "./node_modules/.bin/webpack --config webpack.config.js --colors --progress --watch",
7+
"lint": "./node_modules/.bin/tslint ./src/**/*.ts -t verbose",
8+
"dev": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --colors --progress"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "MIT",
13+
"dependencies": {
14+
"@angular/cli": "~1.0.0",
15+
"@angular/common": "~4.0.0",
16+
"@angular/compiler": "~4.0.0",
17+
"@angular/core": "~4.0.0",
18+
"@angular/forms": "~4.0.0",
19+
"@angular/http": "~4.0.0",
20+
"@angular/platform-browser": "~4.0.0",
21+
"@angular/platform-browser-dynamic": "~4.0.0",
22+
"@angular/router": "~4.0.0",
23+
"angular-in-memory-web-api": "~0.3.0",
24+
"core-js": "^2.4.1",
25+
"reflect-metadata": "^0.1.10",
26+
"rxjs": "5.3.0",
27+
"systemjs": "0.19.40",
28+
"zone.js": "^0.8.4"
29+
},
30+
"devDependencies": {
31+
"@angular/cli": "~1.0.0",
32+
"@angular/compiler-cli": "~4.0.0",
33+
"@angular/animations": " ~4.0.0",
34+
"@ngtools/webpack": "~1.6.0",
35+
"@types/jasmine": "2.5.36",
36+
"@types/node": "^6.0.46",
37+
"awesome-typescript-loader": "^3.1.3",
38+
"angular2-template-loader": "~0.6.2",
39+
"angular-router-loader": "~0.6.0",
40+
"babel-core": "^6.24.1",
41+
"babel-loader": "^6.4.1",
42+
"canonical-path": "0.0.2",
43+
"compression-webpack-plugin": "^0.3.2",
44+
"concurrently": "^3.2.0",
45+
"copy-webpack-plugin": "^4.0.1",
46+
"css-loader": "^0.27.3",
47+
"glob-stream": "^6.1.0",
48+
"gulp": "^3.9.1",
49+
"gulp-sass": "^3.1.0",
50+
"gulp-sourcemaps": "^2.5.1",
51+
"gulp-typescript": "^3.1.6",
52+
"html-webpack-plugin": "^2.28.0",
53+
"is-valid-glob": "^0.3.0",
54+
"jasmine-core": "~2.4.1",
55+
"karma": "^1.3.0",
56+
"karma-chrome-launcher": "^2.0.0",
57+
"karma-cli": "^1.0.1",
58+
"karma-jasmine": "^1.0.2",
59+
"karma-jasmine-html-reporter": "^0.2.2",
60+
"lazystream": "^1.0.0",
61+
"lite-server": "^2.2.2",
62+
"lodash": "^4.16.4",
63+
"lodash.isequal": "^4.5.0",
64+
"merge-stream": "^1.0.1",
65+
"node-sass": "^4.5.2",
66+
"primeng": "^4.0.0-rc.3",
67+
"protractor": "~4.0.14",
68+
"raw-loader": "^0.5.1",
69+
"rimraf": "^2.5.4",
70+
"sass-loader": "^6.0.3",
71+
"strip-bom-stream": "^3.0.0",
72+
"style-loader": "^0.13.1",
73+
"stylus": "^0.54.5",
74+
"stylus-loader": "^2.4.0",
75+
"to-string-loader": "^1.1.5",
76+
"tslint": "^3.15.1",
77+
"typescript": "~2.1.5",
78+
"vali-date": "^1.0.0",
79+
"vinyl-fs": "^2.4.4",
80+
"webpack": "~2.4.1",
81+
"webpack-dev-server": "~2.4.2",
82+
"webpack-merge": "~4.1.0",
83+
"yargs": "^6.4.0"
84+
},
85+
"repository": {}
86+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>ZKWeb MVVM Demo</title>
5+
<base href="/">
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link href="favicon.ico" rel="icon" type="image/x-icon" />
9+
<link rel="stylesheet" href="preloader.css" />
10+
</head>
11+
<body class="skin-default">
12+
<my-app>
13+
<div class="preloader-container">
14+
<div class="preloader"></div>
15+
</div>
16+
</my-app>
17+
<script>
18+
window.appConfig = {
19+
// apiUrlBase: "http://localhost:53128",
20+
apiUrlBase: null
21+
};
22+
</script>
23+
</body>
24+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// import { enableProdMode } from '@angular/core';
2+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3+
import { AppModule } from './modules/app_module/app.module';
4+
5+
// 启用生产模式可以取消注释以下行
6+
// enableProdMode();
7+
8+
platformBrowserDynamic().bootstrapModule(AppModule);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4+
import { RouterModule } from '@angular/router';
5+
import { InputTextModule } from 'primeng/components/inputtext/inputtext';
6+
import { PanelModule } from 'primeng/components/panel/panel';
7+
import { ButtonModule } from 'primeng/components/button/button';
8+
import { MessagesModule } from 'primeng/components/messages/messages';
9+
import { BlockUIModule } from 'primeng/components/blockui/blockui';
10+
import { GrowlModule } from 'primeng/components/growl/growl';
11+
import { SlideMenuModule } from 'primeng/components/slidemenu/slidemenu';
12+
13+
import { BaseModule } from '../base_module/base.module';
14+
import { GeneratedModule } from '../generated_module/generated.module';
15+
16+
import { AdminContainerComponent } from './components/admin-container.component';
17+
import { AdminToastService } from './services/admin-toast-service';
18+
19+
@NgModule({
20+
imports: [
21+
CommonModule,
22+
FormsModule,
23+
ReactiveFormsModule,
24+
InputTextModule,
25+
PanelModule,
26+
ButtonModule,
27+
MessagesModule,
28+
BlockUIModule,
29+
GrowlModule,
30+
SlideMenuModule,
31+
BaseModule,
32+
GeneratedModule,
33+
RouterModule
34+
],
35+
declarations: [
36+
AdminContainerComponent,
37+
],
38+
providers: [
39+
AdminToastService
40+
],
41+
exports: [
42+
RouterModule,
43+
AdminContainerComponent
44+
]
45+
})
46+
export class AdminBaseModule { }

0 commit comments

Comments
 (0)