Skip to content

Commit

Permalink
登陆与后台联调,从网关授权登陆
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoutaoo committed Aug 25, 2018
1 parent 0710578 commit 0c6063b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/dev.env.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
NODE_ENV: '"development"',
ENV_CONFIG: '"dev"',
BASE_API: '"https://api-dev"'
BASE_API: '"http://localhost:9527"'
}
8 changes: 8 additions & 0 deletions config/dev.proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const TARGET_URL = 'http://localhost:8443';

module.exports = {
'/authorization-server': {
target: TARGET_URL, // 接口的域名
changeOrigin: true // 如果接口跨域,需要进行这个参数配置
}
}
3 changes: 2 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')
const proxyTable = require('./dev.proxy')

module.exports = {
dev: {

// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
proxyTable: proxyTable,

// Various Dev Server settings

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>vue-element-admin</title>
<title>SpringCloud微服务治理平台</title>
</head>
<body>
<script src=<%= htmlWebpackPlugin.options.path %>/tinymce4.7.5/tinymce.min.js></script>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "vue-element-admin",
"name": "sc-admin",
"version": "3.7.2",
"description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features",
"author": "Pan <panfree23@gmail.com>",
"author": "zhoutaoo@foxmail.com",
"license": "MIT",
"scripts": {
"dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
Expand Down
14 changes: 10 additions & 4 deletions src/api/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import request from '@/utils/request'

export function loginByUsername(username, password) {
const data = {
username,
password
username: username,
password: password,
grant_type: 'password',
scope: 'read'
}
return request({
url: '/oauth/token',
url: '/authorization-server/oauth/token',
headers: {
'Authorization': 'Basic dGVzdF9jbGllbnQ6dGVzdF9zZWNyZXQ=',
'Content-Type': 'application/x-www-form-urlencoded'
},
method: 'post',
data
params: data
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import roleAPI from './organiztion/role'
// })

// 登录相关
Mock.mock(/\/oauth\/token/, 'post', loginAPI.loginByUsername)
// Mock.mock(/\/authorization-server\/oauth\/token/, 'post', loginAPI.loginByUsername)
Mock.mock(/\/login\/logout/, 'post', loginAPI.logout)
Mock.mock(/\/user\/current/, 'get', loginAPI.getUserInfo)

Expand Down
5 changes: 2 additions & 3 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" :placeholder="$t('login.username')"
/>
<el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" :placeholder="$t('login.username')"/>
</el-form-item>

<el-form-item prop="password">
Expand Down Expand Up @@ -78,7 +77,7 @@ export default {
return {
loginForm: {
username: 'admin',
password: '1111111'
password: 'password'
},
loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
Expand Down

0 comments on commit 0c6063b

Please sign in to comment.