Browse Source

Merge branch 'iteration-20240603-bug' into online

lex 11 months ago
parent
commit
4bce77fdd7

+ 1 - 1
public/version.json

@@ -1 +1 @@
-{"version":1717401681157}
+{"version":1717663410831}

+ 105 - 104
src/router/index.ts

@@ -1,104 +1,105 @@
-import { App } from 'vue';
-import {
-  createRouter,
-  createWebHistory,
-  LocationQuery,
-  LocationQueryRaw,
-  LocationQueryValue,
-  Router
-} from 'vue-router';
-import { constantRoutes } from './routes/index';
-import { AesEncryption } from '@/utils/cipher';
-import { createRouterGuards } from './router-guards';
-const aes = new AesEncryption();
-
-/** Used as references for various `Number` constants. */
-const MAX_SAFE_INTEGER = 9007199254740991;
-function isLength(value: any) {
-  return (
-    typeof value === 'number' &&
-    value > -1 &&
-    value % 1 == 0 &&
-    value <= MAX_SAFE_INTEGER
-  );
-}
-function isUndefined(value: any) {
-  return value === undefined;
-}
-function isArray(value: any) {
-  return value != null && typeof value !== 'function' && isLength(value.length);
-}
-function isNull(value: any) {
-  return value === null;
-}
-/**
- *
- * @description 加密:反序列化字符串参数
- */
-export function stringifyQuery(obj: LocationQueryRaw): string {
-  if (!obj) return '';
-  const result = Object.keys(obj)
-    .map(key => {
-      const value: any = obj[key];
-      if (isUndefined(value)) return '';
-      if (isNull(value)) return key;
-      if (Array.isArray(value)) {
-        const resArray: string[] = [];
-        value.forEach((item: string) => {
-          if (isUndefined(item)) return;
-          if (isNull(item)) {
-            resArray.push(key);
-          } else {
-            resArray.push(key + '=' + item);
-          }
-        });
-        return resArray.join('&');
-      }
-      return `${key}=${value}`;
-    })
-    .filter(x => x.length > 0)
-    .join('&');
-  return result ? `?${aes.encryptByAES(result)}` : '';
-}
-
-/**
- *
- * @description 解密:反序列化字符串参数
- */
-export function parseQuery(query: string): LocationQuery {
-  const res: LocationQuery = {};
-  query = query.trim().replace(/^(\?|#|&)/, '');
-  if (!query) return res;
-  query = aes.decryptByAES(query);
-  query.split('&').forEach(param => {
-    const parts = param.replace(/\+/g, ' ').split('=');
-    const key: any = parts.shift();
-    const val = parts.length > 0 ? parts.join('=') : null;
-    if (!isUndefined(key)) {
-      if (isUndefined(res[key])) {
-        res[key] = val;
-      } else if (isArray(res[key])) {
-        (res[key] as LocationQueryValue[]).push(val);
-      } else {
-        res[key] = [res[key] as LocationQueryValue, val];
-      }
-    }
-  });
-  return res;
-}
-
-const router: Router = createRouter({
-  history: createWebHistory('/classroom'),
-  routes: [...constantRoutes],
-  stringifyQuery,
-  parseQuery,
-  scrollBehavior: () => ({ top: 0 })
-});
-
-export function setupRouter(app: App) {
-  app.use(router);
-  // 创建路由守卫
-  createRouterGuards(router);
-}
-
-export default router;
+import { App } from 'vue';
+import {
+  createRouter,
+  createWebHashHistory,
+  createWebHistory,
+  LocationQuery,
+  LocationQueryRaw,
+  LocationQueryValue,
+  Router
+} from 'vue-router';
+import { constantRoutes } from './routes/index';
+import { AesEncryption } from '@/utils/cipher';
+import { createRouterGuards } from './router-guards';
+const aes = new AesEncryption();
+
+/** Used as references for various `Number` constants. */
+const MAX_SAFE_INTEGER = 9007199254740991;
+function isLength(value: any) {
+  return (
+    typeof value === 'number' &&
+    value > -1 &&
+    value % 1 == 0 &&
+    value <= MAX_SAFE_INTEGER
+  );
+}
+function isUndefined(value: any) {
+  return value === undefined;
+}
+function isArray(value: any) {
+  return value != null && typeof value !== 'function' && isLength(value.length);
+}
+function isNull(value: any) {
+  return value === null;
+}
+/**
+ *
+ * @description 加密:反序列化字符串参数
+ */
+export function stringifyQuery(obj: LocationQueryRaw): string {
+  if (!obj) return '';
+  const result = Object.keys(obj)
+    .map(key => {
+      const value: any = obj[key];
+      if (isUndefined(value)) return '';
+      if (isNull(value)) return key;
+      if (Array.isArray(value)) {
+        const resArray: string[] = [];
+        value.forEach((item: string) => {
+          if (isUndefined(item)) return;
+          if (isNull(item)) {
+            resArray.push(key);
+          } else {
+            resArray.push(key + '=' + item);
+          }
+        });
+        return resArray.join('&');
+      }
+      return `${key}=${value}`;
+    })
+    .filter(x => x.length > 0)
+    .join('&');
+  return result ? `?${aes.encryptByAES(result)}` : '';
+}
+
+/**
+ *
+ * @description 解密:反序列化字符串参数
+ */
+export function parseQuery(query: string): LocationQuery {
+  const res: LocationQuery = {};
+  query = query.trim().replace(/^(\?|#|&)/, '');
+  if (!query) return res;
+  query = aes.decryptByAES(query);
+  query.split('&').forEach(param => {
+    const parts = param.replace(/\+/g, ' ').split('=');
+    const key: any = parts.shift();
+    const val = parts.length > 0 ? parts.join('=') : null;
+    if (!isUndefined(key)) {
+      if (isUndefined(res[key])) {
+        res[key] = val;
+      } else if (isArray(res[key])) {
+        (res[key] as LocationQueryValue[]).push(val);
+      } else {
+        res[key] = [res[key] as LocationQueryValue, val];
+      }
+    }
+  });
+  return res;
+}
+
+const router: Router = createRouter({
+  history: createWebHashHistory('/classroom'),
+  routes: [...constantRoutes],
+  stringifyQuery,
+  parseQuery,
+  scrollBehavior: () => ({ top: 0 })
+});
+
+export function setupRouter(app: App) {
+  app.use(router);
+  // 创建路由守卫
+  createRouterGuards(router);
+}
+
+export default router;

+ 35 - 35
src/utils/urlUtils.ts

@@ -1,35 +1,35 @@
-export function vaildUrl() {
-  const url: string = window.location.href;
-  let returnUrl = '';
-  if (/test/.test(url)) {
-    // dev 环境
-    returnUrl = 'https://test.kt.colexiu.com';
-  } else if (/dev/.test(url)) {
-    returnUrl = 'https://dev.kt.colexiu.com';
-  } else if (/localhost/.test(url)) {
-    //   //本地环境
-    returnUrl = 'https://test.kt.colexiu.com';
-  } else {
-    // 默认dev环境
-    returnUrl = 'https://kt.colexiu.com';
-  }
-  return returnUrl;
-}
-
-export function vaildMusicScoreUrl() {
-  const url: string = window.location.href;
-  let returnUrl = '';
-
-  if (/test/.test(url)) {
-    // dev 环境
-    returnUrl = 'https://test.kt.colexiu.com';
-  } else if (/dev/.test(url)) {
-    returnUrl = 'https://dev.kt.colexiu.com';
-  } else if (/localhost/.test(url)) {
-    //   //本地环境
-    returnUrl = 'https://test.kt.colexiu.com';
-  } else {
-    returnUrl = 'https://mec.colexiu.com';
-  }
-  return returnUrl;
-}
+export function vaildUrl() {
+  const url: string = window.location.hostname;
+  let returnUrl = '';
+  if (/test/.test(url)) {
+    // dev 环境
+    returnUrl = 'https://test.kt.colexiu.com';
+  } else if (/dev/.test(url)) {
+    returnUrl = 'https://dev.kt.colexiu.com';
+  } else if (/localhost/.test(url)) {
+    //   //本地环境
+    returnUrl = 'https://test.kt.colexiu.com';
+  } else {
+    // 默认dev环境
+    returnUrl = 'https://kt.colexiu.com';
+  }
+  return returnUrl;
+}
+
+export function vaildMusicScoreUrl() {
+  const url: string = window.location.hostname;
+  let returnUrl = '';
+
+  if (/test/.test(url)) {
+    // dev 环境
+    returnUrl = 'https://test.kt.colexiu.com';
+  } else if (/dev/.test(url)) {
+    returnUrl = 'https://dev.kt.colexiu.com';
+  } else if (/localhost/.test(url)) {
+    //   //本地环境
+    returnUrl = 'https://test.kt.colexiu.com';
+  } else {
+    returnUrl = 'https://mec.colexiu.com';
+  }
+  return returnUrl;
+}

+ 1 - 1
src/views/prepare-lessons/components/directory-main/index.tsx

@@ -183,6 +183,7 @@ export default defineComponent({
             });
           }
         });
+        await getLessonCoursewareDetail();
         // 判断教材里面是否有当前选择的声部,如果没有则默认选择第一个
         console.log(status, 'status');
         if (status) {
@@ -195,7 +196,6 @@ export default defineComponent({
         }
       }
 
-      getLessonCoursewareDetail();
       setLastUseCoursewareId(item.id);
     };
 

+ 14 - 6
src/views/prepare-lessons/components/lesson-main/courseware-presets/index.tsx

@@ -115,6 +115,7 @@ export default defineComponent({
         if (!Array.isArray(data)) {
           return;
         }
+
         const tempList: any = [];
         data.forEach((item: any) => {
           // const firstItem: any =
@@ -143,14 +144,22 @@ export default defineComponent({
     };
 
     // 监听选择的key 左侧选择了其它的课
+    let timer: any = null;
     watch(
       () => [prepareStore.getSelectKey, prepareStore.getInstrumentId],
       async () => {
-        eventGlobal.emit('openCoursewareChanged');
-        await getCoursewareList();
-        // await getOpenCoursewareList();
-
-        subjectRef.value?.syncBarPosition();
+        clearTimeout(timer);
+        timer = setTimeout(async () => {
+          if (!prepareStore.getInstrumentId) {
+            // 获取教材分类列表
+            checkInstrumentIds();
+          } else {
+            getInitInstrumentId();
+          }
+          eventGlobal.emit('openCoursewareChanged');
+          await getCoursewareList();
+          subjectRef.value?.syncBarPosition();
+        }, 100);
       }
     );
 
@@ -446,7 +455,6 @@ export default defineComponent({
             paneWrapperClass={styles.paneWrapperContainer}
             value={tabInstrumentValue.value}
             onUpdate:value={(val: any) => {
-              console.log(val, 'item.id', prepareStore.getFormatInstrumentList);
               prepareStore.getFormatInstrumentList.forEach((item: any) => {
                 if (item.value.toString() === val.toString()) {
                   prepareStore.setInstrumentId(val);