From eab1e7457a6446b5d679fe13cdf2a23ead72d17c Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Mon, 1 Aug 2022 17:44:18 +0800
Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/api/index.js                    |   1 +
 src/assets/img/exts/pdf.png         | Bin 0 -> 371 bytes
 src/assets/img/exts/pic.png         | Bin 0 -> 330 bytes
 src/assets/img/exts/txt.png         | Bin 0 -> 341 bytes
 src/assets/img/exts/word.png        | Bin 0 -> 437 bytes
 src/layouts/header/index.vue        |  30 +++++++++++++++++++---------
 src/pages/account/login/index.vue   |  21 +++++++++++++------
 src/pages/match/list/index.vue      |   2 +-
 src/pages/station/preview/index.vue |  10 ++++++++--
 src/store/modules/user.js           |  13 ++++++++----
 10 files changed, 55 insertions(+), 22 deletions(-)
 create mode 100644 src/assets/img/exts/pdf.png
 create mode 100644 src/assets/img/exts/pic.png
 create mode 100644 src/assets/img/exts/txt.png
 create mode 100644 src/assets/img/exts/word.png

diff --git a/src/api/index.js b/src/api/index.js
index c09db6c..458ce35 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -12,6 +12,7 @@ export default {
     getToken: `users/users/user/getToken`,
     getOtherAccountByPhone: `users/users/user/getOtherAccountByPhone`,
     unbindAccounts: `users/users/user/unbindAccounts`,
+    getUserRolesPermissionMenu: `${host}users/users/user-role/getUserRolesPermissionMenu`,
 
     platformLogList: `nakadai/nakadai/log/platformLogList`,
     logNotification: `nakadai/nakadai/log/logNotification`,
diff --git a/src/assets/img/exts/pdf.png b/src/assets/img/exts/pdf.png
new file mode 100644
index 0000000000000000000000000000000000000000..39e05f16aea5a0173afaa277b82ab775478bf1c7
GIT binary patch
literal 371
zcmV-(0gV2MP)<h;3K|Lk000e1NJLTq000sI000sQ0{{R3VGw?000001b5ch_0Itp)
z=>Px#pHNIxMgLq}{$5`HUS9rQUjAQS{$ODKVPXDaV*X=e{$^(WYHI##YyNI-{%>#o
za&rE8dH#fi{)L79iHZJ-ivEp_{*{&fnVJ5fq5i9@{;sb6wYC1YxBk1k{=UBc#Kiu~
z%l^*J{?E_;(9r(T(f-ub{@2(3+1dWu+Wz6;{^jNV=H~wA=l<yE{_5)f@9+Nb@c#Gr
z{`vX-{QUm?{r~^}UMmFc00003bW%=JNaEtAvkII50047IL_t&-(_>&@WJUpu3=B-n
z%;;jw7yu?DrpbveB&{NVE+nBRh%O{z!iz4%Z_I~bmaYmbst}hxkGdQi2Ro9Gl#Gb1
ziJ_5}GF(X1KvhzROITi80V>3)Xd;g0dL<n-7BnFZ6>e;PL>6Mi3>?fL1OVx=2~~1<
RU#<WE002ovPDHLkV1gWZzU=@2

literal 0
HcmV?d00001

diff --git a/src/assets/img/exts/pic.png b/src/assets/img/exts/pic.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f6324466b3c6ec06710f4ac1ff68b6b159241b2
GIT binary patch
literal 330
zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+3?vf;>QaFeV{wqX6T`Z5GB1Ig(g2?jSBJyP
z?7+zW@G|EkD_oAOa6h`r>)2|)6Kg|GZU{TIG3xZDgtOZ+&hN~;u&dzGo{B36Dy|-w
zc<0Q_`xoXuxVZAk_07+3?|ymz@SDd+-#j__?%A1l&(FMn{^Z-Imp{I|{rUa#@1NiP
z{Qmv#@1K8v|NaAk|NsBb`ekDUbO2LHkYBLJBL?&CM38elT^vIsF6UnG6l!u1VYzsJ
zsf9lWQ{Muod;dH16s%?)i`f_II@7YZNUZyb&t#uVJ9nxInoe*ldAheVW8Sw(>uq^u
z_qjS4dv>eOU%ULtzDZmQzLYGyw37MOU5Ddho1_|6Eq}@#zkRxo7H3tDTT5{Aui|rG
a4#_t!<Mv)uDOn420E4HipUXO@geCy?2c{wb

literal 0
HcmV?d00001

diff --git a/src/assets/img/exts/txt.png b/src/assets/img/exts/txt.png
new file mode 100644
index 0000000000000000000000000000000000000000..bb1276a7fa916d9eed511b4f7394ffbb012d61b5
GIT binary patch
literal 341
zcmV-b0jmCqP)<h;3K|Lk000e1NJLTq000;O000;W1^@s6;CDUv00001b5ch_0Itp)
z=>Px$4@pEpR7gwRm9c69K@f(&QAr!ifay}Eu?*xfQiN23q)HR}1Q8Ex@&ai@(g-&C
z0wIlEKvJYgN&_kE(^%ce$rVa&?{-~I<hGre|6~50*%fj=lCwTV1hn-ExOTEmc_WbL
zq?-R0b@Y*tzzG0-x^jDvfCaELbW;IN<Jd2-K$#FoZ!<sLq7n_@JrNL61771;A7PAg
zPFJ4n0rnTMGvEc78#q<q-me2?i13pL5ROsq`~Z8fs6~kn1LuU0k#7fIz@Gtd1k`;2
zwkGX7ML7T-^nx;%v2qh-fS{=);S;FXE!w71Tc^M@6A;xXXTU6bleYmkwjQnXqKWIs
ncluM|q?nyt#4j_uYp0AA-S2rBDf$cj00000NkvXXu0mjfw^WP}

literal 0
HcmV?d00001

diff --git a/src/assets/img/exts/word.png b/src/assets/img/exts/word.png
new file mode 100644
index 0000000000000000000000000000000000000000..aeb4ddc232bd565b68d72c22c3d2768f934bd930
GIT binary patch
literal 437
zcmV;m0ZRUfP)<h;3K|Lk000e1NJLTq000sI000sQ0{{R3VGw?000001b5ch_0Itp)
z=>Px#z)(z7MQW=5YN-5bsQqfF{A;NEY^nThs{C=R{Bo@Pbguk$uKakg{Cl$ef3*C8
zwfu&-{D`^yiMsrYyZn#6{FuZ1nZx{=#QdDa{GP`ApvU~8$^5Cz{i)6UtIhqZ&i$;;
z{jSjcveNyt(*3v9{kYcszuEo5+x^4b{lwh;$KL(O-~Gzp{mbC})#m-z=l$2`{@CdL
z+v@(^>;B;F{^Rcc=kfmR^ZxAg{_ytx^7sDp`2O|z{`dO+`uzU<{r>&_{<zHs8UO$Q
z19VbOQ%K_Crn3s10001#Nkl<Z7#Rh@i6R1F00zKs|5=K#DU@4>93i)IzW-a9Nh$!K
zN(ul#2><{A03fta)-i0*>><>vKCRz5?j{IsChRYkHLD(igBNB;&t1)DjiB|j;k`2+
zxwwVE!(ivt?vup;0;kt!Q}wd*-G;#S$9<pq)guUa`&#4h?;HdSkFj~V1p)v-002k<
f0H~4z0F?X#CV&he4(g=n00000NkvXXu0mjf*P8h%

literal 0
HcmV?d00001

diff --git a/src/layouts/header/index.vue b/src/layouts/header/index.vue
index 0731ba2..0d3a74b 100644
--- a/src/layouts/header/index.vue
+++ b/src/layouts/header/index.vue
@@ -10,16 +10,16 @@
         <div class="inner">
             <navbar class="nav-wrap" ref="nav"></navbar>
             
-            <template v-if="token">
+            <template v-if="token || serverToken">
               <div class="user-wrap">
                 <el-dropdown size="medium" @command="menuChange">
                   <div class="user">
                     <el-avatar :size="35" :src="avatar"></el-avatar>
-                    <span class="username">{{ customerName || userName }}</span>
+                    <span class="username">{{ customerName || cName || userName }}</span>
                   </div>
                   <el-dropdown-menu slot="dropdown">
-                    <el-dropdown-item v-if="isIndex" command="index">前往学习</el-dropdown-item>
-                    <el-dropdown-item v-if="!customerName" command="info">个人中心</el-dropdown-item>
+                    <el-dropdown-item v-if="isIndex" command="index">前往{{ serverToken ? '教学' : '学习' }}</el-dropdown-item>
+                    <el-dropdown-item v-if="!customerName && !serverToken" command="info">个人中心</el-dropdown-item>
                     <el-dropdown-item command="logout">退出登录</el-dropdown-item>
                   </el-dropdown-menu>
                 </el-dropdown>
@@ -29,7 +29,6 @@
                 <img src="@/assets/img/user.png" alt="">
                 <span>登录</span>
             </div>
-            
         </div>
     </div>
 </template>
@@ -38,10 +37,13 @@ import { mapState, mapMutations, mapActions } from "vuex";
 import Setting from "@/setting";
 import util from "@/libs/util";
 import navbar from "../navbar";
+import axios from 'axios'
 export default {
     data() {
         return {
-            token: util.local.get(Setting.tokenKey),
+            token: util.local.get(Setting.tokenKey), // 学生端token
+            serverToken: util.local.get('oc_server_token'), // 教师端token
+            cName: util.cookies.get('customerName'),
             isIndex: Setting.whiteList.find(e => e === this.$route.path), // 是否是在白名单页面
         };
     },
@@ -108,9 +110,19 @@ export default {
         toNew(path) {
           // 如果缓存里有教师端的标识,则前往教师端,否则,打开学生端
           if (util.cookies.get('serverLogin') === 'true' && util.local.get('oc_server_token')) {
-            window.open(process.env.NODE_ENV === 'development' ?
-              'http://192.168.31.125:8081/#/index' :
-              `${location.origin}/admin/#/index`)
+            const defaultPath = '/station/list' // 默认路径
+            // 查询教师端的权限
+            axios.get(`${this.api.getUserRolesPermissionMenu}?platformId=1`, {
+              headers: {
+                token: this.serverToken
+              }
+            }).then(({ data }) => {
+              const list = data.permissionMenu[0].children
+              const route = list.find(e => e.path === defaultPath) ? defaultPath : list[0].path // 如果有默认路由的权限,则跳转到默认路由,否则跳转到第一个
+              window.open(process.env.NODE_ENV === 'development' ?
+                `http://192.168.31.125:8081/#${route}` :
+                `${location.origin}/admin/#${route}`)
+            }).catch(err => {})
           } else {
             window.open(this.$router.resolve(path).href)
           }
diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue
index e4ada4e..706df76 100644
--- a/src/pages/account/login/index.vue
+++ b/src/pages/account/login/index.vue
@@ -368,16 +368,25 @@ export default {
         },
         // 跳转到教师端
         toMang() {
-          util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires)
+          const { token } = this
+          util.local.set('oc_server_token', token, Setting.tokenExpires)
           // 从学生端登录到教师端的标识,教师端需要使用
           util.cookies.set('serverLogin', true, {
             expires: new Date(Date.now() + 15 * 60 * 1000) // 15分钟后过期
           })
-          this.reloadIndex()
-          // 跳转到教师端的重定向页面
-          location.href = Setting.isDev ?
-            `http://${location.hostname}:8081/#/redirect?auth=${btoa(this.token)}` :
-            `${location.origin}/admin/#/redirect?auth=${window.btoa(this.token)}`
+          axios.get(this.api.isClient, {
+            headers: {
+              token
+            }
+          }).then(({ data }) => {
+            // 如果是客户
+            data.customerName && util.cookies.set('customerName', data.customerName)
+            this.reloadIndex()
+            // 跳转到教师端的重定向页面
+            location.href = Setting.isDev ?
+              `http://${location.hostname}:8081/#/redirect?auth=${btoa(this.token)}` :
+              `${location.origin}/admin/#/redirect?auth=${window.btoa(this.token)}`
+          }).catch(res => {})
         },
         // 选择端
         selectRole(val) {
diff --git a/src/pages/match/list/index.vue b/src/pages/match/list/index.vue
index 6d6cfb2..c86915c 100644
--- a/src/pages/match/list/index.vue
+++ b/src/pages/match/list/index.vue
@@ -461,7 +461,7 @@ export default {
             }
             dd {
                 padding: 5px 15px;
-                color: #4c4c4c;
+                color: #6a6a6a;
                 font-size: 16px;
                 white-space: nowrap;
                 cursor: pointer;
diff --git a/src/pages/station/preview/index.vue b/src/pages/station/preview/index.vue
index 268eceb..f737ac2 100644
--- a/src/pages/station/preview/index.vue
+++ b/src/pages/station/preview/index.vue
@@ -20,7 +20,7 @@
                         <div class="excel-mask1" style="height: 48px;"></div>
                     </template>
                 </template>
-                <div class="pdf inner" v-else-if="pdfSrc">
+                <div class="pdf" v-else-if="pdfSrc">
                     <p class="arrow">
                         <span @click="changePdfPage(0)" class="turn el-icon-arrow-left"
                                 :class="{grey: currentPage==1}"></span>
@@ -53,7 +53,12 @@
                                 <div class="section" v-if="item.subsectionList.length">
                                     <p class="sectionName" :class="{active: curLink === `${item.name}${section.name}`}" v-for="(section,i) in item.subsectionList" :key="i" @click="preview(section, item.name)">
                                         <img v-if="section.fileType === 'pptx'" src="@/assets/img/exts/ppt.png" alt="">
-                                        <img v-else src="@/assets/img/exts/video.png" alt="">
+                                        <img v-else-if="section.fileType === 'mp4'" src="@/assets/img/exts/video.png" alt="">
+                                        <img v-else-if="section.fileType === 'doc' || section.fileType === 'docx'" src="@/assets/img/exts/word.png" alt="">
+                                        <img v-else-if="section.fileType === 'pptx'" src="@/assets/img/exts/ppt.png" alt="">
+                                        <img v-else-if="section.fileType === 'txt'" src="@/assets/img/exts/txt.png" alt="">
+                                        <img v-else-if="section.fileType === 'pdf'" src="@/assets/img/exts/pdf.png" alt="">
+                                        <img v-else src="@/assets/img/exts/pic.png" alt="">
                                         {{ section.name }}
                                     </p>
                                 </div>
@@ -238,6 +243,7 @@ export default {
                 this.coverUrl = row.fileUrl;
             } else if (row.fileType == "pdf") {
                 this.pdfSrc = row.fileUrl;
+                console.log("🚀 ~ file: index.vue ~ line 246 ~ preview ~ this.pdfSrc", this.pdfSrc)
                 this.pdfVisible = true;
             } else {
                 this.$get(`${this.api.curriculumGetSubsection}/${row.id}`).then(res => {
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 5549770..7fccdb9 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -79,10 +79,15 @@ export default {
         },
         logout({ commit, state, dispatch }) {
             return new Promise((resolve, reject) => {
-                util.local.remove(Setting.storeKey);
-                util.local.remove(Setting.tokenKey);
-                location.reload();
-                resolve();
+              if (util.local.get(Setting.storeKey)) {
+                util.local.remove(Setting.storeKey)
+                util.local.remove(Setting.tokenKey)
+              } else {
+                util.local.remove('oc_server_token')
+                util.local.remove('oc_server_store')
+              }
+              location.reload()
+              resolve()
             });
         },
         setInfo({ state, commit }, info) {