소스 검색

feat: link icon

chenlei 10 달 전
부모
커밋
e7f55d979c
1개의 변경된 파일16개의 추가작업 그리고 2개의 파일을 삭제
  1. 16 2
      src/components/Rbottom.vue

+ 16 - 2
src/components/Rbottom.vue

@@ -41,7 +41,7 @@
               class="scene-list-item el-tooltip__trigger el-tooltip__trigger el-dropdown-menu__item"
               @click="openHot(item)"
             >
-              {{ item.title?.split("&")[0] }}
+              {{ getHotTitle(item.title) }}
             </li>
           </el-dropdown-menu>
         </el-dropdown>
@@ -281,7 +281,21 @@ export default {
     },
 
     openHot(item) {
-      this.$emit("openHot", item);
+      const isLink = item.title.startsWith('(link)')
+
+      if (isLink) {
+        const regex = new RegExp(`<\/?p[^>]*>`, 'g')
+        const link = item.content.replace(regex, '')
+        const isHttp = link.startsWith('http')
+        window.location.href = isHttp ? link : `https://scene.4dage.com${link}`
+      } else {
+        this.$emit("openHot", item);
+      }
+    },
+
+    getHotTitle(str = '') {
+      str = str.replace('(link)', '')
+      return str.split("&")[0]
     },
 
     selectHis(val) {