Browse Source

Merge branch 'iteration-20250313-light' into jenkins-test

lex-xin 3 months ago
parent
commit
50ad038d35

+ 14 - 6
src/components/card-type/index.module.less

@@ -169,15 +169,16 @@
   }
 
   .footer {
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
+    // display: flex;
+    // align-items: center;
+    // justify-content: space-between;
     // padding: 3px 0;
   }
 
   .title {
     display: flex;
     align-items: center;
+    flex: 1;
 
     .titleType {
       width: 13Px;
@@ -189,17 +190,24 @@
     .titleContent {
       padding-left: 6px;
       font-size: max(16px, 12Px);
-      max-width: 160px;
+      // max-width: 160px;
+      max-width: 78%;
       color: #131415;
       font-weight: 600 !important;
-      flex: 1;
+      // flex: 1;
+    }
+
+    .titleContentDownload {
+      max-width: 64%;
     }
   }
 
   // 收藏按钮
   .btnGroup {
     position: absolute;
-    right: 12px;
+    top: -5px;
+    right: 0;
+    // right: 12px;
     flex-shrink: 0;
     display: flex;
     align-items: center;

+ 65 - 58
src/components/card-type/index.tsx

@@ -116,7 +116,7 @@ export default defineComponent({
     /** 是否开始错误提示 border isError */
     isError: {
       type: Boolean,
-      default: false,
+      default: false
     }
   },
   /**
@@ -474,66 +474,73 @@ export default defineComponent({
             ),
             footer: () => (
               <div class={styles.footer}>
-                <div class={[styles.title, 'footerTitle']}>
-                  <NImage
-                    class={[styles.titleType]}
-                    src={formatType(props.item.type)}
-                    objectFit="cover"
-                  />
-                  <span class={[styles.titleContent, 'titleContent']}>
-                    <TheNoticeBar
-                      isAnimation={isAnimation.value}
-                      text={props.item.title}
+                <div style={{ position: 'relative' }}>
+                  <div class={[styles.title, 'footerTitle']}>
+                    <NImage
+                      class={[styles.titleType]}
+                      src={formatType(props.item.type)}
+                      objectFit="cover"
                     />
-                  </span>
-                </div>
-                {/* 收藏 */}
-                <div class={styles.btnGroup}>
-                  {props.isDownload && (
-                    <div class={styles.btnItem} onClick={onDownload}>
-                      <NSpin show={downloadStatus.value} size={'small'}>
-                        <img
-                          src={iconDownload}
-                          key="3"
-                          class={[styles.iconCollect]}
-                        />
-                      </NSpin>
-                    </div>
-                  )}
-                  {props.isShowCollect && (
-                    <div
-                      class={[styles.iconCollect, styles.btnItem]}
-                      onClick={(e: MouseEvent) => {
-                        e.stopPropagation();
-                        e.preventDefault();
-                        // 判断是否可以收藏
-                        if (props.isCollect) {
-                          emit('collect', props.item);
-                        }
-                      }}>
-                      <Transition name="favitor" mode="out-in">
-                        {props.item.isCollect ? (
-                          <img
-                            src={iconCollectActive}
-                            key="1"
-                            class={[
-                              styles.iconCollect,
-                              props.isCollect ? styles.isCollect : ''
-                            ]}
-                          />
-                        ) : (
+                    <span
+                      class={[
+                        styles.titleContent,
+                        props.isDownload && styles.titleContentDownload,
+                        'titleContent'
+                      ]}>
+                      <TheNoticeBar
+                        isAnimation={isAnimation.value}
+                        text={props.item.title}
+                      />
+                    </span>
+                  </div>
+                  {/* 收藏 */}
+                  <div class={styles.btnGroup}>
+                    {props.isDownload && (
+                      <div class={styles.btnItem} onClick={onDownload}>
+                        <NSpin show={downloadStatus.value} size={'small'}>
                           <img
-                            src={iconCollectDefault}
-                            key="2"
-                            class={[
-                              styles.iconCollect,
-                              props.isCollect ? styles.isCollect : ''
-                            ]}
+                            src={iconDownload}
+                            key="3"
+                            class={[styles.iconCollect]}
                           />
-                        )}
-                      </Transition>
-                    </div>
-                  )}
+                        </NSpin>
+                      </div>
+                    )}
+                    {props.isShowCollect && (
+                      <div
+                        class={[styles.iconCollect, styles.btnItem]}
+                        onClick={(e: MouseEvent) => {
+                          e.stopPropagation();
+                          e.preventDefault();
+                          // 判断是否可以收藏
+                          if (props.isCollect) {
+                            emit('collect', props.item);
+                          }
+                        }}>
+                        <Transition name="favitor" mode="out-in">
+                          {props.item.isCollect ? (
+                            <img
+                              src={iconCollectActive}
+                              key="1"
+                              class={[
+                                styles.iconCollect,
+                                props.isCollect ? styles.isCollect : ''
+                              ]}
+                            />
+                          ) : (
+                            <img
+                              src={iconCollectDefault}
+                              key="2"
+                              class={[
+                                styles.iconCollect,
+                                props.isCollect ? styles.isCollect : ''
+                              ]}
+                            />
+                          )}
+                        </Transition>
+                      </div>
+                    )}
+                  </div>
                 </div>
 
                 {/* 精选 */}

+ 35 - 36
src/views/classList/components/classStudent.tsx

@@ -57,7 +57,6 @@ export default defineComponent({
     );
     const search = () => {
       state.pagination.page = 1;
-      getInfo();
       getList();
       setCache({ current: state.searchForm, saveKey: 'classDetailStudent' });
     };
@@ -68,7 +67,6 @@ export default defineComponent({
         gender: '' as any,
         membership: '' as any
       };
-      getInfo();
       search();
       setCache({ current: state.searchForm, saveKey: 'classDetailStudent' });
     };
@@ -103,7 +101,7 @@ export default defineComponent({
       try {
         const { data } = await api_studentStat({
           classGroupId: route.query.id as any,
-          ...state.searchForm
+          // ...state.searchForm
         });
         payForm.studentNum = data.studentNum || 0;
         payForm.vipStudentNum = data.vipStudentNum || 0;
@@ -231,6 +229,39 @@ export default defineComponent({
     };
     return () => (
       <div>
+        <div class={['section-container']}>
+          <div class={styles.TrainDataTop}>
+            <div class={styles.TrainDataTopLeft}>
+              <div class={styles.TrainDataItem}>
+                <p class={styles.TrainDataItemTitle}>
+                  <div>
+                    <span>
+                      <NNumberAnimation
+                        from={0}
+                        to={payForm.studentNum}></NNumberAnimation>
+                    </span>
+                    人
+                  </div>
+                </p>
+                <p class={styles.TrainDataItemsubTitle}>班级人数</p>
+              </div>
+              <div class={styles.TrainDataItem}>
+                <p class={styles.TrainDataItemTitle}>
+                  <div>
+                    <span>
+                      <NNumberAnimation
+                        from={0}
+                        to={payForm.vipStudentNum}></NNumberAnimation>
+                    </span>
+                    人
+                  </div>
+                </p>
+                <p class={styles.TrainDataItemsubTitle}>会员人数</p>
+              </div>
+            </div>
+            <div class={styles.TrainDataTopRight}></div>
+          </div>
+        </div>
         <div class={styles.searchList}>
           <NForm label-placement="left" inline>
             <NFormItem>
@@ -306,39 +337,7 @@ export default defineComponent({
             </NFormItem>
           </NForm>
         </div>
-        <div class={['section-container']}>
-          <div class={styles.TrainDataTop}>
-            <div class={styles.TrainDataTopLeft}>
-              <div class={styles.TrainDataItem}>
-                <p class={styles.TrainDataItemTitle}>
-                  <div>
-                    <span>
-                      <NNumberAnimation
-                        from={0}
-                        to={payForm.studentNum}></NNumberAnimation>
-                    </span>
-                    人
-                  </div>
-                </p>
-                <p class={styles.TrainDataItemsubTitle}>班级人数</p>
-              </div>
-              <div class={styles.TrainDataItem}>
-                <p class={styles.TrainDataItemTitle}>
-                  <div>
-                    <span>
-                      <NNumberAnimation
-                        from={0}
-                        to={payForm.vipStudentNum}></NNumberAnimation>
-                    </span>
-                    人
-                  </div>
-                </p>
-                <p class={styles.TrainDataItemsubTitle}>会员人数</p>
-              </div>
-            </div>
-            <div class={styles.TrainDataTopRight}></div>
-          </div>
-        </div>
+
         <div class={styles.tableWrap}>
           <NDataTable
             v-slots={{

+ 29 - 26
src/views/content-information/useSpeak.ts

@@ -88,8 +88,20 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
   const getSelectText = () => {
     const selection: any = window.getSelection();
     const range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
-
-
+    // if (range) {
+    //   const startNode = range.startContainer;
+    //   let currentParagraph = startNode;
+    //   while (
+    //     currentParagraph.nodeType !== Node.ELEMENT_NODE ||
+    //     currentParagraph.tagName !== 'P'
+    //   ) {
+    //     currentParagraph = currentParagraph.parentNode;
+    //   }
+    //   range.setEnd(currentParagraph, currentParagraph.childNodes.length);
+    //   selection.removeAllRanges();
+    //   selection.addRange(range);
+    // }
+    // console.log(selection, 'selection.selectAllChildren()')
     if (selection.toString().length > 0) {
       state.showDom = true;
       const textContainer: any = document.querySelector(_musicContent);
@@ -99,7 +111,10 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
         anchorOffset = 0,
         endIndex = 0,
         focusOffset = 0;
-      console.log(selection, 'selection');
+      // console.log(selection, 'selection');
+      // sentences.forEach((item: any) => {
+      //   console.log(selection.containsNode(item), '---', item)
+      // })
 
       // 都为0的情况下判断为选中某一个段
       if (selection.focusOffset === 0 && selection.anchorOffset === 0) {
@@ -110,6 +125,7 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
         const firstNode = startParagraph.childNodes[0];
         const endNode =
           startParagraph.childNodes[startParagraph.childNodes.length - 1];
+
         sentences?.forEach((element: any, index: number) => {
           if (element === firstNode) {
             startIndex = index;
@@ -121,15 +137,16 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
           }
         });
       } else {
+        const direction = checkSelectionDirection(selection);
         const firstNode =
-          checkSelectionDirection(selection) === 'up'
+          direction === 'up'
             ? selection.anchorNode.parentNode
             : selection.focusNode.parentNode;
         const endNode =
-          checkSelectionDirection(selection) === 'down'
+          direction === 'down'
             ? selection.anchorNode.parentNode
             : selection.focusNode.parentNode;
-        if (checkSelectionDirection(selection) === 'up') {
+        if (direction === 'up') {
           anchorOffset = selection.anchorOffset;
           focusOffset = selection.focusOffset;
         } else {
@@ -140,19 +157,20 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
           if (element === firstNode) {
             startIndex = index;
             anchorOffset =
-              checkSelectionDirection(selection) === 'up'
+              direction === 'up'
                 ? selection.anchorOffset
                 : selection.focusOffset;
           }
           if (element === endNode) {
             endIndex = index;
             focusOffset =
-              checkSelectionDirection(selection) === 'down'
+              direction === 'down'
                 ? selection.anchorOffset
                 : selection.focusOffset;
           }
         });
       }
+
       state.selectOptions.startIndex = startIndex;
       state.selectOptions.anchorOffset = anchorOffset;
       state.selectOptions.endIndex = endIndex;
@@ -174,7 +192,7 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
       const rects = range.getClientRects();
 
       if (rects.length > 0) {
-        // console.log(rects, 'rects');
+        // console.log(rects, 'rects', range);
         const firstRect = rects[rects.length - 1];
         const x = firstRect.right;
         const y = firstRect.top;
@@ -203,20 +221,6 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
             showDom.style.left = 'auto';
           }
         }
-
-        // if (parentRect?.width - (x - parentRect?.left) > showDomRect.width) {
-        //   // 判断是否选择到最右边 超出边界
-        //   // showDom.style.left = (x - parentRect?.right).toFixed(2) + 'px';
-        //   // showDom.style.right = 'auto';
-        //   showDom.style.right = (parentRect?.right - x - 6).toFixed(2) + 'px';
-        //   showDom.style.left = 'auto';
-        // } else {
-        //   // showDom.style.right = '0px';
-        //   // showDom.style.left = 'auto';
-
-        //   showDom.style.right = 'auto';
-        //   showDom.style.left = '0';
-        // }
       }
     }
   };
@@ -355,7 +359,6 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
 
     // 初始化高亮显示
     const initLightText = () => {
-
       sentences?.forEach((sentence: any, i: number) => {
         if (i >= currentSentenceIndex && i <= end) {
           const text = sentence.textContent;
@@ -397,8 +400,6 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
       });
     };
 
-    initLightText();
-
     // 开始播放
     const speaker = () => {
       try {
@@ -490,6 +491,8 @@ export const useSpeak = (musicContent?: string, selectionCouser?: string) => {
     };
 
     speaker();
+
+    initLightText();
   };
 
   const onDestory = () => {