从"Blog"仓库中分离出来
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
dist
|
||||||
|
node_modules
|
||||||
|
.editorconfig
|
||||||
97
README.md
Normal file
97
README.md
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
# 小海博客前端页面
|
||||||
|
|
||||||
|
基于angular的前端展示页面
|
||||||
|
|
||||||
|
#### 主要使用的技术
|
||||||
|
|
||||||
|
| 使用的技术 | 名称 |
|
||||||
|
| :--------------------- | ---------- |
|
||||||
|
| 前端框架 | angular |
|
||||||
|
| UI库 | ant design |
|
||||||
|
| 文章展示 | markdown |
|
||||||
|
| markdown实现| Editor.md |
|
||||||
|
|
||||||
|
#### 部分截图
|
||||||
|
|
||||||
|
##### 前台页面
|
||||||
|
|
||||||
|
> 首页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> 文章页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
##### 后台页面
|
||||||
|
|
||||||
|
> 后台首页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> 普通用户后台
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> 写作页面
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### 🔨构建和发布
|
||||||
|
|
||||||
|
##### 构建
|
||||||
|
|
||||||
|
> - index
|
||||||
|
>
|
||||||
|
> > 1. 进入index目录
|
||||||
|
> > 2. npm install
|
||||||
|
> > 3. 修改环境数据中的host
|
||||||
|
> >
|
||||||
|
> > - ` /src/environments/environment.ts` (本地开发环境)
|
||||||
|
> > - `/src/environments/environment-prod.ts`(线上发布环境)
|
||||||
|
> > 4. ng build --prod
|
||||||
|
>
|
||||||
|
> - admin
|
||||||
|
>
|
||||||
|
> > 1. cd admin
|
||||||
|
> > 2. npm install
|
||||||
|
> > 3. 修改环境数据中的host
|
||||||
|
> > - ` /src/environments/environment.ts` (本地开发环境)
|
||||||
|
> > - `/src/environments/environment-prod.ts`(线上发布环境)
|
||||||
|
> > 4. ng build --prod
|
||||||
|
> > 5. 修改index.html将` <base href="/">`改为 ` <base href="/admin/">`
|
||||||
|
>
|
||||||
|
>
|
||||||
|
|
||||||
|
##### 发布
|
||||||
|
|
||||||
|
- 将`index/dist/index`下的全部文件上传到网站根目录
|
||||||
|
|
||||||
|
- 将`admin/dist/admin`文件夹上传到根目录
|
||||||
|
|
||||||
|
- 目录结构如下:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- 修改nginx的location配置
|
||||||
|
```nginx
|
||||||
|
location ~ /admin/* {
|
||||||
|
try_files $uri $uri /admin/index.html;
|
||||||
|
}
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### 📝TODO
|
||||||
|
|
||||||
|
|
||||||
|
#### 📌FIXME
|
||||||
|
|
||||||
|
|
||||||
27
admin/README.md
Normal file
27
admin/README.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Admin
|
||||||
|
|
||||||
|
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.0.4.
|
||||||
|
|
||||||
|
## Development server
|
||||||
|
|
||||||
|
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
||||||
|
|
||||||
|
## Code scaffolding
|
||||||
|
|
||||||
|
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||||
|
|
||||||
|
## Running end-to-end tests
|
||||||
|
|
||||||
|
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
||||||
|
|
||||||
|
## Further help
|
||||||
|
|
||||||
|
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
||||||
128
admin/angular.json
Normal file
128
admin/angular.json
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"version": 1,
|
||||||
|
"newProjectRoot": "projects",
|
||||||
|
"projects": {
|
||||||
|
"admin": {
|
||||||
|
"projectType": "application",
|
||||||
|
"schematics": {},
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"prefix": "app",
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "dist/admin/",
|
||||||
|
"index": "src/index.html",
|
||||||
|
"main": "src/main.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.app.json",
|
||||||
|
"aot": false,
|
||||||
|
"assets": [
|
||||||
|
"src/favicon.ico",
|
||||||
|
"src/assets",
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "./node_modules/@ant-design/icons-angular/src/inline-svg/",
|
||||||
|
"output": "/assets/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"./node_modules/ng-zorro-antd/ng-zorro-antd.min.css",
|
||||||
|
"src/styles.css"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"extractCss": true,
|
||||||
|
"namedChunks": false,
|
||||||
|
"aot": true,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "admin:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"browserTarget": "admin:build:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "admin:build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"main": "src/test.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.spec.json",
|
||||||
|
"karmaConfig": "karma.conf.js",
|
||||||
|
"assets": [
|
||||||
|
"src/favicon.ico",
|
||||||
|
"src/assets"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"./node_modules/ng-zorro-antd/ng-zorro-antd.min.css",
|
||||||
|
"src/styles.css"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"tsconfig.app.json",
|
||||||
|
"tsconfig.spec.json",
|
||||||
|
"e2e/tsconfig.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"e2e": {
|
||||||
|
"builder": "@angular-devkit/build-angular:protractor",
|
||||||
|
"options": {
|
||||||
|
"protractorConfig": "e2e/protractor.conf.js",
|
||||||
|
"devServerTarget": "admin:serve"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"devServerTarget": "admin:serve:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultProject": "admin"
|
||||||
|
}
|
||||||
12
admin/browserslist
Normal file
12
admin/browserslist
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||||
|
# For additional information regarding the format and rule options, please see:
|
||||||
|
# https://github.com/browserslist/browserslist#queries
|
||||||
|
|
||||||
|
# You can see what browsers were selected by your queries by running:
|
||||||
|
# npx browserslist
|
||||||
|
|
||||||
|
> 0.5%
|
||||||
|
last 2 versions
|
||||||
|
Firefox ESR
|
||||||
|
not dead
|
||||||
|
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
||||||
32
admin/e2e/protractor.conf.js
Normal file
32
admin/e2e/protractor.conf.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// @ts-check
|
||||||
|
// Protractor configuration file, see link for more information
|
||||||
|
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||||
|
|
||||||
|
const { SpecReporter } = require('jasmine-spec-reporter');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type { import("protractor").Config }
|
||||||
|
*/
|
||||||
|
exports.config = {
|
||||||
|
allScriptsTimeout: 11000,
|
||||||
|
specs: [
|
||||||
|
'./src/**/*.e2e-spec.ts'
|
||||||
|
],
|
||||||
|
capabilities: {
|
||||||
|
'browserName': 'chrome'
|
||||||
|
},
|
||||||
|
directConnect: true,
|
||||||
|
baseUrl: 'http://localhost:4200/',
|
||||||
|
framework: 'jasmine',
|
||||||
|
jasmineNodeOpts: {
|
||||||
|
showColors: true,
|
||||||
|
defaultTimeoutInterval: 30000,
|
||||||
|
print: function() {}
|
||||||
|
},
|
||||||
|
onPrepare() {
|
||||||
|
require('ts-node').register({
|
||||||
|
project: require('path').join(__dirname, './tsconfig.json')
|
||||||
|
});
|
||||||
|
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||||
|
}
|
||||||
|
};
|
||||||
23
admin/e2e/src/app.e2e-spec.ts
Normal file
23
admin/e2e/src/app.e2e-spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { AppPage } from './app.po';
|
||||||
|
import { browser, logging } from 'protractor';
|
||||||
|
|
||||||
|
describe('workspace-project App', () => {
|
||||||
|
let page: AppPage;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
page = new AppPage();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display welcome message', () => {
|
||||||
|
page.navigateTo();
|
||||||
|
expect(page.getTitleText()).toEqual('Welcome to admin!');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
// Assert that there are no errors emitted from the browser
|
||||||
|
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||||
|
expect(logs).not.toContain(jasmine.objectContaining({
|
||||||
|
level: logging.Level.SEVERE,
|
||||||
|
} as logging.Entry));
|
||||||
|
});
|
||||||
|
});
|
||||||
11
admin/e2e/src/app.po.ts
Normal file
11
admin/e2e/src/app.po.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { browser, by, element } from 'protractor';
|
||||||
|
|
||||||
|
export class AppPage {
|
||||||
|
navigateTo() {
|
||||||
|
return browser.get(browser.baseUrl) as Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTitleText() {
|
||||||
|
return element(by.css('app-root h1')).getText() as Promise<string>;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
admin/e2e/tsconfig.json
Normal file
13
admin/e2e/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../out-tsc/e2e",
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"jasminewd2",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
32
admin/karma.conf.js
Normal file
32
admin/karma.conf.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Karma configuration file, see link for more information
|
||||||
|
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
config.set({
|
||||||
|
basePath: '',
|
||||||
|
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||||
|
plugins: [
|
||||||
|
require('karma-jasmine'),
|
||||||
|
require('karma-chrome-launcher'),
|
||||||
|
require('karma-jasmine-html-reporter'),
|
||||||
|
require('karma-coverage-istanbul-reporter'),
|
||||||
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
|
],
|
||||||
|
client: {
|
||||||
|
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||||
|
},
|
||||||
|
coverageIstanbulReporter: {
|
||||||
|
dir: require('path').join(__dirname, './coverage/admin'),
|
||||||
|
reports: ['html', 'lcovonly', 'text-summary'],
|
||||||
|
fixWebpackSourcePaths: true
|
||||||
|
},
|
||||||
|
reporters: ['progress', 'kjhtml'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: true,
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
singleRun: false,
|
||||||
|
restartOnFileChange: true
|
||||||
|
});
|
||||||
|
};
|
||||||
9678
admin/package-lock.json
generated
Normal file
9678
admin/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
48
admin/package.json
Normal file
48
admin/package.json
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"ng": "ng",
|
||||||
|
"start": "ng serve",
|
||||||
|
"build": "ng build",
|
||||||
|
"test": "ng test",
|
||||||
|
"lint": "ng lint",
|
||||||
|
"e2e": "ng e2e"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/animations": "~8.0.1",
|
||||||
|
"@angular/common": "~8.0.1",
|
||||||
|
"@angular/compiler": "~8.0.1",
|
||||||
|
"@angular/core": "~8.0.1",
|
||||||
|
"@angular/forms": "~8.0.1",
|
||||||
|
"@angular/platform-browser": "~8.0.1",
|
||||||
|
"@angular/platform-browser-dynamic": "~8.0.1",
|
||||||
|
"@angular/router": "~8.0.1",
|
||||||
|
"ng-zorro-antd": "^8.1.0",
|
||||||
|
"rxjs": "~6.4.0",
|
||||||
|
"tslib": "^1.9.0",
|
||||||
|
"zone.js": "~0.9.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular-devkit/build-angular": "~0.800.0",
|
||||||
|
"@angular/cli": "~8.0.4",
|
||||||
|
"@angular/compiler-cli": "~8.0.1",
|
||||||
|
"@angular/language-service": "~8.0.1",
|
||||||
|
"@types/node": "~8.9.4",
|
||||||
|
"@types/jasmine": "~3.3.8",
|
||||||
|
"@types/jasminewd2": "~2.0.3",
|
||||||
|
"codelyzer": "^5.0.0",
|
||||||
|
"jasmine-core": "~3.4.0",
|
||||||
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
|
"karma": "~4.1.0",
|
||||||
|
"karma-chrome-launcher": "~2.2.0",
|
||||||
|
"karma-coverage-istanbul-reporter": "~2.0.1",
|
||||||
|
"karma-jasmine": "~2.0.1",
|
||||||
|
"karma-jasmine-html-reporter": "^1.4.0",
|
||||||
|
"protractor": "~5.4.0",
|
||||||
|
"ts-node": "~7.0.0",
|
||||||
|
"tslint": "~5.15.0",
|
||||||
|
"typescript": "~3.4.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
70
admin/src/app/app-routing.module.ts
Normal file
70
admin/src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import {NgModule} from '@angular/core';
|
||||||
|
import {NavigationStart, Router, RouterModule, Routes} from '@angular/router';
|
||||||
|
import {filter} from 'rxjs/operators';
|
||||||
|
import {UserService} from './services/user/user.service';
|
||||||
|
|
||||||
|
import {AIndexComponent} from './pages/a-index/a-index.component';
|
||||||
|
import {ArticleManagerComponent} from './pages/article-manager/article-manager.component';
|
||||||
|
import {CommentManagerComponent} from './pages/comment-manager/comment-manager.component';
|
||||||
|
import {TagManagerComponent} from './pages/tag-manager/tag-manager.component';
|
||||||
|
import {UserInfoComponent} from './pages/user-info/user-info.component';
|
||||||
|
import {CategoryManagerComponent} from './pages/category-manager/category-manager.component';
|
||||||
|
import {LinksManagerComponent} from './pages/links-manager/links.component';
|
||||||
|
import {VisitorManagerComponent} from './pages/visitor-manager/visitor-manager.component';
|
||||||
|
import {UpdateManagerComponent} from './pages/update-manager/update.component';
|
||||||
|
import {UserManagerComponent} from './pages/user-manager/user-manager.component';
|
||||||
|
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{path: '', component: AIndexComponent},
|
||||||
|
{path: 'articles', component: ArticleManagerComponent},
|
||||||
|
{path: 'comments', component: CommentManagerComponent},
|
||||||
|
{path: 'tags', component: TagManagerComponent},
|
||||||
|
{path: 'userInfo', component: UserInfoComponent},
|
||||||
|
{path: 'categories', component: CategoryManagerComponent},
|
||||||
|
{path: 'links', component: LinksManagerComponent},
|
||||||
|
{path: 'visitors', component: VisitorManagerComponent},
|
||||||
|
{path: 'update', component: UpdateManagerComponent},
|
||||||
|
{path: 'users', component: UserManagerComponent},
|
||||||
|
{path: '**', component: AIndexComponent}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forRoot(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class AppRoutingModule {
|
||||||
|
|
||||||
|
// todo : 换用路由守卫
|
||||||
|
constructor(private router: Router, private userService: UserService) {
|
||||||
|
this.router.events.pipe(filter((event) => event instanceof NavigationStart)
|
||||||
|
).subscribe((event: NavigationStart) => {
|
||||||
|
if (!this.userService.userInfo) {
|
||||||
|
this.userService.getUserInfo().subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.checkPermission(event);
|
||||||
|
} else if (data.code === 301) {
|
||||||
|
window.location.href = '/login';
|
||||||
|
} else {
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.checkPermission(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private checkPermission(event) {
|
||||||
|
if (this.userService.userInfo.role === 'user') {
|
||||||
|
switch (event.url) {
|
||||||
|
case '/':
|
||||||
|
case '/comments':
|
||||||
|
case '/userInfo':
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
this.router.navigateByUrl('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
49
admin/src/app/app.component.css
Normal file
49
admin/src/app/app.component.css
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
.menu {
|
||||||
|
position: fixed;
|
||||||
|
max-width: 240px;
|
||||||
|
top: 50px;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.myCard {
|
||||||
|
width: 180px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
position: absolute;
|
||||||
|
top: 50px;
|
||||||
|
right: 0;
|
||||||
|
left: 240px;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nz-content {
|
||||||
|
margin-left: 30px;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inner-content {
|
||||||
|
padding: 15px;
|
||||||
|
background: #fff;
|
||||||
|
min-height: 560px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nz-footer {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 768px) {
|
||||||
|
nz-content {
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
96
admin/src/app/app.component.html
Normal file
96
admin/src/app/app.component.html
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<app-header></app-header>
|
||||||
|
<div style="height: 60px;"></div>
|
||||||
|
|
||||||
|
<nz-layout class="layout">
|
||||||
|
|
||||||
|
<nz-sider nzCollapsible
|
||||||
|
[(nzCollapsed)]="isCollapsed"
|
||||||
|
[nzBreakpoint]="'lg'"
|
||||||
|
[nzCollapsedWidth]="0"
|
||||||
|
[nzZeroTrigger]="zeroTrigger"
|
||||||
|
nzTheme="light"
|
||||||
|
*ngIf="userService.userInfo">
|
||||||
|
<ul nz-menu nzTheme="light" nzMode="inline" [nzInlineCollapsed]="isCollapsed">
|
||||||
|
<li nz-menu-item routerLink="/">
|
||||||
|
<i nz-icon nzType="desktop" nzTheme="outline"></i>
|
||||||
|
<span>后台首页</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-submenu nzTitle="文章管理" nzIcon="file" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<ul>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a href="../write">
|
||||||
|
<i nz-icon nzType="form" nzTheme="outline"></i>
|
||||||
|
<span>新增文章</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item routerLink="/articles">
|
||||||
|
<i nz-icon nzType="ordered-list" nzTheme="outline"></i>
|
||||||
|
<span>文章列表</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="comments">
|
||||||
|
<i nz-icon nzType="message" nzTheme="outline"></i>
|
||||||
|
<span>评论管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="tags" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<i nz-icon nzType="tags" nzTheme="outline"></i>
|
||||||
|
<span>标签管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="categories" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<i nz-icon nzType="appstore" nzTheme="outline"></i>
|
||||||
|
<span>分类管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="userInfo">
|
||||||
|
<i nz-icon nzType="idcard" nzTheme="outline"></i>
|
||||||
|
<span>修改信息</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="users" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<i nz-icon nzType="user" nzTheme="outline"></i>
|
||||||
|
<span>用户管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="links" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<i nz-icon nzType="link" nzTheme="outline"></i>
|
||||||
|
<span>友链管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="visitors" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<i nz-icon nzType="chrome" nzTheme="outline"></i>
|
||||||
|
<span>访问管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li nz-menu-item routerLink="update" *ngIf="userService.userInfo.role=='admin'">
|
||||||
|
<i nz-icon nzType="arrow-up" nzTheme="outline"></i>
|
||||||
|
<span>更新管理</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<!--TODO : do something here ..... -->
|
||||||
|
<nz-card class="myCard" *ngIf="!isCollapsed&&userService.userInfo.role=='admin'">
|
||||||
|
<p>别管别人言语</p>
|
||||||
|
<p>做最好的自己</p>
|
||||||
|
</nz-card>
|
||||||
|
<nz-card class="myCard" *ngIf="!isCollapsed&&userService.userInfo.role=='user'">
|
||||||
|
<p>欢迎来访小海博客</p>
|
||||||
|
</nz-card>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nz-sider>
|
||||||
|
<nz-layout>
|
||||||
|
<nz-content>
|
||||||
|
<div class="inner-content">
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
</div>
|
||||||
|
</nz-content>
|
||||||
|
<nz-footer>© <a href="https://www.celess.cn">小海博客</a> - Design by 小海</nz-footer>
|
||||||
|
</nz-layout>
|
||||||
|
</nz-layout>
|
||||||
|
<ng-template #zeroTrigger>
|
||||||
|
<i nz-icon nzType="menu-fold" nzTheme=outline></i>
|
||||||
|
</ng-template>
|
||||||
35
admin/src/app/app.component.spec.ts
Normal file
35
admin/src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
|
|
||||||
|
describe('AppComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
AppComponent
|
||||||
|
],
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the app', () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should have as title 'admin'`, () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app.title).toEqual('admin');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render title in a h1 tag', () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const compiled = fixture.debugElement.nativeElement;
|
||||||
|
expect(compiled.querySelector('h1').textContent).toContain('Welcome to admin!');
|
||||||
|
});
|
||||||
|
});
|
||||||
21
admin/src/app/app.component.ts
Normal file
21
admin/src/app/app.component.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {UserService} from './services/user/user.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-root',
|
||||||
|
templateUrl: './app.component.html',
|
||||||
|
styleUrls: ['./app.component.css']
|
||||||
|
})
|
||||||
|
export class AppComponent implements OnInit {
|
||||||
|
|
||||||
|
isCollapsed: boolean = false;
|
||||||
|
|
||||||
|
constructor(public userService: UserService) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
63
admin/src/app/app.module.ts
Normal file
63
admin/src/app/app.module.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
|
import {NgModule} from '@angular/core';
|
||||||
|
import {NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
|
||||||
|
import {FormsModule} from '@angular/forms';
|
||||||
|
import {HttpClientModule} from '@angular/common/http';
|
||||||
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
|
import {registerLocaleData} from '@angular/common';
|
||||||
|
import zh from '@angular/common/locales/zh';
|
||||||
|
import {AppRoutingModule} from './app-routing.module';
|
||||||
|
import {AppComponent} from './app.component';
|
||||||
|
|
||||||
|
|
||||||
|
// components
|
||||||
|
import {HeaderComponent} from './components/header/header.component';
|
||||||
|
// pages
|
||||||
|
import {AIndexComponent} from './pages/a-index/a-index.component';
|
||||||
|
import {ArticleManagerComponent} from './pages/article-manager/article-manager.component';
|
||||||
|
import {CommentManagerComponent} from './pages/comment-manager/comment-manager.component';
|
||||||
|
import {TagManagerComponent} from './pages/tag-manager/tag-manager.component';
|
||||||
|
import {UserInfoComponent} from './pages/user-info/user-info.component';
|
||||||
|
import {CategoryManagerComponent} from './pages/category-manager/category-manager.component';
|
||||||
|
import {LinksManagerComponent} from './pages/links-manager/links.component';
|
||||||
|
import {VisitorManagerComponent} from './pages/visitor-manager/visitor-manager.component';
|
||||||
|
import {UpdateManagerComponent} from './pages/update-manager/update.component';
|
||||||
|
import {UserManagerComponent} from './pages/user-manager/user-manager.component';
|
||||||
|
// services
|
||||||
|
import {HttpService} from './services/http.service';
|
||||||
|
|
||||||
|
|
||||||
|
registerLocaleData(zh);
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
AppComponent,
|
||||||
|
|
||||||
|
HeaderComponent,
|
||||||
|
AIndexComponent,
|
||||||
|
ArticleManagerComponent,
|
||||||
|
CommentManagerComponent,
|
||||||
|
TagManagerComponent,
|
||||||
|
UserInfoComponent,
|
||||||
|
CategoryManagerComponent,
|
||||||
|
LinksManagerComponent,
|
||||||
|
VisitorManagerComponent,
|
||||||
|
UpdateManagerComponent,
|
||||||
|
UserManagerComponent
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
AppRoutingModule,
|
||||||
|
NgZorroAntdModule,
|
||||||
|
FormsModule,
|
||||||
|
HttpClientModule,
|
||||||
|
BrowserAnimationsModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{provide: NZ_I18N, useValue: zh_CN},
|
||||||
|
HttpService
|
||||||
|
],
|
||||||
|
bootstrap: [AppComponent]
|
||||||
|
})
|
||||||
|
export class AppModule {
|
||||||
|
}
|
||||||
19
admin/src/app/classes/article.ts
Normal file
19
admin/src/app/classes/article.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export class Article {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
summary: string;
|
||||||
|
mdContent?: string;
|
||||||
|
original?: boolean;
|
||||||
|
url?: string;
|
||||||
|
publishDateFormat?: string;
|
||||||
|
updateDateFormat?: string;
|
||||||
|
category?: string;
|
||||||
|
tags?: string[];
|
||||||
|
authorName?: string;
|
||||||
|
preArticleId?: number;
|
||||||
|
nextArticleId?: number;
|
||||||
|
preArticleTitle?: string;
|
||||||
|
nextArticleTitle?: string;
|
||||||
|
readingNumber?: number;
|
||||||
|
open?: string;
|
||||||
|
}
|
||||||
6
admin/src/app/classes/category.ts
Normal file
6
admin/src/app/classes/category.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export class Category {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
articles: string;
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
13
admin/src/app/classes/comment.ts
Normal file
13
admin/src/app/classes/comment.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export class Comment {
|
||||||
|
id: number;
|
||||||
|
type: number;
|
||||||
|
authorName: string;
|
||||||
|
authorAvatarImgUrl: string;
|
||||||
|
content: string;
|
||||||
|
date: string;
|
||||||
|
pid: number;
|
||||||
|
responseId: string;
|
||||||
|
articleID: number;
|
||||||
|
articleTitle: string;
|
||||||
|
child: Comment[];
|
||||||
|
}
|
||||||
19
admin/src/app/classes/commentReq.ts
Normal file
19
admin/src/app/classes/commentReq.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export class CommentReq {
|
||||||
|
articleID: number;
|
||||||
|
comment: boolean;
|
||||||
|
content: string;
|
||||||
|
id: number;
|
||||||
|
pid: number;
|
||||||
|
responseId: string;
|
||||||
|
|
||||||
|
constructor(comment: boolean) {
|
||||||
|
this.comment = comment;
|
||||||
|
this.responseId = '';
|
||||||
|
if (!comment) {
|
||||||
|
this.articleID = -1;
|
||||||
|
}
|
||||||
|
this.pid = -1;
|
||||||
|
this.id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
6
admin/src/app/classes/data.ts
Normal file
6
admin/src/app/classes/data.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export class Data {
|
||||||
|
code: number;
|
||||||
|
msg: string;
|
||||||
|
result: any;
|
||||||
|
date: number;
|
||||||
|
}
|
||||||
6
admin/src/app/classes/link.ts
Normal file
6
admin/src/app/classes/link.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export class Link {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
open: boolean;
|
||||||
|
}
|
||||||
20
admin/src/app/classes/page.ts
Normal file
20
admin/src/app/classes/page.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export class Page<T> {
|
||||||
|
total: number;
|
||||||
|
list: T[];
|
||||||
|
pageNum: number;
|
||||||
|
pageSize: number;
|
||||||
|
size: number;
|
||||||
|
startRow: number;
|
||||||
|
endRow: number;
|
||||||
|
pages: number;
|
||||||
|
prePage: number;
|
||||||
|
nextPage: number;
|
||||||
|
isFirstPage: boolean;
|
||||||
|
isLastPage: boolean;
|
||||||
|
hasPreviousPage: boolean;
|
||||||
|
hasNextPage: boolean;
|
||||||
|
navigatePages: number;
|
||||||
|
navigatepageNums: number[];
|
||||||
|
navigateFirstPage: number;
|
||||||
|
navigateLastPage: number;
|
||||||
|
}
|
||||||
6
admin/src/app/classes/tag.ts
Normal file
6
admin/src/app/classes/tag.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export class Tag {
|
||||||
|
id?: number;
|
||||||
|
name: string;
|
||||||
|
articles?: string;
|
||||||
|
size: number;
|
||||||
|
}
|
||||||
5
admin/src/app/classes/updateInfo.ts
Normal file
5
admin/src/app/classes/updateInfo.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export class UpdateInfo {
|
||||||
|
id: number;
|
||||||
|
info: string;
|
||||||
|
time: string;
|
||||||
|
}
|
||||||
11
admin/src/app/classes/user.ts
Normal file
11
admin/src/app/classes/user.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export class User {
|
||||||
|
id: number;
|
||||||
|
email: string;
|
||||||
|
displayName: string;
|
||||||
|
emailStatus: boolean;
|
||||||
|
avatarImgUrl: string;
|
||||||
|
recentlyLandedDate: string;
|
||||||
|
desc: string;
|
||||||
|
role: string;
|
||||||
|
pwd?: string;
|
||||||
|
}
|
||||||
9
admin/src/app/classes/visitor.ts
Normal file
9
admin/src/app/classes/visitor.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export class Visitor {
|
||||||
|
id: number;
|
||||||
|
ip: string;
|
||||||
|
date: string;
|
||||||
|
browserName: string;
|
||||||
|
browserVersion: string;
|
||||||
|
location?: string;
|
||||||
|
osname: string;
|
||||||
|
}
|
||||||
129
admin/src/app/components/header/header.component.css
Normal file
129
admin/src/app/components/header/header.component.css
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
header {
|
||||||
|
height: 50px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
opacity: 0.8;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 1;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
header img {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin: 5px 5px 5px 30px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerButton {
|
||||||
|
border: none;
|
||||||
|
background: #3F66FF;
|
||||||
|
color: #ffffff !important;
|
||||||
|
margin-right: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 8px 13px;
|
||||||
|
line-height: 50px
|
||||||
|
}
|
||||||
|
|
||||||
|
#landr {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loged {
|
||||||
|
float: right;
|
||||||
|
margin-right: 20px;
|
||||||
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blogTitle,
|
||||||
|
#desc {
|
||||||
|
display: block;
|
||||||
|
margin-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blogTitle :hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #797979;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blogTitle {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blogTitle :hover {
|
||||||
|
font-size: 23px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#desc {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (min-width: 768px) {
|
||||||
|
/**导航栏*/
|
||||||
|
.nav-desktop {
|
||||||
|
position: fixed;
|
||||||
|
width: auto;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-phone {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-desktop li {
|
||||||
|
float: left;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-desktop li:hover {
|
||||||
|
background: #ececec;
|
||||||
|
color: #797979;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-desktop li a {
|
||||||
|
height: 100%;
|
||||||
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and ( max-width: 768px) {
|
||||||
|
.nav-desktop {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-phone {
|
||||||
|
display: block;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ul {
|
||||||
|
width: 300px;
|
||||||
|
text-align: center
|
||||||
|
}
|
||||||
|
|
||||||
|
.ul li {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
border-bottom: 1px solid #ececec
|
||||||
|
}
|
||||||
|
|
||||||
|
#click-main {
|
||||||
|
line-height: 50px;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
admin/src/app/components/header/header.component.html
Normal file
40
admin/src/app/components/header/header.component.html
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<header>
|
||||||
|
<a href="/">
|
||||||
|
<div>
|
||||||
|
<img src="https://56462271.oss-cn-beijing.aliyuncs.com/web/logo.png"/>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div>
|
||||||
|
<a href="/" id="blogTitle"><span>小海博客</span></a>
|
||||||
|
<span id="desc">记录学习成长历程</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="loged" *ngIf="userService.userInfo">
|
||||||
|
<a nz-dropdown [nzDropdownMenu]="menu" nzTrigger="click" [nzClickHide]="false" [(nzVisible)]="visible">
|
||||||
|
{{userService.userInfo.displayName ? userService.userInfo.displayName : userService.userInfo.email}}
|
||||||
|
<i nz-icon nzType="down"></i>
|
||||||
|
</a>
|
||||||
|
<nz-dropdown-menu #menu="nzDropdownMenu">
|
||||||
|
<ul nz-menu>
|
||||||
|
<li nz-menu-item><a href="../">博客首页</a></li>
|
||||||
|
<hr style="margin: 10px 0 5px 0;">
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a (click)="logout()">退出登录</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-dropdown-menu>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="landr" *ngIf="!userService.userInfo">
|
||||||
|
<div class="login">
|
||||||
|
<a class="headerButton" style="border-radius: 8px;color: white"
|
||||||
|
id="index-topbar-forLogin" (click)="toPage('login')">登录</a>
|
||||||
|
</div>
|
||||||
|
<div class="registration">
|
||||||
|
<a class="headerButton" style="border-radius: 8px;color: white" (click)="toPage('registration')">注册</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</header>
|
||||||
25
admin/src/app/components/header/header.component.spec.ts
Normal file
25
admin/src/app/components/header/header.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HeaderComponent } from './header.component';
|
||||||
|
|
||||||
|
describe('HeaderComponent', () => {
|
||||||
|
let component: HeaderComponent;
|
||||||
|
let fixture: ComponentFixture<HeaderComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ HeaderComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(HeaderComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
30
admin/src/app/components/header/header.component.ts
Normal file
30
admin/src/app/components/header/header.component.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {UserService} from '../../services/user/user.service';
|
||||||
|
import {environment} from '../../../environments/environment';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-header',
|
||||||
|
templateUrl: './header.component.html',
|
||||||
|
styleUrls: ['./header.component.css']
|
||||||
|
})
|
||||||
|
export class HeaderComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
|
constructor(public userService: UserService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 菜单是否可见
|
||||||
|
public visible: boolean = false;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
this.userService.logout();
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
toPage(path: string) {
|
||||||
|
window.location.href = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
50
admin/src/app/pages/a-index/a-index.component.css
Normal file
50
admin/src/app/pages/a-index/a-index.component.css
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
.dashboardUl {
|
||||||
|
width: 100%;
|
||||||
|
padding: 1.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboardUl i {
|
||||||
|
font-size: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboardUl li {
|
||||||
|
float: left;
|
||||||
|
border-right: 1px solid #ececec;
|
||||||
|
width: 25%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboardUl li:last-child {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
border-radius: 50%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log {
|
||||||
|
margin-top: 20px;
|
||||||
|
max-height: 500px;
|
||||||
|
padding: 10px;
|
||||||
|
background: #F8F8F8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reloadLog {
|
||||||
|
position: absolute;
|
||||||
|
right: 20px;
|
||||||
|
top: 10px;
|
||||||
|
z-index: 990;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card i {
|
||||||
|
font-size: 40px;
|
||||||
|
}
|
||||||
71
admin/src/app/pages/a-index/a-index.component.html
Normal file
71
admin/src/app/pages/a-index/a-index.component.html
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<!-- content start -->
|
||||||
|
<div class="admin-content" id="index">
|
||||||
|
<div class="admin-content-body" *ngIf="userService.userInfo&&userService.userInfo.role=='user'">
|
||||||
|
<div>
|
||||||
|
<div><strong class="part-title">首页</strong></div>
|
||||||
|
</div>
|
||||||
|
<h2 style="text-align: center;">
|
||||||
|
Welcome {{userService.userInfo.displayName}}!
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<nz-card class="card">
|
||||||
|
<ul class="dashboardUl">
|
||||||
|
<li style="width: 50%">
|
||||||
|
<div><i nz-icon nzType="login" nzTheme="outline"></i></div>
|
||||||
|
<p>上次登录</p>
|
||||||
|
<p>{{userService.userInfo.recentlyLandedDate}}</p>
|
||||||
|
</li>
|
||||||
|
<li style="width: 50%">
|
||||||
|
<div><i nz-icon nzType="environment" nzTheme="outline"></i></div>
|
||||||
|
<p>您的ip和位置</p>
|
||||||
|
<p>
|
||||||
|
ip:{{ip}}
|
||||||
|
<br>
|
||||||
|
位置:{{location}}
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- administrator page -->
|
||||||
|
<div *ngIf="userService.userInfo&&userService.userInfo.role=='admin'">
|
||||||
|
<nz-card>
|
||||||
|
<ul class="dashboardUl">
|
||||||
|
<li>
|
||||||
|
<div><i nz-icon nzType="ie" nzTheme="outline"></i></div>
|
||||||
|
<p>总访问量</p>
|
||||||
|
<p>{{visitorService.totalVisitCount}}</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div><i nz-icon nzType="chrome" nzTheme="outline"></i></div>
|
||||||
|
<p>今日访问量</p>
|
||||||
|
<p>{{visitorService.dayVisit}}</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div><i nz-icon nzType="login" nzTheme="outline"></i></div>
|
||||||
|
<p>上次登录</p>
|
||||||
|
<p>{{userService.userInfo.recentlyLandedDate}}</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div><i nz-icon nzType="arrow-up" nzTheme="outline"></i></div>
|
||||||
|
<p>上次更新</p>
|
||||||
|
<p>{{webUpdateService.lastestUpdateTime}}</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-card>
|
||||||
|
|
||||||
|
<div style="position: relative">
|
||||||
|
<button nz-button nzType="danger" nzShape="circle" class="reloadLog" (click)="readLog()">
|
||||||
|
<i nz-icon nzType="reload" nzTheme="outline"></i>
|
||||||
|
</button>
|
||||||
|
<nz-spin [nzSpinning]="Loading">
|
||||||
|
<pre class="log">
|
||||||
|
{{this.logService.logText}}
|
||||||
|
</pre>
|
||||||
|
</nz-spin>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- content end -->
|
||||||
25
admin/src/app/pages/a-index/a-index.component.spec.ts
Normal file
25
admin/src/app/pages/a-index/a-index.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { AIndexComponent } from './a-index.component';
|
||||||
|
|
||||||
|
describe('AIndexComponent', () => {
|
||||||
|
let component: AIndexComponent;
|
||||||
|
let fixture: ComponentFixture<AIndexComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ AIndexComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(AIndexComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
80
admin/src/app/pages/a-index/a-index.component.ts
Normal file
80
admin/src/app/pages/a-index/a-index.component.ts
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {UserService} from '../../services/user/user.service';
|
||||||
|
import {VisitorService} from '../../services/visitor/visitor.service';
|
||||||
|
import {WebUpdateService} from '../../services/update/web-update.service';
|
||||||
|
import {LogService} from '../../services/log/log.service';
|
||||||
|
import {Observable} from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-a-index',
|
||||||
|
templateUrl: './a-index.component.html',
|
||||||
|
styleUrls: ['./a-index.component.css']
|
||||||
|
})
|
||||||
|
export class AIndexComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public userService: UserService,
|
||||||
|
public visitorService: VisitorService,
|
||||||
|
public webUpdateService: WebUpdateService,
|
||||||
|
public logService: LogService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading: boolean = false;
|
||||||
|
ip: string;
|
||||||
|
location: string;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (this.userService.userInfo) {
|
||||||
|
if (this.userService.userInfo.role === 'admin') {
|
||||||
|
this.admin();
|
||||||
|
} else {
|
||||||
|
this.user();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.userService.getUserInfo().subscribe(data => {
|
||||||
|
if (data.result.role === 'admin') {
|
||||||
|
this.admin();
|
||||||
|
} else {
|
||||||
|
this.user();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
admin() {
|
||||||
|
if (!this.visitorService.dayVisit) {
|
||||||
|
this.visitorService.getDayVisitor();
|
||||||
|
}
|
||||||
|
this.visitorService.getTotalVisitorCount();
|
||||||
|
if (!this.webUpdateService.lastestUpdateTime) {
|
||||||
|
this.webUpdateService.getLastestUpdateTime();
|
||||||
|
}
|
||||||
|
this.readLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
user() {
|
||||||
|
this.visitorService.getLocalIp().subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.ip = data.result;
|
||||||
|
const getip = this.visitorService.getIp(this.ip);
|
||||||
|
if (getip instanceof Observable) {
|
||||||
|
getip.subscribe(ipOb => {
|
||||||
|
this.location = ipOb.result;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.location = getip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
readLog() {
|
||||||
|
this.Loading = true;
|
||||||
|
this.logService.getLog().subscribe(date => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.Loading = false;
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
.popup-content {
|
||||||
|
text-align: center;
|
||||||
|
height: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<!--文章管理-->
|
||||||
|
|
||||||
|
<div class="admin-content" id="article-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<div><strong class="part-title">文章管理</strong></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="scrollable-horizontal" *ngIf="articleService.currentPage">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>标题</th>
|
||||||
|
<th>发布日期</th>
|
||||||
|
<th>更新日期</th>
|
||||||
|
<th>阅读量</th>
|
||||||
|
<th title="(可见/不可见)勾选则可见,否则不可见">文章状态</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let article of articleService.currentPage.list">
|
||||||
|
<td>{{article.id}}</td>
|
||||||
|
<td><a [routerLink]="[ '/article']" [queryParams]="{'id':article.id}">{{article.title}}</a>
|
||||||
|
</td>
|
||||||
|
<td>{{article.publishDateFormat}}</td>
|
||||||
|
<td>{{article.updateDateFormat}}</td>
|
||||||
|
<td><span class="badge badge-success">{{article.readingNumber}}</span></td>
|
||||||
|
<td style="text-align: center">
|
||||||
|
<input type="checkbox" class="disabled" disabled [checked]="article.open"
|
||||||
|
[title]="article.open?'可见':'不可见'">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a [href]="'../write?id='+article.id">
|
||||||
|
<i nz-icon nzType="edit" nzTheme="twotone" nzTwotoneColor="#52c41a"></i> 编辑
|
||||||
|
</a>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-dropdown [nzDropdownMenu]="menu" nzPlacement="bottomLeft" nzTrigger="click">
|
||||||
|
更多 <i nz-icon nzType="down" nzTheme="outline"></i>
|
||||||
|
</a>
|
||||||
|
<nz-dropdown-menu #menu="nzDropdownMenu">
|
||||||
|
|
||||||
|
|
||||||
|
<ul nz-menu nzSelectable>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a [href]="'../article/'+article.id">
|
||||||
|
<i nz-icon nzType="file" nzTheme="twotone" nzTwotoneColor="#3F66FF"></i> 查看
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a nz-popconfirm [nzTitle]="'是否要删除'+article.title+'?'"
|
||||||
|
(nzOnConfirm)="doDel(article.id)">
|
||||||
|
<i nz-icon nzType="delete" nzTheme="twotone" nzTwotoneColor="#eb2f96"></i> 删除
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-dropdown-menu>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<nz-pagination align="center" [nzHideOnSinglePage]="true" [nzPageIndex]="pageNum" [nzPageSize]="pageSize"
|
||||||
|
[nzTotal]="articleService.currentPage.total"
|
||||||
|
(nzPageIndexChange)="toPage($event)">
|
||||||
|
</nz-pagination>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ArticleManagerComponent } from './article-manager.component';
|
||||||
|
|
||||||
|
describe('ArticleManagerComponent', () => {
|
||||||
|
let component: ArticleManagerComponent;
|
||||||
|
let fixture: ComponentFixture<ArticleManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ArticleManagerComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ArticleManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {ArticleService} from '../../services/article/article.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-article-manager',
|
||||||
|
templateUrl: './article-manager.component.html',
|
||||||
|
styleUrls: ['./article-manager.component.css']
|
||||||
|
})
|
||||||
|
export class ArticleManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(private message: NzMessageService,
|
||||||
|
public articleService: ArticleService) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public pageNum = 1;
|
||||||
|
|
||||||
|
public pageSize = 10;
|
||||||
|
|
||||||
|
showPupup = false;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.articleService.getArticle(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
doDel(id) {
|
||||||
|
this.showPupup = false;
|
||||||
|
this.articleService.deleteArticle(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('删除成功');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toPage(e: number) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
a{
|
||||||
|
padding: 10px 0;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<!--分类-->
|
||||||
|
<div class="admin-content" id="category-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<strong class="part-title">分类管理</strong>
|
||||||
|
<button nz-button nzGhost="true" nzType="primary" style="margin-left: 30px" (click)="addNewOne()">新增分类
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="scrollable-horizontal" *ngIf="categoryService.categories">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>分类名称</th>
|
||||||
|
<th>分类文章</th>
|
||||||
|
<th>文章数目</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let category of categoryService.categories">
|
||||||
|
<td>{{category.id}}</td>
|
||||||
|
<td class="text-truncate" style="max-width: 150px">{{category.name}}</td>
|
||||||
|
<td>{{category.articles}}</td>
|
||||||
|
<td><span class="badge badge-success">{{category.articles.split(",").length - 1}}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<a [href]="'../category?name='+category.name">
|
||||||
|
<i nz-icon nzType="book" nzTheme="twotone"></i> 查看
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-dropdown [nzDropdownMenu]="menu" nzPlacement="bottomLeft" nzTrigger="click">
|
||||||
|
更多 <i nz-icon nzType="down" nzTheme="outline"></i>
|
||||||
|
</a>
|
||||||
|
<nz-dropdown-menu #menu="nzDropdownMenu">
|
||||||
|
<ul nz-menu nzSelectable>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a class="btn btn-secondary " (click)="edit(category.id,category.name)">编辑</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这个分类?" (nzOnConfirm)="doDel(category.id)">删除
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-dropdown-menu>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<nz-modal [(nzVisible)]="showPupup" nzTitle="编辑" (nzOnCancel)="cancel()" (nzOnOk)="submit()">
|
||||||
|
<input nz-input style="width: 80%;margin-left: 10%" [(ngModel)]="updateReqBody.name">
|
||||||
|
</nz-modal>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CategoryManagerComponent } from './category-manager.component';
|
||||||
|
|
||||||
|
describe('CategoryManagerComponent', () => {
|
||||||
|
let component: CategoryManagerComponent;
|
||||||
|
let fixture: ComponentFixture<CategoryManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ CategoryManagerComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(CategoryManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {CategoryService} from '../../services/category/category.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-category-manager',
|
||||||
|
templateUrl: './category-manager.component.html',
|
||||||
|
styleUrls: ['./category-manager.component.css']
|
||||||
|
})
|
||||||
|
export class CategoryManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public categoryService: CategoryService, private message: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
showPupup = false;
|
||||||
|
|
||||||
|
updateReqBody = {
|
||||||
|
id: null,
|
||||||
|
name: null
|
||||||
|
};
|
||||||
|
isAddNowOne = false; // 是否是新增分类的标识
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
if (this.categoryService.categories) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.categoryService.getAllCategory();
|
||||||
|
}
|
||||||
|
|
||||||
|
edit(id, name) {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.updateReqBody.id = id;
|
||||||
|
this.updateReqBody.name = name;
|
||||||
|
this.isAddNowOne = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
if (this.updateReqBody.name === '') {
|
||||||
|
alert('不能修改为空值!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.showPupup = false;
|
||||||
|
if (!this.isAddNowOne) {
|
||||||
|
// 更新
|
||||||
|
this.categoryService.update(this.updateReqBody).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('修改成功');
|
||||||
|
for (let i = 0; i < this.categoryService.categories.length; i++) {
|
||||||
|
if ( this.categoryService.categories[i].id === this.updateReqBody.id) {
|
||||||
|
this.categoryService.categories[i].name = this.updateReqBody.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.message.error('修改失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 新建
|
||||||
|
this.categoryService.create(this.updateReqBody.name).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('新增成功');
|
||||||
|
} else {
|
||||||
|
this.message.error('新增失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
doDel(id) {
|
||||||
|
|
||||||
|
this.categoryService.delete(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('删除成功');
|
||||||
|
} else {
|
||||||
|
this.message.error('删除失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addNewOne() {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.updateReqBody.name = name;
|
||||||
|
this.isAddNowOne = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.showPupup = !this.showPupup;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
.modal-mask {
|
||||||
|
background: black;
|
||||||
|
opacity: 0.4;
|
||||||
|
position: absolute;
|
||||||
|
overflow: hidden;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment {
|
||||||
|
border: 1px solid #cccccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<!--评论管理-->
|
||||||
|
<div class="admin-content" id="comment-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
|
||||||
|
<div><strong class="part-title">评论管理</strong>
|
||||||
|
<select class="select" [(ngModel)]="commentType" (change)="doInquire()">
|
||||||
|
<option class="option" selected value="1">评论</option>
|
||||||
|
<option class="option" value="0">留言</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 评论 -->
|
||||||
|
<div *ngIf="commentType==1&&commentService.currentComment">
|
||||||
|
<div class="scrollable-horizontal">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>文章标题</th>
|
||||||
|
<th>评论内容</th>
|
||||||
|
<th>评论日期</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let comment of commentService.currentComment.list">
|
||||||
|
<td>{{comment.id}}</td>
|
||||||
|
<td class="text-truncate" [title]="comment.articleID+'.'+comment.articleTitle">
|
||||||
|
<a [routerLink]="[ '/article']"
|
||||||
|
[queryParams]="{'id':comment.articleID}">{{comment.articleTitle}}</a>
|
||||||
|
</td>
|
||||||
|
<td [title]="comment.content">
|
||||||
|
<span>{{comment.content.length > 40 ? (comment.content.substr(0, 40) + '...') : comment.content}}</span>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a style="float: right;clear: both" (click)="prepareComment(comment)">查看</a>
|
||||||
|
</td>
|
||||||
|
<td>{{comment.date}}</td>
|
||||||
|
<td>
|
||||||
|
<a (click)="edit(0,comment.id,comment.content)">
|
||||||
|
<i nz-icon nzType="edit" nzTheme="twotone" nzTwotoneColor="#52c41a"></i> 编辑
|
||||||
|
</a>
|
||||||
|
<a nz-dropdown [nzDropdownMenu]="menu" nzPlacement="bottomLeft" nzTrigger="click">
|
||||||
|
更多 <i nz-icon nzType="down" nzTheme="outline"></i>
|
||||||
|
</a>
|
||||||
|
<nz-dropdown-menu #menu="nzDropdownMenu">
|
||||||
|
<ul nz-menu nzSelectable>
|
||||||
|
<!-- <li nz-menu-item>-->
|
||||||
|
<!-- <a disabled="true">回复</a>-->
|
||||||
|
<!-- </li>-->
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这条评论?"
|
||||||
|
(nzOnConfirm)="doDel(comment.id)">删除
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-dropdown-menu>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<nz-pagination align="center" [nzHideOnSinglePage]="true" [nzPageIndex]="pageNum"
|
||||||
|
[nzTotal]="commentService.currentComment.total"
|
||||||
|
[nzPageSize]="pageSize" (nzPageIndexChange)="toPage($event)">
|
||||||
|
</nz-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 留言 -->
|
||||||
|
<div *ngIf="commentType==0&&commentService.currentLeaveMsg">
|
||||||
|
<div class=" scrollable-horizontal">
|
||||||
|
<table class="table ">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>留言者</th>
|
||||||
|
<th>留言内容</th>
|
||||||
|
<th>留言日期</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let leaveMsg of commentService.currentLeaveMsg.list">
|
||||||
|
<td>{{leaveMsg.id}}</td>
|
||||||
|
<td>{{leaveMsg.authorName}}</td>
|
||||||
|
<td [title]="leaveMsg.content">
|
||||||
|
<span>{{leaveMsg.content.length > 40 ? (leaveMsg.content.substr(0, 40) + '...') : leaveMsg.content}}</span>
|
||||||
|
<a style="float: right;clear: both" (click)="prepareComment(leaveMsg)">查看</a>
|
||||||
|
</td>
|
||||||
|
<td>{{leaveMsg.date}}</td>
|
||||||
|
<td>
|
||||||
|
<a (click)="edit(1,leaveMsg.id,leaveMsg.content)">
|
||||||
|
<i nz-icon nzType="edit" nzTheme="twotone" nzTwotoneColor="#52c41a"></i> 编辑
|
||||||
|
</a>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-dropdown [nzDropdownMenu]="menu" nzPlacement="bottomLeft" nzTrigger="click">
|
||||||
|
更多 <i nz-icon nzType="down" nzTheme="outline"></i>
|
||||||
|
</a>
|
||||||
|
<nz-dropdown-menu #menu="nzDropdownMenu">
|
||||||
|
<ul nz-menu nzSelectable>
|
||||||
|
<!-- <li nz-menu-item>-->
|
||||||
|
<!-- <a disabled="true">回复</a>-->
|
||||||
|
<!-- </li>-->
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这条留言?"
|
||||||
|
(nzOnConfirm)="doDel(leaveMsg.id)">删除
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-dropdown-menu>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<nz-pagination align="center" [nzHideOnSinglePage]="true" [nzPageIndex]="pageNum"
|
||||||
|
[nzTotal]="commentService.currentLeaveMsg.total"
|
||||||
|
[nzPageSize]="pageSize" (nzPageIndexChange)="toPage($event)">
|
||||||
|
</nz-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 带输入框的弹出层 -->
|
||||||
|
|
||||||
|
<nz-modal [(nzVisible)]="showPupup" nzTitle="编辑" (nzOnCancel)="showPupup=!showPupup" (nzOnOk)="update()">
|
||||||
|
|
||||||
|
<textarea nz-input [(ngModel)]="updateReqBody.content"
|
||||||
|
[nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
|
||||||
|
|
||||||
|
</nz-modal>
|
||||||
|
|
||||||
|
<nz-modal [(nzVisible)]="showCommentDetail" (nzOnCancel)="showCommentDetail=!showCommentDetail"
|
||||||
|
(nzOnOk)="showCommentDetail=!showCommentDetail">
|
||||||
|
<nz-comment [nzAuthor]="commentDetail.authorName"
|
||||||
|
[nzDatetime]="commentDetail.date">
|
||||||
|
<nz-avatar nz-comment-avatar nzIcon="user" [nzSrc]="commentDetail.authorAvatarImgUrl"></nz-avatar>
|
||||||
|
<nz-comment-content class="comment">
|
||||||
|
<p>{{commentDetail.content}}</p>
|
||||||
|
</nz-comment-content>
|
||||||
|
|
||||||
|
<ng-container *ngIf="commentDetail.child && commentDetail.child.length">
|
||||||
|
<nz-comment *ngFor="let secLeaveMsg of commentDetail.child" [nzAuthor]="secLeaveMsg.authorName"
|
||||||
|
[nzDatetime]="secLeaveMsg.date">
|
||||||
|
<nz-avatar nz-comment-avatar nzIcon="user" [nzSrc]="secLeaveMsg.authorAvatarImgUrl"></nz-avatar>
|
||||||
|
<nz-comment-content class="comment">
|
||||||
|
<p>{{secLeaveMsg.content}}</p>
|
||||||
|
</nz-comment-content>
|
||||||
|
</nz-comment>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<nz-comment>
|
||||||
|
<nz-comment-content>
|
||||||
|
<nz-form-item>
|
||||||
|
<textarea [(ngModel)]="responseComment.content" nz-input
|
||||||
|
[nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
|
||||||
|
</nz-form-item>
|
||||||
|
<nz-form-item>
|
||||||
|
<button nz-button nzType="primary" [disabled]="!responseComment.content"
|
||||||
|
(click)="reply()"> 回复
|
||||||
|
</button>
|
||||||
|
<button nz-button nzType="default" style="margin-left: 15px;"
|
||||||
|
(click)="responseComment.pid=null"> 取消
|
||||||
|
</button>
|
||||||
|
</nz-form-item>
|
||||||
|
</nz-comment-content>
|
||||||
|
</nz-comment>
|
||||||
|
</nz-comment>
|
||||||
|
</nz-modal>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CommentManagerComponent } from './comment-manager.component';
|
||||||
|
|
||||||
|
describe('CommentManagerComponent', () => {
|
||||||
|
let component: CommentManagerComponent;
|
||||||
|
let fixture: ComponentFixture<CommentManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ CommentManagerComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(CommentManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
130
admin/src/app/pages/comment-manager/comment-manager.component.ts
Normal file
130
admin/src/app/pages/comment-manager/comment-manager.component.ts
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {UserService} from '../../services/user/user.service';
|
||||||
|
import {CommentService} from '../../services/comment/comment.service';
|
||||||
|
import {Comment} from '../../classes/comment';
|
||||||
|
import {CommentReq} from '../../classes/commentReq';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-comment-manager',
|
||||||
|
templateUrl: './comment-manager.component.html',
|
||||||
|
styleUrls: ['./comment-manager.component.css']
|
||||||
|
})
|
||||||
|
export class CommentManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public userService: UserService,
|
||||||
|
public commentService: CommentService,
|
||||||
|
private message: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pageNum: number = 1;
|
||||||
|
pageSize: number = 10;
|
||||||
|
|
||||||
|
commentType: number = 0;
|
||||||
|
|
||||||
|
showPupup = false;
|
||||||
|
|
||||||
|
updateReqBody = {
|
||||||
|
id: null,
|
||||||
|
type: null,
|
||||||
|
content: null
|
||||||
|
};
|
||||||
|
showCommentDetail: boolean = false;
|
||||||
|
commentDetail: Comment = new Comment();
|
||||||
|
|
||||||
|
responseComment: CommentReq = new CommentReq(true);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (!this.userService.userInfo) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.doInquire();
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
this.doInquire();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doInquire() {
|
||||||
|
const isAdmin: boolean = this.userService.userInfo.role === 'admin';
|
||||||
|
if (this.commentType) {
|
||||||
|
this.commentService.getComments(this.pageNum, this.pageSize, isAdmin);
|
||||||
|
} else {
|
||||||
|
this.commentService.getLeaveMsg(this.pageNum, this.pageSize, isAdmin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
toPage(e: number) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.doInquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareComment(comment: Comment) {
|
||||||
|
this.showCommentDetail = true;
|
||||||
|
this.commentDetail = comment;
|
||||||
|
this.commentService.getByPid(comment.id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.commentDetail.child = data.result.list;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// tslint:disable-next-line:triple-equals
|
||||||
|
this.responseComment.comment = this.commentType == 1;
|
||||||
|
// 若展示的是顶级评论 则pid为顶级评论的id 否则为该二级评论的pid
|
||||||
|
this.responseComment.pid = this.commentDetail.pid === -1 ? this.commentDetail.id : this.commentDetail.pid;
|
||||||
|
this.responseComment.articleID = this.commentDetail.articleID;
|
||||||
|
console.log(`${this.commentType.valueOf() == 1} and type is ${this.commentType}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
edit(type, id, content) {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.updateReqBody.id = id;
|
||||||
|
this.updateReqBody.type = type;
|
||||||
|
this.updateReqBody.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
if (this.updateReqBody.content === '') {
|
||||||
|
this.message.warning('不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.showPupup = false;
|
||||||
|
this.commentService.update(this.updateReqBody).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('修改成功!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
doDel(id) {
|
||||||
|
this.commentService.delete(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('删除成功');
|
||||||
|
} else {
|
||||||
|
this.message.error('删除失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
reply() {
|
||||||
|
if (this.responseComment.content == null || this.responseComment.content === '') {
|
||||||
|
this.message.info('内容不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.responseComment.content = `@${this.commentDetail.authorName} ${this.responseComment.content}`
|
||||||
|
this.commentService.rely(this.responseComment).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.commentDetail.child.push(data.result);
|
||||||
|
this.message.success('回复成功');
|
||||||
|
this.responseComment = new CommentReq(true);
|
||||||
|
// tslint:disable-next-line:triple-equals
|
||||||
|
if (this.commentType == 1) {
|
||||||
|
this.commentService.currentComment.list.push(data.result);
|
||||||
|
} else {
|
||||||
|
this.commentService.currentLeaveMsg.list.push(data.result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
59
admin/src/app/pages/links-manager/links.component.html
Normal file
59
admin/src/app/pages/links-manager/links.component.html
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<div class="admin-content" id="links-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<strong class="part-title">友链管理</strong>
|
||||||
|
<button nz-button nzType="primary" nzGhost="true" style="margin-left: 30px;" (click)="add()">新增</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class=" scrollable-horizontal" *ngIf="linkService.currentPage">
|
||||||
|
<table class="table ">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>友链名称</th>
|
||||||
|
<th>友链链接</th>
|
||||||
|
<th>状态</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let link of linkService.currentPage.list">
|
||||||
|
<td>{{link.id}}</td>
|
||||||
|
<td class="text-truncate" style="max-width: 150px" [title]="link.name">{{link.name}}</td>
|
||||||
|
<td><a [href]="link.url" target="_blank">{{link.url}}</a></td>
|
||||||
|
<td><input type="checkbox" [checked]="link.open" disabled="disabled"></td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a (click)="edit(link)">编辑</a>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这条友链?" (nzOnConfirm)="doDel(link.id)">删除</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
<nz-pagination align="center" [nzPageIndex]="pageNum" [nzHideOnSinglePage]="true"
|
||||||
|
[nzTotal]="linkService.currentPage.total" [nzPageSize]="pageSize"
|
||||||
|
(nzPageIndexChange)="toPage($event)"></nz-pagination>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 带输入框的弹出层 -->
|
||||||
|
<nz-modal [(nzVisible)]="showPupup" nzTitle="友链编辑" (nzOnCancel)="showPupup=!showPupup" (nzOnOk)="update()">
|
||||||
|
<label style="margin-left: 10%;">网站名称:</label>
|
||||||
|
<input nz-input style="width: 80%;margin-left: 10%" [(ngModel)]="updateReqBody.name">
|
||||||
|
<label style="margin-left: 10%;">网站链接:</label>
|
||||||
|
<input nz-input style="width: 80%;margin-left: 10%" [(ngModel)]="updateReqBody.url">
|
||||||
|
<label style="margin-left: 10%;">是否公开显示:</label>
|
||||||
|
<select [(ngModel)]="updateReqBody.open">
|
||||||
|
<option value="">请选择</option>
|
||||||
|
<option value="true">显示</option>
|
||||||
|
<option value="false">不显示</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</nz-modal>
|
||||||
25
admin/src/app/pages/links-manager/links.component.spec.ts
Normal file
25
admin/src/app/pages/links-manager/links.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LinksManagerComponent } from './links.component';
|
||||||
|
|
||||||
|
describe('LinksComponent', () => {
|
||||||
|
let component: LinksManagerComponent;
|
||||||
|
let fixture: ComponentFixture<LinksManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [LinksManagerComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(LinksManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
104
admin/src/app/pages/links-manager/links.component.ts
Normal file
104
admin/src/app/pages/links-manager/links.component.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {LinkService} from '../../services/link/link.service';
|
||||||
|
import {Link} from '../../classes/link';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-links',
|
||||||
|
templateUrl: './links.component.html',
|
||||||
|
styleUrls: ['./links.component.css']
|
||||||
|
})
|
||||||
|
export class LinksManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public linkService: LinkService, private message: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pageNum: number = 1;
|
||||||
|
pageSize: number = 10;
|
||||||
|
|
||||||
|
showPupup = false;
|
||||||
|
|
||||||
|
updateReqBody = new Link();
|
||||||
|
|
||||||
|
isUpdate;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.linkService.getLinks(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
toPage(e: number) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
edit(link) {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.updateReqBody = link;
|
||||||
|
this.isUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
if (this.updateReqBody.name === '') {
|
||||||
|
this.message.warning('友链名称不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.updateReqBody.url === '') {
|
||||||
|
this.message.warning('友链链接不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
// tslint:disable-next-line:triple-equals
|
||||||
|
if (this.updateReqBody.open == '') {
|
||||||
|
this.message.warning('友链状态不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.showPupup = false;
|
||||||
|
if (this.isUpdate) {
|
||||||
|
this.linkService.update(this.updateReqBody).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('更新成功');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('更新失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
this.updateReqBody.name = null;
|
||||||
|
this.updateReqBody.url = null;
|
||||||
|
this.updateReqBody.open = null;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.linkService.create(this.updateReqBody).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('新增成功');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('新增失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
this.updateReqBody.name = null;
|
||||||
|
this.updateReqBody.url = null;
|
||||||
|
this.updateReqBody.open = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add() {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.isUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
doDel(id) {
|
||||||
|
this.linkService.delete(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('删除成功!');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('删除失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
admin/src/app/pages/tag-manager/tag-manager.component.css
Normal file
11
admin/src/app/pages/tag-manager/tag-manager.component.css
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#publishArticle{
|
||||||
|
width: 100%;
|
||||||
|
height: 32px;
|
||||||
|
border-bottom-left-radius: 10px;
|
||||||
|
border-bottom-right-radius: 10px;
|
||||||
|
border: none;
|
||||||
|
background: turquoise;
|
||||||
|
color: white
|
||||||
|
}
|
||||||
68
admin/src/app/pages/tag-manager/tag-manager.component.html
Normal file
68
admin/src/app/pages/tag-manager/tag-manager.component.html
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<!--标签-->
|
||||||
|
<div class="admin-content" id="tag-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<div><strong class="part-title">标签管理</strong></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="g">
|
||||||
|
<div class="scrollable-horizontal" *ngIf="tagService.currentTagPage">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>标签名称</th>
|
||||||
|
<th>标签文章</th>
|
||||||
|
<th>文章数目</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let tag of tagService.currentTagPage.list">
|
||||||
|
<td>{{tag.id}}</td>
|
||||||
|
<td class="text-truncate" style="max-width: 150px" [title]="tag.name">{{tag.name}}</td>
|
||||||
|
<td>{{tag.articles}}</td>
|
||||||
|
<td><span class="badge badge-success">{{tag.articles.split(',').length - 1}}</span></td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<a [href]="'../tag?name='+tag.name">
|
||||||
|
<i nz-icon nzType="tag" nzTheme="twotone"></i> 查看
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-dropdown [nzDropdownMenu]="menu" nzPlacement="bottomLeft" nzTrigger="click">
|
||||||
|
更多 <i nz-icon nzType="down" nzTheme="outline"></i>
|
||||||
|
</a>
|
||||||
|
<nz-dropdown-menu #menu="nzDropdownMenu">
|
||||||
|
<ul nz-menu nzSelectable>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a (click)="edit(tag.id,tag.name)">编辑</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这条标签?" (nzOnConfirm)="doDel(tag.id)">删除</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nz-dropdown-menu>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<nz-pagination align="center" [nzPageIndex]="pageNum" [nzHideOnSinglePage]="true"
|
||||||
|
[nzTotal]="tagService.currentTagPage.total" [nzPageSize]="pageSize"
|
||||||
|
(nzPageIndexChange)="toPage($event)"></nz-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 带输入框的弹出层 -->
|
||||||
|
|
||||||
|
<nz-modal [(nzVisible)]="showPupup" nzTitle="编辑" (nzOnCancel)="showPupup=!showPupup" (nzOnOk)="update()">
|
||||||
|
<input class="select" style="width: 80%;margin-left: 10%" [(ngModel)]="updateReqBody.name">
|
||||||
|
</nz-modal>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { TagManagerComponent } from './tag-manager.component';
|
||||||
|
|
||||||
|
describe('TagManagerComponent', () => {
|
||||||
|
let component: TagManagerComponent;
|
||||||
|
let fixture: ComponentFixture<TagManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ TagManagerComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(TagManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
72
admin/src/app/pages/tag-manager/tag-manager.component.ts
Normal file
72
admin/src/app/pages/tag-manager/tag-manager.component.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {TagService} from '../../services/tag/tag.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-tag-manager',
|
||||||
|
templateUrl: './tag-manager.component.html',
|
||||||
|
styleUrls: ['./tag-manager.component.css']
|
||||||
|
})
|
||||||
|
export class TagManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public tagService: TagService, private message: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pageNum: number = 1;
|
||||||
|
|
||||||
|
pageSize: number = 10;
|
||||||
|
|
||||||
|
showPupup: boolean = false;
|
||||||
|
|
||||||
|
updateReqBody = {
|
||||||
|
id: null,
|
||||||
|
name: null
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.tagService.getTags(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
toPage(e: number) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
edit(id, name) {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.updateReqBody.id = id;
|
||||||
|
this.updateReqBody.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
if (this.updateReqBody.name === '') {
|
||||||
|
this.message.warning('不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.showPupup = false;
|
||||||
|
this.tagService.update(this.updateReqBody.id, this.updateReqBody.name).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('修改成功!');
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
doDel(id) {
|
||||||
|
this.tagService.delete(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('删除成功');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error(`删除失败,原因:${data.msg}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
54
admin/src/app/pages/update-manager/update.component.html
Normal file
54
admin/src/app/pages/update-manager/update.component.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<div class="admin-content" id="tag-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<strong class="part-title">更新管理</strong>
|
||||||
|
<button nz-button nzType="primary" nzGhost="true" style="margin-left: 30px;" (click)="add()">新增</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class=" scrollable-horizontal" *ngIf="updateService.updateInfoList">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>更新内容</th>
|
||||||
|
<th>更新日期</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let update of updateService.updateInfoList.list">
|
||||||
|
<td>{{update.id}}</td>
|
||||||
|
<td style="max-width: 150px" nz-tooltip [nzTitle]="update.info">
|
||||||
|
{{update.info.length > 20 ? update.info.substr(0, 20) + '...' : update.info}}
|
||||||
|
</td>
|
||||||
|
<td>{{update.time}}</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a (click)="edit(update)">编辑</a>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这条更新?" (nzOnConfirm)="doDel(update.id)">删除</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<nz-pagination align="center" [nzPageIndex]="pageNum" [nzHideOnSinglePage]="true"
|
||||||
|
[nzTotal]="updateService.updateInfoList.total"
|
||||||
|
[nzPageSize]="pageSize" (nzPageIndexChange)="toPage($event)"></nz-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 带输入框的弹出层 -->
|
||||||
|
|
||||||
|
<nz-modal [(nzVisible)]="showPupup" nzTitle="编辑" (nzOnCancel)="showPupup=!showPupup" (nzOnOk)="submit()">
|
||||||
|
<label style="margin-left: 10%;margin-bottom: 10px">更新内容:</label>
|
||||||
|
<textarea nz-input style="width: 80%;margin-left: 10%; height: 100px;"
|
||||||
|
[(ngModel)]="updateReqBody.info" placeholder="更新内容"
|
||||||
|
[nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
|
||||||
|
|
||||||
|
</nz-modal>
|
||||||
25
admin/src/app/pages/update-manager/update.component.spec.ts
Normal file
25
admin/src/app/pages/update-manager/update.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { UpdateManagerComponent } from './update.component';
|
||||||
|
|
||||||
|
describe('UpdateComponent', () => {
|
||||||
|
let component: UpdateManagerComponent;
|
||||||
|
let fixture: ComponentFixture<UpdateManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [UpdateManagerComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(UpdateManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
95
admin/src/app/pages/update-manager/update.component.ts
Normal file
95
admin/src/app/pages/update-manager/update.component.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {WebUpdateService} from '../../services/update/web-update.service';
|
||||||
|
import {UpdateInfo} from "../../classes/updateInfo";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-update',
|
||||||
|
templateUrl: './update.component.html',
|
||||||
|
styleUrls: ['./update.component.css']
|
||||||
|
})
|
||||||
|
export class UpdateManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public updateService: WebUpdateService, private message: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
isUpdate = false;
|
||||||
|
|
||||||
|
pageNum: number = 1;
|
||||||
|
pageSize: number = 10;
|
||||||
|
|
||||||
|
showPupup = false;
|
||||||
|
|
||||||
|
updateReqBody = new UpdateInfo();
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.updateService.getUpdateInfo(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
toPage(e: number) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
edit(link) {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.updateReqBody = link;
|
||||||
|
this.isUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
if (this.updateReqBody.info === '') {
|
||||||
|
this.message.warning('更新内容不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.showPupup = false;
|
||||||
|
if (this.isUpdate) {
|
||||||
|
this.updateService.update(this.updateReqBody).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('更新成功');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('更新失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.updateReqBody.id = null;
|
||||||
|
this.updateService.create(this.updateReqBody.info).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('新增成功');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('新增失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.updateReqBody.id = null;
|
||||||
|
this.updateReqBody.info = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
add() {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.isUpdate = false;
|
||||||
|
this.updateReqBody.id = null;
|
||||||
|
this.updateReqBody.info = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
doDel(id: number) {
|
||||||
|
this.updateService.delete(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('删除成功!');
|
||||||
|
this.getData();
|
||||||
|
} else {
|
||||||
|
this.message.error('删除失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
78
admin/src/app/pages/user-info/user-info.component.css
Normal file
78
admin/src/app/pages/user-info/user-info.component.css
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
.label {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.4em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 200px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
background: #eeeeee;
|
||||||
|
height: 30px;
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#user-gender input {
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit {
|
||||||
|
width: 80%;
|
||||||
|
margin-left: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#avatar {
|
||||||
|
position: absolute;
|
||||||
|
right: 20px;
|
||||||
|
top: 30%;
|
||||||
|
border: 1px solid #999999;
|
||||||
|
border-radius: 1px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#avatarimg {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#info {
|
||||||
|
width: 350px;
|
||||||
|
position: relative;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, 50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
#info i {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#info .sendEmail {
|
||||||
|
position: absolute;
|
||||||
|
margin-top: 3px;
|
||||||
|
top: 0;
|
||||||
|
right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#info input {
|
||||||
|
width: 90%;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
46
admin/src/app/pages/user-info/user-info.component.html
Normal file
46
admin/src/app/pages/user-info/user-info.component.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<!--修改信息-->
|
||||||
|
<div class="admin-content" id="user-info">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<div><strong class="part-title">个人资料</strong> /
|
||||||
|
<small>Personal information</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<div id="info">
|
||||||
|
<i nz-icon nzType="mail" nzTheme="twotone"></i>
|
||||||
|
<input nz-input [(ngModel)]="user.email" style="display: inline" [disabled]="true"/>
|
||||||
|
<button *ngIf="!user.emailStatus" nz-button nzType="primary" class="sendEmail" (click)="sendEmail()"
|
||||||
|
[title]="'发生邮件到'+user.email+'中'" [disabled]="!clickable">
|
||||||
|
发送激活邮件
|
||||||
|
</button>
|
||||||
|
<br>
|
||||||
|
<i nz-icon nzType="info-circle" nzTheme="twotone"></i>
|
||||||
|
<input nz-input type="text" placeholder="用一句话来描述自己吧" name="desc" id="desc" [(ngModel)]="user.desc">
|
||||||
|
<br>
|
||||||
|
<i nz-icon nzType="crown" nzTheme="twotone"></i>
|
||||||
|
<input nz-input type="text" placeholder="昵称" name="displayName" id="displayName"
|
||||||
|
[(ngModel)]="user.displayName">
|
||||||
|
<br>
|
||||||
|
<button nz-button nzType="primary" nzGhost="true" [nzBlock]="true" (click)="userInfoSubmit()">提交</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="avatar">
|
||||||
|
<h3><strong>头像</strong></h3>
|
||||||
|
<div>
|
||||||
|
<img id="avatarimg" [src]="user.avatarImgUrl" alt="avatar">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<nz-upload [nzAction]="host+'/user/imgUpload'" nzWithCredentials="true" nzLimit="1" nzSize="2048"
|
||||||
|
(nzChange)="avatarUpload($event)">
|
||||||
|
<button nz-button><i nz-icon nzType="upload"></i><span>选择图片上传</span></button>
|
||||||
|
</nz-upload>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
25
admin/src/app/pages/user-info/user-info.component.spec.ts
Normal file
25
admin/src/app/pages/user-info/user-info.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { UserInfoComponent } from './user-info.component';
|
||||||
|
|
||||||
|
describe('UserInfoComponent', () => {
|
||||||
|
let component: UserInfoComponent;
|
||||||
|
let fixture: ComponentFixture<UserInfoComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ UserInfoComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(UserInfoComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
74
admin/src/app/pages/user-info/user-info.component.ts
Normal file
74
admin/src/app/pages/user-info/user-info.component.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
import {UserService} from '../../services/user/user.service';
|
||||||
|
import {User} from '../../classes/user';
|
||||||
|
import {environment} from '../../../environments/environment';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-user-info',
|
||||||
|
templateUrl: './user-info.component.html',
|
||||||
|
styleUrls: ['./user-info.component.css']
|
||||||
|
})
|
||||||
|
export class UserInfoComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public userService: UserService,
|
||||||
|
private message: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
host: string;
|
||||||
|
|
||||||
|
user: User = new User();
|
||||||
|
|
||||||
|
clickable: boolean = true;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (!this.userService.userInfo) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.user = this.userService.userInfo;
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
this.user = this.userService.userInfo;
|
||||||
|
}
|
||||||
|
this.host = environment.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userInfoSubmit() {
|
||||||
|
const info = {
|
||||||
|
desc: this.user.desc,
|
||||||
|
displayName: this.user.displayName
|
||||||
|
};
|
||||||
|
this.userService.updateInfo(info).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('修改成功');
|
||||||
|
} else if (data.code === 301) {
|
||||||
|
window.location.href = '/login';
|
||||||
|
} else {
|
||||||
|
this.message.error('修改信息失败,原因:' + data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sendEmail() {
|
||||||
|
this.clickable = false;
|
||||||
|
if (!this.userService.userInfo) {
|
||||||
|
window.location.href = '/login';
|
||||||
|
}
|
||||||
|
this.userService.sendEmail().subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.message.success('发送成功!请前往邮箱进行激活');
|
||||||
|
} else {
|
||||||
|
this.message.error(data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarUpload(info: any) {
|
||||||
|
if (info.type === 'success' && info.file.response.code === 0) {
|
||||||
|
const time = new Date().valueOf();
|
||||||
|
this.userService.userInfo.avatarImgUrl = this.userService.avatarHost + '/' + info.file.response.result;
|
||||||
|
// 加上时间戳 让图片自动预览,避免读取本地缓存而不显示新头像
|
||||||
|
this.user.avatarImgUrl = this.userService.avatarHost + '/' + info.file.response.result + '?time=' + time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.error {
|
||||||
|
padding-left: 20px;
|
||||||
|
color: red;
|
||||||
|
border: 1px solid #eb2f96;
|
||||||
|
border-radius: 2px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
77
admin/src/app/pages/user-manager/user-manager.component.html
Normal file
77
admin/src/app/pages/user-manager/user-manager.component.html
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<!--标签-->
|
||||||
|
<div class="admin-content" id="tag-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<div><strong class="part-title">用户管理</strong></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="g">
|
||||||
|
<div class="scrollable-horizontal" *ngIf="userService.currentUserPage">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>用户邮箱</th>
|
||||||
|
<th>用户昵称</th>
|
||||||
|
<th>用户角色</th>
|
||||||
|
<th>管理</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let user of userService.currentUserPage.list">
|
||||||
|
<td align="center">{{user.id}}</td>
|
||||||
|
<td align="center" class="text-truncate">{{user.email}}</td>
|
||||||
|
<td align="center">{{user.displayName}}</td>
|
||||||
|
<td align="center"><span class="badge badge-success">{{user.role}}</span></td>
|
||||||
|
<td>
|
||||||
|
<a (click)="edit(user)"><i nz-icon nzType="tag" nzTheme="twotone"></i> 编辑</a>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<a nz-popconfirm nzTitle="是否要删除这名用户?" (nzOnConfirm)="delete(user.id)">
|
||||||
|
<i nz-icon nzType="delete" nzTheme="twotone" nzTwotoneColor="#eb2f96"></i> 删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<nz-pagination align="center" [nzPageIndex]="pageNum" [nzHideOnSinglePage]="true"
|
||||||
|
[nzTotal]="userService.currentUserPage.total" [nzPageSize]="pageSize"
|
||||||
|
(nzPageIndexChange)="toPage($event)"></nz-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!--用户编辑-->
|
||||||
|
<nz-modal [(nzVisible)]="showPupup" nzTitle="编辑" (nzOnCancel)="showPupup=!showPupup" (nzOnOk)="update()">
|
||||||
|
<form action="#">
|
||||||
|
<label for="email">邮箱:</label>
|
||||||
|
<input nz-input type="email" id="email" name="email" [(ngModel)]="editUser.email" (blur)="getEmailStatus()">
|
||||||
|
<ng-template [ngIf]="showError">
|
||||||
|
<span class="error">
|
||||||
|
<i nz-icon nzType="exclamation-circle" nzTheme="twotone" nzTwotoneColor="#eb2f96"></i>
|
||||||
|
邮箱已被占用!
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
|
<label for="display-name">昵称:</label>
|
||||||
|
<input nz-input type="text" id="display-name" name="display-name" [(ngModel)]="editUser.displayName">
|
||||||
|
<label for="pwd">密码:<span style="font-weight: lighter;font-size: smaller">留空则不重设密码,反之则设置为输入的密码</span></label>
|
||||||
|
<input nz-input type="password" id="pwd" name="pwd" [(ngModel)]="editUser.pwd" placeholder="******">
|
||||||
|
<label for="user-role">角色:</label>
|
||||||
|
<nz-select name="user-role" style="width: 100%" id="user-role"
|
||||||
|
[nzDisabled]="editUser.id==userService.userInfo.id" [(ngModel)]="editUser.role">
|
||||||
|
<nz-option nzValue="user" nzLabel="user"></nz-option>
|
||||||
|
<nz-option nzValue="admin" nzLabel="admin"></nz-option>
|
||||||
|
</nz-select>
|
||||||
|
<label for="email-status">邮箱验证状态:</label>
|
||||||
|
<br>
|
||||||
|
<nz-radio-group name="email-status" id="email-status" [(ngModel)]="editUser.emailStatus">
|
||||||
|
<label nz-radio [nzValue]="true">已验证</label>
|
||||||
|
<label nz-radio [nzValue]="false">未验证</label>
|
||||||
|
</nz-radio-group>
|
||||||
|
<br>
|
||||||
|
<label for="desc">描述:</label>
|
||||||
|
<textarea rows="4" id="desc" name="desc" nz-input [(ngModel)]="editUser.desc"></textarea>
|
||||||
|
</form>
|
||||||
|
</nz-modal>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { UserManagerComponent } from './user-manager.component';
|
||||||
|
|
||||||
|
describe('UserManagerComponent', () => {
|
||||||
|
let component: UserManagerComponent;
|
||||||
|
let fixture: ComponentFixture<UserManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ UserManagerComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(UserManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
91
admin/src/app/pages/user-manager/user-manager.component.ts
Normal file
91
admin/src/app/pages/user-manager/user-manager.component.ts
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {UserService} from '../../services/user/user.service';
|
||||||
|
import {User} from '../../classes/user';
|
||||||
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-user-manager',
|
||||||
|
templateUrl: './user-manager.component.html',
|
||||||
|
styleUrls: ['./user-manager.component.css']
|
||||||
|
})
|
||||||
|
export class UserManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public userService: UserService,
|
||||||
|
private messageService: NzMessageService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pageNum: number = 1;
|
||||||
|
pageSize: number = 10;
|
||||||
|
showPupup: boolean = false;
|
||||||
|
editUser: User = new User();
|
||||||
|
showError: boolean = false;
|
||||||
|
formerEmail: string;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.userService.getPageUser(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
toPage(e: number) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.userService.getPageUser(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
edit(user: User) {
|
||||||
|
this.showPupup = true;
|
||||||
|
this.showError = false;
|
||||||
|
// 避免引用赋值,采用json进行浅拷贝!!
|
||||||
|
this.editUser = JSON.parse(JSON.stringify(user));
|
||||||
|
this.formerEmail = this.editUser.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number) {
|
||||||
|
this.userService.delete(id).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
if (data.result[0].status) {
|
||||||
|
this.messageService.success('删除成功!');
|
||||||
|
this.userService.getPageUser(this.pageNum, this.pageSize);
|
||||||
|
} else {
|
||||||
|
this.messageService.error(`删除失败,原因:${data.result[0].msg}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.messageService.error(`请求失败,原因:${data.msg}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.editUser.recentlyLandedDate = null;
|
||||||
|
this.editUser.avatarImgUrl = null;
|
||||||
|
if (this.showError) {
|
||||||
|
this.showPupup = false;
|
||||||
|
this.messageService.warning('邮箱不可用,请修改!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.userService.update(this.editUser).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.messageService.success('修改成功!');
|
||||||
|
if (this.userService.userInfo.id === this.editUser.id) {
|
||||||
|
this.userService.userInfo = this.editUser;
|
||||||
|
}
|
||||||
|
this.userService.getPageUser(this.pageNum, this.pageSize, true);
|
||||||
|
} else {
|
||||||
|
this.messageService.error('修改失败!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.showPupup = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getEmailStatus() {
|
||||||
|
if (this.editUser.email === this.formerEmail) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.userService.getExistOfEmail(this.editUser.email).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.showError = data.result;
|
||||||
|
} else {
|
||||||
|
this.messageService.error(data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<!--访问量-->
|
||||||
|
<div class="admin-content" id="visitor-manager">
|
||||||
|
<div class="admin-content-body">
|
||||||
|
<div>
|
||||||
|
<div><strong class="part-title">访问管理</strong>
|
||||||
|
<span>---当日访问量{{visitorService.dayVisit}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="g">
|
||||||
|
<div class="scrollable-horizontal" *ngIf="visitorService.currentPage">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>ip地址</th>
|
||||||
|
<th>访问日期</th>
|
||||||
|
<th>浏览器类型</th>
|
||||||
|
<th>系统</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let visitor of visitorService.currentPage.list">
|
||||||
|
<td>{{visitor.id}}</td>
|
||||||
|
<td>
|
||||||
|
<span (mouseenter)="getIp(visitor.ip)" [title]="location">{{visitor.ip}}</span>
|
||||||
|
<i nz-icon nzType="smile" nzTheme="twotone" nzTwotoneColor="#00DC25"
|
||||||
|
*ngIf="visitor.ip==localIp" style="float: right;clear: both" title="您的访问记录"></i>
|
||||||
|
</td>
|
||||||
|
<td>{{visitor.date}}</td>
|
||||||
|
<td style="text-align: center" [title]="visitor.browserVersion">
|
||||||
|
<span *ngIf="visitor.browserName!='Unknown'"> {{visitor.browserName}}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span *ngIf="visitor.osname!='Unknown' "> {{visitor.osname}}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<nz-pagination align="center " [nzPageIndex]="pageNum " [nzHideOnSinglePage]="true "
|
||||||
|
[nzTotal]="visitorService.currentPage.total " [nzPageSize]="pageSize "
|
||||||
|
(nzPageIndexChange)="toPage($event) "></nz-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { VisitorManagerComponent } from './visitor-manager.component';
|
||||||
|
|
||||||
|
describe('VisitorManagerComponent', () => {
|
||||||
|
let component: VisitorManagerComponent;
|
||||||
|
let fixture: ComponentFixture<VisitorManagerComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ VisitorManagerComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(VisitorManagerComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {VisitorService} from '../../services/visitor/visitor.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-visitor-manager',
|
||||||
|
templateUrl: './visitor-manager.component.html',
|
||||||
|
styleUrls: ['./visitor-manager.component.css']
|
||||||
|
})
|
||||||
|
export class VisitorManagerComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public visitorService: VisitorService) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pageNum: number = 1;
|
||||||
|
pageSize: number = 10;
|
||||||
|
|
||||||
|
|
||||||
|
localIp = '';
|
||||||
|
|
||||||
|
location: string;
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getPageData();
|
||||||
|
this.visitorService.getDayVisitor();
|
||||||
|
this.visitorService.getLocalIp().subscribe(data => {
|
||||||
|
this.localIp = data.result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getIp(ip) {
|
||||||
|
const result = this.visitorService.getIp(ip);
|
||||||
|
if (typeof result === 'string') {
|
||||||
|
this.location = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.location = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPageData() {
|
||||||
|
this.visitorService.getVisitor(this.pageNum, this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
toPage(e) {
|
||||||
|
this.pageNum = e;
|
||||||
|
this.getPageData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
12
admin/src/app/services/article/article.service.spec.ts
Normal file
12
admin/src/app/services/article/article.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ArticleService } from './article.service';
|
||||||
|
|
||||||
|
describe('ArticleService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: ArticleService = TestBed.get(ArticleService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
49
admin/src/app/services/article/article.service.ts
Normal file
49
admin/src/app/services/article/article.service.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
import {Article} from '../../classes/article';
|
||||||
|
import {Observable, of} from 'rxjs';
|
||||||
|
import {exist} from '../../utils/dataUtil';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ArticleService {
|
||||||
|
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存储所有已经请求过的数据<首页数据>
|
||||||
|
pageList: Page<Article>[] = [];
|
||||||
|
|
||||||
|
currentPage: Page<Article>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文章
|
||||||
|
* @param pageNum 页码数
|
||||||
|
* @param pageSize 单页数据量
|
||||||
|
*/
|
||||||
|
getArticle(pageNum: number, pageSize: number): object {
|
||||||
|
const articlePage = exist<Article>(pageNum, pageSize, this.pageList);
|
||||||
|
if (articlePage) {
|
||||||
|
articlePage.subscribe(data => {
|
||||||
|
this.currentPage = data;
|
||||||
|
});
|
||||||
|
return articlePage;
|
||||||
|
}
|
||||||
|
const observable = this.http.get('/admin/articles?page=' + pageNum + '&count=' + pageSize);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.currentPage = data.result;
|
||||||
|
this.pageList.push(data.result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteArticle(id) {
|
||||||
|
return this.http.delete('/admin/article/del?articleID=' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
admin/src/app/services/category/category.service.spec.ts
Normal file
12
admin/src/app/services/category/category.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CategoryService } from './category.service';
|
||||||
|
|
||||||
|
describe('CategoryService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: CategoryService = TestBed.get(CategoryService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
56
admin/src/app/services/category/category.service.ts
Normal file
56
admin/src/app/services/category/category.service.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {Category} from '../../classes/category';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CategoryService {
|
||||||
|
|
||||||
|
// FIXME : !!!!!!!!!!!!!!!!!!数据处理全部放到一个模块中!!!!!!!!!!!!!!!!!!
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
categories: Category[];
|
||||||
|
|
||||||
|
getAllCategory() {
|
||||||
|
const observable = this.http.get('/categories');
|
||||||
|
observable.subscribe((data) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.categories = data.result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(submitBody: { id: number, name: string }) {
|
||||||
|
return this.http.put('/admin/category/update', submitBody, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(nameStr: string) {
|
||||||
|
const observable = this.http.post('/admin/category/create', {name: nameStr}, false);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.categories.push(data.result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number) {
|
||||||
|
const observable = this.http.delete(`/admin/category/del?id=${id}`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
// tslint:disable-next-line:prefer-for-of
|
||||||
|
for (let i = 0; i < this.categories.length; i++) {
|
||||||
|
if (this.categories[i].id === id) {
|
||||||
|
this.categories.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
admin/src/app/services/comment/comment.service.spec.ts
Normal file
12
admin/src/app/services/comment/comment.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CommentService } from './comment.service';
|
||||||
|
|
||||||
|
describe('CommentService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: CommentService = TestBed.get(CommentService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
98
admin/src/app/services/comment/comment.service.ts
Normal file
98
admin/src/app/services/comment/comment.service.ts
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
import {Comment} from '../../classes/comment';
|
||||||
|
import {exist} from '../../utils/dataUtil';
|
||||||
|
import {CommentReq} from "../../classes/commentReq";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CommentService {
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存放
|
||||||
|
leaveMsgPage: Page<Comment>[] = [];
|
||||||
|
|
||||||
|
commentPage: Page<Comment>[] = [];
|
||||||
|
|
||||||
|
currentComment: Page<Comment>;
|
||||||
|
|
||||||
|
currentLeaveMsg: Page<Comment>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 评论
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 单页数据数量
|
||||||
|
* @param isAdmin 是否是管理员
|
||||||
|
*/
|
||||||
|
getComments(pageNum: number, pageSize: number, isAdmin: boolean) {
|
||||||
|
const exist1 = exist<Comment>(pageNum, pageSize, this.commentPage);
|
||||||
|
if (exist1) {
|
||||||
|
exist1.subscribe(data => {
|
||||||
|
this.currentComment = data;
|
||||||
|
});
|
||||||
|
return exist1;
|
||||||
|
}
|
||||||
|
const observable = this.http.get(`/${isAdmin ? 'admin' : 'user'}/comment/type/1?count=${pageSize}&page=${pageNum}`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.commentPage.unshift(data.result);
|
||||||
|
this.currentComment = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 留言
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 单页数据数量
|
||||||
|
* @param isAdmin 是否是管理员
|
||||||
|
*/
|
||||||
|
getLeaveMsg(pageNum: number, pageSize: number, isAdmin: boolean) {
|
||||||
|
const exist1 = exist<Comment>(pageNum, pageSize, this.leaveMsgPage);
|
||||||
|
if (exist1) {
|
||||||
|
exist1.subscribe(data => {
|
||||||
|
this.currentLeaveMsg = data;
|
||||||
|
});
|
||||||
|
return exist1;
|
||||||
|
}
|
||||||
|
const observable = this.http.get(`/${isAdmin ? 'admin' : 'user'}/comment/type/0?count=${pageSize}&page=${pageNum}`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.leaveMsgPage.unshift(data.result);
|
||||||
|
this.currentLeaveMsg = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复评论/留言
|
||||||
|
* @param responseComment 请求体
|
||||||
|
*/
|
||||||
|
rely(responseComment: CommentReq) {
|
||||||
|
return this.http.post('/user/comment/create', responseComment, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过父评论 获取回复
|
||||||
|
* @param pid 父评论id
|
||||||
|
*/
|
||||||
|
getByPid(pid: number) {
|
||||||
|
return this.http.get('/comment/pid/' + pid + '?count=5&page=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
update(subComment) {
|
||||||
|
return this.http.put('/user/comment/update', subComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number) {
|
||||||
|
return this.http.delete('/user/comment/del?id=' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
12
admin/src/app/services/http.service.spec.ts
Normal file
12
admin/src/app/services/http.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HttpService } from './http.service';
|
||||||
|
|
||||||
|
describe('HttpService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: HttpService = TestBed.get(HttpService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
103
admin/src/app/services/http.service.ts
Normal file
103
admin/src/app/services/http.service.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||||
|
import {environment} from '../../environments/environment';
|
||||||
|
import {Observable} from 'rxjs';
|
||||||
|
import {Data} from '../classes/data';
|
||||||
|
import {reqBody2Str} from '../utils/dataUtil';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class HttpService {
|
||||||
|
|
||||||
|
constructor(public httpClient: HttpClient) {
|
||||||
|
this.host = environment.host;
|
||||||
|
const item = localStorage.getItem('token');
|
||||||
|
this.token = item == null ? '' : item;
|
||||||
|
this.httpOptions = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
Accept: '*/*',
|
||||||
|
Authorization: this.token,
|
||||||
|
}),
|
||||||
|
withCredentials: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求的主机地址
|
||||||
|
public host: string;
|
||||||
|
private token: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http请求配置
|
||||||
|
*/
|
||||||
|
private httpOptions: object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get 请求
|
||||||
|
* @param path 路径
|
||||||
|
*/
|
||||||
|
get(path: string): Observable<Data> {
|
||||||
|
return this.httpClient.get<Data>(this.getPath(path), this.httpOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post请求
|
||||||
|
* @param path 路径
|
||||||
|
* @param reqBody 请求体
|
||||||
|
* @param isJson 请求数据是否是json格式
|
||||||
|
*/
|
||||||
|
post(path: string, reqBody: object, isJson: boolean): Observable<Data> {
|
||||||
|
const Options = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
Accept: '*/*',
|
||||||
|
Authorization: this.token,
|
||||||
|
'Content-Type': isJson ? 'application/json' : 'application/x-www-form-urlencoded'
|
||||||
|
}),
|
||||||
|
withCredentials: true
|
||||||
|
};
|
||||||
|
return this.httpClient.post<Data>(this.getPath(path), isJson ? reqBody : reqBody2Str(reqBody), Options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* put 请求
|
||||||
|
* @param path 请求路径
|
||||||
|
* @param reqBody 请求体
|
||||||
|
* @param isJson 是否发生json格式数据到服务器
|
||||||
|
*/
|
||||||
|
put(path: string, reqBody: object, isJson: boolean = false): Observable<Data> {
|
||||||
|
const Options = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
Accept: '*/*',
|
||||||
|
Authorization: this.token,
|
||||||
|
'Content-Type': isJson ? 'application/json' : 'application/x-www-form-urlencoded'
|
||||||
|
}),
|
||||||
|
withCredentials: true
|
||||||
|
};
|
||||||
|
return this.httpClient.put<Data>(this.getPath(path), isJson ? reqBody : reqBody2Str(reqBody), Options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete 请求
|
||||||
|
* @param path 请求路径
|
||||||
|
*/
|
||||||
|
delete(path: string): Observable<Data> {
|
||||||
|
return this.httpClient.delete<Data>(this.getPath(path), this.httpOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查path 并拼接
|
||||||
|
* @param path 请求路径
|
||||||
|
* @return 拼接后的url
|
||||||
|
*/
|
||||||
|
private getPath(path: string): string {
|
||||||
|
if (path == null || path.length === 0 || path.substr(0, 1) !== '/') {
|
||||||
|
throw new Error('路径不合法');
|
||||||
|
}
|
||||||
|
return this.host + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeToken() {
|
||||||
|
localStorage.removeItem('token');
|
||||||
|
this.token = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
admin/src/app/services/link/link.service.spec.ts
Normal file
12
admin/src/app/services/link/link.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LinkService } from './link.service';
|
||||||
|
|
||||||
|
describe('LinkService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: LinkService = TestBed.get(LinkService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
39
admin/src/app/services/link/link.service.ts
Normal file
39
admin/src/app/services/link/link.service.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {Link} from '../../classes/link';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class LinkService {
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不采取存储page[] :: 数据量较少
|
||||||
|
public currentPage: Page<Link>;
|
||||||
|
|
||||||
|
getLinks(pageNum: number, pageSize: number) {
|
||||||
|
const observable = this.http.get(`/admin/links?page=${pageNum}&count=${pageSize}`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.currentPage = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(submitBody: Link) {
|
||||||
|
return this.http.put('/admin/links/update', submitBody, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(submitBody: Link) {
|
||||||
|
submitBody.id = null;
|
||||||
|
return this.http.post('/admin/links/create', submitBody, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id) {
|
||||||
|
return this.http.delete(`/admin/links/del/${id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
admin/src/app/services/log/log.service.spec.ts
Normal file
12
admin/src/app/services/log/log.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LogService } from './log.service';
|
||||||
|
|
||||||
|
describe('LogService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: LogService = TestBed.get(LogService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
22
admin/src/app/services/log/log.service.ts
Normal file
22
admin/src/app/services/log/log.service.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class LogService {
|
||||||
|
|
||||||
|
constructor(private http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
logText: string;
|
||||||
|
|
||||||
|
getLog() {
|
||||||
|
// @ts-ignore
|
||||||
|
const observable = this.http.httpClient.get<string>('https://api.celess.cn/blog.log', {responseType: 'text'});
|
||||||
|
observable.subscribe(data => {
|
||||||
|
this.logText = data;
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
admin/src/app/services/tag/tag.service.spec.ts
Normal file
12
admin/src/app/services/tag/tag.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { TagService } from './tag.service';
|
||||||
|
|
||||||
|
describe('TagService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: TagService = TestBed.get(TagService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
43
admin/src/app/services/tag/tag.service.ts
Normal file
43
admin/src/app/services/tag/tag.service.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {Tag} from '../../classes/tag';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
import {exist} from '../../utils/dataUtil';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class TagService {
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
tagPages: Page<Tag>[] = [];
|
||||||
|
currentTagPage: Page<Tag>;
|
||||||
|
|
||||||
|
getTags(pageNum: number, pageSize: number) {
|
||||||
|
const exist1 = exist<Tag>(pageNum, pageSize, this.tagPages);
|
||||||
|
if (exist1) {
|
||||||
|
exist1.subscribe(data => {
|
||||||
|
this.currentTagPage = data;
|
||||||
|
});
|
||||||
|
return exist1;
|
||||||
|
}
|
||||||
|
const observable = this.http.get(`/tags?count=${pageSize}&page=${pageNum}`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.currentTagPage = data.result;
|
||||||
|
this.tagPages.unshift(data.result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: number, name: string) {
|
||||||
|
return this.http.put(`/admin/tag/update?id=${id}&name=${name}`, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number) {
|
||||||
|
return this.http.delete(`/admin/tag/del?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
admin/src/app/services/update/web-update.service.spec.ts
Normal file
12
admin/src/app/services/update/web-update.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { WebUpdateService } from './web-update.service';
|
||||||
|
|
||||||
|
describe('WebUpdateService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: WebUpdateService = TestBed.get(WebUpdateService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
48
admin/src/app/services/update/web-update.service.ts
Normal file
48
admin/src/app/services/update/web-update.service.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {UpdateInfo} from '../../classes/updateInfo';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class WebUpdateService {
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public updateInfoList: Page<UpdateInfo>;
|
||||||
|
|
||||||
|
public lastestUpdateTime: string;
|
||||||
|
|
||||||
|
getUpdateInfo(pageNum: number, pageSize: number) {
|
||||||
|
const observable = this.http.get(`/webUpdate/pages?page=${pageNum}&count=${pageSize}`);
|
||||||
|
observable.subscribe((data: any) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.updateInfoList = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLastestUpdateTime() {
|
||||||
|
this.http.get('/lastestUpdateTime').subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.lastestUpdateTime = data.result;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
update(submitBody: { id: number, info: string }) {
|
||||||
|
return this.http.put('/admin/webUpdate/update', submitBody, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(infoStr: string) {
|
||||||
|
return this.http.post('/admin/webUpdate/create', {info: infoStr}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number) {
|
||||||
|
return this.http.delete(`/admin/webUpdate/del/${id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
admin/src/app/services/user/user.service.spec.ts
Normal file
12
admin/src/app/services/user/user.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { UserService } from './user.service';
|
||||||
|
|
||||||
|
describe('UserService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: UserService = TestBed.get(UserService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
97
admin/src/app/services/user/user.service.ts
Normal file
97
admin/src/app/services/user/user.service.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {User} from '../../classes/user';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
import {exist} from '../../utils/dataUtil';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class UserService {
|
||||||
|
|
||||||
|
userInfo: User;
|
||||||
|
|
||||||
|
avatarHost: string = 'http://cdn.celess.cn';
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
this.getUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
userPage: Page<User>[] = [];
|
||||||
|
currentUserPage: Page<User>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户信息
|
||||||
|
*/
|
||||||
|
getUserInfo() {
|
||||||
|
const observable = this.http.get('/user/userInfo');
|
||||||
|
observable.subscribe((data: any) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.userInfo = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销登录
|
||||||
|
*/
|
||||||
|
logout() {
|
||||||
|
this.http.get('/logout').subscribe((data: any) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.userInfo = null;
|
||||||
|
this.http.removeToken();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateInfo(submitBody: { desc: string, displayName: string }) {
|
||||||
|
const observable = this.http.put('/user/userInfo/update', submitBody, false);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.userInfo.desc = submitBody.desc;
|
||||||
|
this.userInfo.displayName = submitBody.displayName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sendEmail() {
|
||||||
|
return this.http.post('/sendVerifyEmail', {email: this.userInfo.email}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分页数据
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 单页数据量
|
||||||
|
* @param refresh 是否强制刷新
|
||||||
|
*/
|
||||||
|
getPageUser(pageNum: number, pageSize: number, refresh: boolean = false) {
|
||||||
|
const existData = exist<User>(pageNum, pageSize, this.userPage);
|
||||||
|
if (existData && !refresh) {
|
||||||
|
existData.subscribe(data => {
|
||||||
|
this.currentUserPage = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.http.get(`/admin/users?page=${pageNum}&count=${pageSize}`).subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.currentUserPage = data.result;
|
||||||
|
this.userPage.unshift(data.result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number) {
|
||||||
|
return this.http.delete(`/admin/user/delete/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(user: User) {
|
||||||
|
return this.http.put('/admin/user', user, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
getExistOfEmail(email: string) {
|
||||||
|
return this.http.get(`/emailStatus/${email}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
admin/src/app/services/visitor/visitor.service.spec.ts
Normal file
12
admin/src/app/services/visitor/visitor.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { VisitorService } from './visitor.service';
|
||||||
|
|
||||||
|
describe('VisitorService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: VisitorService = TestBed.get(VisitorService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
76
admin/src/app/services/visitor/visitor.service.ts
Normal file
76
admin/src/app/services/visitor/visitor.service.ts
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpService} from '../http.service';
|
||||||
|
import {Page} from '../../classes/page';
|
||||||
|
import {Visitor} from '../../classes/visitor';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class VisitorService {
|
||||||
|
|
||||||
|
constructor(public http: HttpService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public pageList: Page<Visitor>[] = [];
|
||||||
|
public currentPage: Page<Visitor>;
|
||||||
|
|
||||||
|
public dayVisit: number;
|
||||||
|
public totalVisitCount: number;
|
||||||
|
|
||||||
|
private ipLocationList: { ip: string, location: string }[] = [];
|
||||||
|
|
||||||
|
getVisitor(pageNum: number, pageSize: number) {
|
||||||
|
const observable = this.http.get(`/admin/visitor/page?count=${pageSize}&page=${pageNum}&showLocation=false`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.pageList.unshift(data.result);
|
||||||
|
this.currentPage = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getDayVisitor() {
|
||||||
|
this.http.get('/dayVisitCount').subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.dayVisit = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getTotalVisitorCount() {
|
||||||
|
this.http.get('/visitor/count').subscribe(data => {
|
||||||
|
this.totalVisitCount = data.result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getIp(ip: string) {
|
||||||
|
const location = this.exist(ip);
|
||||||
|
if (location) {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
const observable = this.http.get(`/ip/${ip}`);
|
||||||
|
observable.subscribe(data => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.ipLocationList.unshift(data.result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalIp() {
|
||||||
|
return this.http.get('/ip');
|
||||||
|
}
|
||||||
|
|
||||||
|
private exist(ip): string {
|
||||||
|
if (this.ipLocationList.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// tslint:disable-next-line:prefer-for-of
|
||||||
|
for (let i = 0; i < this.ipLocationList.length; i++) {
|
||||||
|
if (this.ipLocationList[i].ip === ip) {
|
||||||
|
return this.ipLocationList[i].location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
admin/src/app/utils/dataUtil.ts
Normal file
42
admin/src/app/utils/dataUtil.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import {Page} from '../classes/page';
|
||||||
|
import {Observable, of} from 'rxjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 一个Page<any>[] 中是否存在一条已查询的数据
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 单页数量
|
||||||
|
* @param pageList 源数据
|
||||||
|
* @return 未查到:null 查到:该条数据
|
||||||
|
*/
|
||||||
|
export function exist<T>(pageNum: number, pageSize: number, pageList: Page<any>[]): Observable<Page<T>> {
|
||||||
|
if (pageList === undefined || pageList == null || pageList.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// tslint:disable-next-line:prefer-for-of
|
||||||
|
for (let i = 0; i < pageList.length; i++) {
|
||||||
|
// tslint:disable-next-line:triple-equals
|
||||||
|
if (pageList[i].pageNum == pageNum && pageList[i].pageSize == pageSize) {
|
||||||
|
return of<Page<T>>(pageList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将reqBody对象 转化为拼接到url上面的字符串
|
||||||
|
* @param reqBody 请求体 from {a:xx,b:xxx}
|
||||||
|
* @return 字符串 to ==> a=xx&b=xxx
|
||||||
|
*/
|
||||||
|
export function reqBody2Str(reqBody: object): string {
|
||||||
|
let submitBody = '';
|
||||||
|
for (const key in reqBody) {
|
||||||
|
// 跳过值为null的参数请求
|
||||||
|
if (reqBody[key] == null || reqBody[key] === 'null') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
submitBody = submitBody + '&' + key + '=' + reqBody[key];
|
||||||
|
}
|
||||||
|
return submitBody.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
0
admin/src/assets/.gitkeep
Normal file
0
admin/src/assets/.gitkeep
Normal file
4
admin/src/environments/environment.prod.ts
Normal file
4
admin/src/environments/environment.prod.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: true,
|
||||||
|
host: 'https://api.celess.cn'
|
||||||
|
};
|
||||||
17
admin/src/environments/environment.ts
Normal file
17
admin/src/environments/environment.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// This file can be replaced during build by using the `fileReplacements` array.
|
||||||
|
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||||
|
// The list of file replacements can be found in `angular.json`.
|
||||||
|
|
||||||
|
export const environment = {
|
||||||
|
production: false,
|
||||||
|
host: 'http://127.0.0.1:8081'
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For easier debugging in development mode, you can import the following file
|
||||||
|
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||||
|
*
|
||||||
|
* This import should be commented out in production mode because it will have a negative impact
|
||||||
|
* on performance if an error is thrown.
|
||||||
|
*/
|
||||||
|
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||||
15
admin/src/index.html
Normal file
15
admin/src/index.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>小海博客|后台管理</title>
|
||||||
|
<base href="/">
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" type="image/x-icon" href="https://56462271.oss-cn-beijing.aliyuncs.com/web/logo.png">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<app-root></app-root>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
12
admin/src/main.ts
Normal file
12
admin/src/main.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { enableProdMode } from '@angular/core';
|
||||||
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
|
import { AppModule } from './app/app.module';
|
||||||
|
import { environment } from './environments/environment';
|
||||||
|
|
||||||
|
if (environment.production) {
|
||||||
|
enableProdMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
|
.catch(err => console.error(err));
|
||||||
63
admin/src/polyfills.ts
Normal file
63
admin/src/polyfills.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* This file includes polyfills needed by Angular and is loaded before the app.
|
||||||
|
* You can add your own extra polyfills to this file.
|
||||||
|
*
|
||||||
|
* This file is divided into 2 sections:
|
||||||
|
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
||||||
|
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
||||||
|
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
||||||
|
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
||||||
|
*
|
||||||
|
* Learn more in https://angular.io/guide/browser-support
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* BROWSER POLYFILLS
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
||||||
|
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web Animations `@angular/platform-browser/animations`
|
||||||
|
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||||
|
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||||
|
*/
|
||||||
|
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||||
|
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||||
|
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||||
|
* will put import in the top of bundle, so user need to create a separate file
|
||||||
|
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||||
|
* into that file, and then add the following code before importing zone.js.
|
||||||
|
* import './zone-flags.ts';
|
||||||
|
*
|
||||||
|
* The flags allowed in zone-flags.ts are listed here.
|
||||||
|
*
|
||||||
|
* The following flags will work for all browsers.
|
||||||
|
*
|
||||||
|
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||||
|
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||||
|
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||||
|
*
|
||||||
|
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||||
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
|
*
|
||||||
|
* (window as any).__Zone_enable_cross_context_check = true;
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Zone JS is required by default for Angular itself.
|
||||||
|
*/
|
||||||
|
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* APPLICATION IMPORTS
|
||||||
|
*/
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user