浏览代码

SPA

master
peter 5 年前
父节点
当前提交
111656b9b4

+ 1
- 1
angular.json 查看文件

15
           "options": {
15
           "options": {
16
             "outputPath": "dist/server",
16
             "outputPath": "dist/server",
17
             "main": "src/backend/Launcher.ts",
17
             "main": "src/backend/Launcher.ts",
18
-            "tsConfig": "tsconfig.server.json"
18
+            "tsConfig": "tsconfig.json"
19
           }
19
           }
20
         }
20
         }
21
       }
21
       }

+ 560
- 5821
package-lock.json
文件差异内容过多而无法显示
查看文件


+ 2
- 13
package.json 查看文件

4
   "version": "1.0.0",
4
   "version": "1.0.0",
5
   "scripts": {
5
   "scripts": {
6
     "tsc": "tsc",
6
     "tsc": "tsc",
7
-    "launch": "node lib/src/backend/Launcher.js",
7
+    "launch": "node dist/server/main.js",
8
     "start": "npm run build && npm run launch",
8
     "start": "npm run build && npm run launch",
9
     "start-backend": "npm run build-backend && npm run launch",
9
     "start-backend": "npm run build-backend && npm run launch",
10
     "test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",
10
     "test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",
11
     "build": "npm run build-backend && npm run build-frontend",
11
     "build": "npm run build-backend && npm run build-frontend",
12
-    "build-backend": "npm run clean-backend && ng v && ng run frontcraft:server",
12
+    "build-backend": "npm run clean-backend && tsc",
13
     "build-frontend": "npm run clean-frontend && (mkdir static || rm -rf static/*) && npm run build-dashboard",
13
     "build-frontend": "npm run clean-frontend && (mkdir static || rm -rf static/*) && npm run build-dashboard",
14
     "build-dashboard": "cd src/frontend && npm i && npm run build && cp -r dist/* ../../static",
14
     "build-dashboard": "cd src/frontend && npm i && npm run build && cp -r dist/* ../../static",
15
     "clean": "rm -rf data && npm run clean-backend && npm run clean-frontend",
15
     "clean": "rm -rf data && npm run clean-backend && npm run clean-frontend",
25
   "author": "frontblock.me",
25
   "author": "frontblock.me",
26
   "license": "ISC",
26
   "license": "ISC",
27
   "dependencies": {
27
   "dependencies": {
28
-    "@angular-devkit/build-angular": "^0.900.5",
29
-    "@angular/compiler": "^9.0.5",
30
-    "@angular/compiler-cli": "^9.0.5",
31
-    "@angular/platform-server": "^9.0.5",
32
-    "@nguniversal/express-engine": "^9.0.1",
33
-    "@nguniversal/module-map-ngfactory-loader": "^8.2.6",
34
     "@types/mocha": "^5.2.7",
28
     "@types/mocha": "^5.2.7",
35
-    "angular": "^1.7.9",
36
     "bsert": "0.0.10",
29
     "bsert": "0.0.10",
37
     "bsock": "^0.1.9",
30
     "bsock": "^0.1.9",
38
     "child-process-promise": "^2.2.1",
31
     "child-process-promise": "^2.2.1",
64
     "xml2js": "^0.4.22"
57
     "xml2js": "^0.4.22"
65
   },
58
   },
66
   "devDependencies": {
59
   "devDependencies": {
67
-    "@angular/cli": "^9.0.5",
68
-    "@types/express": "^4.17.0",
69
-    "@types/node": "^11.13.19",
70
-    "@types/semver": "^6.0.1",
71
     "madge": "^3.6.0",
60
     "madge": "^3.6.0",
72
     "mocha": "^7.0.0",
61
     "mocha": "^7.0.0",
73
     "terser-webpack-plugin": "^1.4.1",
62
     "terser-webpack-plugin": "^1.4.1",

+ 22
- 17
src/backend/Admin/Admin.ts 查看文件

22
 import { Shoutbox } from '../Components/Shoutbox/Shoutbox';
22
 import { Shoutbox } from '../Components/Shoutbox/Shoutbox';
23
 import { PubSub } from '../Components/PubSub/PubSub';
23
 import { PubSub } from '../Components/PubSub/PubSub';
24
 
24
 
25
-import { ngExpressEngine } from '@nguniversal/express-engine';
26
-import { APP_BASE_HREF } from '@angular/common';
27
-import { AppServerModule } from './app.server.module';
25
+//import { ngExpressEngine } from '../../frontend/node_modules/@nguniversal/express-engine';
26
+//import { APP_BASE_HREF } from '../../frontend/';
27
+//import { AppServerModule } from './app.server.module';
28
 
28
 
29
 
29
 
30
 const logger = getLogger("admin", 'debug') 
30
 const logger = getLogger("admin", 'debug') 
134
         
134
         
135
         let port:number = this.config.getConfig().httpPort
135
         let port:number = this.config.getConfig().httpPort
136
         this.express = express()
136
         this.express = express()
137
-        this.express.use('/', express.static('static'))
138
-
139
 
137
 
138
+    /*
140
         this.express.engine('html', ngExpressEngine({
139
         this.express.engine('html', ngExpressEngine({
141
             bootstrap: AppServerModule,
140
             bootstrap: AppServerModule,
142
         }));
141
         }));
143
-    
142
+        
144
         this.express.set('view engine', 'html');
143
         this.express.set('view engine', 'html');
145
         this.express.set('views', 'static');
144
         this.express.set('views', 'static');
146
         
145
         
148
         this.express.get('*.*', express.static('static', {
147
         this.express.get('*.*', express.static('static', {
149
             maxAge: '1y'
148
             maxAge: '1y'
150
         }));
149
         }));
151
-        
150
+
151
+        this.express.get("/", (request, response) => {
152
+            response.status(200)
153
+            response.sendFile('index.html');
154
+        })
155
+
152
           // All regular routes use the Universal engine
156
           // All regular routes use the Universal engine
153
         this.express.get('*', (req, res) => {
157
         this.express.get('*', (req, res) => {
154
-            res.render('index', { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
158
+            res.status(301)
159
+            res.redirect('/')
160
+            //res.render('index', { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
155
         });
161
         });
162
+*/
163
+/* */
164
+        // get the compiled FrontendPlugins.js
165
+        this.express.use('/', express.static('static'))
156
 
166
 
157
-        /**
158
-         * get the compiled FrontendPlugins.js
159
-         */
160
         this.express.get('/plugins/:id'+".js", async (request, response) => {
167
         this.express.get('/plugins/:id'+".js", async (request, response) => {
161
             const pth = Path.resolve("plugins/"+request.params.id, "FrontendPlugin.js");
168
             const pth = Path.resolve("plugins/"+request.params.id, "FrontendPlugin.js");
162
             const file = await fs.readFile(pth)
169
             const file = await fs.readFile(pth)
167
             response.send(frontend)
174
             response.send(frontend)
168
         })
175
         })
169
 
176
 
170
-        /**
171
-         * serve the index.html from the static folder
172
-         */
177
+        // serve the index.html from the static folder
173
         this.express.get("/", (request, response) => {
178
         this.express.get("/", (request, response) => {
174
             response.status(200)
179
             response.status(200)
175
             response.sendFile('index.html');
180
             response.sendFile('index.html');
176
         })
181
         })
177
 
182
 
178
-        /**
179
-         * redirect all the other traffic to the single page app
180
-         */
183
+        // redirect all the other traffic to the single page app
181
         this.express.get("*", (request, response) => {
184
         this.express.get("*", (request, response) => {
182
             response.status(301)
185
             response.status(301)
183
             response.redirect('/')
186
             response.redirect('/')
187
         this.httpServer.listen(port, () => {
190
         this.httpServer.listen(port, () => {
188
             logger.info('Admin panel listening for HTTP on *'+port)
191
             logger.info('Admin panel listening for HTTP on *'+port)
189
         })
192
         })
193
+
194
+/* */
190
     }
195
     }
191
 
196
 
192
     private stopWebserver(){
197
     private stopWebserver(){

+ 5
- 3
src/backend/Admin/app.server.module.ts 查看文件

1
-import { NgModule } from '@angular/core';
2
-import { ServerModule } from '@angular/platform-server';
3
-import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';
1
+/*
2
+import { NgModule } from '../../frontend/node_modules/@angular/core';
3
+import { ServerModule } from '../../frontend/node_modules/@angular/platform-server';
4
+import { ModuleMapLoaderModule } from '../../frontend/node_modules/@nguniversal/module-map-ngfactory-loader';
4
 
5
 
5
 import { AppModule } from '../../frontend/src/app/app.module';
6
 import { AppModule } from '../../frontend/src/app/app.module';
6
 import { AppComponent } from '../../frontend/src/app/app.component';
7
 import { AppComponent } from '../../frontend/src/app/app.component';
17
   bootstrap: [ AppComponent ],
18
   bootstrap: [ AppComponent ],
18
 })
19
 })
19
 export class AppServerModule {}
20
 export class AppServerModule {}
21
+*/

+ 2
- 3
src/backend/Components/User/UserManager.ts 查看文件

1
 import { RPCServer, Socket, RPCInterface } from "rpclibrary";
1
 import { RPCServer, Socket, RPCInterface } from "rpclibrary";
2
 import { Inject, Injectable } from "../../Injector/ServiceDecorator";
2
 import { Inject, Injectable } from "../../Injector/ServiceDecorator";
3
-import { FrontworkAdmin } from "../../Admin/Admin";
4
 import { GuildManager } from "../Guild/GuildManager";
3
 import { GuildManager } from "../Guild/GuildManager";
5
 import { ItemManager } from "../Item/ItemManager";
4
 import { ItemManager } from "../Item/ItemManager";
6
 import { RaidManager } from "../Raid/RaidManager";
5
 import { RaidManager } from "../Raid/RaidManager";
35
     name = "UserManager" as "UserManager"
34
     name = "UserManager" as "UserManager"
36
 
35
 
37
     @Inject(IAdmin)
36
     @Inject(IAdmin)
38
-    private admin: FrontworkAdmin
37
+    private admin: IAdmin
39
 
38
 
40
     @Inject(IGuildManager)
39
     @Inject(IGuildManager)
41
     private guild : GuildManager
40
     private guild : GuildManager
50
     private character : CharacterManager
49
     private character : CharacterManager
51
     
50
     
52
     exporters :any[] = []
51
     exporters :any[] = []
53
-    rankServer :  Serverstate<{}, FrontcraftFeatureIfc>
52
+    rankServer : Serverstate<{}, FrontcraftFeatureIfc>
54
     userLogins : {[username in string] : UserRecord} = {}
53
     userLogins : {[username in string] : UserRecord} = {}
55
     allowed: string[] = []
54
     allowed: string[] = []
56
 
55
 

+ 4
- 4
src/backend/Injector/ServiceDecorator.ts 查看文件

7
  * @returns {GenericClassDecorator<Type<any>>}
7
  * @returns {GenericClassDecorator<Type<any>>}
8
  * @constructor
8
  * @constructor
9
  */
9
  */
10
-export const Injectable = (_interface?: Type<any>) : GenericClassDecorator<Type<any>> => {
10
+export function Injectable (_interface?: Type<any>) : GenericClassDecorator<Type<any>> {
11
   return (target: Type<any>) => {
11
   return (target: Type<any>) => {
12
     Injector.modules.push({
12
     Injector.modules.push({
13
       implements: _interface,
13
       implements: _interface,
20
  * @returns {GenericClassDecorator<Type<any>>}
20
  * @returns {GenericClassDecorator<Type<any>>}
21
  * @constructor
21
  * @constructor
22
  */
22
  */
23
-export const RootComponent = (config : {
23
+export function RootComponent(config : {
24
     injectable : Type<any>
24
     injectable : Type<any>
25
     injects : Type<RPCExporter>[]
25
     injects : Type<RPCExporter>[]
26
-  }) : GenericClassDecorator<Type<any>> => {
26
+  }) : GenericClassDecorator<Type<any>>{
27
   return (target: Type<any>) => {
27
   return (target: Type<any>) => {
28
     Injector.rootModules = config.injects
28
     Injector.rootModules = config.injects
29
     Injector.rootInterface = config.injectable
29
     Injector.rootInterface = config.injectable
31
   }
31
   }
32
 }
32
 }
33
 
33
 
34
-export const Inject = (type: any) => {
34
+export function Inject(type: any) {
35
   return function (_this, key) {
35
   return function (_this, key) {
36
     Injector.injectionQueue.push({what: type, target: _this, where:key})
36
     Injector.injectionQueue.push({what: type, target: _this, where:key})
37
   }
37
   }

+ 2
- 0
src/backend/main.server.ts 查看文件

1
+//import { enableProdMode } from '../frontend/node_modules/@angular/core';
2
+//enableProdMode();

+ 6124
- 9612
src/frontend/package-lock.json
文件差异内容过多而无法显示
查看文件


+ 3
- 3
src/frontend/package.json 查看文件

13
     "ng": "ng",
13
     "ng": "ng",
14
     "conventional-changelog": "conventional-changelog",
14
     "conventional-changelog": "conventional-changelog",
15
     "start": "ng serve",
15
     "start": "ng serve",
16
-    "build": "ng build --aot",
16
+    "build": "ng build",
17
     "build:prod": "npm run build -- --prod --aot",
17
     "build:prod": "npm run build -- --prod --aot",
18
     "test": "ng test",
18
     "test": "ng test",
19
     "test:coverage": "rimraf coverage && npm run test -- --code-coverage",
19
     "test:coverage": "rimraf coverage && npm run test -- --code-coverage",
44
     "@nebular/auth": "4.4.0",
44
     "@nebular/auth": "4.4.0",
45
     "@nebular/eva-icons": "4.4.0",
45
     "@nebular/eva-icons": "4.4.0",
46
     "@nebular/security": "4.4.0",
46
     "@nebular/security": "4.4.0",
47
-    "@nebular/theme": "4.4.0",
47
+    "@nebular/theme": "^4.4.0",
48
     "@swimlane/ngx-charts": "^10.0.0",
48
     "@swimlane/ngx-charts": "^10.0.0",
49
     "angular-tree-component": "7.2.0",
49
     "angular-tree-component": "7.2.0",
50
     "angular2-chartjs": "0.4.1",
50
     "angular2-chartjs": "0.4.1",
109
     "ts-node": "3.2.2",
109
     "ts-node": "3.2.2",
110
     "tslint": "^5.7.0",
110
     "tslint": "^5.7.0",
111
     "tslint-language-service": "^0.9.9",
111
     "tslint-language-service": "^0.9.9",
112
-    "typescript": "3.4.5"
112
+    "typescript": "^3.5.1"
113
   }
113
   }
114
 }
114
 }

+ 11
- 4
src/frontend/src/app/app.component.ts 查看文件

3
  * Copyright Akveo. All Rights Reserved.
3
  * Copyright Akveo. All Rights Reserved.
4
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
  * Licensed under the MIT License. See License.txt in the project root for license information.
5
  */
5
  */
6
-import { Component, OnInit } from '@angular/core';
6
+import { Component, OnInit, Inject, PLATFORM_ID, APP_ID } from '@angular/core';
7
 import { ApiService } from './frontcraft/services/login-api';
7
 import { ApiService } from './frontcraft/services/login-api';
8
+import { isPlatformBrowser } from '@angular/common';
8
 
9
 
9
 @Component({
10
 @Component({
10
   selector: 'ngx-app',
11
   selector: 'ngx-app',
12
 })
13
 })
13
 export class AppComponent implements OnInit {
14
 export class AppComponent implements OnInit {
14
 
15
 
15
-  constructor(private loginSvc: ApiService) {
16
-    
16
+  constructor(
17
+    private loginSvc: ApiService,
18
+    @Inject(PLATFORM_ID) private platformId: Object,
19
+    @Inject(APP_ID) private appId: string
20
+  ) {
21
+      if(!isPlatformBrowser(platformId)){
22
+        global['window'] = {}
23
+      }
17
   }
24
   }
18
 
25
 
19
   ngOnInit(): void {
26
   ngOnInit(): void {
20
-    window['s'] = this.loginSvc
27
+
21
   }
28
   }
22
 }
29
 }

+ 1
- 3
src/frontend/src/app/frontcraft/pages/raid/raid.component.ts 查看文件

39
       tokens:{},
39
       tokens:{},
40
       tier: 'null'
40
       tier: 'null'
41
     }
41
     }
42
-    tokens = {}
42
+    tokens: {[itemname in string]: (Character & SRToken & Item)[]} = {}
43
     displayedtokens = {}
43
     displayedtokens = {}
44
     search = ""
44
     search = ""
45
     uuid
45
     uuid
51
       private dialogService : NbDialogService,
51
       private dialogService : NbDialogService,
52
       private toast: NbToastrService
52
       private toast: NbToastrService
53
     ){
53
     ){
54
-      window['r'] = this
55
       router.events.subscribe(event => {
54
       router.events.subscribe(event => {
56
         if (event instanceof NavigationStart) {
55
         if (event instanceof NavigationStart) {
57
           this.ngOnDestroy()
56
           this.ngOnDestroy()
163
       const raiddata = await raidManager.getRaidData(<any>{
162
       const raiddata = await raidManager.getRaidData(<any>{
164
         id: param
163
         id: param
165
       })
164
       })
166
-      console.log(raiddata);
167
       
165
       
168
       this.display(raiddata)
166
       this.display(raiddata)
169
       
167
       

+ 16
- 2
tsconfig.json 查看文件

2
     "compilerOptions": {
2
     "compilerOptions": {
3
       "strictPropertyInitialization": false,
3
       "strictPropertyInitialization": false,
4
       "noImplicitAny": false,
4
       "noImplicitAny": false,
5
-      "target": "ESnext",
5
+      "target": "esNext",
6
       "declaration": true,
6
       "declaration": true,
7
+      "module": "commonjs",
8
+      "moduleResolution": "node",
7
       "strict": true,
9
       "strict": true,
8
       "experimentalDecorators": true,
10
       "experimentalDecorators": true,
9
-      "emitDecoratorMetadata": true
11
+      "emitDecoratorMetadata": true,
12
+
13
+      "outDir": "./lib",
14
+      //"types": ["node"],
15
+      "strictNullChecks": false
10
     },
16
     },
17
+    "include": ["src/backend/**/*"],
18
+    "exclude": [
19
+      "./src/frontend/**/*",
20
+      "./node_modules/**/*", 
21
+      "./src/frontend/node_modules/**/*", 
22
+      "./test",
23
+    ],
11
     "angularCompilerOptions": {
24
     "angularCompilerOptions": {
25
+      "enableIvy": false,
12
       "entryModule": "./src/backend/Admin/app.server.module#AppServerModule"
26
       "entryModule": "./src/backend/Admin/app.server.module#AppServerModule"
13
     }
27
     }
14
 }
28
 }

+ 0
- 14
tsconfig.server.json 查看文件

1
-{
2
-  "extends": "./tsconfig.json",
3
-  "compilerOptions": {
4
-    "outDir": "./lib",
5
-    "module": "commonjs",
6
-    "types": ["node"]
7
-  },
8
-  "include": ["src/backend/**/*", "test/**/*"],
9
-  "exclude": ["node_modules", "**/__tests__/*"],
10
-
11
-  "angularCompilerOptions": {
12
-    "entryModule": "./src/app/app.server.module#AppServerModule"
13
-  }
14
-}

正在加载...
取消
保存