Explorar el Código

资讯增加链接

jinxia.mo hace 4 semanas
padre
commit
29716469fc

+ 33 - 0
back-ui/src/views/system/bWwwNews/index.vue

@@ -192,6 +192,21 @@
         </template>
       </el-table-column>
       <el-table-column label="省份" align="center" prop="location" />
+      <el-table-column label="链接" align="center" prop="url" width="60">
+        <template #default="scope">
+          <el-tooltip v-if="scope.row.url" :content="scope.row.url" placement="top" effect="dark">
+            <el-link 
+              type="primary" 
+              :underline="false" 
+              @click="handleUrlClick(scope.row.url)"
+              style="cursor: pointer;"
+            >
+              {{ scope.row.url.length > 30 ? scope.row.url.substring(0, 30) + '...' : scope.row.url }}
+            </el-link>
+          </el-tooltip>
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
 <!--      <el-table-column label="原id" align="center" prop="originId" />-->
 <!--      <el-table-column label="source" align="center" prop="source" />-->
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -277,6 +292,9 @@
         <el-form-item label="省份" prop="location">
           <el-input v-model="form.location" placeholder="请输入省份" />
         </el-form-item>
+        <el-form-item label="链接" prop="url">
+          <el-input v-model="form.url" placeholder="请输入链接" />
+        </el-form-item>
 <!--        <el-form-item label="原id" prop="originId">-->
 <!--          <el-input v-model="form.originId" placeholder="请输入原id" />-->
 <!--        </el-form-item>-->
@@ -309,6 +327,7 @@
         </div>
       </template>
     </el-dialog>
+
   </div>
 </template>
 
@@ -352,6 +371,7 @@ const data = reactive({
     isTop: null,
     createTime: null,
     location: null,
+    url: null,
     originId: null,
     source: null
   },
@@ -402,6 +422,7 @@ function reset() {
     isTop: null,
     createTime: null,
     location: null,
+    url: null,
     originId: null,
     source: null
   }
@@ -494,6 +515,18 @@ function handlePreviewContent(row) {
   previewOpen.value = true
 }
 
+/** 点击链接,直接在新窗口打开 */
+function handleUrlClick(url) {
+  if (url) {
+    // 检查链接是否包含协议,如果没有则添加 https://
+    let finalUrl = url
+    if (!finalUrl.startsWith('http://') && !finalUrl.startsWith('https://')) {
+      finalUrl = 'https://' + finalUrl
+    }
+    window.open(finalUrl, '_blank')
+  }
+}
+
 getList()
 </script>
 

+ 9 - 0
ie-system/src/main/java/com/ruoyi/syzy/domain/BWwwNews.java

@@ -57,6 +57,7 @@ public class BWwwNews extends BaseEntity {
     private String description;
     private Integer isTop;
     private String location;
+    private String url;
 
     public List<String> getIds() {
         return ids;
@@ -98,6 +99,14 @@ public class BWwwNews extends BaseEntity {
         this.location = location;
     }
 
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
     public void setId(Long id) {
         this.id = id;
     }

+ 5 - 1
ie-system/src/main/resources/mapper/syzy/BWwwNewsMapper.xml

@@ -18,10 +18,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <result property="description" column="description" />
     <result property="isTop" column="isTop" />
     <result property="location" column="location" />
+    <result property="url" column="url" />
   </resultMap>
 
   <sql id="selectBWwwNewsVo">
-    select id, type, title, f, sendDate, content, createTime, clicked, status,keywords,description,isTop,location from b_www_news
+    select id, type, title, f, sendDate, content, createTime, clicked, status,keywords,description,isTop,location,url from b_www_news
   </sql>
 
   <select id="selectBWwwNewsList" parameterType="BWwwNews" resultMap="BWwwNewsResult">
@@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       <if test="clicked != null">clicked,</if>
       <if test="status != null">status,</if>
       <if test="location != null and location != '' ">location,</if>
+      <if test="url != null and url != '' ">url,</if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="type != null">#{type},</if>
@@ -78,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       <if test="clicked != null">#{clicked},</if>
       <if test="status != null">#{status},</if>
       <if test="location != null and location != '' ">#{location},</if>
+      <if test="url != null and url != '' ">#{url},</if>
     </trim>
   </insert>
 
@@ -94,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       <if test="status != null">status = #{status},</if>
       <if test="isTop != null">isTop = #{isTop},</if>
       <if test="location != null and location != ''">location = #{location},</if>
+      <if test="url != null and url != ''">url = #{url},</if>
     </trim>
     where id = #{id}
   </update>