Skip to content

Commit

Permalink
[bug] fix film tag show is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed Feb 16, 2025
1 parent 89c184b commit 9e22fea
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 35 deletions.
14 changes: 9 additions & 5 deletions src/renderer/src/pages/film/components/Detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
</div>
<div class="right">
<div class="info">
<p class="name txthide">{{ infoConf.vod_name }}</p>
<p class="title txthide">{{ infoConf.vod_name }}</p>
<p class="info-item txthide">
<span class="label">{{ $t('pages.film.info.release') }}: {{ infoConf?.vod_year || $t('pages.film.info.unknown') }}</span>
<span class="name">{{ $t('pages.film.info.release') }}: </span>
<span class="role">{{ formatContent(infoConf?.vod_year) || $t('pages.film.info.unknown') }}</span>
</p>
<p class="info-item txthide">
<span class="label">{{ $t('pages.film.info.type') }}: {{ infoConf?.type_name || $t('pages.film.info.unknown') }}</span>
<span class="name">{{ $t('pages.film.info.type') }}: </span>
<span class="role">{{ formatContent(infoConf?.type_name) || $t('pages.film.info.unknown') }}</span>
</p>
<p class="info-item txthide">
<span class="label">{{ $t('pages.film.info.area') }}: {{ infoConf?.vod_area || $t('pages.film.info.unknown') }}</span>
<span class="name">{{ $t('pages.film.info.area') }}: </span>
<span class="role">{{ formatContent(infoConf?.vod_area) || $t('pages.film.info.unknown') }}</span>
</p>
</div>
<div class="add-box" @click="putBinge(false)">
Expand Down Expand Up @@ -112,6 +115,7 @@ import {
reverseOrderHelper,
formatName,
formatIndex,
formatContent,
formatSeason,
formatReverseOrder
} from '@/utils/common/film';
Expand Down Expand Up @@ -501,7 +505,7 @@ const setup = async () => {
}
.info {
.name {
.title {
margin-bottom: var(--td-comp-margin-s);
color: var(--td-text-color-primary);
font-weight: 700;
Expand Down
22 changes: 11 additions & 11 deletions src/renderer/src/pages/play/componets/AsideFilm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
{{ info['vod_score'] ? info['vod_score'] : '0.0' }}
</span>
<t-divider layout="vertical" v-show="info['type_name']" />
<span v-show="info['type_name']" class="txthide">{{ info['type_name'] }}</span>
<span v-show="info['type_name']" class="txthide">{{ formatContent(info['type_name']) }}</span>
<t-divider layout="vertical" v-show="info['vod_area']" />
<span v-show="info['vod_area']" class="txthide">{{ info['vod_area'] }}</span>
<span v-show="info['vod_area']" class="txthide">{{ formatContent(info['vod_area']) }}</span>
<t-divider layout="vertical" v-show="info['vod_year']" />
<span v-show="info['vod_year']" class="txthide">{{ info['vod_year'] }}</span>
<span v-show="info['vod_year']" class="txthide">{{ formatContent(info['vod_year']) }}</span>
</div>
<div class="function">
<div class="func-item like" @click="putBinge(false)">
Expand Down Expand Up @@ -157,27 +157,27 @@
/>
</div>
<div class="content">
<div class="name">{{ info['vod_name'] }}</div>
<div class="type">{{ info['type_name'] }}</div>
<div class="num">{{ info['vod_remarks'] }}</div>
<div class="name" v-show="info['vod_name']">{{ formatContent(info['vod_name']) || $t('pages.film.info.unknown') }}</div>
<div class="type" v-show="info['type_name']">{{ formatContent(info['type_name']) }}</div>
<div class="num" v-show="info['vod_remarks']">{{ formatContent(info['vod_remarks']) }}</div>
</div>
</div>
<div class="background">
<div class="title">{{ $t('pages.player.film.background') }} </div>
<div class="content">
<span class="txt" v-html="formatContent(info['vod_content'], '简介')"></span>
<span class="txt" v-html="formatContent(info['vod_content']) || $t('pages.film.info.unknown')"></span>
</div>
</div>
<div class="case">
<div class="title">{{ $t('pages.player.film.actors') }}</div>
<div class="content">
<div v-show="info['vod_director']">
<div class="director">
<span class="name">{{ $t('pages.player.film.director') }}: </span>
<span class="role">{{ formatContent(info['vod_director'], '导演') }}</span>
<span class="role">{{ formatContent(info['vod_director']) || $t('pages.film.info.unknown') }}</span>
</div>
<div v-show="info['vod_actor']">
<div class="actor">
<span class="name">{{ $t('pages.player.film.actor') }}: </span>
<span class="role">{{ formatContent(info['vod_actor'], '主演') }}</span>
<span class="role">{{ formatContent(info['vod_actor']) || $t('pages.film.info.unknown') }}</span>
</div>
</div>
</div>
Expand Down
49 changes: 30 additions & 19 deletions src/renderer/src/utils/common/film.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,27 +385,38 @@ const formatIndex = (item: string): { index: string; url: string } => {
* @param keyword 关键字
* @returns 文本
*/
const formatContent = (text: string | undefined | null, keyword: string): string => {
const formatContent = (text: string | undefined | null): string => {
if (!text) return '';
let res = text;
// 创建一个正则表达式来匹配关键字后面的内容
const regex = new RegExp(`${keyword}[::]\\s*([^\\n]+)`, 'i');
// 执行匹配
const match = text.match(regex);

// 如果匹配成功,清理并返回结果
if (match && match[1]) {
// 去除可能的多余空格和换行符,并分割成数组
const names = match[1]
.split(/,\s*/)
.map((name) => name.trim())
.filter((name) => name);
res = names.join(' ');
} else {
// 如果没有匹配到关键字,返回空字符串
res = '';
text = text.trim();

const retainTextMap = [
'年份', '年代', '上映',
'地区', '类型', '语言', '更新', '更新至', '评分',
'导演', '编剧', '主演', '演员',
'简介', '背景', '详情',
'片长', '状态', '播放', '集数', '标签', '更新至',
];
const retainCharMap = [':', ':', ' '];

// 遍历关键词,处理匹配的文本
for (const keyword of retainTextMap) {
if (text.startsWith(keyword)) {
const remainingText = text.slice(keyword.length).trim();
for (const char of retainCharMap) {
if (remainingText.startsWith(char)) {
text = remainingText.slice(char.length).trim();
break;
}
}
break;
}
}
return res.replace(/style\s*?=\s*?(["])[\s\S]*?\1/gi, '');

if (text.startsWith('/') || text.endsWith('/')) {
text = text.split('/').filter(Boolean).join(' | ');
}

return text;
};

/**
Expand Down

0 comments on commit 9e22fea

Please sign in to comment.