Browse Source

fix:the bug when the course details page is switched between tabs

子悦 王 4 years ago
parent
commit
ceb77d4503
4 changed files with 43 additions and 55 deletions
  1. 0 12
      src/App.vue
  2. 2 3
      src/main.js
  3. 40 39
      src/views/CoursePage/CourseDetail.vue
  4. 1 1
      src/views/ManagePage/managePage.css

+ 0 - 12
src/App.vue

@@ -3,20 +3,8 @@
 </template>
 
 <script>
-// import store from "@/store";
 
 export default {
-  // created() {
-  //   //Vuex相关
-  //   // 在页面加载时读取sessionStorage里的状态信息
-  //   if (sessionStorage.getItem("store")) {
-  //     store.replaceState(Object.assign({}, store.state, JSON.parse(sessionStorage.getItem("store"))));
-  //   }
-  //   // 在页面刷新时将vuex里的信息保存到sessionStorage里
-  //   window.addEventListener("beforeunload", () => {
-  //     sessionStorage.setItem("store", JSON.stringify(store.state));
-  //   });
-  // },
   mounted() {
     const that = this;
     if (sessionStorage.token) {

+ 2 - 3
src/main.js

@@ -16,15 +16,14 @@ app.directive("title", {
 
 app.directive("teacher-permission", {
   mounted(el, binding) {
-    if (binding.value.role.toUpperCase() !== "TEACHER") {
+    if (binding.value.role !== "TEACHER") {
       el.parentNode.removeChild(el);
     }
   },
 });
-
 app.directive("student-permission", {
   mounted(el, binding) {
-    if (binding.value.role.toUpperCase() !== "STUDENT") {
+    if (binding.value.role !== "STUDENT") {
       el.parentNode.removeChild(el);
     }
   },

+ 40 - 39
src/views/CoursePage/CourseDetail.vue

@@ -31,48 +31,49 @@
           <el-radio-button label="notice">通知栏</el-radio-button>
           <el-radio-button label="courseware">课件列表</el-radio-button>
         </el-radio-group>
-        <el-popover v-if="tabName==='notice'" v-model:visible="showPopover" :width="160" placement="bottom">
-          <div class="sel-notice-type">
-            <div :style="{color:themeColor.orange}" class="notice-type-icon">
-              公告
+        <div v-teacher-permission="{role:role}">
+          <el-popover v-if="tabName==='notice'" v-model:visible="showPopover" :width="160" placement="bottom">
+            <div class="sel-notice-type">
+              <div :style="{color:themeColor.orange}" class="notice-type-icon">
+                公告
+              </div>
+              <div class="notice-type-txt" @click="selAndInitNotice('announce')">
+                发布公告
+              </div>
             </div>
-            <div class="notice-type-txt" @click="selAndInitNotice('announce')">
-              发布公告
+            <div class="sel-notice-type">
+              <div :style="{color:themeColor.blue}" class="notice-type-icon">
+                作业
+              </div>
+              <div class="notice-type-txt" @click="selAndInitNotice('homework')">
+                发布作业
+              </div>
             </div>
-          </div>
-          <div class="sel-notice-type">
-            <div :style="{color:themeColor.blue}" class="notice-type-icon">
-              作业
-            </div>
-            <div class="notice-type-txt" @click="selAndInitNotice('homework')">
-              发布作业
-            </div>
-          </div>
-          <div class="sel-notice-type">
-            <div :style="{color:themeColor.red}" class="notice-type-icon">
-              考试
+            <div class="sel-notice-type">
+              <div :style="{color:themeColor.red}" class="notice-type-icon">
+                考试
+              </div>
+              <div class="notice-type-txt" @click="selAndInitNotice('test')">
+                发布考试
+              </div>
             </div>
-            <div class="notice-type-txt" @click="selAndInitNotice('test')">
-              发布考试
-            </div>
-          </div>
-          <template #reference>
-            <el-button v-teacher-permission="{role:role}" plain type="warning" @click="showPopover = true">添加发布
-            </el-button>
-          </template>
-        </el-popover>
-        <el-upload
-            v-if="tabName==='courseware'"
-            v-teacher-permission="{role:role}"
-            :action="actionUrl"
-            :http-request="handleFileUploading"
-            :on-success="handFileUploadSuccess"
-            :show-file-list="false"
-            class="upload-demo width-100"
-            method="put"
-        >
-          <el-button plain type="primary">上传课件</el-button>
-        </el-upload>
+            <template #reference>
+              <el-button plain type="warning" @click="showPopover = true">添加发布
+              </el-button>
+            </template>
+          </el-popover>
+          <el-upload
+              v-if="tabName==='courseware'"
+              :action="actionUrl"
+              :http-request="handleFileUploading"
+              :on-success="handFileUploadSuccess"
+              :show-file-list="false"
+              class="upload-demo width-100"
+              method="put"
+          >
+            <el-button plain type="primary">上传课件</el-button>
+          </el-upload>
+        </div>
       </div>
       <div class="course-tab-content">
         <div v-if="tabName==='tasks'" class="tab-tasks">

+ 1 - 1
src/views/ManagePage/managePage.css

@@ -72,7 +72,7 @@
     }
 }
 
-@media screen and (max-width: 1350px) and (min-width: 1100px) {
+@media screen and (max-width: 1350px) {
     .cItem {
         display: inline-block;
         width: 30%;