lex-xin 6 kuukautta sitten
vanhempi
commit
5d85aabc5e

+ 8 - 4
src/components/layout/guide-section/guide-drag.ts

@@ -178,9 +178,8 @@ export default function useDrag(
   watch(dragShow, () => {
     if (dragShow.value) {
       // 初始化pos值
-      // initPos();
       window.addEventListener('resize', refreshPos);
-
+      console.log('first - show', boxClass);
       nextTick(() => {
         const layoutTopHeight =
           document.querySelector('.layoutTop')?.clientHeight || 0;
@@ -206,7 +205,6 @@ export default function useDrag(
 
         // 初始化定位
         if (initSize?.defaultPosition === 'center') {
-          // alert(initSize.width)
           const transformX = (window.innerWidth - baseSize.defaultWidth) / 2;
           const transformY =
             (baseSize.windowHeight - baseSize.defaultHeight) / 2;
@@ -365,7 +363,13 @@ export default function useDrag(
   }
 
   function refreshPos() {
-    onReset();
+    baseSize.winMinWidth = initSize?.minWidth || 800;
+    baseSize.minWidth = initSize?.minWidth || 400;
+    baseSize.minHeight = initSize?.minHeight || 340;
+    baseSize.defaultWidth = initSize?.width || 400;
+    baseSize.defaultHeight = initSize?.height || 640;
+
+    dragShow.value = false;
   }
 
   /** 切换窗口 */

+ 6 - 3
src/components/layout/guide-section/index.module.less

@@ -171,7 +171,7 @@
       border-top: none !important;
       margin-top: 0;
       .n-collapse-item__header {
-        padding: 9px 0;
+        padding: 12px 0;
       }
     }
     // .n-collapse .n-collapse-item:not(:first-child)
@@ -193,11 +193,13 @@
     color: #333333;
     line-height: 20px;
     // margin-top: 8Px;
+    margin-bottom: 6px;
     cursor: pointer;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
-    &:hover {
+    &:hover,
+    &.active {
       color: #097bec;
       background: #e8f4ff;
       border-radius: 6px;
@@ -269,7 +271,7 @@
   background: #ffffff;
   box-shadow: -2px 5px 12px 0px rgba(0, 0, 0, 0.12);
   // border: 1px solid #e8e8e8;
-  border-radius: 12Px !important;
+  border-radius: 12px !important;
   overflow: hidden !important;
   display: flex;
   flex-direction: column;
@@ -279,3 +281,4 @@
     }
   }
 }
+

+ 9 - 13
src/components/layout/guide-section/index.tsx

@@ -75,7 +75,7 @@ export default defineComponent({
         windowInfo.showType === 'CONTENT' &&
         windowInfo.windowType === 'SMALL'
       ) {
-        name = '返回';
+        name = opInfo.manualDetail?.name || '返回';
       }
       return name;
     });
@@ -209,14 +209,6 @@ export default defineComponent({
     window.onLookVideo = (target: any) => {
       const sourceElement = target.querySelector('source');
       const videoSrc = sourceElement ? sourceElement.src : null;
-      // previewUrl.value = '';
-
-      // nextTick(() => {
-      //   setTimeout(() => {
-      //     previewUrl.value = videoSrc;
-      //     previewShow.value = true;
-      //   }, 0);
-      // });
       previewUrl.value = videoSrc;
       previewShow.value = true;
     };
@@ -309,7 +301,13 @@ export default defineComponent({
                                 {item.children &&
                                   item.children.map((child: any) => (
                                     <div
-                                      class={styles.childItem}
+                                      class={[
+                                        styles.childItem,
+                                        windowInfo.windowType === 'LARGE' &&
+                                        child.id === opInfo.manualDetail?.id
+                                          ? styles.active
+                                          : ''
+                                      ]}
                                       onClick={() => onClickItem(child)}>
                                       {child.name}
                                     </div>
@@ -352,9 +350,7 @@ export default defineComponent({
                       }}>
                       <NSpace>
                         {previewImgList.value.map((src: string) => (
-                          <NImage
-                            width="0"
-                            src={src}></NImage>
+                          <NImage width="0" src={src}></NImage>
                         ))}
                       </NSpace>
                     </NImageGroup>

+ 144 - 146
src/router/router-guards.ts

@@ -1,146 +1,144 @@
-import { isNavigationFailure, Router } from 'vue-router';
-import { useUserStore } from '@/store/modules/users';
-import { storage } from '@/utils/storage';
-import { PageEnum } from '@/enums/pageEnum';
-import { ACCESS_TOKEN, ACCESS_TOKEN_ADMIN } from '@/store/mutation-types';
-import { getAuthForAdmin } from '../utils';
-
-const LOGIN_PATH = PageEnum.BASE_LOGIN;
-
-const whitePathList = [LOGIN_PATH]; // no redirect whitelist
-const isChrome = () => {
-  const isChromium = (window as any).chrome;
-  const winNav = window.navigator;
-  const vendorName = winNav.vendor;
-  const isOpera = typeof (window as any).opr !== 'undefined';
-  const isIEedge = winNav.userAgent.indexOf('Edge') > -1;
-  const isIOSChrome = winNav.userAgent.match('CriOS');
-  return (
-    isIOSChrome ||
-    (isChromium !== null &&
-      typeof isChromium !== 'undefined' &&
-      vendorName === 'Google Inc.' &&
-      isOpera === false &&
-      isIEedge === false)
-  );
-};
-export function createRouterGuards(router: Router) {
-  const userStore = useUserStore();
-  router.beforeEach(async (to, from, next) => {
-    if (to.path === '/attend-class') {
-      let title = to.meta.title;
-      if (to.query.type === 'preview') {
-        title = '预览课件';
-      }
-      (document as any).title = title ? title : ('音乐数字课堂' as string);
-    } else {
-      (document as any).title = to.meta.title
-        ? to.meta.title
-        : ('音乐数字课堂' as string);
-    }
-
-    if ('serviceWorker' in navigator) {
-      console.log(caches.keys(), 'caches.keys()');
-      caches.keys().then(function (cacheNames) {
-        cacheNames.forEach(function (cacheName) {
-          caches.delete(cacheName);
-        });
-      });
-    }
-    if (!isChrome()) {
-      return;
-    }
-    window.$loadingBar && window.$loadingBar.start();
-
-    // console.log(window.$loadingBar, '232332');
-    if (from.path === LOGIN_PATH && to.name === 'errorPage') {
-      next(PageEnum.BASE_HOME);
-      return;
-    }
-
-    // Whitelist can be directly entered
-    if (whitePathList.includes(to.path as PageEnum)) {
-      next();
-      return;
-    }
-
-
-    // 为了处理课堂乐器后台预览课件的功能
-    // const authSource = sessionStorage.getItem('authSource');
-    const userAuth = getAuthForAdmin()
-    let token = "";
-    if (userAuth.authSource === 'admin') {
-      token = userAuth.Authorization;
-    } else {
-      token = storage.get(ACCESS_TOKEN)
-    }
-    // console.log(token, 'access token');
-    if (!token) {
-      // You can access without permissions. You need to set the routing meta.ignoreAuth to true
-      if (to.meta.ignoreAuth) {
-        next();
-        return;
-      }
-      // redirect login page
-      const redirectData: { path: string; replace: boolean; query?: any } = {
-        path: LOGIN_PATH,
-        replace: true
-      };
-
-      if (to.path) {
-        redirectData.query = {
-          ...redirectData.query,
-          redirect: to.path
-        };
-      }
-      console.log(redirectData, to);
-      next(redirectData);
-      return;
-    }
-
-    if(!userStore.getNickname) {
-      await userStore.getInfo();
-    }
-    
-
-    // const redirectPath = (from.query.redirect || to.path) as string;
-    // const redirect = decodeURIComponent(redirectPath);
-    // const nextData =
-    //   to.path === redirect ? { ...to, replace: true } : { path: redirect };
-    // next(nextData);
-    next();
-    // window.$loadingBar && window.$loadingBar.finish();
-  });
-
-  router.afterEach((to, _, failure) => {
-    if (isNavigationFailure(failure)) {
-      console.log('failed navigation', failure);
-    }
-    // const asyncRouteStore = useAsyncRouteStoreWidthOut();
-    // // 在这里设置需要缓存的组件名称
-    // const keepAliveComponents = asyncRouteStore.keepAliveComponents;
-    // const currentComName: any = to.matched.find(
-    //   item => item.name == to.name
-    // )?.name;
-    // if (
-    //   currentComName &&
-    //   !keepAliveComponents.includes(currentComName) &&
-    //   to.meta?.keepAlive
-    // ) {
-    //   // 需要缓存的组件
-    //   keepAliveComponents.push(currentComName);
-    // } else if (!to.meta?.keepAlive || to.name == 'Redirect') {
-    //   // 不需要缓存的组件
-    //   const index = asyncRouteStore.keepAliveComponents.findIndex(
-    //     name => name == currentComName
-    //   );
-    //   if (index != -1) {
-    //     keepAliveComponents.splice(index, 1);
-    //   }
-    // }
-    // asyncRouteStore.setKeepAliveComponents(keepAliveComponents);
-    window.$loadingBar && window.$loadingBar.finish();
-  });
-
-  // router.onError(error => {});
-}
+import { isNavigationFailure, Router } from 'vue-router';
+import { useUserStore } from '@/store/modules/users';
+import { storage } from '@/utils/storage';
+import { PageEnum } from '@/enums/pageEnum';
+import { ACCESS_TOKEN, ACCESS_TOKEN_ADMIN } from '@/store/mutation-types';
+import { getAuthForAdmin } from '../utils';
+
+const LOGIN_PATH = PageEnum.BASE_LOGIN;
+
+const whitePathList = [LOGIN_PATH]; // no redirect whitelist
+const isChrome = () => {
+  const isChromium = (window as any).chrome;
+  const winNav = window.navigator;
+  const vendorName = winNav.vendor;
+  const isOpera = typeof (window as any).opr !== 'undefined';
+  const isIEedge = winNav.userAgent.indexOf('Edge') > -1;
+  const isIOSChrome = winNav.userAgent.match('CriOS');
+  return (
+    isIOSChrome ||
+    (isChromium !== null &&
+      typeof isChromium !== 'undefined' &&
+      vendorName === 'Google Inc.' &&
+      isOpera === false &&
+      isIEedge === false)
+  );
+};
+export function createRouterGuards(router: Router) {
+  const userStore = useUserStore();
+  router.beforeEach(async (to, from, next) => {
+    if (to.path === '/attend-class') {
+      let title = to.meta.title;
+      if (to.query.type === 'preview') {
+        title = '预览课件';
+      }
+      (document as any).title = title ? title : ('音乐数字课堂' as string);
+    } else {
+      (document as any).title = to.meta.title
+        ? to.meta.title
+        : ('音乐数字课堂' as string);
+    }
+
+    // if ('serviceWorker' in navigator) {
+    //   console.log(caches.keys(), 'caches.keys()');
+    //   caches.keys().then(function (cacheNames) {
+    //     cacheNames.forEach(function (cacheName) {
+    //       caches.delete(cacheName);
+    //     });
+    //   });
+    // }
+    if (!isChrome()) {
+      return;
+    }
+    window.$loadingBar && window.$loadingBar.start();
+
+    // console.log(window.$loadingBar, '232332');
+    if (from.path === LOGIN_PATH && to.name === 'errorPage') {
+      next(PageEnum.BASE_HOME);
+      return;
+    }
+
+    // Whitelist can be directly entered
+    if (whitePathList.includes(to.path as PageEnum)) {
+      next();
+      return;
+    }
+
+    // 为了处理课堂乐器后台预览课件的功能
+    // const authSource = sessionStorage.getItem('authSource');
+    const userAuth = getAuthForAdmin();
+    let token = '';
+    if (userAuth.authSource === 'admin') {
+      token = userAuth.Authorization;
+    } else {
+      token = storage.get(ACCESS_TOKEN);
+    }
+    // console.log(token, 'access token');
+    if (!token) {
+      // You can access without permissions. You need to set the routing meta.ignoreAuth to true
+      if (to.meta.ignoreAuth) {
+        next();
+        return;
+      }
+      // redirect login page
+      const redirectData: { path: string; replace: boolean; query?: any } = {
+        path: LOGIN_PATH,
+        replace: true
+      };
+
+      if (to.path) {
+        redirectData.query = {
+          ...redirectData.query,
+          redirect: to.path
+        };
+      }
+      console.log(redirectData, to);
+      next(redirectData);
+      return;
+    }
+
+    if (!userStore.getNickname) {
+      await userStore.getInfo();
+    }
+
+    // const redirectPath = (from.query.redirect || to.path) as string;
+    // const redirect = decodeURIComponent(redirectPath);
+    // const nextData =
+    //   to.path === redirect ? { ...to, replace: true } : { path: redirect };
+    // next(nextData);
+    next();
+    // window.$loadingBar && window.$loadingBar.finish();
+  });
+
+  router.afterEach((to, _, failure) => {
+    if (isNavigationFailure(failure)) {
+      console.log('failed navigation', failure);
+    }
+    // const asyncRouteStore = useAsyncRouteStoreWidthOut();
+    // // 在这里设置需要缓存的组件名称
+    // const keepAliveComponents = asyncRouteStore.keepAliveComponents;
+    // const currentComName: any = to.matched.find(
+    //   item => item.name == to.name
+    // )?.name;
+    // if (
+    //   currentComName &&
+    //   !keepAliveComponents.includes(currentComName) &&
+    //   to.meta?.keepAlive
+    // ) {
+    //   // 需要缓存的组件
+    //   keepAliveComponents.push(currentComName);
+    // } else if (!to.meta?.keepAlive || to.name == 'Redirect') {
+    //   // 不需要缓存的组件
+    //   const index = asyncRouteStore.keepAliveComponents.findIndex(
+    //     name => name == currentComName
+    //   );
+    //   if (index != -1) {
+    //     keepAliveComponents.splice(index, 1);
+    //   }
+    // }
+    // asyncRouteStore.setKeepAliveComponents(keepAliveComponents);
+    window.$loadingBar && window.$loadingBar.finish();
+  });
+
+  // router.onError(error => {});
+}