更新国际化文件,添加消息模板相关文本,并优化模板编辑器界面

This commit is contained in:
jxxghp
2025-05-05 20:31:15 +08:00
parent 6d789ed73b
commit 3f4165e4b1
4 changed files with 104 additions and 68 deletions

View File

@@ -726,6 +726,7 @@ export default {
filterEdition: 'Edition',
filterResolution: 'Resolution',
filterReleaseGroup: 'Release Group',
noMatchingResults: 'No matching data',
},
calendar: {
episode: 'Episode {number}',
@@ -792,6 +793,7 @@ export default {
},
site: {
noSites: 'No Sites',
noFilterData: 'No matching sites found',
sitesWillBeShownHere: 'Added and supported sites will be displayed here.',
title: 'Site',
status: {
@@ -1120,7 +1122,8 @@ export default {
downloadAdded: 'Download Added',
subscribeAdded: 'Subscribe Added',
subscribeComplete: 'Subscribe Complete',
templateConfig: 'Template Configuration',
templateConfigTitle: 'Message Template',
templateConfigDesc: 'Set message template, support Jinja2 syntax.',
templateSaveFailed: 'Failed to save template!',
templateSaveSuccess: 'Template saved successfully',
templateLoadFailed: 'Failed to load template!',

View File

@@ -723,6 +723,7 @@ export default {
filterEdition: '质量',
filterResolution: '分辨率',
filterReleaseGroup: '制作组',
noMatchingResults: '没有数据',
},
calendar: {
episode: '第{number}集',
@@ -790,6 +791,7 @@ export default {
site: {
noSites: '没有站点',
sitesWillBeShownHere: '已添加并支持的站点将会在这里显示。',
noFilterData: '没有符合条件的站点',
title: '站点',
status: {
enabled: '启用',
@@ -1106,9 +1108,10 @@ export default {
channelsDesc: '设置消息发送渠道参数。',
organizeSuccess: '资源入库',
downloadAdded: '资源下载',
subscribeAdded: '订阅添加',
subscribeAdded: '添加订阅',
subscribeComplete: '订阅完成',
templateConfig: '模板格式配置',
templateConfigTitle: '通知模板',
templateConfigDesc: '设置通知模板支持Jinja2语法。',
templateSaveFailed: '模板保存失败!',
templateSaveSuccess: '模板保存成功',
templateLoadFailed: '模板加载失败!',
@@ -1869,7 +1872,7 @@ export default {
renamingAll: '正在重命名 {path} 及目录内所有文件...',
close: '关闭',
loadingDirectoryStructure: '加载目录结构...',
reorganize: '重新整理',
reorganize: '整理',
},
person: {
alias: '别名:',

View File

@@ -724,6 +724,7 @@ export default {
filterEdition: '质量',
filterResolution: '分辨率',
filterReleaseGroup: '製作組',
noMatchingResults: '沒有數據',
},
calendar: {
episode: '第{number}集',
@@ -791,6 +792,7 @@ export default {
},
site: {
noSites: '沒有站點',
noFilterData: '沒有符合條件的站點',
sitesWillBeShownHere: '已添加並支持的站點將會在這裡顯示。',
title: '站點',
status: {
@@ -1108,9 +1110,10 @@ export default {
channelsDesc: '設置消息發送渠道參數。',
organizeSuccess: '資源入庫',
downloadAdded: '資源下載',
subscribeAdded: '訂閱添加',
subscribeAdded: '添加訂閱',
subscribeComplete: '訂閱完成',
templateConfig: '消息模板配置',
templateConfigTitle: '通知模板',
templateConfigDesc: '設置通知模板支持Jinja2語法。',
templateSaveFailed: '模板保存失敗!',
templateSaveSuccess: '模板保存成功',
templateLoadFailed: '模板載入失敗!',

View File

@@ -7,6 +7,7 @@ import NotificationChannelCard from '@/components/cards/NotificationChannelCard.
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import { useI18n } from 'vue-i18n'
import { notificationSwitchDict } from '@/api/constants'
import { useTheme } from 'vuetify'
// 国际化
const { t } = useI18n()
@@ -16,29 +17,35 @@ const templateConfigs = ref<Record<string, string>>({
organizeSuccess: '{}',
downloadAdded: '{}',
subscribeAdded: '{}',
subscribeComplete: '{}'
subscribeComplete: '{}',
})
// 模板类型配置
const templateTypes = ref([
{
{
type: 'organizeSuccess',
label: t('setting.notification.organizeSuccess')
label: t('setting.notification.organizeSuccess'),
},
{
type: 'downloadAdded',
label: t('setting.notification.downloadAdded')
label: t('setting.notification.downloadAdded'),
},
{
{
type: 'subscribeAdded',
label: t('setting.notification.subscribeAdded')
label: t('setting.notification.subscribeAdded'),
},
{
{
type: 'subscribeComplete',
label: t('setting.notification.subscribeComplete')
}
label: t('setting.notification.subscribeComplete'),
},
])
// 编辑器主题
const { name: themeName, global: globalTheme } = useTheme()
const savedTheme = ref(localStorage.getItem('theme') ?? themeName)
const currentThemeName = ref(savedTheme.value)
const editorTheme = computed(() => (currentThemeName.value === 'light' ? 'github' : 'monokai'))
// 所有消息渠道
const notifications = ref<NotificationConf[]>([])
@@ -153,7 +160,7 @@ async function saveTemplate() {
try {
await api.post('system/setting/NotificationTemplates', {
...templateConfigs.value,
[currentTemplate.value]: editorContent.value
[currentTemplate.value]: editorContent.value,
})
$toast.success(t('setting.notification.templateSaveSuccess'))
editorVisible.value = false
@@ -286,7 +293,7 @@ onMounted(() => {
<VBtn mtype="submit" @click="saveNotificationSetting"> {{ t('common.save') }} </VBtn>
<VBtn color="success" variant="tonal">
<VIcon icon="mdi-plus" />
<VMenu activator="parent" close-on-content-click>
<VMenu :activator="'parent'" :close-on-content-click="true">
<VList>
<VListItem @click="addNotification('wechat')">
<VListItemTitle>{{ t('setting.notification.wechat') }}</VListItemTitle>
@@ -315,33 +322,46 @@ onMounted(() => {
</VCard>
</VCol>
</VRow>
<VCard>
<VCardItem>
<VCardTitle>{{ t('setting.notification.templateConfig') }}</VCardTitle>
</VCardItem>
<VCardText>
<VRow>
<VCol
v-for="item in templateTypes"
:key="item.type"
cols="12"
sm="6"
lg="3"
>
<VCard
variant="tonal"
@click="openEditor(item.type)"
>
<VCardText>
<div class="text-h6 align-center">
{{ item.label }}
</div>
</VCardText>
</VCard>
</VCol>
</VRow>
</VCardText>
</VCard>
<VRow>
<VCol cols="12">
<VCard>
<VCardItem>
<VCardTitle>{{ t('setting.notification.templateConfigTitle') }}</VCardTitle>
<VCardSubtitle>{{ t('setting.notification.templateConfigDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<VRow>
<VCol v-for="item in templateTypes" :key="item.type" cols="12" sm="6" md="3">
<VCard variant="tonal" class="template-card" :class="{ 'on-hover': true }" @click="openEditor(item.type)">
<VCardItem>
<template #prepend>
<VAvatar color="primary" variant="tonal" rounded size="42" class="me-3">
<VIcon
size="24"
:icon="
item.type === 'organizeSuccess'
? 'mdi-folder-check'
: item.type === 'downloadAdded'
? 'mdi-download'
: item.type === 'subscribeAdded'
? 'mdi-rss'
: 'mdi-check-circle'
"
/>
</VAvatar>
</template>
<VCardTitle>{{ item.label }}</VCardTitle>
<template #append>
<VIcon icon="mdi-chevron-right" />
</template>
</VCardItem>
</VCard>
</VCol>
</VRow>
</VCardText>
</VCard>
</VCol>
</VRow>
<VRow>
<VCol cols="12">
<VCard>
@@ -418,29 +438,27 @@ onMounted(() => {
:indeterminate="true"
/>
<!-- 模板编辑器对话框 -->
<VDialog v-model="editorVisible" max-width="800">
<VCard>
<VCardTitle>{{ templateTypes.find(t => t.type === currentTemplate)?.label }}</VCardTitle>
<VCardText>
<VAceEditor
v-model:value="editorContent"
lang="json"
theme="monokai"
style="block-size: 30rem"
class="rounded"
/>
</VCardText>
<VCardActions>
<VSpacer />
<VBtn color="primary" @click="saveTemplate">
{{ t('common.save') }}
</VBtn>
<VBtn @click="editorVisible = false">
{{ t('common.cancel') }}
</VBtn>
</VCardActions>
</VCard>
</VDialog>
<VDialog v-model="editorVisible" v-if="editorVisible" max-width="50rem">
<VCard>
<VCardItem>
<VCardTitle>{{ templateTypes.find(t => t.type === currentTemplate)?.label }}消息模板</VCardTitle>
<VDialogCloseBtn @click="editorVisible = false" />
</VCardItem>
<VCardText class="py-0">
<VAceEditor
v-model:value="editorContent"
lang="json"
:theme="editorTheme"
class="w-full min-h-[30rem] rounded"
/>
</VCardText>
<VCardActions class="mx-auto pt-3">
<VBtn variant="elevated" color="primary" @click="saveTemplate" prepend-icon="mdi-content-save" class="px-5">
{{ t('common.save') }}
</VBtn>
</VCardActions>
</VCard>
</VDialog>
</template>
<style scoped>
/* Monaco编辑器容器样式 */
@@ -450,4 +468,13 @@ onMounted(() => {
overflow: hidden;
margin-top: 1rem;
}
</style>
.template-card {
cursor: pointer;
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.template-card.on-hover:hover {
transform: translateY(-4px);
}
</style>