feat: add cookie support for aixos; 🌟

新增:aixos 请求增加 cookie;
master
iczer 4 years ago
parent 8688661c8c
commit b2e0accd97
  1. 1
      package.json
  2. 1
      src/mock/user/login.js
  3. 2
      src/pages/login/Login.vue
  4. 8
      src/utils/request.js
  5. 5
      yarn.lock

@ -22,6 +22,7 @@
"core-js": "^3.6.5",
"date-fns": "^2.14.0",
"enquire.js": "^2.1.6",
"js-cookie": "^2.2.1",
"mockjs": "^1.1.0",
"pouchdb": "^7.2.1",
"viser-vue": "^2.4.8",

@ -22,6 +22,7 @@ Mock.mock('/login', 'post', ({body}) => {
result.message = Mock.mock('@TIMEFIX').CN + ',欢迎回来'
result.data = {}
result.data.user = user
result.data.token = 'Authorization'
}
return result
})

@ -76,6 +76,7 @@
<script>
import CommonLayout from '@/layouts/CommonLayout'
import {login} from '@/services'
import Cookie from 'js-cookie'
export default {
name: 'Login',
@ -111,6 +112,7 @@ export default {
const user = result.data.user
this.$router.push('/dashboard/workplace')
this.$store.commit('account/setUser', user)
Cookie.set('token', result.data.token)
this.$message.success(result.message, 3)
} else {
this.error = result.message

@ -1,4 +1,12 @@
import axios from 'axios'
import Cookie from 'js-cookie'
axios.defaults.timeout = 5000
axios.defaults.withCredentials= true
const cookies = Cookie.get()
Object.keys(cookies).forEach(key => {
axios.defaults.headers.common[key] = cookies[key]
})
const METHOD = {
GET: 'get',

@ -6166,6 +6166,11 @@ jest-worker@^25.4.0:
merge-stream "^2.0.0"
supports-color "^7.0.0"
js-cookie@^2.2.1:
version "2.2.1"
resolved "https://registry.npm.taobao.org/js-cookie/download/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha1-aeEG3F1YBolFYpAqpbrsN0Tpsrg=
js-message@1.0.5:
version "1.0.5"
resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.5.tgz#2300d24b1af08e89dd095bc1a4c9c9cfcb892d15"

Loading…
Cancel
Save