浏览代码

Merge branch 'master' into leng_dev

# Conflicts:
#	src/config/env.js
冷冷 6 年之前
父节点
当前提交
6874cc3e8c
共有 6 个文件被更改,包括 168 次插入79 次删除
  1. 1 1
      src/config/env.js
  2. 72 28
      src/page/login/authredirect.vue
  3. 1 0
      src/page/login/index.vue
  4. 68 40
      src/page/login/thirdlogin.vue
  5. 4 0
      src/router/axios.js
  6. 22 10
      src/views/admin/user/info.vue

+ 1 - 1
src/config/env.js

@@ -3,7 +3,7 @@
 const env = process.env
 let baseUrl = ''
 // 图表库为avue和pig2套地址
-let iconfontVersion = ['567566_qo5lxgtishg', '667895_nwumdsqxyc']
+let iconfontVersion = ['567566_qo5lxgtishg', '667895_yslsidqtk6s']
 let iconfontUrl = `//at.alicdn.com/t/font_$key.css`
 let codeUrl = `${window.location.origin}/code`
 let actUrl = `${window.location.origin}/act/modeler.html?modelId=`

+ 72 - 28
src/page/login/authredirect.vue

@@ -3,38 +3,82 @@
 </template>
 
 <script>
-import request from '@/router/axios'
-import { mapGetters } from 'vuex'
-export default {
-  name: 'authredirect',
-  computed: {
-    ...mapGetters(['tagWel'])
-  },
-  created () {
-    const params = this.$route.query
-    const state = params.state
-    const code = params.code
-    const type = params.type
+  import request from '@/router/axios'
+  import {mapGetters} from 'vuex'
 
-    if (type === 'BIND') {
-      request({
-        url: '/admin/social/bind',
-        method: 'post',
-        params: { state, code }
-      }).then(() => {
-        this.$alert('社交账号绑定成功', '成功', {
-          confirmButtonText: '确定',
-          callback: action => {
-            window.close()
-          }
+  export default {
+    name: 'authredirect',
+    computed: {
+      ...mapGetters(['tagWel'])
+    },
+    created() {
+      const params = this.$route.query
+      let code = params.code
+      let url = window.location.href
+      // 登录请求
+      if (url.indexOf('LOGIN') > 0) {
+        //QQ 微信强大 可以解析
+        if (url.indexOf('WX') > 0 || url.indexOf('QQ') > 0) {
+          let state = params.state.split("-")[0]
+          let code = params.code
+          window.opener.location.href = `${window.location.origin}/#/login?state=${state}&code=${code}&time=` + new Date().getTime()
+        } else if (url.indexOf('OSC') > 0) {
+          let start = url.indexOf("=") + 1
+          let end = url.indexOf("&state")
+          code = url.substring(start, end)
+          window.opener.location.href = `${window.location.origin}/#/login?state=OSC&code=${code}&time=` + new Date().getTime()
+        } else if (url.indexOf('GITEE') > 0) {
+          let start = url.indexOf("=") + 1
+          let end = url.indexOf("&state")
+          code = url.substring(start, end)
+          window.opener.location.href = `${window.location.origin}/#/login?state=GITEE&code=${code}&time=` + new Date().getTime()
+        }
+        window.close()
+      } else {
+        if (url.indexOf('WX') > 0 || url.indexOf('QQ') > 0) {
+          let state = params.state.split("-")[0]
+          let code = params.code
+          request({
+            url: '/admin/social/bind',
+            method: 'post',
+            params: {state, code}
+          }).then(() => {
+            this.$alert('社交账号绑定成功', '成功', {
+              confirmButtonText: '确定',
+              callback: action => {
+                window.close()
+              }
+            })
+          })
+        } else if (url.indexOf('OSC') > 0) {
+          let state = 'OSC'
+          this.bind(state, url)
+        } else if (url.indexOf('GITEE') > 0) {
+          let state = 'GITEE'
+          this.bind(state, url)
+        }
+      }
+    },
+    methods: {
+      bind: function (state, url) {
+        let start = url.indexOf("=") + 1
+        let end = url.indexOf("#")
+        let code = url.substring(start, end)
+        request({
+          url: '/admin/social/bind',
+          method: 'post',
+          params: {state, code}
+        }).then(() => {
+          this.$alert('社交账号绑定成功', '成功', {
+            confirmButtonText: '确定',
+            callback: action => {
+              window.close()
+            }
+          })
         })
-      })
-    } else {
-      window.close()
-      window.opener.location.href = `${window.location.origin}/#/login?state=${state}&code=${code}&time=`+new Date().getTime()
+      }
     }
   }
-}
 </script>
 
 

+ 1 - 0
src/page/login/index.vue

@@ -78,6 +78,7 @@
 
           this.socialForm.state = params.state
           this.socialForm.code = params.code
+
           const loading = this.$loading({
             lock: true,
             text: `登录中,请稍后。。。`,

+ 68 - 40
src/page/login/thirdlogin.vue

@@ -18,56 +18,84 @@
       </span>
       <p class="title">QQ</p>
     </div>
+    <div class="box"
+         @click="handleClick('gitee')">
+      <span class="container"
+            :style="{backgroundColor:'#bf3030'}">
+        <i icon-class="qq"
+           class="iconfont icon-logo_gitee_icon"></i>
+      </span>
+      <p class="title">Gitee</p>
+    </div>
+    <div class="box"
+         @click="handleClick('osc')">
+      <span class="container"
+            :style="{backgroundColor:'#007B25'}">
+        <i icon-class="qq"
+           class="iconfont icon-OSChina_logo_"></i>
+      </span>
+      <p class="title">开源中国</p>
+    </div>
   </div>
 </template>
 
 <script>
-import { openWindow } from '@/util/util'
+  import {openWindow} from '@/util/util'
 
-export default {
-  name: 'social-signin',
-  methods: {
-    handleClick (thirdpart) {
-      let appid, client_id, redirect_uri, url
-      redirect_uri = encodeURIComponent(window.location.origin + '/#/authredirect')
-      if (thirdpart === 'wechat') {
-        appid = 'wxd1678d3f83b1d83a'
-        url = 'https://open.weixin.qq.com/connect/qrconnect?appid=' + appid + '&redirect_uri=' + redirect_uri + '&state=WX&response_type=code&scope=snsapi_login#wechat_redirect'
-      } else if (thirdpart === 'tencent') {
-        client_id = '101322838'
-        url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&state=QQ&client_id=' + client_id + '&redirect_uri=' + redirect_uri
+  export default {
+    name: 'social-signin',
+    methods: {
+      handleClick(thirdpart) {
+        let appid, client_id, redirect_uri, url
+        redirect_uri = encodeURIComponent(window.location.origin + '/#/authredirect')
+        if (thirdpart === 'wechat') {
+          appid = 'wxd1678d3f83b1d83a'
+          url = 'https://open.weixin.qq.com/connect/qrconnect?appid=' + appid + '&redirect_uri=' + redirect_uri + '&state=WX-LOGIN&response_type=code&scope=snsapi_login#wechat_redirect'
+        } else if (thirdpart === 'tencent') {
+          client_id = '101322838'
+          url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&state=QQ-LOGIN&client_id=' + client_id + '&redirect_uri=' + redirect_uri
+        } else if (thirdpart === 'gitee') {
+          client_id = '8fc54e0e76e7842cf767c3ae3b9fdc48c03cefed27aa565ff7b2a39d142d9892'
+          url = 'https://gitee.com/oauth/authorize?response_type=code&client_id=' + client_id + '&state=GITEE-LOGIN&redirect_uri=' + redirect_uri
+        } else if (thirdpart === 'osc') {
+          client_id = 'neIIqlwGsjsfsA6uxNqD'
+          url = 'https://www.oschina.net/action/oauth2/authorize?response_type=code&client_id=' + client_id + '&state=OSC-LOGIN&redirect_uri=' + redirect_uri
+        }
+        openWindow(url, thirdpart, 540, 540)
       }
-      openWindow(url, thirdpart, 540, 540)
     }
   }
-}
 </script>
 
 <style rel="stylesheet/scss" lang="scss" scoped>
-.social-container {
-  margin: 20px 0;
-  display: flex;
-  align-items: center;
-  justify-content: space-around;
-  .box {
-    cursor: pointer;
-  }
-  .iconfont {
-    color: #fff;
-    font-size: 30px;
-  }
-  .container {
-    $height: 50px;
-    display: inline-block;
-    width: $height;
-    height: $height;
-    line-height: $height;
-    text-align: center;
-    border-radius: 4px;
-    margin-bottom: 10px;
-  }
-  .title {
-    text-align: center;
+  .social-container {
+    margin: 20px 0;
+    display: flex;
+    align-items: center;
+    justify-content: space-around;
+
+    .box {
+      cursor: pointer;
+    }
+
+    .iconfont {
+      color: #fff;
+      font-size: 30px;
+    }
+
+    .container {
+      $height: 50px;
+      display: inline-block;
+      width: $height;
+      height: $height;
+      line-height: $height;
+      text-align: center;
+      border-radius: 4px;
+      margin-bottom: 10px;
+    }
+
+    .title {
+      text-align: center;
+    }
   }
-}
 </style>

+ 4 - 0
src/router/axios.js

@@ -47,6 +47,10 @@ axios.interceptors.response.use(res => {
   const status = Number(res.status) || 200
   const message = res.data.msg || errorCode[status] || errorCode['default']
   if (status === 401) {
+    Message({
+      message: message,
+      type: 'error'
+    })
     store.dispatch('FedLogOut').then(() => {
       router.push({ path: '/login' })
     })

+ 22 - 10
src/views/admin/user/info.vue

@@ -57,7 +57,13 @@
                             prop="social">
                 <a href="#"
                    style="color: blue"
-                   @click="handleClick('wechat')">绑定微信</a>
+                   @click="handleClick('wechat')">绑定微信</a>|
+                <a href="#"
+                   style="color: blue"
+                   @click="handleClick('gitee')">绑定码云</a> |
+                <a href="#"
+                   style="color: blue"
+                   @click="handleClick('osc')">开源中国</a>
               </el-form-item>
               <el-form-item>
                 <el-button type="primary"
@@ -213,13 +219,19 @@
       },
       handleClick(thirdpart) {
         let appid, client_id, redirect_uri, url
-        redirect_uri = encodeURIComponent(window.location.origin + '/#/authredirect?type=BIND')
+        redirect_uri = encodeURIComponent(window.location.origin + '/#/authredirect')
         if (thirdpart === 'wechat') {
           appid = 'wxd1678d3f83b1d83a'
-          url = 'https://open.weixin.qq.com/connect/qrconnect?appid=' + appid + '&redirect_uri=' + redirect_uri + '&state=' + appid + '&response_type=code&scope=snsapi_login#wechat_redirect'
+          url = 'https://open.weixin.qq.com/connect/qrconnect?appid=' + appid + '&redirect_uri=' + redirect_uri + '&state=WX-BIND&response_type=code&scope=snsapi_login#wechat_redirect'
         } else if (thirdpart === 'tencent') {
           client_id = '101322838'
-          url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&state=' + appid + '&client_id=' + client_id + '&redirect_uri=' + redirect_uri
+          url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&state=QQ-BIND&client_id=' + client_id + '&redirect_uri=' + redirect_uri
+        } else if (thirdpart === 'gitee') {
+          client_id = '8fc54e0e76e7842cf767c3ae3b9fdc48c03cefed27aa565ff7b2a39d142d9892'
+          url = 'https://gitee.com/oauth/authorize?response_type=code&state=GITEE--BIND&client_id=' + client_id + '&redirect_uri=' +redirect_uri
+        } else if (thirdpart === 'osc') {
+          client_id = 'neIIqlwGsjsfsA6uxNqD'
+          url = 'https://www.oschina.net/action/oauth2/authorize?response_type=code&client_id=' + client_id + '&state=OSC-BIND&redirect_uri=' + redirect_uri
         }
         openWindow(url, thirdpart, 540, 540)
       },
@@ -244,12 +256,12 @@
   }
 
   .avatar-uploader-icon {
-    font-size: 28px!important;
-    color: #8c939d!important;
-    width: 178px!important;
-    height: 178px!important;
-    line-height: 178px!important;
-    text-align: center!important;
+    font-size: 28px !important;
+    color: #8c939d !important;
+    width: 178px !important;
+    height: 178px !important;
+    line-height: 178px !important;
+    text-align: center !important;
   }
 
   .avatar {