From 265ee27863f3e553a4de2d057de2c3a637ae53d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=9B=E5=B0=91=E7=88=B7?= Date: Thu, 24 Oct 2019 19:23:06 +0800 Subject: [PATCH 1/2] Update gitment.js --- src/gitment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gitment.js b/src/gitment.js index 06fe17a..cbdb53b 100644 --- a/src/gitment.js +++ b/src/gitment.js @@ -99,7 +99,7 @@ class Gitment { }, options) this.state.user.isLoggingIn = true - http.post('https://gh-oauth.imsun.net', { + http.post('https://github.com/login/oauth/access_token', { code, client_id, client_secret, From 5e1d11e2f009a52fcf04e5007732c7497ab59536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=9B=9B?= Date: Fri, 25 Oct 2019 11:32:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8E=9F=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E6=8F=90=E4=BE=9B=E6=9C=8D=E5=8A=A1=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E8=B7=A8=E5=9F=9F=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- package.json | 3 ++- src/gitment.js | 2 +- src/utils.js | 8 +++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5897cd8..e23b9c1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ node_modules dist test/config.js -index.html \ No newline at end of file +index.html +/nbproject/private/ \ No newline at end of file diff --git a/package.json b/package.json index d7a066a..2444f34 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "homepage": "https://github.com/imsun/gitment", "scripts": { - "build": "babel src --out-dir dist --ignore test.js --source-maps & NODE_ENV=production webpack --config webpack.config.js --progress --profile --colors", + "build": "babel src --out-dir dist --ignore test.js --source-maps & cross-env NODE_ENV=production webpack --config webpack.config.js --progress --profile --colors", "dev": "webpack-dev-server --config webpack.dev.config.js --host 0.0.0.0 --progress --profile --colors" }, "devDependencies": { @@ -32,6 +32,7 @@ "webpack-dev-server": "^2.4.2" }, "dependencies": { + "cross-env": "^6.0.3", "mobx": "^3.1.7" }, "license": "MIT" diff --git a/src/gitment.js b/src/gitment.js index cbdb53b..62fc82d 100644 --- a/src/gitment.js +++ b/src/gitment.js @@ -99,7 +99,7 @@ class Gitment { }, options) this.state.user.isLoggingIn = true - http.post('https://github.com/login/oauth/access_token', { + http.post('https://gitment.jermey.cn/login/oauth/access_token', { code, client_id, client_secret, diff --git a/src/utils.js b/src/utils.js index 69de733..b2488f0 100644 --- a/src/utils.js +++ b/src/utils.js @@ -66,7 +66,7 @@ function ajaxFactory(method) { }) req.open(method, url, true) - req.setRequestHeader('Accept', 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json') + if (token) { req.setRequestHeader('Authorization', `token ${token}`) } @@ -74,6 +74,12 @@ function ajaxFactory(method) { body = JSON.stringify(data) req.setRequestHeader('Content-Type', 'application/json') } + if(apiPath=='https://gitment.jermey.cn/login/oauth/access_token'){ + req.setRequestHeader('Accept','application/json') + } + else{ + req.setRequestHeader('Accept', 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json') + } req.send(body) return p