fix: 修复文章链接域名读取(data是dict格式,用data['key'].value获取)
This commit is contained in:
@@ -30,7 +30,9 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="文章" min-width="180" show-overflow-tooltip>
|
<el-table-column label="文章" min-width="180" show-overflow-tooltip>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-link :href="getArticleUrl(row.article_id)" target="_blank" type="primary" style="font-size:13px">{{ row.article_title || row.article_id || '--' }}</el-link>
|
<el-link
|
||||||
|
:href="row.article_url || '#'"
|
||||||
|
target="_blank" type="primary" style="font-size:13px">{{ row.article_title || row.article_id || '--' }}</el-link>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="类型" width="80" align="center">
|
<el-table-column label="类型" width="80" align="center">
|
||||||
@@ -83,14 +85,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
import { ref, reactive, onMounted, onUnmounted, nextTick, computed } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { getInteractions, retryInteraction, exportInteractions, cancelInteraction , getSystemConfigs } from '@/api'
|
import { getInteractions, retryInteraction, exportInteractions, cancelInteraction , getSystemConfigs } from '@/api'
|
||||||
|
|
||||||
const records = ref([])
|
const records = ref([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const articleBaseDomain = ref('https://fat-open.99hui.com') // 默认测试环境
|
const articleBaseDomain = ref('') // 从系统配置动态读取
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const pageSize = ref(20)
|
const pageSize = ref(20)
|
||||||
const dateRange = ref(null)
|
const dateRange = ref(null)
|
||||||
@@ -106,30 +108,45 @@ function onDateChange(v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 构造文章详情页 URL(H5 分享页面)
|
// 构造文章详情页 URL(H5 分享页面)
|
||||||
|
// 用 computed 确保 articleBaseDomain 变化时响应式更新
|
||||||
|
const articleUrlBase = computed(() => articleBaseDomain.value)
|
||||||
|
|
||||||
function getArticleUrl(articleId) {
|
function getArticleUrl(articleId) {
|
||||||
if (!articleId) return '#'
|
if (!articleId || !articleUrlBase.value) return '#'
|
||||||
return `${articleBaseDomain.value}/huihui-h5/#/news/share?id=${articleId}&login=no`
|
return `${articleUrlBase.value}/huihui-h5/#/news/share?id=${articleId}&login=no`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从系统配置获取业务接口域名,用于拼接文章链接
|
// 从系统配置获取业务接口域名,用于拼接文章链接
|
||||||
async function loadArticleDomain() {
|
async function loadArticleDomain() {
|
||||||
try {
|
try {
|
||||||
const res = await getSystemConfigs()
|
const res = await getSystemConfigs()
|
||||||
const cfgs = res.data || []
|
// data 是 {key: {value, type, desc}} 格式的字典
|
||||||
const bizUrl = cfgs.find(c => c.config_key === 'news_platform_base_url')?.config_value || ''
|
const cfgData = res.data || {}
|
||||||
|
const bizUrl = cfgData['news_platform_base_url']?.value || ''
|
||||||
if (bizUrl) {
|
if (bizUrl) {
|
||||||
// 从 https://99hui.com/api/huihuibusiness 提取 https://99hui.com
|
// 从 https://99hui.com/api/huihuibusiness 提取 https://99hui.com
|
||||||
const parts = bizUrl.split('/')
|
const parts = bizUrl.split('/')
|
||||||
if (parts.length >= 3) articleBaseDomain.value = parts[0] + '//' + parts[2]
|
if (parts.length >= 3) {
|
||||||
|
articleBaseDomain.value = parts[0] + '//' + parts[2]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) { console.error('loadArticleDomain error:', e) }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await getInteractions({ page: page.value, page_size: pageSize.value, ...filters })
|
const res = await getInteractions({ page: page.value, page_size: pageSize.value, ...filters })
|
||||||
records.value = res.data?.items || []
|
const items = res.data?.items || []
|
||||||
|
// 直接拼接文章 URL,避免响应式追踪问题
|
||||||
|
items.forEach(item => {
|
||||||
|
if (item.article_id && articleBaseDomain.value) {
|
||||||
|
item.article_url = `${articleBaseDomain.value}/huihui-h5/#/news/share?id=${item.article_id}&login=no`
|
||||||
|
} else {
|
||||||
|
item.article_url = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
records.value = items
|
||||||
total.value = res.data?.total || 0
|
total.value = res.data?.total || 0
|
||||||
} finally { loading.value = false }
|
} finally { loading.value = false }
|
||||||
}
|
}
|
||||||
@@ -177,8 +194,8 @@ async function handleExport() {
|
|||||||
const a = document.createElement('a'); a.href = url; a.download = 'interactions.xlsx'; a.click()
|
const a = document.createElement('a'); a.href = url; a.download = 'interactions.xlsx'; a.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
loadArticleDomain()
|
await loadArticleDomain() // 先等域名加载完
|
||||||
load()
|
load()
|
||||||
window.addEventListener('page-refresh', load)
|
window.addEventListener('page-refresh', load)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user