diff --git a/client/package-lock.json b/client/package-lock.json index 99e5117..1e3391d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -2845,6 +2845,11 @@ "event-emitter": "0.3.5" } }, + "es6-object-assign": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", + "integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=" + }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", @@ -9350,6 +9355,11 @@ "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", "dev": true }, + "promise-polyfill": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.1.0.tgz", + "integrity": "sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc=" + }, "protractor": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/protractor/-/protractor-5.1.2.tgz", @@ -11156,6 +11166,15 @@ "whet.extend": "0.9.9" } }, + "sweetalert": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/sweetalert/-/sweetalert-2.1.0.tgz", + "integrity": "sha512-9YKj0SvjKyBfRWco50UOsIbXVeifYbxzT9Qda7EsqC01eafHGCSG0IR7g942ufjzt7lnwO8ZZBwr6emXv2fQrg==", + "requires": { + "es6-object-assign": "1.1.0", + "promise-polyfill": "6.1.0" + } + }, "symbol-observable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", diff --git a/client/package.json b/client/package.json index 0e7ac11..2032866 100644 --- a/client/package.json +++ b/client/package.json @@ -28,6 +28,7 @@ "file-input-accessor": "^1.0.9", "jquery": "^3.3.1", "rxjs": "^5.5.2", + "sweetalert": "^2.1.0", "zone.js": "^0.8.14" }, "devDependencies": { diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index 3971c65..ffd1a74 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -13,7 +13,7 @@ import {ActivityManagementComponent} from "./view/admin/activity-management/acti import {WorkManagementComponent} from "./view/admin/work-management/work-management.component"; import {AuthComponent} from "./view/admin/auth/auth.component"; import {AdminGuardService} from "./common/admin-guard.service"; -import {FundingManagementComponent} from "./view/admin/funding-management/funding-management.component"; +import {QaComponent} from "./view/qa/qa.component"; const routes: Routes = [ { @@ -48,7 +48,16 @@ const routes: Routes = [ }, { path:'about', - component:AboutComponent + children:[ + { + path:'', + component:AboutComponent + }, + { + path:'question', + component:QaComponent + } + ] }, { path:'admin', @@ -87,7 +96,7 @@ const routes: Routes = [ { path:'**', redirectTo:'/404' - } + }, ]; @NgModule({ diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index e9614fb..7212703 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -32,7 +32,10 @@ import {FileInputAccessorModule} from "file-input-accessor"; import { FundingManagementComponent } from './view/admin/funding-management/funding-management.component'; import {VersionService} from "./service/version.service"; import {environment} from "../environments/environment"; - +import { QaComponent } from './view/qa/qa.component'; +import { QaService } from './service/qa.service'; +import { QaManagementComponent } from './view/admin/qa-management/qa-management.component'; +import { TextSlicePipe } from './common/pipe/text-slice.pipe'; @NgModule({ @@ -52,7 +55,10 @@ import {environment} from "../environments/environment"; WorkManagementComponent, FooterComponent, AuthComponent, - FundingManagementComponent + FundingManagementComponent, + QaComponent, + QaManagementComponent, + TextSlicePipe, ], imports: [ BrowserModule, @@ -72,8 +78,9 @@ import {environment} from "../environments/environment"; VersionService, { provide: BrowserXhr, - useClass:cros - } + useClass:cros, + }, + QaService ], bootstrap: [AppComponent] }) diff --git a/client/src/app/common/admin-guard.service.ts b/client/src/app/common/admin-guard.service.ts index dd6b120..81040c0 100644 --- a/client/src/app/common/admin-guard.service.ts +++ b/client/src/app/common/admin-guard.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import {AuthService} from "../service/auth.service"; -import {Router} from "@angular/router"; +import {ActivatedRouteSnapshot, Router, RouterStateSnapshot} from "@angular/router"; +import {Observable} from "rxjs/Observable"; @Injectable() export class AdminGuardService { @@ -10,13 +11,16 @@ export class AdminGuardService { private router:Router ) { } - canActivate(){ - if(this.authService.isLoggedIn()){ - return true; - }else { - this.router.navigate(['/']); - return false; - } + canActivate(route:ActivatedRouteSnapshot, state:RouterStateSnapshot):Observable|boolean { + let the_cookie = document.cookie.split(';'); + let token = the_cookie[0].split("=")[1]; + if(token){ + return true + }else{ + this.router.navigate(['/']); + return false; + } + } } diff --git a/client/src/app/common/pipe/text-slice.pipe.ts b/client/src/app/common/pipe/text-slice.pipe.ts new file mode 100644 index 0000000..9cdfbca --- /dev/null +++ b/client/src/app/common/pipe/text-slice.pipe.ts @@ -0,0 +1,16 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'textSlice' +}) +export class TextSlicePipe implements PipeTransform { + + transform(value: String, args?: number): String { + if(value.length <= args){ + return value + }else{ + return value.slice(0,args)+"..." + } + } + +} diff --git a/client/src/app/service/auth.service.ts b/client/src/app/service/auth.service.ts index ec116ed..ac8c66c 100644 --- a/client/src/app/service/auth.service.ts +++ b/client/src/app/service/auth.service.ts @@ -24,9 +24,4 @@ export class AuthService { .get(environment.apiBase+'/users/status'); } - isLoggedIn(){ - return localStorage.getItem('loggedIn') == 'true'; - } - - } diff --git a/client/src/app/service/qa.service.ts b/client/src/app/service/qa.service.ts new file mode 100644 index 0000000..71f0eb0 --- /dev/null +++ b/client/src/app/service/qa.service.ts @@ -0,0 +1,39 @@ +import { Injectable } from '@angular/core'; +import {Http, RequestOptions} from "@angular/http"; +import {environment} from "../../environments/environment"; + +@Injectable() +export class QaService { + + constructor( + private http:Http + ) { } + + fetchQaList(page:number,limit:number){ + return this.http + .get(environment.apiBase+'/qa?page='+page+'&limit='+limit) + } + + createQa(data){ + return this.http + .post(environment.apiBase+'/qa/ask',data) + } + + fetchAllQaList(page:number,limit:number){ + return this.http + .get(environment.apiBase+'/qa/all?page='+page+'&limit='+limit) + } + + answerQa(data){ + return this.http + .patch(environment.apiBase+'/qa/answer',data) + } + + deleteQa(uid:String){ + return this.http + .delete(environment.apiBase+'/qa/delete',new RequestOptions({ + body: {uid:uid} + })) + } + +} diff --git a/client/src/app/view/about/about.component.css b/client/src/app/view/about/about.component.css index 330e2de..0fe416d 100644 --- a/client/src/app/view/about/about.component.css +++ b/client/src/app/view/about/about.component.css @@ -1,6 +1,15 @@ .introh1{ color: #23b1f7; } +.intro{ + font-size: large; + font-family: "微软雅黑",-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; +} .blockquote{ - border-left:5px solid #eee + border-left:5px solid #eee; + font-size: large; +} +.qBox{ + padding: 25px; + text-align: center; } diff --git a/client/src/app/view/about/about.component.html b/client/src/app/view/about/about.component.html index 7785bb5..29b68f9 100644 --- a/client/src/app/view/about/about.component.html +++ b/client/src/app/view/about/about.component.html @@ -20,13 +20,17 @@

关于我们

-
+

Latest System Releases: {{Version}}

-
-

Front-End: v1.0.3

-

Back-End: v1.0.3

-

Latest Commit: {{commit}}

+
+

Front-End: v1.0.4

+

Back-End: v1.0.4

+

Latest Commit: {{commit}}

+
+
+

Any Questions?

+
diff --git a/client/src/app/view/admin/auth/auth.component.ts b/client/src/app/view/admin/auth/auth.component.ts index 2cbf829..1b07885 100644 --- a/client/src/app/view/admin/auth/auth.component.ts +++ b/client/src/app/view/admin/auth/auth.component.ts @@ -16,7 +16,6 @@ export class AuthComponent implements OnInit { ) { } loginForm: FormGroup; - ngOnInit() { this.loginForm = new FormGroup({ username: new FormControl('',[ diff --git a/client/src/app/view/admin/dashboard/dashboard.component.html b/client/src/app/view/admin/dashboard/dashboard.component.html index 88621c9..1bde0d0 100644 --- a/client/src/app/view/admin/dashboard/dashboard.component.html +++ b/client/src/app/view/admin/dashboard/dashboard.component.html @@ -9,6 +9,9 @@ +

@@ -56,6 +59,9 @@
+
+ +
diff --git a/client/src/app/view/admin/funding-management/funding-management.component.html b/client/src/app/view/admin/funding-management/funding-management.component.html index c1025fd..25db625 100644 --- a/client/src/app/view/admin/funding-management/funding-management.component.html +++ b/client/src/app/view/admin/funding-management/funding-management.component.html @@ -24,11 +24,11 @@
-