8000 move configuration · pycoder404/blog-vue@9faeae6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9faeae6

Browse files
committed
move configuration
1 parent 992f3ea commit 9faeae6

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ NODE_ENV = 'development'
33

44
# base api
55
VUE_APP_BASE_API = 'http://10.89.228.206:28088'
6+
7+
# github login client id
8+
VUE_APP_GITHUB_CLIENTID='aa6d9aa35a3d63374015'

.env.production

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# just a flag
2+
NODE_ENV = 'production'
3+
4+
# base api
5+
VUE_APP_BASE_API = 'http://123.57.53.141:8080'
6+
7+
VUE_APP_GITHUB_CLIENTID='ed02b9b9c2673b64d007'

src/api/user.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function login(data) {
88
})
99
}
1010

11-
export function socialLogin(thirdPart,data) {
11+
export function socialLogin(thirdPart, data) {
1212
return request({
1313
url: '/api/user/login/' + thirdPart + '/',
1414
method: 'post',
@@ -30,3 +30,4 @@ export function logout() {
3030
method: 'post'
3131
})
3232
}
33+

src/permission.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ router.beforeEach(async (to, from, next) => {
6969
// get user info
7070
// question: roles must be a object array! such as: ['admin'] or ,['developer','editor']
7171
// question 这里的roles是user/GetInfo如何反馈的,如何只反馈roles的
72+
// note: await 's result and 对象解构赋值
7273
const { roles } = await store.dispatch('user/getInfo')
7374
console.log(roles)
7475
// // generate accessible routes map based on roles

src/store/modules/user.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ const mutations = {
4848
}
4949
}
5050

51+
52+
5153
const actions = {
5254
// user login
5355
login({commit}, userInfo) {
5456
// console.info("login in store")
5557
const {username, password} = userInfo
5658
return new Promise((resolve, reject) => {
57-
login({ username: username.trim(), password: password }).then(response => {
59+
login({username: username.trim(), password: password}).then(response => {
5860
const data = response
5961
// console.log("login done")
6062
commit('SET_ACCESS_TOKEN', data.access)
@@ -71,14 +73,7 @@ const actions = {
7173
},
7274

7375
socialLogin({commit}, oauthInfo) {
74-
// console.info("login in store")
75-
// console.info(thirdPart)
76-
// console.info("xx")
77-
// console.info(oauthCode)
78-
// fixme 这里后续应该直接获取到github的access token发送到后端去
79-
// fixme 这样后端就不用写callback url即可
8076
const {thirdPart, oauthCode} = oauthInfo
81-
8277
const data = {code: oauthCode}
8378
return new Promise((resolve, reject) => {
8479
socialLogin(thirdPart, data).then(response => {
@@ -104,11 +99,7 @@ const actions = {
10499
getInfo({commit, state}) {
105100
return new Promise((resolve, reject) => {
106101
getInfo(state.accessToken).then(response => {
107-
// console.log('response is:',response)
108-
// const { data } = response
109102
const data = response
110-
// console.log('data is:',data)
111-
112103
if (!data) {
113104
reject('Verification failed, please Login again.')
114105
}

src/views/article/components/ArticleComment.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
:key="comment.id"
99
>
1010
<template #header>
11-
<div class="card-header" id="comment.comment_order">
11+
<div class="card-header">
1212
<!-- todo add isAuthor label -->
13-
<span>
13+
<span>
1414
{{ comment.comment_order}}楼 <b>{{comment.author}}</b> @<span>{{comment.created_time}} </span>
1515
</span>
1616

src/views/login/components/SocialSignin.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import IconGithub from "@/components/SvgIcon/components/IconGithub";
1818
import IconWechat from "@/components/SvgIcon/components/IconWechat";
1919
20-
20+
const GITHUBCLIENTID = process.env.VUE_APP_GITHUB_CLIENTID
2121
export default {
2222
name: 'SocialSignin',
2323
components: {
@@ -26,7 +26,7 @@
2626
},
2727
data() {
2828
return {
29-
githubAuthBaseUri: "https://github.com/login/oauth/authorize?client_id=aa6d9aa35a3d63374015"
29+
githubAuthBaseUri: "https://github.com/login/oauth/authorize?client_id="
3030
}
3131
3232
},
@@ -37,7 +37,7 @@
3737
const thirdPart = window.location.search === '' ? "?thirdPart=github" : "&thirdPart=github"
3838
const redirect_uri = window.location.href + thirdPart
3939
console.info(redirect_uri)
40-
return this.githubAuthBaseUri + "&redirect_uri=" + encodeURIComponent(redirect_uri)
40+
return this.githubAuthBaseUri + GITHUBCLIENTID + "&redirect_uri=" + encodeURIComponent(redirect_uri)
4141
}
4242
}
4343
,

0 commit comments

Comments
 (0)
0