瀏覽代碼

SPA

master
peter 5 年之前
父節點
當前提交
111656b9b4

+ 1
- 1
angular.json 查看文件

@@ -15,7 +15,7 @@
15 15
           "options": {
16 16
             "outputPath": "dist/server",
17 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,12 +4,12 @@
4 4
   "version": "1.0.0",
5 5
   "scripts": {
6 6
     "tsc": "tsc",
7
-    "launch": "node lib/src/backend/Launcher.js",
7
+    "launch": "node dist/server/main.js",
8 8
     "start": "npm run build && npm run launch",
9 9
     "start-backend": "npm run build-backend && npm run launch",
10 10
     "test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",
11 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 13
     "build-frontend": "npm run clean-frontend && (mkdir static || rm -rf static/*) && npm run build-dashboard",
14 14
     "build-dashboard": "cd src/frontend && npm i && npm run build && cp -r dist/* ../../static",
15 15
     "clean": "rm -rf data && npm run clean-backend && npm run clean-frontend",
@@ -25,14 +25,7 @@
25 25
   "author": "frontblock.me",
26 26
   "license": "ISC",
27 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 28
     "@types/mocha": "^5.2.7",
35
-    "angular": "^1.7.9",
36 29
     "bsert": "0.0.10",
37 30
     "bsock": "^0.1.9",
38 31
     "child-process-promise": "^2.2.1",
@@ -64,10 +57,6 @@
64 57
     "xml2js": "^0.4.22"
65 58
   },
66 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 60
     "madge": "^3.6.0",
72 61
     "mocha": "^7.0.0",
73 62
     "terser-webpack-plugin": "^1.4.1",

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

@@ -22,9 +22,9 @@ import { Injector } from '../Injector/Injector';
22 22
 import { Shoutbox } from '../Components/Shoutbox/Shoutbox';
23 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 30
 const logger = getLogger("admin", 'debug') 
@@ -134,13 +134,12 @@ implements TableDefinitionExporter, IAdmin {
134 134
         
135 135
         let port:number = this.config.getConfig().httpPort
136 136
         this.express = express()
137
-        this.express.use('/', express.static('static'))
138
-
139 137
 
138
+    /*
140 139
         this.express.engine('html', ngExpressEngine({
141 140
             bootstrap: AppServerModule,
142 141
         }));
143
-    
142
+        
144 143
         this.express.set('view engine', 'html');
145 144
         this.express.set('views', 'static');
146 145
         
@@ -148,15 +147,23 @@ implements TableDefinitionExporter, IAdmin {
148 147
         this.express.get('*.*', express.static('static', {
149 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 156
           // All regular routes use the Universal engine
153 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 167
         this.express.get('/plugins/:id'+".js", async (request, response) => {
161 168
             const pth = Path.resolve("plugins/"+request.params.id, "FrontendPlugin.js");
162 169
             const file = await fs.readFile(pth)
@@ -167,17 +174,13 @@ implements TableDefinitionExporter, IAdmin {
167 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 178
         this.express.get("/", (request, response) => {
174 179
             response.status(200)
175 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 184
         this.express.get("*", (request, response) => {
182 185
             response.status(301)
183 186
             response.redirect('/')
@@ -187,6 +190,8 @@ implements TableDefinitionExporter, IAdmin {
187 190
         this.httpServer.listen(port, () => {
188 191
             logger.info('Admin panel listening for HTTP on *'+port)
189 192
         })
193
+
194
+/* */
190 195
     }
191 196
 
192 197
     private stopWebserver(){

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

@@ -1,6 +1,7 @@
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 6
 import { AppModule } from '../../frontend/src/app/app.module';
6 7
 import { AppComponent } from '../../frontend/src/app/app.component';
@@ -17,3 +18,4 @@ import { AppComponent } from '../../frontend/src/app/app.component';
17 18
   bootstrap: [ AppComponent ],
18 19
 })
19 20
 export class AppServerModule {}
21
+*/

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

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

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

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

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

@@ -0,0 +1,2 @@
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,7 +13,7 @@
13 13
     "ng": "ng",
14 14
     "conventional-changelog": "conventional-changelog",
15 15
     "start": "ng serve",
16
-    "build": "ng build --aot",
16
+    "build": "ng build",
17 17
     "build:prod": "npm run build -- --prod --aot",
18 18
     "test": "ng test",
19 19
     "test:coverage": "rimraf coverage && npm run test -- --code-coverage",
@@ -44,7 +44,7 @@
44 44
     "@nebular/auth": "4.4.0",
45 45
     "@nebular/eva-icons": "4.4.0",
46 46
     "@nebular/security": "4.4.0",
47
-    "@nebular/theme": "4.4.0",
47
+    "@nebular/theme": "^4.4.0",
48 48
     "@swimlane/ngx-charts": "^10.0.0",
49 49
     "angular-tree-component": "7.2.0",
50 50
     "angular2-chartjs": "0.4.1",
@@ -109,6 +109,6 @@
109 109
     "ts-node": "3.2.2",
110 110
     "tslint": "^5.7.0",
111 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,8 +3,9 @@
3 3
  * Copyright Akveo. All Rights Reserved.
4 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 7
 import { ApiService } from './frontcraft/services/login-api';
8
+import { isPlatformBrowser } from '@angular/common';
8 9
 
9 10
 @Component({
10 11
   selector: 'ngx-app',
@@ -12,11 +13,17 @@ import { ApiService } from './frontcraft/services/login-api';
12 13
 })
13 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 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,7 +39,7 @@ export class FrontcraftRaidComponent implements OnInit, OnDestroy{
39 39
       tokens:{},
40 40
       tier: 'null'
41 41
     }
42
-    tokens = {}
42
+    tokens: {[itemname in string]: (Character & SRToken & Item)[]} = {}
43 43
     displayedtokens = {}
44 44
     search = ""
45 45
     uuid
@@ -51,7 +51,6 @@ export class FrontcraftRaidComponent implements OnInit, OnDestroy{
51 51
       private dialogService : NbDialogService,
52 52
       private toast: NbToastrService
53 53
     ){
54
-      window['r'] = this
55 54
       router.events.subscribe(event => {
56 55
         if (event instanceof NavigationStart) {
57 56
           this.ngOnDestroy()
@@ -163,7 +162,6 @@ export class FrontcraftRaidComponent implements OnInit, OnDestroy{
163 162
       const raiddata = await raidManager.getRaidData(<any>{
164 163
         id: param
165 164
       })
166
-      console.log(raiddata);
167 165
       
168 166
       this.display(raiddata)
169 167
       

+ 16
- 2
tsconfig.json 查看文件

@@ -2,13 +2,27 @@
2 2
     "compilerOptions": {
3 3
       "strictPropertyInitialization": false,
4 4
       "noImplicitAny": false,
5
-      "target": "ESnext",
5
+      "target": "esNext",
6 6
       "declaration": true,
7
+      "module": "commonjs",
8
+      "moduleResolution": "node",
7 9
       "strict": true,
8 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 24
     "angularCompilerOptions": {
25
+      "enableIvy": false,
12 26
       "entryModule": "./src/backend/Admin/app.server.module#AppServerModule"
13 27
     }
14 28
 }

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

@@ -1,14 +0,0 @@
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
-}

Loading…
取消
儲存