Commit 0e87ade2 authored by i317280's avatar i317280

update

parent 8886309e
...@@ -23,8 +23,6 @@ export let TermStore: { ...@@ -23,8 +23,6 @@ export let TermStore: {
term: Array<Term>; term: Array<Term>;
termlist: Array<string>; termlist: Array<string>;
termActive: number; termActive: number;
} = { } = {
term: [new Term()], term: [new Term()],
termlist: [], termlist: [],
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* Created by liuzheng on 2017/8/31. * Created by liuzheng on 2017/8/31.
*/ */
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {AppService} from './app.service'; import {AppService,HttpService} from './app.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
providers: [AppService], providers: [AppService, HttpService],
// directives: [LeftbarComponent, TermComponent] // directives: [LeftbarComponent, TermComponent]
}) })
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by liuzheng on 2017/8/30. * Created by liuzheng on 2017/8/30.
*/ */
import {Injectable, NgModule} from '@angular/core'; import {Injectable, NgModule} from '@angular/core';
import {Http, Request, RequestOptionsArgs, Headers} from '@angular/http'; import {Http, RequestOptionsArgs, Headers} from '@angular/http';
import {Cookie} from 'ng2-cookies/ng2-cookies'; import {Cookie} from 'ng2-cookies/ng2-cookies';
import {Logger} from 'angular2-logger/core'; import {Logger} from 'angular2-logger/core';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
...@@ -93,48 +93,73 @@ export let Browser: { ...@@ -93,48 +93,73 @@ export let Browser: {
vendor: navigator.vendor, vendor: navigator.vendor,
}; };
@Injectable()
export class HttpService { export class HttpService {
headers = new Headers(); headers = new Headers();
constructor(private _http: Http) { constructor(private _http: Http) {
} }
request(url: string | Request, options?: RequestOptionsArgs) { // request(url: string | Request, options?: RequestOptionsArgs) {
options.headers = this.headers; // if (options == null) {
return this._http.request(url, options) // options = {};
} // }
// options.headers = this.headers;
// return this._http.request(url, options)
// }
get(url: string, options?: RequestOptionsArgs) { get(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.get(url, options) return this._http.get(url, options)
} }
post(url: string, body: any, options?: RequestOptionsArgs) { post(url: string, body: any, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.post(url, body, options) return this._http.post(url, body, options)
} }
put(url: string, body: any, options?: RequestOptionsArgs) { put(url: string, body: any, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.put(url, body, options) return this._http.put(url, body, options)
} }
delete(url: string, options?: RequestOptionsArgs) { delete(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.delete(url, options) return this._http.delete(url, options)
} }
patch(url: string, body: any, options?: RequestOptionsArgs) { patch(url: string, body: any, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.patch(url, body, options) return this._http.patch(url, body, options)
} }
head(url: string, options?: RequestOptionsArgs) { head(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.head(url, options) return this._http.head(url, options)
} }
options(url: string, options?: RequestOptionsArgs) { options(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers; options.headers = this.headers;
return this._http.options(url, options) return this._http.options(url, options)
} }
...@@ -275,6 +300,7 @@ export class AppService { ...@@ -275,6 +300,7 @@ export class AppService {
} }
browser() { browser() {
this._http.headers.append("aa", "vvv");
this._http.post('/api/browser', JSON.stringify(Browser)).map(res => res.json()) this._http.post('/api/browser', JSON.stringify(Browser)).map(res => res.json())
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment