Skip to content

Commit

Permalink
[change] i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed Jun 3, 2024
1 parent 54b7adf commit dd5ef41
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 53 deletions.
33 changes: 24 additions & 9 deletions src/renderer/src/locales/lang/en_US/pages/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ export default {
recommend: 'Recommend',
actors: 'ActingStaff',
director: 'Director',
actor: 'Actor'
actor: 'Actor',
},
iptv: {
epg: 'EPG',
channel: 'Channel'
channel: 'Channel',
},
drive: {
anthology: 'Anthology'
anthology: 'Anthology',
},
status: {
unplay: 'unplay',
played: 'played',
playing: 'play'
playing: 'play',
},
infiniteLoading: {
complete: 'load complete',
Expand All @@ -38,10 +38,10 @@ export default {
official: 'Analyze completed, data is derived from {0}',
noDefaultAnalyze: 'Not set default, Choose your own analysis line',
noRecommendSearch: 'No recommendation found for this source, Switch is not performed',
next: 'One moment, Switching next'
next: 'One moment, Switching next',
},
placeholder: {
analyze: 'AnalyzeApi'
analyze: 'AnalyzeApi',
},
setting: {
title: 'Setting',
Expand All @@ -51,6 +51,21 @@ export default {
skipEnd: 'End',
skipSeconds: 'S',
skipAd: 'Skip ads',
tip: 'The switch takes effect globally.'
}
}
tip: 'The switch takes effect globally.',
},
download: {
title: 'Offline Cache',
copy: 'Copy Link',
copyCurrentUrl: 'Copy Current Link',
recommendDownloaderName: 'M3U8-Downloader',
recommendDownloaderTip: 'Recommend downloader',
statusAwaitDownload: 'To be',
statusRequireDownload: 'Need',
soureceSelect: 'Please select',
copySuccess: 'Copy success, quick download to the downloader',
copyFail: 'Copy failed, the current environment does not support one-click copying',
copyEmpty: 'Please select what you want to download first',
copyError: 'The current environment does not support one-click copy, please copy the link manually',
copyCheck: 'Currently copied content may require sniffing',
},
};
25 changes: 20 additions & 5 deletions src/renderer/src/locales/lang/zh_CN/pages/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
recommend: '猜你喜欢',
actors: '演职员',
director: '导演',
actor: '主演'
actor: '主演',
},
iptv: {
epg: '节目',
Expand All @@ -38,10 +38,10 @@ export default {
sniiferError: '嗅探失败,请换源',
noDefaultAnalyze: '未配置默认解析,自行选择解析线路',
noRecommendSearch: '该源未找到相关推荐,不执行本次切换',
next: '请稍候,正在切换下集'
next: '请稍候,正在切换下集',
},
placeholder: {
analyze: '解析接口'
analyze: '解析接口',
},
setting: {
title: '设置',
Expand All @@ -51,6 +51,21 @@ export default {
skipEnd: '结束',
skipSeconds: '秒',
skipAd: '跳广告',
tip: '开关全局生效'
}
tip: '开关全局生效',
},
download: {
title: '离线缓存',
copy: '复制链接',
copyCurrentUrl: '复制当前地址',
recommendedDownloaderName: 'M3U8-Downloader',
recommendedDownloaderTip: '推荐使用开源下载器',
statusAwaitDownload: '待下载',
statusRequireDownload: '需下载',
soureceSelect: '请选下载源',
copySuccess: '复制成功,快到下载器里下载吧',
copyFail: '复制失败,当前环境不支持一键复制',
copyEmpty: '请先选择需要下载的内容',
copyError: '当前环境不支持一键复制, 请手动复制链接',
copyCheck: '当前复制的内容可能需要嗅探',
},
};
66 changes: 27 additions & 39 deletions src/renderer/src/pages/play/componets/DialogDownload.vue
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
<template>
<t-dialog
v-model:visible="formVisible"
header="离线缓存"
width="508"
placement="center"
confirm-btn="复制下载链接"
:on-confirm="copyDownloadUrl"
:cancel-btn="null"
>
<t-dialog v-model:visible="formVisible" :header="$t('pages.player.download.title')" width="508" placement="center"
:confirm-btn="$t('pages.player.download.copy')" :on-confirm="copyDownloadUrl" :cancel-btn="null">
<template #body>
<div class="download-warp">
<div class="source-warp">
<t-select
v-model="downloadSource"
placeholder="请选下载源"
size="small"
style="width: 200px; display: inline-block"
@change="downloadSourceChange"
>
<t-select v-model="downloadSource" :placeholder="$t('pages.player.download.soureceSelect')" size="small"
style="width: 200px; display: inline-block" @change="downloadSourceChange">
<t-option v-for="(_, key) in formData.season" :key="key" :value="key">{{ key }}</t-option>
</t-select>
<t-button size="small" theme="default" @click="copyCurrentUrl">复制当前地址</t-button>
<!-- <div>仅支持后缀为m3u8、flv、mp4</div> -->
<t-button size="small" theme="default" @click="copyCurrentUrl">{{ $t('pages.player.download.copyCurrentUrl')
}}</t-button>
</div>
<div class="content-warp">
<t-transfer v-model="downloadTarget" :data="downloadEpisodes">
<template #title="props">
<div>{{ props.type === 'target' ? '需下载' : '待下载' }}</div>
<div>{{ props.type === 'target' ? $t('pages.player.download.statusAwaitDownload') :
$t('pages.player.download.statusRequireDownload') }}</div>
</template>
</t-transfer>
</div>
<div class="tip-warp">
<span>推荐使用开源下载器:</span>
<t-link
theme="primary"
underline
href="https://github.com/HeiSir2014/M3U8-Downloader/releases/"
target="_blank"
>
M3U8-Downloader
<span>{{ $t('pages.player.download.recommendDownloaderTip') }}</span>
<t-link theme="primary" underline href="https://github.com/HeiSir2014/M3U8-Downloader/releases/"
target="_blank">
{{ $t('pages.player.download.recommendDownloaderName') }}
</t-link>
</div>
</div>
Expand All @@ -49,9 +34,12 @@
<script setup lang="ts">
import { useClipboard } from '@vueuse/core';
import _ from 'lodash';
import { reactive, ref, watch } from 'vue';
import { ref, watch } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next';
import { t } from '@/locales';
import { supportedFormats } from '@/utils/tool';
const props = defineProps({
visible: {
type: Boolean,
Expand Down Expand Up @@ -98,11 +86,10 @@ watch(
// 检查复制的复制
const checkDownloadUrl = (url) => {
const allowedExtensions = ['m3u8', 'flv', 'mp4'];
const urlExtension = url.match(/\.([^.]+)$/)?.[1]; // 使用正则表达式提取文件扩展名
const isValid = urlExtension && allowedExtensions.includes(urlExtension); // 检查是否在允许的扩展名列表中
const isValid = urlExtension && supportedFormats.includes(urlExtension); // 检查是否在允许的扩展名列表中
if (!isValid) MessagePlugin.warning('注意: 当前选择非m3u8/flv/mp4播放源');
if (!isValid) MessagePlugin.warning(t('pages.player.download.copyCheck'));
};
// 复制到剪贴板
Expand All @@ -114,7 +101,7 @@ const copyToClipboard = (content, successMessage, errorMessage) => {
// 复制下载地址列表
const downloadSourceChange = () => {
const list = [];
const list: any = [];
for (const item of formData.value.season[downloadSource.value]) {
const [index, url] = item.split('$');
list.push({
Expand All @@ -132,21 +119,21 @@ const copyDownloadUrl = () => {
if (firstUrl) {
const downloadUrl = downloadTarget.value.join('\n');
const successMessage = '复制成功,快到下载器里下载吧!';
const errorMessage = '复制失败,当前环境不支持一键复制!';
const successMessage = t('pages.player.download.copySuccess');
const errorMessage = t('pages.player.download.copyFail');
checkDownloadUrl(firstUrl);
copyToClipboard(downloadUrl, successMessage, errorMessage);
formVisible.value = false;
} else {
MessagePlugin.warning('请先选择需要下载的内容!');
MessagePlugin.warning(t('pages.player.download.copyEmpty'));
}
};
// 复制当前播放地址
const copyCurrentUrl = () => {
const successMessage = '复制成功, 请使用第三方软件!';
const errorMessage = '当前环境不支持一键复制,请手动复制链接!';
const successMessage = t('pages.player.download.copySuccess');
const errorMessage = t('pages.player.download.copyError');
copyToClipboard(formData.value.current, successMessage, errorMessage);
checkDownloadUrl(formData.value.current);
Expand All @@ -168,6 +155,7 @@ const copyCurrentUrl = () => {
.content-warp {
margin: var(--td-comp-margin-s) 0;
:deep(.t-button + .t-button) {
margin-left: 0 !important;
}
Expand Down Expand Up @@ -228,7 +216,7 @@ const copyCurrentUrl = () => {
border: var(--td-size-1) solid transparent;
}
&__list-header + :not(.t-transfer__list--with-search) {
&__list-header+ :not(.t-transfer__list--with-search) {
border-top: 1px solid var(--td-border-level-1-color);
}
Expand Down

0 comments on commit dd5ef41

Please sign in to comment.