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

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
+4 -1
View File
@@ -726,6 +726,7 @@ export default {
filterEdition: 'Edition', filterEdition: 'Edition',
filterResolution: 'Resolution', filterResolution: 'Resolution',
filterReleaseGroup: 'Release Group', filterReleaseGroup: 'Release Group',
noMatchingResults: 'No matching data',
}, },
calendar: { calendar: {
episode: 'Episode {number}', episode: 'Episode {number}',
@@ -792,6 +793,7 @@ export default {
}, },
site: { site: {
noSites: 'No Sites', noSites: 'No Sites',
noFilterData: 'No matching sites found',
sitesWillBeShownHere: 'Added and supported sites will be displayed here.', sitesWillBeShownHere: 'Added and supported sites will be displayed here.',
title: 'Site', title: 'Site',
status: { status: {
@@ -1120,7 +1122,8 @@ export default {
downloadAdded: 'Download Added', downloadAdded: 'Download Added',
subscribeAdded: 'Subscribe Added', subscribeAdded: 'Subscribe Added',
subscribeComplete: 'Subscribe Complete', subscribeComplete: 'Subscribe Complete',
templateConfig: 'Template Configuration', templateConfigTitle: 'Message Template',
templateConfigDesc: 'Set message template, support Jinja2 syntax.',
templateSaveFailed: 'Failed to save template!', templateSaveFailed: 'Failed to save template!',
templateSaveSuccess: 'Template saved successfully', templateSaveSuccess: 'Template saved successfully',
templateLoadFailed: 'Failed to load template!', templateLoadFailed: 'Failed to load template!',
+6 -3
View File
@@ -723,6 +723,7 @@ export default {
filterEdition: '质量', filterEdition: '质量',
filterResolution: '分辨率', filterResolution: '分辨率',
filterReleaseGroup: '制作组', filterReleaseGroup: '制作组',
noMatchingResults: '没有数据',
}, },
calendar: { calendar: {
episode: '第{number}集', episode: '第{number}集',
@@ -790,6 +791,7 @@ export default {
site: { site: {
noSites: '没有站点', noSites: '没有站点',
sitesWillBeShownHere: '已添加并支持的站点将会在这里显示。', sitesWillBeShownHere: '已添加并支持的站点将会在这里显示。',
noFilterData: '没有符合条件的站点',
title: '站点', title: '站点',
status: { status: {
enabled: '启用', enabled: '启用',
@@ -1106,9 +1108,10 @@ export default {
channelsDesc: '设置消息发送渠道参数。', channelsDesc: '设置消息发送渠道参数。',
organizeSuccess: '资源入库', organizeSuccess: '资源入库',
downloadAdded: '资源下载', downloadAdded: '资源下载',
subscribeAdded: '订阅添加', subscribeAdded: '添加订阅',
subscribeComplete: '订阅完成', subscribeComplete: '订阅完成',
templateConfig: '模板格式配置', templateConfigTitle: '通知模板',
templateConfigDesc: '设置通知模板,支持Jinja2语法。',
templateSaveFailed: '模板保存失败!', templateSaveFailed: '模板保存失败!',
templateSaveSuccess: '模板保存成功', templateSaveSuccess: '模板保存成功',
templateLoadFailed: '模板加载失败!', templateLoadFailed: '模板加载失败!',
@@ -1869,7 +1872,7 @@ export default {
renamingAll: '正在重命名 {path} 及目录内所有文件...', renamingAll: '正在重命名 {path} 及目录内所有文件...',
close: '关闭', close: '关闭',
loadingDirectoryStructure: '加载目录结构...', loadingDirectoryStructure: '加载目录结构...',
reorganize: '重新整理', reorganize: '整理',
}, },
person: { person: {
alias: '别名:', alias: '别名:',
+5 -2
View File
@@ -724,6 +724,7 @@ export default {
filterEdition: '质量', filterEdition: '质量',
filterResolution: '分辨率', filterResolution: '分辨率',
filterReleaseGroup: '製作組', filterReleaseGroup: '製作組',
noMatchingResults: '沒有數據',
}, },
calendar: { calendar: {
episode: '第{number}集', episode: '第{number}集',
@@ -791,6 +792,7 @@ export default {
}, },
site: { site: {
noSites: '沒有站點', noSites: '沒有站點',
noFilterData: '沒有符合條件的站點',
sitesWillBeShownHere: '已添加並支持的站點將會在這裡顯示。', sitesWillBeShownHere: '已添加並支持的站點將會在這裡顯示。',
title: '站點', title: '站點',
status: { status: {
@@ -1108,9 +1110,10 @@ export default {
channelsDesc: '設置消息發送渠道參數。', channelsDesc: '設置消息發送渠道參數。',
organizeSuccess: '資源入庫', organizeSuccess: '資源入庫',
downloadAdded: '資源下載', downloadAdded: '資源下載',
subscribeAdded: '訂閱添加', subscribeAdded: '添加訂閱',
subscribeComplete: '訂閱完成', subscribeComplete: '訂閱完成',
templateConfig: '消息模板配置', templateConfigTitle: '通知模板',
templateConfigDesc: '設置通知模板,支持Jinja2語法。',
templateSaveFailed: '模板保存失敗!', templateSaveFailed: '模板保存失敗!',
templateSaveSuccess: '模板保存成功', templateSaveSuccess: '模板保存成功',
templateLoadFailed: '模板載入失敗!', templateLoadFailed: '模板載入失敗!',
@@ -7,6 +7,7 @@ import NotificationChannelCard from '@/components/cards/NotificationChannelCard.
import ProgressDialog from '@/components/dialog/ProgressDialog.vue' import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { notificationSwitchDict } from '@/api/constants' import { notificationSwitchDict } from '@/api/constants'
import { useTheme } from 'vuetify'
// 国际化 // 国际化
const { t } = useI18n() const { t } = useI18n()
@@ -16,29 +17,35 @@ const templateConfigs = ref<Record<string, string>>({
organizeSuccess: '{}', organizeSuccess: '{}',
downloadAdded: '{}', downloadAdded: '{}',
subscribeAdded: '{}', subscribeAdded: '{}',
subscribeComplete: '{}' subscribeComplete: '{}',
}) })
// 模板类型配置 // 模板类型配置
const templateTypes = ref([ const templateTypes = ref([
{ {
type: 'organizeSuccess', type: 'organizeSuccess',
label: t('setting.notification.organizeSuccess') label: t('setting.notification.organizeSuccess'),
}, },
{ {
type: 'downloadAdded', type: 'downloadAdded',
label: t('setting.notification.downloadAdded') label: t('setting.notification.downloadAdded'),
}, },
{ {
type: 'subscribeAdded', type: 'subscribeAdded',
label: t('setting.notification.subscribeAdded') label: t('setting.notification.subscribeAdded'),
}, },
{ {
type: 'subscribeComplete', 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[]>([]) const notifications = ref<NotificationConf[]>([])
@@ -153,7 +160,7 @@ async function saveTemplate() {
try { try {
await api.post('system/setting/NotificationTemplates', { await api.post('system/setting/NotificationTemplates', {
...templateConfigs.value, ...templateConfigs.value,
[currentTemplate.value]: editorContent.value [currentTemplate.value]: editorContent.value,
}) })
$toast.success(t('setting.notification.templateSaveSuccess')) $toast.success(t('setting.notification.templateSaveSuccess'))
editorVisible.value = false editorVisible.value = false
@@ -286,7 +293,7 @@ onMounted(() => {
<VBtn mtype="submit" @click="saveNotificationSetting"> {{ t('common.save') }} </VBtn> <VBtn mtype="submit" @click="saveNotificationSetting"> {{ t('common.save') }} </VBtn>
<VBtn color="success" variant="tonal"> <VBtn color="success" variant="tonal">
<VIcon icon="mdi-plus" /> <VIcon icon="mdi-plus" />
<VMenu activator="parent" close-on-content-click> <VMenu :activator="'parent'" :close-on-content-click="true">
<VList> <VList>
<VListItem @click="addNotification('wechat')"> <VListItem @click="addNotification('wechat')">
<VListItemTitle>{{ t('setting.notification.wechat') }}</VListItemTitle> <VListItemTitle>{{ t('setting.notification.wechat') }}</VListItemTitle>
@@ -315,33 +322,46 @@ onMounted(() => {
</VCard> </VCard>
</VCol> </VCol>
</VRow> </VRow>
<VCard> <VRow>
<VCardItem> <VCol cols="12">
<VCardTitle>{{ t('setting.notification.templateConfig') }}</VCardTitle> <VCard>
</VCardItem> <VCardItem>
<VCardText> <VCardTitle>{{ t('setting.notification.templateConfigTitle') }}</VCardTitle>
<VRow> <VCardSubtitle>{{ t('setting.notification.templateConfigDesc') }}</VCardSubtitle>
<VCol </VCardItem>
v-for="item in templateTypes" <VCardText>
:key="item.type" <VRow>
cols="12" <VCol v-for="item in templateTypes" :key="item.type" cols="12" sm="6" md="3">
sm="6" <VCard variant="tonal" class="template-card" :class="{ 'on-hover': true }" @click="openEditor(item.type)">
lg="3" <VCardItem>
> <template #prepend>
<VCard <VAvatar color="primary" variant="tonal" rounded size="42" class="me-3">
variant="tonal" <VIcon
@click="openEditor(item.type)" size="24"
> :icon="
<VCardText> item.type === 'organizeSuccess'
<div class="text-h6 align-center"> ? 'mdi-folder-check'
{{ item.label }} : item.type === 'downloadAdded'
</div> ? 'mdi-download'
</VCardText> : item.type === 'subscribeAdded'
</VCard> ? 'mdi-rss'
</VCol> : 'mdi-check-circle'
</VRow> "
</VCardText> />
</VCard> </VAvatar>
</template>
<VCardTitle>{{ item.label }}</VCardTitle>
<template #append>
<VIcon icon="mdi-chevron-right" />
</template>
</VCardItem>
</VCard>
</VCol>
</VRow>
</VCardText>
</VCard>
</VCol>
</VRow>
<VRow> <VRow>
<VCol cols="12"> <VCol cols="12">
<VCard> <VCard>
@@ -418,29 +438,27 @@ onMounted(() => {
:indeterminate="true" :indeterminate="true"
/> />
<!-- 模板编辑器对话框 --> <!-- 模板编辑器对话框 -->
<VDialog v-model="editorVisible" max-width="800"> <VDialog v-model="editorVisible" v-if="editorVisible" max-width="50rem">
<VCard> <VCard>
<VCardTitle>{{ templateTypes.find(t => t.type === currentTemplate)?.label }}</VCardTitle> <VCardItem>
<VCardText> <VCardTitle>{{ templateTypes.find(t => t.type === currentTemplate)?.label }}消息模板</VCardTitle>
<VAceEditor <VDialogCloseBtn @click="editorVisible = false" />
v-model:value="editorContent" </VCardItem>
lang="json" <VCardText class="py-0">
theme="monokai" <VAceEditor
style="block-size: 30rem" v-model:value="editorContent"
class="rounded" lang="json"
/> :theme="editorTheme"
</VCardText> class="w-full min-h-[30rem] rounded"
<VCardActions> />
<VSpacer /> </VCardText>
<VBtn color="primary" @click="saveTemplate"> <VCardActions class="mx-auto pt-3">
{{ t('common.save') }} <VBtn variant="elevated" color="primary" @click="saveTemplate" prepend-icon="mdi-content-save" class="px-5">
</VBtn> {{ t('common.save') }}
<VBtn @click="editorVisible = false"> </VBtn>
{{ t('common.cancel') }} </VCardActions>
</VBtn> </VCard>
</VCardActions> </VDialog>
</VCard>
</VDialog>
</template> </template>
<style scoped> <style scoped>
/* Monaco编辑器容器样式 */ /* Monaco编辑器容器样式 */
@@ -450,4 +468,13 @@ onMounted(() => {
overflow: hidden; overflow: hidden;
margin-top: 1rem; 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>