Compare commits

..

18 Commits

Author SHA1 Message Date
InfinityPacer
81ab3f9da8 fix(subscribe): show best version mode tag (#471) 2026-05-15 06:51:03 +08:00
Album
d520645a8b fix: keep manual reorganize preview visible on partial failures (#470) 2026-05-14 23:05:41 +08:00
jxxghp
af67fddce0 fix: ensure clear cache reloads page 2026-05-14 22:45:23 +08:00
Album
6d89dad8de fix: prevent duplicate manual reorganize requests in filtered directories (#469) 2026-05-14 21:13:46 +08:00
jxxghp
f3ab2a8eff feat: add collapsible section for AI agent settings to reduce visual clutter 2026-05-14 20:27:28 +08:00
jxxghp
74c980c7a5 feat: split agent audio input and output settings 2026-05-14 19:37:46 +08:00
jxxghp
52fc2557ec fix: refresh transfer history on activation 2026-05-14 18:15:08 +08:00
jxxghp
34124418f8 perf: optimize initial load by implementing lazy loading for modules and fine-tuning authentication/resource initialization logic. 2026-05-14 13:19:48 +08:00
jxxghp
e2d36da299 refactor: invert background poster opacity logic to represent transparency percentage 2026-05-13 22:53:15 +08:00
jxxghp
9965428bae feat: add configurable opacity and blur settings for the transparent theme background 2026-05-13 22:34:12 +08:00
jxxghp
e62a0b5a8d refactor: optimize performance by centralizing state calculations and stabilizing virtual list data refs 2026-05-13 22:01:13 +08:00
Album
3c926f7485 refactor: remove redundant path cards from reorganize preview panel (#468) 2026-05-13 21:32:31 +08:00
DDSRem
de3f4e6374 feat: add wildcard glob support to file manager filter (#467) 2026-05-13 21:15:07 +08:00
jxxghp
2e22f6ae86 feat: virtualize media server dashboard grids 2026-05-13 21:08:59 +08:00
jxxghp
99665c7d79 feat: virtualize card grids 2026-05-13 19:07:46 +08:00
jxxghp
a4a00586c7 更新 package.json 2026-05-13 17:08:11 +08:00
jxxghp
cf59a07d4b feat: add full season upgrade option to TV subscription edit dialog 2026-05-13 15:55:50 +08:00
jxxghp
8a362d0740 fix: prevent SubscribeCard overflow by adding truncation and flex constraints to username and progress display 2026-05-13 14:51:13 +08:00
45 changed files with 2603 additions and 1274 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "moviepilot",
"version": "2.11.2",
"version": "2.11.3",
"private": true,
"type": "module",
"bin": "dist/service.js",

View File

@@ -264,6 +264,8 @@ const target = join(__dirname, 'icons-bundle.js');
console.log(`Saved ${target} (${bundle.length} bytes)`)
})().catch((err) => {
console.error(err)
// 构建图标失败时必须终止构建,避免继续发布上一次遗留的超大 icons-bundle。
process.exitCode = 1
})
async function collectUsedIcons(rootDir: string): Promise<string[]> {

View File

@@ -14,6 +14,8 @@ import PWAInstallPrompt from '@/components/PWAInstallPrompt.vue'
import { themeManager } from '@/utils/themeManager'
import { configureApexChartsTheme } from '@/utils/apexCharts'
const LOGIN_WALLPAPER_ROUTE = '/login'
// 生效主题
const { global: globalTheme } = useTheme()
let themeValue = localStorage.getItem('theme') || 'auto'
@@ -37,6 +39,7 @@ setI18nLanguage(localeValue as SupportedLocale)
// 检查是否登录
const authStore = useAuthStore()
const isLogin = computed(() => authStore.token)
const route = useRoute()
// 全局设置store
const globalSettingsStore = useGlobalSettingsStore()
@@ -48,6 +51,32 @@ const loginStateKey = computed(() => (isLogin.value ? 'logged-in' : 'logged-out'
const backgroundImages = ref<string[]>([])
const activeImageIndex = ref(0)
const isTransparentTheme = computed(() => globalTheme.name.value === 'transparent')
const shouldLoadBackgroundImages = computed(
() => (!isLogin.value && route.path === LOGIN_WALLPAPER_ROUTE) || (Boolean(isLogin.value) && isTransparentTheme.value),
)
let backgroundRetryTimer: number | null = null
let backgroundRequestController: AbortController | null = null
let authenticatedStateTimer: number | null = null
function getStoredNumber(key: string, fallback: number, min: number, max: number) {
const parsed = Number.parseFloat(localStorage.getItem(key) || '')
if (!Number.isFinite(parsed)) return fallback
return Math.min(max, Math.max(min, parsed))
}
function applyTransparentBackgroundSettings() {
document.documentElement.style.setProperty(
'--transparent-background-poster-opacity',
(1 - getStoredNumber('transparency-background-poster-opacity', 0, 0, 1)).toString(),
)
document.documentElement.style.setProperty(
'--transparent-background-blur',
`${getStoredNumber('transparency-background-blur', 16, 0, 30)}px`,
)
}
applyTransparentBackgroundSettings()
// 心跳检测
let heartbeatInterval: number | null = null
@@ -89,9 +118,10 @@ function updateHtmlThemeAttribute(themeName: string) {
// 获取背景图片
async function fetchBackgroundImages() {
try {
const controller = new AbortController()
backgroundRequestController?.abort()
backgroundRequestController = new AbortController()
backgroundImages.value = await api.get(`/login/wallpapers`, {
signal: controller.signal,
signal: backgroundRequestController.signal,
})
activeImageIndex.value = 0
} catch (e) {
@@ -133,6 +163,42 @@ function startBackgroundRotation() {
}
}
function stopBackgroundLoading() {
backgroundRequestController?.abort()
backgroundRequestController = null
if (backgroundRetryTimer) {
window.clearTimeout(backgroundRetryTimer)
backgroundRetryTimer = null
}
removeBackgroundTimer('background-rotation')
}
async function initializeAuthenticatedState() {
if (!isLogin.value) return
try {
globalLoadingStateManager.setLoadingState('global-settings', true)
await globalSettingsStore.initialize()
await globalSettingsStore.loadUserSettings()
} finally {
globalLoadingStateManager.setLoadingState('global-settings', false)
}
}
function scheduleAuthenticatedStateInitialization() {
if (authenticatedStateTimer) {
window.clearTimeout(authenticatedStateTimer)
}
// 登录后会立刻发生路由切换,稍后再拉取设置可避开导航中止请求。
authenticatedStateTimer = window.setTimeout(() => {
authenticatedStateTimer = null
initializeAuthenticatedState()
}, 150)
}
// 添加logo动画效果并延迟移除加载界面
function animateAndRemoveLoader() {
const loadingBg = document.querySelector('#loading-bg') as HTMLElement
@@ -155,8 +221,6 @@ async function removeLoadingWithStateCheck() {
try {
// 设置各个组件的加载状态
globalLoadingStateManager.setLoadingState('pwa-state', true)
globalLoadingStateManager.setLoadingState('global-settings', true)
globalLoadingStateManager.setLoadingState('background-images', true)
// 静默检查PWA状态恢复
const pwaController = (window as any).pwaStateController
@@ -165,22 +229,7 @@ async function removeLoadingWithStateCheck() {
}
globalLoadingStateManager.setLoadingState('pwa-state', false)
// 并行加载关键资源
await Promise.all([
globalSettingsStore.initialize().then(async () => {
// 如果已登录,加载用户相关设置
if (isLogin.value) {
await globalSettingsStore.loadUserSettings()
}
globalLoadingStateManager.setLoadingState('global-settings', false)
}),
new Promise(resolve => {
setTimeout(() => {
globalLoadingStateManager.setLoadingState('background-images', false)
resolve(void 0)
}, 50)
}),
])
await initializeAuthenticatedState()
// 等待所有加载完成
await globalLoadingStateManager.waitForAllComplete()
@@ -189,7 +238,9 @@ async function removeLoadingWithStateCheck() {
animateAndRemoveLoader()
// 检查未读消息
checkAndEmitUnreadMessages()
if (isLogin.value) {
checkAndEmitUnreadMessages()
}
} catch (error) {
// 即使出错也要移除加载界面
globalLoadingStateManager.reset()
@@ -208,7 +259,8 @@ async function loadBackgroundImages(retryCount = 0) {
if (retryCount < maxRetries) {
const baseDelay = isAbortError ? 1000 : 3000
const retryDelay = Math.min(baseDelay * Math.pow(2, retryCount), 10000)
setTimeout(() => {
backgroundRetryTimer = window.setTimeout(() => {
backgroundRetryTimer = null
loadBackgroundImages(retryCount + 1)
}, retryDelay)
}
@@ -244,20 +296,51 @@ onMounted(async () => {
},
)
// 加载背景图片
loadBackgroundImages()
// 登录页壁纸仅在未登录登录页需要,避免其他首屏额外发起图片列表请求。
watch(
shouldLoadBackgroundImages,
shouldLoad => {
stopBackgroundLoading()
if (shouldLoad) {
loadBackgroundImages()
} else if (!isTransparentTheme.value) {
backgroundImages.value = []
}
},
{ immediate: true },
)
// 使用优化后的加载界面移除逻辑
ensureRenderComplete(() => {
nextTick(removeLoadingWithStateCheck)
})
// 启动心跳
startHeartbeat()
if (isLogin.value) {
startHeartbeat()
}
// 登录状态可能在当前单页会话中变化,这里按需补齐登录后初始化和心跳。
watch(isLogin, loggedIn => {
if (loggedIn) {
startHeartbeat()
scheduleAuthenticatedStateInitialization()
} else {
if (authenticatedStateTimer) {
window.clearTimeout(authenticatedStateTimer)
authenticatedStateTimer = null
}
stopHeartbeat()
}
})
})
onUnmounted(() => {
// 清除背景轮换定时器
removeBackgroundTimer('background-rotation')
stopBackgroundLoading()
if (authenticatedStateTimer) {
window.clearTimeout(authenticatedStateTimer)
authenticatedStateTimer = null
}
// 停止心跳
stopHeartbeat()
})
@@ -266,7 +349,11 @@ onUnmounted(() => {
<template>
<div class="app-wrapper">
<!-- 透明主题背景 -->
<div v-if="backgroundImages.length > 0 && (isTransparentTheme || !isLogin)" class="background-container">
<div
v-if="backgroundImages.length > 0 && (isTransparentTheme || !isLogin)"
class="background-container"
:class="{ 'is-transparent-theme': isTransparentTheme && isLogin }"
>
<div
v-for="(imageUrl, index) in backgroundImages"
:key="`bg-${index}-${loginStateKey}`"
@@ -331,11 +418,15 @@ onUnmounted(() => {
}
}
.background-container.is-transparent-theme .background-image.active {
opacity: var(--transparent-background-poster-opacity, 1);
}
/* 全局磨砂层 */
.global-blur-layer {
position: absolute;
z-index: 1;
backdrop-filter: blur(16px);
backdrop-filter: blur(var(--transparent-background-blur, 16px));
background-color: rgba(128, 128, 128, 30%);
block-size: 100%;
inline-size: 100%;

View File

@@ -58,6 +58,8 @@ export interface Subscribe {
sites: number[]
// 是否洗版数字或者boolean
best_version: any
// 是否只洗全集整包数字或者boolean
best_version_full?: any
// 使用 imdbid 搜索
search_imdbid?: any
// 当前优先级

View File

@@ -1,10 +1,8 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import { copyToClipboard } from '@/@core/utils/navigator'
import { CustomRule, FilterRuleGroup } from '@/api/types'
import FilterRuleCard from '@/components/cards/FilterRuleCard.vue'
import { useToast } from 'vue-toastification'
import ImportCodeDialog from '@/components/dialog/ImportCodeDialog.vue'
import filter_group_svg from '@images/svg/filter-group.svg'
import { cloneDeep } from 'lodash-es'
import { useI18n } from 'vue-i18n'
@@ -16,6 +14,10 @@ const display = useDisplay()
// 获取i18n实例
const { t } = useI18n()
// 规则组详情弹窗内才需要拖拽和导入代码,避免规则组卡片列表首屏带入重交互依赖。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const ImportCodeDialog = defineAsyncComponent(() => import('@/components/dialog/ImportCodeDialog.vue'))
// 输入参数
const props = defineProps({
// 单个规则组
@@ -273,7 +275,7 @@ function onClose() {
</VRow>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="filterRuleCards"
handle=".cursor-move"
item-key="pri"
@@ -291,7 +293,7 @@ function onClose() {
@close="filterCardClose(element.pri)"
/>
</template>
</draggable>
</Draggable>
<div class="text-center" v-if="filterRuleCards.length == 0">{{ t('filterRule.add') }}</div>
</VCardText>
<VCardActions class="pt-3">

View File

@@ -11,13 +11,15 @@ import VersionHistory from '@/components/misc/VersionHistory.vue'
import ProgressDialog from '../dialog/ProgressDialog.vue'
import PluginConfigDialog from '../dialog/PluginConfigDialog.vue'
import PluginDataDialog from '../dialog/PluginDataDialog.vue'
import LoggingView from '@/views/system/LoggingView.vue'
import { useI18n } from 'vue-i18n'
import { useDisplay } from 'vuetify'
// 显示器宽度
const display = useDisplay()
// 插件日志面板只有点击“查看日志”时才需要,延后加载可减轻插件列表首屏。
const LoggingView = defineAsyncComponent(() => import('@/views/system/LoggingView.vue'))
// 输入参数
const props = defineProps({
plugin: Object as PropType<Plugin>,

View File

@@ -67,6 +67,25 @@ const subscribeState = ref<string>(props.media?.state ?? 'P')
// 上一次更新时间
const lastUpdateText = computed(() => (props.media?.last_update ? formatDateDifference(props.media.last_update) : ''))
// 判断后端数字/布尔开关是否启用
function isEnabledFlag(value: any) {
return value === true || value === 1 || value === '1'
}
// 订阅列表接口通常返回中文媒体类型,插件或缓存数据可能只保留剧集字段
function isTvSubscribe(media?: Subscribe) {
return media?.type === '电视剧' || media?.type === 'tv' || !!media?.season || !!media?.total_episode
}
// TV 洗版订阅在卡片上展示分集或全集短标签
const bestVersionModeLabel = computed(() => {
if (!isEnabledFlag(props.media?.best_version) || !isTvSubscribe(props.media)) return ''
return isEnabledFlag(props.media?.best_version_full)
? t('subscribe.bestVersionWholeShort')
: t('subscribe.bestVersionEpisodeShort')
})
// 图片加载完成响应
function imageLoadHandler() {
imageLoaded.value = true
@@ -408,8 +427,8 @@ function handleCardClick() {
</div>
</div>
</VCardText>
<VCardText class="flex justify-space-between align-center flex-wrap px-3">
<div class="flex align-center">
<VCardText class="flex min-w-0 justify-space-between align-center flex-wrap px-3">
<div class="flex min-w-0 max-w-full align-center">
<VIcon
v-if="props.media?.total_episode && props.sortable"
icon="mdi-progress-download"
@@ -424,13 +443,23 @@ function handleCardClick() {
icon="mdi-progress-download"
color="white"
/>
<div v-if="props.media?.season" class="text-subtitle-2 me-2 text-white">
<div v-if="props.media?.season" class="flex-shrink-0 text-subtitle-2 me-2 text-white">
{{ (props.media?.total_episode || 0) - (props.media?.lack_episode || 0) }} /
{{ props.media?.total_episode }}
</div>
<VIcon v-if="props.media?.username && props.sortable" icon="mdi-account" size="small" color="white" class="me-1" />
<IconBtn v-else-if="props.media?.username" icon="mdi-account" size="small" color="white" />
<span v-if="props.media?.username" class="text-subtitle-2 text-white">
<VChip
v-if="bestVersionModeLabel"
size="x-small"
color="primary"
variant="flat"
class="me-2 flex-shrink-0"
>
{{ bestVersionModeLabel }}
</VChip>
<VIcon v-if="props.media?.username && props.sortable" icon="mdi-account" size="small" color="white" class="flex-shrink-0 me-1" />
<IconBtn v-else-if="props.media?.username" icon="mdi-account" size="small" color="white" class="flex-shrink-0" />
<!-- 用户名过长时限制在卡片宽度内并用省略号展示剩余内容 -->
<span v-if="props.media?.username" class="min-w-0 truncate text-subtitle-2 text-white" :title="props.media?.username">
{{ props.media?.username }}
</span>
</div>

View File

@@ -123,10 +123,10 @@ onMounted(() => {
'transition-transform duration-300 hover:-translate-y-1',
!props.user.is_active ? 'opacity-85 bg-surface-lighten-1' : '',
]"
class="flex flex-column"
class="user-card flex flex-column h-full"
@click="userEditDialog = true"
>
<div class="flex-grow">
<div class="user-card__body flex-grow flex-grow-1">
<!-- 用户头像和基本信息 -->
<VCardItem :class="[user.is_superuser ? 'admin-header' : '']">
<template v-slot:prepend>
@@ -247,7 +247,7 @@ onMounted(() => {
</div>
<!-- 独立的邮箱显示 -->
<VDivider class="mx-4" />
<div>
<div class="user-card__footer">
<VCardText class="d-flex align-center py-2 px-4 text-medium-emphasis">
<VIcon icon="mdi-email-outline" size="small" color="primary" class="mr-2 opacity-70" />
<span class="text-body-2 truncate">{{ user.email || t('user.noEmail') }}</span>
@@ -308,6 +308,16 @@ onMounted(() => {
</template>
<style scoped>
.user-card {
block-size: 100%;
}
/* 让邮箱和订阅统计固定在卡片底部,保证同一行用户卡片视觉等高。 */
.user-card__footer {
flex-shrink: 0;
margin-block-start: auto;
}
.admin-decoration {
position: absolute;
z-index: 1;

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { formatDateDifference } from '@/@core/utils/formatters'
import api from '@/api'
import { clearCachesAndServiceWorker, reloadWithTimestamp } from '@/composables/useVersionChecker'
import { clearCacheAndReload } from '@/composables/useVersionChecker'
import MarkdownIt from 'markdown-it'
import mdLinkAttributes from 'markdown-it-link-attributes'
import { useI18n } from 'vue-i18n'
@@ -138,9 +138,7 @@ function releaseTime(releaseDate: string) {
// 强制清除缓存
async function clearCache() {
await clearCachesAndServiceWorker()
// 刷新页面,添加时间戳参数以强制更新
reloadWithTimestamp()
await clearCacheAndReload()
}
onMounted(() => {

View File

@@ -89,6 +89,27 @@ const previewLoaded = ref(false)
// 预览数据
const previewData = ref<ManualTransferPreviewData>()
function getFileItemKey(item?: FileItem) {
return [item?.storage ?? '', item?.type ?? '', item?.path ?? ''].join('|')
}
function dedupeFileItems(fileItems?: FileItem[]) {
if (!fileItems?.length) return []
const uniqueItems = new Map<string, FileItem>()
fileItems.forEach(item => {
uniqueItems.set(getFileItemKey(item), item)
})
return Array.from(uniqueItems.values())
}
function getPreviewItemKey(item: ManualTransferPreviewItem) {
return [item.source ?? '', item.target ?? '', item.success === false ? 'failed' : 'success'].join('|')
}
const normalizedItems = computed(() => dedupeFileItems(props.items))
// 分页
const previewPage = ref(1)
const previewPageSize = ref(10)
@@ -128,18 +149,21 @@ const dialogTitle = computed(() => {
// 副标题
const dialogSubtitle = computed(() => {
if (props.items) {
if (props.items.length > 1) return t('dialog.reorganize.multipleItemsTitle', { count: props.items.length })
return t('dialog.reorganize.singleItemTitle', { path: props.items[0].path })
if (normalizedItems.value.length) {
if (normalizedItems.value.length > 1) {
return t('dialog.reorganize.multipleItemsTitle', { count: normalizedItems.value.length })
}
return t('dialog.reorganize.singleItemTitle', { path: normalizedItems.value[0].path })
} else if (props.logids) {
return t('dialog.reorganize.multipleItemsTitle', { count: props.logids.length })
}
})
// 禁用指定集数
const disableEpisodeDetail = computed(() => {
if (props.items) {
if (normalizedItems.value.length) {
if (transferForm.episode_format) return false
return !(props.items.length === 1 && props.items[0].type !== 'dir')
return !(normalizedItems.value.length === 1 && normalizedItems.value[0].type !== 'dir')
}
})
@@ -249,39 +273,6 @@ function getFileName(path?: string) {
return normalizedPath.split('/').pop() || normalizedPath
}
// 获取目录路径
function getDirectoryPath(path?: string) {
const normalizedPath = normalizePath(path)
if (!normalizedPath) return ''
if (normalizedPath.endsWith('/')) return normalizedPath
const parts = normalizedPath.split('/')
parts.pop()
const joined = parts.join('/')
return joined ? `${joined}/` : '/'
}
// 计算公共路径
function getCommonPath(paths: string[]) {
const validPaths = paths.map(item => normalizePath(item)).filter(Boolean)
if (validPaths.length === 0) return ''
if (validPaths.length === 1) return validPaths[0]
const splitPaths = validPaths.map(path => path.split('/'))
const commonParts: string[] = []
for (let index = 0; index < splitPaths[0].length; index++) {
const part = splitPaths[0][index]
if (splitPaths.every(pathParts => pathParts[index] === part)) {
commonParts.push(part)
} else {
break
}
}
return commonParts.join('/') || '/'
}
// 获取唯一非空值
function getUniqueValues(values: (string | undefined)[]) {
return [...new Set(values.map(item => item?.trim()).filter(Boolean) as string[])]
@@ -324,18 +315,6 @@ function getPreviewSeasonNumber(item: ManualTransferPreviewItem) {
)
}
// 顶部原始路径
const previewSourcePath = computed(() => {
const paths = filteredPreviewItems.value.map(item => getDirectoryPath(item.source))
return getCommonPath(paths) || '-'
})
// 顶部目的路径
const previewTargetPath = computed(() => {
const targetDirs = filteredPreviewItems.value.map(item => item.target_dir || getDirectoryPath(item.target))
return getCommonPath(targetDirs) || '-'
})
// 顶部媒体信息
const previewMediaInfo = computed(() => {
const titles = getUniqueValues(filteredPreviewItems.value.map(item => item.title))
@@ -415,11 +394,7 @@ const previewFileRows = computed(() => {
// 是否需要拓宽窗口
const previewNeedsWideLayout = computed(() => {
const candidates = [
previewSourcePath.value,
previewTargetPath.value,
...previewFileRows.value.map(item => `${item.sourceName}${item.targetName}`),
]
const candidates = [...previewFileRows.value.map(item => `${item.sourceName}${item.targetName}`)]
return candidates.some(item => item.length > 72)
})
@@ -484,29 +459,56 @@ function previewHasFailures(data?: ManualTransferPreviewData) {
return (data.summary.failed ?? 0) > 0 || (data.items ?? []).some(item => item.success === false)
}
function getPreviewFailureMessage(data?: ManualTransferPreviewData) {
return (
data?.items.find(item => item.success === false)?.message ||
data?.message ||
t('dialog.reorganize.previewRequestFailed')
)
function getPreviewResultSummaryMessage(data?: ManualTransferPreviewData) {
const success = data?.summary.success ?? 0
const failed = data?.summary.failed ?? 0
return [
t('dialog.reorganize.previewSuccess', { count: success }),
t('dialog.reorganize.previewFailed', { count: failed }),
].join('')
}
function createFailedPreviewData(options: { source?: string; type?: string; title?: string; message?: string }) {
const failedItem: ManualTransferPreviewItem = {
source: options.source,
target: '',
success: false,
message: options.message || t('dialog.reorganize.previewRequestFailed'),
type: options.type,
title: options.title,
}
return {
summary: {
total: 1,
success: 0,
failed: 1,
},
items: [failedItem],
message: failedItem.message,
} satisfies ManualTransferPreviewData
}
// 合并多次预览结果
function mergePreviewData(target: ManualTransferPreviewData, incoming?: ManualTransferPreviewData) {
if (!incoming) return
const incomingItems = incoming.items ?? []
const incomingSummary = incoming.summary ?? {
total: incomingItems.length,
success: incomingItems.filter(item => item.success).length,
failed: incomingItems.filter(item => item.success === false).length,
}
const mergedItems = [...(target.items ?? [])]
const existingItemKeys = new Set(mergedItems.map(item => getPreviewItemKey(item)))
target.summary.total += incomingSummary.total ?? 0
target.summary.success += incomingSummary.success ?? 0
target.summary.failed += incomingSummary.failed ?? 0
target.items.push(...incomingItems)
;(incoming.items ?? []).forEach(item => {
const itemKey = getPreviewItemKey(item)
if (existingItemKeys.has(itemKey)) return
existingItemKeys.add(itemKey)
mergedItems.push(item)
})
target.items = mergedItems
target.summary.total = mergedItems.length
target.summary.success = mergedItems.filter(item => item.success !== false).length
target.summary.failed = mergedItems.filter(item => item.success === false).length
if (incoming.message) {
target.message = [target.message, incoming.message].filter(Boolean).join('')
@@ -515,7 +517,7 @@ function mergePreviewData(target: ManualTransferPreviewData, incoming?: ManualTr
// 预览整理结果
async function previewTransfer() {
if (!props.logids && !props.items) return
if (!props.logids && !normalizedItems.value.length) return
previewLoading.value = true
resetPreviewState()
@@ -525,20 +527,38 @@ async function previewTransfer() {
try {
const tasks: Promise<void>[] = []
if (props.items) {
if (normalizedItems.value.length) {
tasks.push(
...props.items.map(async item => {
...normalizedItems.value.map(async item => {
try {
const result = await requestManualTransfer<ManualTransferPreviewData>(
createTransferPayload({ item, preview: true }),
)
if (!result.success) throw new Error(result.message || t('dialog.reorganize.previewRequestFailed'))
if (!result.success) {
mergePreviewData(
mergedPreviewData,
createFailedPreviewData({
source: item.path || item.name,
type: item.type,
title: item.name,
message: result.message || t('dialog.reorganize.previewRequestFailed'),
}),
)
return
}
mergePreviewData(mergedPreviewData, result.data)
} catch (err: any) {
console.warn(`预览请求异常: ${err?.message}`)
const label = item.name || item.path
throw new Error(`${label}: ${err?.message || t('dialog.reorganize.previewRequestFailed')}`)
mergePreviewData(
mergedPreviewData,
createFailedPreviewData({
source: item.path || item.name,
type: item.type,
title: item.name,
message: `${item.name || item.path}: ${err?.message || t('dialog.reorganize.previewRequestFailed')}`,
}),
)
}
}),
)
@@ -551,12 +571,27 @@ async function previewTransfer() {
const result = await requestManualTransfer<ManualTransferPreviewData>(
createTransferPayload({ logid, preview: true }),
)
if (!result.success) throw new Error(result.message || t('dialog.reorganize.previewRequestFailed'))
if (!result.success) {
mergePreviewData(
mergedPreviewData,
createFailedPreviewData({
source: `历史记录 ${logid}`,
message: result.message || t('dialog.reorganize.previewRequestFailed'),
}),
)
return
}
mergePreviewData(mergedPreviewData, result.data)
} catch (err: any) {
console.warn(`预览请求异常: ${err?.message}`)
throw new Error(`历史记录 ${logid}: ${err?.message || t('dialog.reorganize.previewRequestFailed')}`)
mergePreviewData(
mergedPreviewData,
createFailedPreviewData({
source: `历史记录 ${logid}`,
message: `历史记录 ${logid}: ${err?.message || t('dialog.reorganize.previewRequestFailed')}`,
}),
)
}
}),
)
@@ -564,13 +599,13 @@ async function previewTransfer() {
await Promise.all(tasks)
if (previewHasFailures(mergedPreviewData)) {
throw new Error(getPreviewFailureMessage(mergedPreviewData))
}
previewData.value = mergedPreviewData
previewLoaded.value = true
nextTick(() => updatePreviewPageSize())
if (previewHasFailures(mergedPreviewData)) {
$toast.warning(getPreviewResultSummaryMessage(mergedPreviewData))
}
} catch (error: any) {
previewVisible.value = false
resetPreviewState()
@@ -691,14 +726,14 @@ function stopLoadingProgress() {
// 整理文件
async function transfer(background: boolean = false) {
if (!props.logids && !props.items) return
if (!props.logids && !normalizedItems.value.length) return
// 显示进度条
progressDialog.value = true
// 文件整理
if (props.items) {
for (const item of props.items) {
if (normalizedItems.value.length) {
for (const item of normalizedItems.value) {
if (!background) {
// 如果是文件计算MD5
const key = item.type === 'dir' ? 'filetransfer' : CryptoJS.MD5(item.path).toString()
@@ -1014,18 +1049,6 @@ onUnmounted(() => {
{{ previewData.message }}
</div>
<div class="preview-summary-grid">
<div class="preview-overview-card preview-overview-card--path">
<span class="preview-overview-card__label">{{ t('dialog.reorganize.previewSourcePath') }}</span>
<span class="preview-overview-card__value preview-overview-card__value--path">{{
previewSourcePath
}}</span>
</div>
<div class="preview-overview-card preview-overview-card--path">
<span class="preview-overview-card__label">{{ t('dialog.reorganize.previewTargetPath') }}</span>
<span class="preview-overview-card__value preview-overview-card__value--path">{{
previewTargetPath
}}</span>
</div>
<div class="preview-overview-card">
<span class="preview-overview-card__label">{{ t('dialog.reorganize.previewMediaName') }}</span>
<span class="preview-overview-card__value">{{ previewMediaInfo.title }}</span>
@@ -1054,6 +1077,7 @@ onUnmounted(() => {
v-for="(item, index) in pagedPreviewRows"
:key="`${item.source}-${item.target}-${index}`"
class="preview-file-row"
:class="{ 'preview-file-row--failed': item.success === false }"
>
<div class="preview-file-row__card preview-file-row__card--source">
<span class="preview-file-row__label">{{ t('dialog.reorganize.previewBeforeColumn') }}</span>
@@ -1067,6 +1091,9 @@ onUnmounted(() => {
<span class="preview-file-row__label">{{ t('dialog.reorganize.previewAfterColumn') }}</span>
<span class="preview-file-row__name">{{ item.targetName }}</span>
<span class="preview-file-row__path">{{ item.target || '-' }}</span>
<span v-if="item.success === false && item.message" class="preview-file-row__message">
{{ item.message }}
</span>
</div>
</div>
</div>
@@ -1260,13 +1287,13 @@ onUnmounted(() => {
}
.preview-note {
border: 1px solid rgba(var(--v-theme-info), 0.16);
border-radius: 0.875rem;
color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
border-radius: 1rem;
color: rgb(var(--v-theme-error));
font-size: 0.875rem;
line-height: 1.5;
padding-block: 0.75rem;
padding-inline: 0.875rem;
padding-block: 0.875rem;
padding-inline: 1rem;
}
.preview-summary-grid {
@@ -1286,10 +1313,6 @@ onUnmounted(() => {
padding-inline: 1rem;
}
.preview-overview-card--path {
grid-column: 1 / -1;
}
.preview-overview-card__label {
color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
font-size: 0.75rem;
@@ -1306,14 +1329,6 @@ onUnmounted(() => {
white-space: nowrap;
}
.preview-overview-card__value--path {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
line-height: 1.5;
overflow-wrap: anywhere;
text-overflow: clip;
white-space: normal;
}
.reorganize-preview-pane__scroll {
display: flex;
overflow: hidden auto;
@@ -1385,6 +1400,10 @@ onUnmounted(() => {
border-block-start: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
}
.preview-file-row--failed {
background: rgba(var(--v-theme-error), 0.04);
}
.preview-file-row__card {
display: flex;
flex-direction: column;
@@ -1420,6 +1439,16 @@ onUnmounted(() => {
color: rgb(var(--v-theme-primary));
}
.preview-file-row--failed .preview-file-row__card--target .preview-file-row__name {
color: rgb(var(--v-theme-error));
}
.preview-file-row__message {
color: rgb(var(--v-theme-error));
font-size: 0.8125rem;
line-height: 1.4;
}
.preview-file-row__arrow {
display: flex;
align-items: center;
@@ -1451,10 +1480,6 @@ onUnmounted(() => {
grid-template-columns: 1fr;
}
.preview-overview-card--path {
grid-column: auto;
}
.preview-file-row {
grid-template-columns: 1fr;
}

View File

@@ -4,6 +4,7 @@ import type { Site, TorrentInfo, SiteCategory } from '@/api/types'
import { formatFileSize } from '@core/utils/formatters'
import { useDisplay } from 'vuetify'
import AddDownloadDialog from '../dialog/AddDownloadDialog.vue'
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
import { useI18n } from 'vue-i18n'
// 国际化
@@ -94,6 +95,10 @@ const isMobileLayout = computed(() => display.smAndDown.value)
// 移动端分页数据
const mobileResourceList = computed(() => resourceDataList.value)
function getResourceItemKey(item: TorrentInfo, index: number) {
return item.page_url || item.enclosure || `${item.title}-${item.pubdate || ''}-${index}`
}
// 打开种子详情页面
function openTorrentDetail(page_url: string) {
if (!page_url) return
@@ -465,98 +470,115 @@ onMounted(() => {
</div>
</div>
<div v-else-if="mobileResourceList.length > 0" class="px-3 pb-4">
<VCard
v-for="(item, index) in mobileResourceList"
:key="item.page_url || item.enclosure || `${item.title}-${index}`"
class="mb-3"
<div v-else-if="mobileResourceList.length > 0" class="site-resource-mobile__list px-3 pb-4">
<ProgressiveCardGrid
:items="mobileResourceList"
:columns="1"
:gap="12"
:estimated-item-height="320"
:overscan-rows="5"
:get-item-key="getResourceItemKey"
>
<VCardText class="pa-4">
<button type="button" class="site-resource-title-btn text-start" @click="addDownload(item)">
<div class="text-body-1 font-weight-medium text-high-emphasis">
{{ item.title }}
</div>
<div
v-if="item.description"
class="site-resource-card__description mt-2 text-body-2 text-medium-emphasis"
>
{{ item.description }}
</div>
</button>
<template #default="{ item }">
<VCard>
<VCardText class="pa-4">
<button type="button" class="site-resource-title-btn text-start" @click="addDownload(item)">
<div class="text-body-1 font-weight-medium text-high-emphasis">
{{ item.title }}
</div>
<div
v-if="item.description"
class="site-resource-card__description mt-2 text-body-2 text-medium-emphasis"
>
{{ item.description }}
</div>
</button>
<div class="mt-3">
<VChip v-if="item.hit_and_run" variant="elevated" size="small" class="me-1 mb-1 text-white bg-black">
H&amp;R
</VChip>
<VChip v-if="item.freedate_diff" variant="elevated" color="secondary" size="small" class="me-1 mb-1">
{{ item.freedate_diff }}
</VChip>
<VChip
v-for="(label, chipIndex) in item.labels"
:key="chipIndex"
variant="elevated"
size="small"
color="primary"
class="me-1 mb-1"
>
{{ label }}
</VChip>
<VChip
v-if="item.downloadvolumefactor !== 1 || item.uploadvolumefactor !== 1"
:class="getVolumeFactorClass(item.downloadvolumefactor, item.uploadvolumefactor)"
variant="elevated"
size="small"
class="me-1 mb-1"
>
{{ item.volume_factor }}
</VChip>
</div>
<div class="mt-3">
<VChip
v-if="item.hit_and_run"
variant="elevated"
size="small"
class="me-1 mb-1 text-white bg-black"
>
H&amp;R
</VChip>
<VChip
v-if="item.freedate_diff"
variant="elevated"
color="secondary"
size="small"
class="me-1 mb-1"
>
{{ item.freedate_diff }}
</VChip>
<VChip
v-for="(label, chipIndex) in item.labels"
:key="chipIndex"
variant="elevated"
size="small"
color="primary"
class="me-1 mb-1"
>
{{ label }}
</VChip>
<VChip
v-if="item.downloadvolumefactor !== 1 || item.uploadvolumefactor !== 1"
:class="getVolumeFactorClass(item.downloadvolumefactor, item.uploadvolumefactor)"
variant="elevated"
size="small"
class="me-1 mb-1"
>
{{ item.volume_factor }}
</VChip>
</div>
<div class="site-resource-card__meta mt-4">
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.timeColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ item.date_elapsed || item.pubdate || '-' }}</div>
<div v-if="item.pubdate" class="text-caption text-medium-emphasis mt-1">{{ item.pubdate }}</div>
</div>
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.sizeColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ formatFileSize(item.size) }}</div>
</div>
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.seedersColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ item.seeders }}</div>
</div>
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.peersColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ item.peers }}</div>
</div>
</div>
<div class="site-resource-card__actions mt-4">
<VBtn color="primary" variant="flat" block prepend-icon="mdi-download" @click="addDownload(item)">
{{ t('actionStep.addDownload') }}
</VBtn>
<div class="site-resource-card__secondary-actions mt-2">
<VBtn
variant="tonal"
prepend-icon="mdi-open-in-new"
@click="openTorrentDetail(item.page_url || '')"
>
{{ t('common.viewDetails') }}
</VBtn>
<VBtn
v-if="item.enclosure?.startsWith('http')"
variant="tonal"
prepend-icon="mdi-tray-arrow-down"
@click="downloadTorrentFile(item.enclosure)"
>
{{ t('dialog.siteResource.downloadTorrent') }}
</VBtn>
</div>
</div>
</VCardText>
</VCard>
<div class="site-resource-card__meta mt-4">
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.timeColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ item.date_elapsed || item.pubdate || '-' }}</div>
<div v-if="item.pubdate" class="text-caption text-medium-emphasis mt-1">{{ item.pubdate }}</div>
</div>
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.sizeColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ formatFileSize(item.size) }}</div>
</div>
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.seedersColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ item.seeders }}</div>
</div>
<div class="site-resource-card__meta-item">
<div class="text-caption text-medium-emphasis">{{ t('dialog.siteResource.peersColumn') }}</div>
<div class="text-body-2 font-weight-medium">{{ item.peers }}</div>
</div>
</div>
<div class="site-resource-card__actions mt-4">
<VBtn color="primary" variant="flat" block prepend-icon="mdi-download" @click="addDownload(item)">
{{ t('actionStep.addDownload') }}
</VBtn>
<div class="site-resource-card__secondary-actions mt-2">
<VBtn
variant="tonal"
prepend-icon="mdi-open-in-new"
@click="openTorrentDetail(item.page_url || '')"
>
{{ t('common.viewDetails') }}
</VBtn>
<VBtn
v-if="item.enclosure?.startsWith('http')"
variant="tonal"
prepend-icon="mdi-tray-arrow-down"
@click="downloadTorrentFile(item.enclosure)"
>
{{ t('dialog.siteResource.downloadTorrent') }}
</VBtn>
</div>
</div>
</VCardText>
</VCard>
</template>
</ProgressiveCardGrid>
</div>
<div v-else class="px-4 py-10 text-center text-medium-emphasis">
@@ -669,6 +691,15 @@ onMounted(() => {
flex: 0 0 auto;
}
.site-resource-mobile {
overflow-y: auto;
block-size: 100%;
}
.site-resource-mobile__list {
min-block-size: 100%;
}
.v-table th {
white-space: nowrap;
}

View File

@@ -52,6 +52,7 @@ const subscribeForm = ref<Subscribe>({
username: '',
sites: [],
best_version: undefined,
best_version_full: undefined,
current_priority: 0,
downloader: '',
date: '',
@@ -226,6 +227,7 @@ async function getSubscribeInfo() {
const result: Subscribe = await api.get(`subscribe/${props.subid}`)
subscribeForm.value = result
subscribeForm.value.best_version = subscribeForm.value.best_version === 1
subscribeForm.value.best_version_full = subscribeForm.value.best_version_full === 1
subscribeForm.value.search_imdbid = subscribeForm.value.search_imdbid === 1
// 加载剧集组
if (subscribeForm.value.type == '电视剧') getEpisodeGroups()
@@ -273,6 +275,16 @@ const targetDirectories = computed(() => {
return downloadDirectories.value.map(item => item.download_path)
})
// 仅电视剧订阅支持全集洗版,电影保持原有洗版逻辑
const isTvSubscribe = computed(() => props.type === '电视剧' || subscribeForm.value.type === '电视剧')
watch(
() => subscribeForm.value.best_version,
bestVersion => {
if (!bestVersion) subscribeForm.value.best_version_full = false
},
)
onMounted(() => {
queryFilterRuleGroups()
loadDownloadDirectories()
@@ -426,6 +438,14 @@ onMounted(() => {
persistent-hint
/>
</VCol>
<VCol v-if="isTvSubscribe && subscribeForm.best_version" cols="12" md="4">
<VSwitch
v-model="subscribeForm.best_version_full"
:label="t('dialog.subscribeEdit.bestVersionFull')"
:hint="t('dialog.subscribeEdit.bestVersionFullHint')"
persistent-hint
/>
</VCol>
<VCol cols="12" md="4">
<VSwitch
v-model="subscribeForm.search_imdbid"

View File

@@ -8,6 +8,16 @@ import { useI18n } from 'vue-i18n'
import { useBackgroundOptimization } from '@/composables/useBackgroundOptimization'
import CryptoJS from 'crypto-js'
type TransferTask = TransferQueue['tasks'][number]
interface MediaTaskGroup {
media: TransferQueue['media']
titleYear: string
tasks: TransferTask[]
total: number
completed: number
}
// 多语言支持
const { t } = useI18n()
const { useProgressSSE } = useBackgroundOptimization()
@@ -29,9 +39,6 @@ const overallProgress = ref({
// 文件进度映射
const fileProgressMap = ref<Map<string, { enable: boolean; value: number }>>(new Map())
// 数据可刷新标志
const refreshFlag = ref(false)
// 进度是否激活
const progressActive = ref(false)
@@ -58,49 +65,58 @@ function getStateColor(state: string) {
else return 'error'
}
// 从dataList中提取所有的媒体信息合并相同title_year的记录
const mediaList = computed(() => {
const mediaMap = new Map<string, any>()
// 按媒体聚合队列,避免模板中按 tab 重复扫描 dataList
const mediaTaskGroups = computed<MediaTaskGroup[]>(() => {
const groupMap = new Map<string, MediaTaskGroup>()
dataList.value.forEach(item => {
const titleYear = item.media.title_year || ''
if (!mediaMap.has(titleYear)) {
mediaMap.set(titleYear, item.media)
let group = groupMap.get(titleYear)
if (!group) {
group = {
media: item.media,
titleYear,
tasks: [],
total: 0,
completed: 0,
}
groupMap.set(titleYear, group)
}
group.tasks.push(...item.tasks)
group.total += item.tasks.length
group.completed += item.tasks.filter(task => task.state === 'completed').length
})
return Array.from(mediaMap.values())
return Array.from(groupMap.values())
})
// 从dataList中提取所有的媒体信息合并相同title_year的记录
const mediaList = computed(() => {
return mediaTaskGroups.value.map(group => group.media)
})
// 按media计算总数和完成数返回 x/x
function getMediaCount(title_year: string) {
// 按title_year查询出所有media列表
const medias = dataList.value.filter(item => item.media.title_year === title_year)
// 计算media下任务的总数
const total = medias.reduce((acc, cur) => acc + cur.tasks.length, 0)
// 计算media下任务的完成数
const completed = medias.reduce((acc, cur) => acc + cur.tasks.filter(task => task.state === 'completed').length, 0)
return `${completed} / ${total}`
const group = mediaTaskGroups.value.find(item => item.titleYear === title_year)
return `${group?.completed ?? 0} / ${group?.total ?? 0}`
}
// 根据媒体信息获取对应的整理任务合并相同title_year的所有任务
const activeTasks = computed(() => {
const tasks = dataList.value.filter(item => item.media.title_year === activeTab.value).flatMap(item => item.tasks)
return tasks
return mediaTaskGroups.value.find(item => item.titleYear === activeTab.value)?.tasks ?? []
})
// 根据媒体title_year获取对应的任务列表
function getTasksByMedia(title_year: string) {
return dataList.value.filter(item => item.media.title_year === title_year).flatMap(item => item.tasks)
return mediaTaskGroups.value.find(item => item.titleYear === title_year)?.tasks ?? []
}
// 计算整体进度
const overallProgressComputed = computed(() => {
if (dataList.value.length === 0) return 0
const allTasks = dataList.value.flatMap(item => item.tasks)
const totalTasks = allTasks.length
const completedTasks = allTasks.filter(task => task.state === 'completed').length
const totalTasks = mediaTaskGroups.value.reduce((total, group) => total + group.total, 0)
const completedTasks = mediaTaskGroups.value.reduce((total, group) => total + group.completed, 0)
return totalTasks > 0 ? (completedTasks / totalTasks) * 100 : 0
})

View File

@@ -107,6 +107,47 @@ const currentItem = ref<FileItem>()
// 选中的项目
const selected = ref<FileItem[]>([])
function getFileItemKey(item?: FileItem) {
return [item?.storage ?? inProps.item.storage ?? '', item?.type ?? '', item?.path ?? ''].join('|')
}
function dedupeFileItems(fileItems: FileItem[]) {
const uniqueItems = new Map<string, FileItem>()
fileItems.forEach(item => {
uniqueItems.set(getFileItemKey(item), item)
})
return Array.from(uniqueItems.values())
}
function syncSelectedItems(nextItems: FileItem[] = items.value) {
if (!selected.value.length) return
const currentItemMap = new Map(nextItems.map(item => [getFileItemKey(item), item]))
selected.value = dedupeFileItems(selected.value)
.map(item => currentItemMap.get(getFileItemKey(item)))
.filter((item): item is FileItem => !!item)
}
const selectedKeys = computed(() => new Set(selected.value.map(item => getFileItemKey(item))))
function isSelected(item: FileItem) {
return selectedKeys.value.has(getFileItemKey(item))
}
function setItemSelected(item: FileItem, checked: boolean) {
const itemKey = getFileItemKey(item)
if (checked) {
if (!selectedKeys.value.has(itemKey)) {
selected.value = [...selected.value, item]
}
return
}
selected.value = selected.value.filter(selectedItem => getFileItemKey(selectedItem) !== itemKey)
}
// 识别结果
const nameTestResult = ref<Context>()
@@ -119,26 +160,46 @@ const dropdownItems = ref<{ [key: string]: any }[]>([])
// 进度是否激活
const progressActive = ref(false)
// 通用过滤
const getFilteredItems = (type: 'dir' | 'file') => {
const filterValue = filter.value
if (!filterValue) {
return items.value.filter(item => item.type === type)
}
if (ignoreCase.value) {
const lowerCaseFilter = filterValue.toLowerCase()
return items.value.filter(item => item.type === type && item.name.toLowerCase().includes(lowerCaseFilter))
} else {
return items.value.filter(item => item.type === type && item.name.includes(filterValue))
}
// 将 glob 模式转换为正则表达式
function globToRegex(pattern: string, flags: string = ''): RegExp {
const regexStr = pattern
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
.replace(/\*/g, '.*')
.replace(/\?/g, '.')
return new RegExp(`^${regexStr}$`, flags)
}
// 通用过滤
const filteredItems = computed(() => {
const filterValue = filter.value
if (!filterValue) {
return items.value
}
// 通配符模式
if (filterValue.includes('*') || filterValue.includes('?')) {
const flags = ignoreCase.value ? 'i' : ''
const regex = globToRegex(filterValue, flags)
return items.value.filter(item => regex.test(item.name ?? ''))
}
// 子字符串模式
if (ignoreCase.value) {
const lowerCaseFilter = filterValue.toLowerCase()
return items.value.filter(item => (item.name ?? '').toLowerCase().includes(lowerCaseFilter))
} else {
return items.value.filter(item => (item.name ?? '').includes(filterValue))
}
})
// 目录过滤
const dirs = computed(() => getFilteredItems('dir'))
const dirs = computed(() => filteredItems.value.filter(item => item.type === 'dir'))
// 文件过滤
const files = computed(() => getFilteredItems('file'))
const files = computed(() => filteredItems.value.filter(item => item.type === 'file'))
// 虚拟列表数据,保持引用稳定,避免模板内联展开数组导致虚拟列表重算。
const displayItems = computed(() => [...dirs.value, ...files.value])
// 是否文件
const isFile = computed(() => inProps.item.type == 'file')
@@ -190,6 +251,7 @@ async function list_files() {
return;
}
items.value = data
syncSelectedItems(data)
emit('loading', false)
loading.value = false
@@ -265,13 +327,7 @@ function changePath(item: FileItem) {
// 点击列表项
function listItemClick(item: FileItem) {
if (selectMode.value) {
if (selected.value.includes(item)) {
selected.value = selected.value.filter(i => i !== item)
} else {
selected.value.push(item)
}
// 去重
selected.value = Array.from(new Set(selected.value))
setItemSelected(item, !isSelected(item))
return false
}
changePath(item)
@@ -416,7 +472,7 @@ function showTransfer(item: FileItem) {
// 显示批量整理对话框
function showBatchTransfer() {
transferItems.value = selected.value
transferItems.value = dedupeFileItems(selected.value)
transferPopper.value = true
}
@@ -453,6 +509,7 @@ watch(
async () => {
// 清空列表
items.value = []
selected.value = []
// 关闭弹窗
nameTestResult.value = undefined
nameTestDialog.value = false
@@ -639,8 +696,8 @@ onUnmounted(() => {
flat
density="compact"
variant="plain"
:placeholder="t('common.search')"
prepend-inner-icon="mdi-filter-outline"
:placeholder="t('file.filterPlaceholder')"
:prepend-inner-icon="(filter.includes('*') || filter.includes('?')) ? 'mdi-asterisk' : 'mdi-filter-outline'"
class="mx-2"
rounded
/>
@@ -699,14 +756,18 @@ onUnmounted(() => {
class="text-high-emphasis file-list-container"
:style="{ height: `${listAvailableHeight}px`, maxHeight: `${listAvailableHeight}px` }"
>
<VVirtualScroll :items="[...dirs, ...files]" style="block-size: 100%">
<VVirtualScroll :items="displayItems" style="block-size: 100%">
<template #default="{ item }">
<VHover>
<template #default="hover">
<VListItem v-bind="hover.props" class="px-3 pe-1" @click="listItemClick(item)">
<template #prepend>
<VListItemAction v-if="selectMode">
<VCheckbox v-model="selected" :value="item" />
<VCheckbox
:model-value="isSelected(item)"
@update:model-value="setItemSelected(item, !!$event)"
@click.stop
/>
</VListItemAction>
<template v-else>
<VIcon

View File

@@ -14,6 +14,11 @@ const display = useDisplay()
const { appMode } = usePWA()
type TreeRow =
| { type: 'root'; key: string; level: number }
| { type: 'loading'; key: string; path: string; level: number }
| { type: 'directory'; key: string; dir: FileItem; level: number }
// 计算列表可用高度
// componentOffset = FileToolbar(48) = 48
const { availableHeight } = useAvailableHeight(48, 300)
@@ -132,37 +137,6 @@ async function loadRootDirectories() {
await loadSubdirectories('/')
}
// 检索所有目录节点
function getAllDirectories() {
const allDirs: { dir: FileItem; level: number; parentPath: string }[] = []
// 添加根目录的子目录
if (treeCache.value['/']) {
treeCache.value['/'].forEach(dir => {
allDirs.push({ dir, level: 0, parentPath: '/' })
addSubdirectories(dir.path || '', 1, allDirs)
})
}
return allDirs
}
// 递归添加子目录
function addSubdirectories(
parentPath: string,
level: number,
result: { dir: FileItem; level: number; parentPath: string }[],
) {
if (treeCache.value[parentPath]) {
treeCache.value[parentPath].forEach(dir => {
result.push({ dir, level, parentPath })
if (isFolderExpanded(dir.path || '')) {
addSubdirectories(dir.path || '', level + 1, result)
}
})
}
}
// 监听当前路径变化,自动展开当前路径
watch(
() => props.currentPath,
@@ -224,38 +198,51 @@ const rootDirectories = computed(() => {
return treeCache.value['/'] || []
})
// 扁平化的目录树
const flattenedDirectories = computed(() => {
return getAllDirectories()
})
// 只生成当前可见的目录行,避免折叠/隐藏节点继续留在 DOM 中
const visibleTreeRows = computed<TreeRow[]>(() => {
const rows: TreeRow[] = [{ type: 'root', key: 'root', level: 0 }]
// 检查路径是否为指定目录的子目录或后代
function isChildOrDescendant(path: string, ancestorPath: string) {
if (!path || !ancestorPath) return false
if (ancestorPath === '/') return true
// 确保路径以斜杠结尾,便于比较
const normalizedPath = path.endsWith('/') ? path : path + '/'
const normalizedAncestorPath = ancestorPath.endsWith('/') ? ancestorPath : ancestorPath + '/'
// 检查路径是否以祖先路径开头,但不是祖先路径本身
return normalizedPath.startsWith(normalizedAncestorPath) && normalizedPath !== normalizedAncestorPath
}
// 计算目录相对于其祖先的缩进级别
function getIndentLevel(path: string, ancestorPath: string) {
if (!path || !ancestorPath) return 0
// 根目录特殊处理
if (ancestorPath === '/') {
return path.split('/').filter(p => p).length - 1
if (loading.value['/']) {
rows.push({ type: 'loading', key: 'loading:/', path: '/', level: 0 })
return rows
}
// 计算路径中斜杠的数量差异
const pathParts = path.split('/').filter(p => p).length
const ancestorParts = ancestorPath.split('/').filter(p => p).length
rootDirectories.value.forEach(dir => addVisibleDirectoryRows(dir, 0, rows))
return pathParts - ancestorParts
return rows
})
function addVisibleDirectoryRows(dir: FileItem, level: number, rows: TreeRow[]) {
const path = dir.path || ''
rows.push({
type: 'directory',
key: path || `${level}:${dir.name}`,
dir,
level,
})
if (!path || !isFolderExpanded(path)) {
return
}
if (loading.value[path]) {
rows.push({
type: 'loading',
key: `loading:${path}`,
path,
level: level + 1,
})
return
}
treeCache.value[path]?.forEach(child => addVisibleDirectoryRows(child, level + 1, rows))
}
function getTreeRowStyle(level: number) {
return {
paddingInlineStart: level > 0 ? `${16 + level * 12}px` : undefined,
}
}
// 组件挂载时初始加载
@@ -267,117 +254,75 @@ onMounted(async () => {
<template>
<VCard class="file-navigator rounded-e-0 rounded-t-0" v-if="!isMobile" :height="`${availableHeight}px`">
<div class="tree-container">
<!-- 根目录项 -->
<div
class="tree-item root-item"
:class="{ 'active': currentPath === '/' }"
@click="
handleFolderClick({
storage: storage,
type: 'dir',
name: '/',
path: '/',
})
"
>
<div class="folder-content">
<VIcon icon="mdi-home" class="me-2" color="primary" />
<span>{{ t('file.rootDirectory') }}</span>
</div>
</div>
<!-- 加载根目录 -->
<div v-if="loading['/']" class="tree-loading">
<VProgressCircular indeterminate size="24" color="primary" class="ma-2" />
<span>{{ t('file.loadingDirectoryStructure') }}</span>
</div>
<!-- 目录树结构 -->
<template v-else>
<!-- 一级目录(根目录下的目录) -->
<div v-for="directory in rootDirectories" :key="directory.path" class="tree-item-container">
<!-- 目录项 -->
<div class="tree-item" :class="{ 'active': currentPath === directory.path }">
<div class="folder-toggle" @click.stop="toggleFolder(directory.path || '')">
<VProgressCircular
v-if="loading[directory.path || '']"
indeterminate
size="14"
width="2"
color="primary"
/>
<VIcon
v-else
size="small"
:icon="isFolderExpanded(directory.path || '') ? 'mdi-chevron-down' : 'mdi-chevron-right'"
/>
</div>
<div class="folder-content" @click.stop="handleFolderClick(directory)">
<VIcon
size="small"
:icon="renderFolderIcon(isFolderExpanded(directory.path || ''))"
:color="currentPath === directory.path ? 'primary' : 'amber-darken-1'"
class="me-1"
/>
<span class="folder-name">
{{ directory.name }}
</span>
</div>
<VVirtualScroll :items="visibleTreeRows" :item-height="32" class="tree-container">
<template #default="{ item }">
<div
v-if="item.type === 'root'"
:key="item.key"
class="tree-item root-item"
:class="{ 'active': currentPath === '/' }"
@click="
handleFolderClick({
storage: storage,
type: 'dir',
name: '/',
path: '/',
})
"
>
<div class="folder-content">
<VIcon icon="mdi-home" class="me-2" color="primary" />
<span>{{ t('file.rootDirectory') }}</span>
</div>
</div>
<!-- 子目录容器 - 如果该目录被展开显示其所有子目录 -->
<div v-if="isFolderExpanded(directory.path || '')">
<!-- 加载中状态 -->
<div v-if="loading[directory.path || '']" class="tree-loading pl-8">
<VProgressCircular indeterminate size="14" color="primary" class="ma-2" />
<span class="text-caption">{{ t('common.loading') }}</span>
</div>
<div
v-else-if="item.type === 'loading'"
:key="item.key"
class="tree-loading"
:style="getTreeRowStyle(item.level)"
>
<VProgressCircular indeterminate size="14" color="primary" class="ma-2" />
<span class="text-caption">
{{ item.path === '/' ? t('file.loadingDirectoryStructure') : t('common.loading') }}
</span>
</div>
<!-- 所有层级的子目录列表 -->
<div v-else>
<!-- 遍历所有扁平化的目录列表查找对应层级的目录 -->
<div
v-for="item in flattenedDirectories"
:key="item.dir.path"
v-show="isChildOrDescendant(item.dir.path || '', directory.path || '')"
class="tree-item"
:class="{ 'active': currentPath === item.dir.path }"
:style="{ paddingLeft: 16 + getIndentLevel(item.dir.path || '', directory.path || '') * 12 + 'px' }"
>
<!-- 展开/折叠按钮 -->
<div class="folder-toggle" @click.stop="toggleFolder(item.dir.path || '')">
<VProgressCircular
v-if="loading[item.dir.path || '']"
indeterminate
size="14"
width="2"
color="primary"
/>
<VIcon
v-else
size="small"
:icon="isFolderExpanded(item.dir.path || '') ? 'mdi-chevron-down' : 'mdi-chevron-right'"
/>
</div>
<!-- 文件夹图标和名称 -->
<div class="folder-content" @click.stop="handleFolderClick(item.dir)">
<VIcon
size="small"
:icon="renderFolderIcon(isFolderExpanded(item.dir.path || ''))"
:color="currentPath === item.dir.path ? 'primary' : 'amber-darken-1'"
class="me-1"
/>
<span class="folder-name">
{{ item.dir.name }}
</span>
</div>
</div>
</div>
<div
v-else
:key="item.key"
class="tree-item"
:class="{ 'active': currentPath === item.dir.path }"
:style="getTreeRowStyle(item.level)"
>
<div class="folder-toggle" @click.stop="toggleFolder(item.dir.path || '')">
<VProgressCircular
v-if="loading[item.dir.path || '']"
indeterminate
size="14"
width="2"
color="primary"
/>
<VIcon
v-else
size="small"
:icon="isFolderExpanded(item.dir.path || '') ? 'mdi-chevron-down' : 'mdi-chevron-right'"
/>
</div>
<div class="folder-content" @click.stop="handleFolderClick(item.dir)">
<VIcon
size="small"
:icon="renderFolderIcon(isFolderExpanded(item.dir.path || ''))"
:color="currentPath === item.dir.path ? 'primary' : 'amber-darken-1'"
class="me-1"
/>
<span class="folder-name">
{{ item.dir.name }}
</span>
</div>
</div>
</template>
</div>
</VVirtualScroll>
</VCard>
</template>
@@ -402,8 +347,8 @@ onMounted(async () => {
}
.tree-container {
overflow: hidden auto;
flex: 1;
min-block-size: 0;
}
.tree-item-container {

View File

@@ -1,21 +1,70 @@
<script setup lang="ts">
import { h, resolveComponent } from 'vue'
import api from '@/api'
import { DashboardItem } from '@/api/types'
import AnalyticsMediaStatistic from '@/views/dashboard/AnalyticsMediaStatistic.vue'
import AnalyticsScheduler from '@/views/dashboard/AnalyticsScheduler.vue'
import AnalyticsSpeed from '@/views/dashboard/AnalyticsSpeed.vue'
import AnalyticsStorage from '@/views/dashboard/AnalyticsStorage.vue'
import AnalyticsWeeklyOverview from '@/views/dashboard/AnalyticsWeeklyOverview.vue'
import AnalyticsCpu from '@/views/dashboard/AnalyticsCpu.vue'
import AnalyticsMemory from '@/views/dashboard/AnalyticsMemory.vue'
import AnalyticsNetwork from '@/views/dashboard/AnalyticsNetwork.vue'
import MediaServerLatest from '@/views/dashboard/MediaServerLatest.vue'
import MediaServerLibrary from '@/views/dashboard/MediaServerLibrary.vue'
import MediaServerPlaying from '@/views/dashboard/MediaServerPlaying.vue'
import DashboardRender from '@/components/render/DashboardRender.vue'
import { isNullOrEmptyObject } from '@/@core/utils'
import { loadRemoteComponent } from '@/utils/federationLoader'
const DashboardSkeleton = {
setup() {
const SkeletonLoader = resolveComponent('VSkeletonLoader')
// 用 render 函数避免 runtime-only Vue 为异步 loadingComponent 解析模板。
return () => h(SkeletonLoader, { type: 'card' })
},
}
const asyncDashboardOptions = {
loadingComponent: DashboardSkeleton,
}
// 内置仪表盘按需加载,关闭的卡片不再挤进 dashboard 首屏 chunk。
const AnalyticsStorage = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsStorage.vue'),
...asyncDashboardOptions,
})
const AnalyticsMediaStatistic = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsMediaStatistic.vue'),
...asyncDashboardOptions,
})
const AnalyticsWeeklyOverview = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsWeeklyOverview.vue'),
...asyncDashboardOptions,
})
const AnalyticsSpeed = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsSpeed.vue'),
...asyncDashboardOptions,
})
const AnalyticsScheduler = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsScheduler.vue'),
...asyncDashboardOptions,
})
const AnalyticsCpu = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsCpu.vue'),
...asyncDashboardOptions,
})
const AnalyticsMemory = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsMemory.vue'),
...asyncDashboardOptions,
})
const AnalyticsNetwork = defineAsyncComponent({
loader: () => import('@/views/dashboard/AnalyticsNetwork.vue'),
...asyncDashboardOptions,
})
const MediaServerLibrary = defineAsyncComponent({
loader: () => import('@/views/dashboard/MediaServerLibrary.vue'),
...asyncDashboardOptions,
})
const MediaServerPlaying = defineAsyncComponent({
loader: () => import('@/views/dashboard/MediaServerPlaying.vue'),
...asyncDashboardOptions,
})
const MediaServerLatest = defineAsyncComponent({
loader: () => import('@/views/dashboard/MediaServerLatest.vue'),
...asyncDashboardOptions,
})
// 输入参数
const props = defineProps({
// 仪表板配置
@@ -53,9 +102,7 @@ const dynamicPluginComponent = defineAsyncComponent({
}
},
// 加载中显示的组件
loadingComponent: {
template: '<VSkeletonLoader type="card"></VSkeletonLoader>',
},
loadingComponent: DashboardSkeleton,
// 添加错误处理
errorComponent: {
template: `

View File

@@ -1,5 +1,8 @@
<script setup lang="ts">
import { useIntersectionObserver } from '@vueuse/core'
import type { ComponentPublicInstance } from 'vue'
type ItemKey = string | number
type ScrollTarget = Window | HTMLElement
const props = withDefaults(
defineProps<{
@@ -9,6 +12,7 @@ const props = withDefaults(
estimatedItemHeight?: number
scrollToIndex?: number
gap?: number
columns?: number
initialCount?: number
batchSize?: number
overscanRows?: number
@@ -20,6 +24,7 @@ const props = withDefaults(
estimatedItemHeight: undefined,
scrollToIndex: undefined,
gap: 16,
columns: undefined,
initialCount: 24,
batchSize: 24,
overscanRows: 4,
@@ -27,24 +32,194 @@ const props = withDefaults(
},
)
interface VirtualCell {
item: any
index: number
key: ItemKey
}
const containerRef = ref<HTMLElement | null>(null)
const sentinelRef = ref<HTMLElement | null>(null)
const renderedCount = ref(0)
const trackRef = ref<HTMLElement | null>(null)
let animationFrameId: number | null = null
const layoutWidth = ref(0)
const viewportTop = ref(0)
const viewportBottom = ref(0)
const heightVersion = ref(0)
const safeInitialCount = computed(() => Math.max(1, props.initialCount))
const safeBatchSize = computed(() => Math.max(1, props.batchSize))
const hasMoreItems = computed(() => renderedCount.value < props.items.length)
const visibleItems = computed(() => props.items.slice(0, renderedCount.value))
const itemHeights = new Map<ItemKey, number>()
const observedElements = new Map<HTMLElement, ItemKey>()
const keyElements = new Map<ItemKey, HTMLElement>()
const itemRefCallbacks = new Map<ItemKey, (element: Element | ComponentPublicInstance | null) => void>()
let resizeObserver: ResizeObserver | null = null
let itemResizeObserver: ResizeObserver | null = null
let scrollTarget: ScrollTarget | null = null
let layoutFrameId: number | null = null
let scrollFrameId: number | null = null
let mounted = false
let pendingRevealIndex: number | null = null
let lastMeasuredColumnCount = 0
let lastMeasuredColumnWidth = 0
const safeGap = computed(() => Math.max(0, props.gap))
const safeMinItemWidth = computed(() => Math.max(1, props.minItemWidth))
const safeOverscanRows = computed(() => Math.max(1, props.overscanRows))
const columnCount = computed(() => {
if (props.columns && props.columns > 0) {
return Math.max(1, Math.floor(props.columns))
}
if (!layoutWidth.value) {
return 1
}
return Math.max(1, Math.floor((layoutWidth.value + safeGap.value) / (safeMinItemWidth.value + safeGap.value)))
})
const columnWidth = computed(() => {
const columns = columnCount.value
const width = layoutWidth.value || safeMinItemWidth.value
return Math.max(1, (width - safeGap.value * (columns - 1)) / columns)
})
const estimatedHeight = computed(() => {
if (props.estimatedItemHeight && props.estimatedItemHeight > 0) {
return props.estimatedItemHeight
}
return Math.max(1, columnWidth.value * props.itemAspectRatio)
})
const itemKeys = computed(() => props.items.map((item, index) => getComparableKey(item, index)))
const keyIndexMap = computed(() => {
const map = new Map<ItemKey, number>()
itemKeys.value.forEach((key, index) => {
map.set(key, index)
})
return map
})
const rowMetrics = computed(() => {
heightVersion.value
const rows = Math.ceil(props.items.length / columnCount.value)
const heights: number[] = []
const measuredRows: boolean[] = []
const offsets: number[] = [0]
for (let row = 0; row < rows; row += 1) {
const startIndex = row * columnCount.value
const endIndex = Math.min(startIndex + columnCount.value, props.items.length)
let rowHeight = 0
let hasUnmeasuredItem = false
for (let index = startIndex; index < endIndex; index += 1) {
const height = itemHeights.get(itemKeys.value[index])
if (height && height > 0) {
rowHeight = Math.max(rowHeight, height)
} else {
hasUnmeasuredItem = true
}
}
if (hasUnmeasuredItem) {
rowHeight = Math.max(rowHeight, estimatedHeight.value)
} else {
rowHeight = Math.max(rowHeight, 1)
}
heights.push(rowHeight)
measuredRows.push(!hasUnmeasuredItem)
offsets.push(offsets[row] + rowHeight + (row < rows - 1 ? safeGap.value : 0))
}
return {
heights,
measuredRows,
offsets,
rowCount: rows,
totalHeight: offsets[rows] ?? 0,
}
})
const totalHeight = computed(() => rowMetrics.value.totalHeight)
const visibleRange = computed(() => {
const { heights, offsets, rowCount } = rowMetrics.value
if (!props.items.length || rowCount === 0) {
return {
endIndex: 0,
endRow: 0,
startIndex: 0,
startRow: 0,
}
}
const top = Math.max(0, Math.min(viewportTop.value, totalHeight.value))
const bottom = Math.max(top, Math.min(viewportBottom.value, totalHeight.value))
const firstVisibleRow = findFirstRowAtOrAfterOffset(offsets, heights, top)
const lastVisibleRow = findLastRowAtOrBeforeOffset(offsets, rowCount, bottom)
const startRow = clamp(firstVisibleRow - safeOverscanRows.value, 0, rowCount - 1)
const endRow = clamp(lastVisibleRow + safeOverscanRows.value, startRow, rowCount - 1)
return {
endIndex: Math.min(props.items.length, (endRow + 1) * columnCount.value),
endRow,
startIndex: startRow * columnCount.value,
startRow,
}
})
const visibleCells = computed<VirtualCell[]>(() => {
const cells: VirtualCell[] = []
for (let index = visibleRange.value.startIndex; index < visibleRange.value.endIndex; index += 1) {
cells.push({
item: props.items[index],
index,
key: itemKeys.value[index],
})
}
return cells
})
const topSpacerHeight = computed(() => rowMetrics.value.offsets[visibleRange.value.startRow] ?? 0)
const visibleBlockHeight = computed(() => {
if (!props.items.length || visibleRange.value.endIndex <= visibleRange.value.startIndex) {
return 0
}
return Math.max(
(rowMetrics.value.offsets[visibleRange.value.endRow] ?? 0) +
(rowMetrics.value.heights[visibleRange.value.endRow] ?? 0) -
(rowMetrics.value.offsets[visibleRange.value.startRow] ?? 0),
0,
)
})
const bottomSpacerHeight = computed(() => {
return Math.max(totalHeight.value - topSpacerHeight.value - visibleBlockHeight.value, 0)
})
const gridStyle = computed(() => ({
columnGap: `${props.gap}px`,
gridTemplateColumns: `repeat(auto-fill, minmax(${props.minItemWidth}px, 1fr))`,
rowGap: `${props.gap}px`,
columnGap: `${safeGap.value}px`,
gridTemplateColumns: `repeat(${columnCount.value}, minmax(0, 1fr))`,
rowGap: `${safeGap.value}px`,
}))
function getComparableKey(item: any, index: number) {
function clamp(value: number, min: number, max: number) {
return Math.min(Math.max(value, min), max)
}
function getComparableKey(item: any, index: number): ItemKey {
if (props.getItemKey) {
return props.getItemKey(item, index)
}
@@ -52,169 +227,545 @@ function getComparableKey(item: any, index: number) {
return index
}
function resolveItemKey(item: any, index: number) {
return getComparableKey(item, index)
}
function findFirstRowAtOrAfterOffset(offsets: number[], heights: number[], offset: number) {
let low = 0
let high = heights.length - 1
let answer = 0
function appendNextBatch() {
renderedCount.value = Math.min(props.items.length, renderedCount.value + safeBatchSize.value)
}
while (low <= high) {
const mid = Math.floor((low + high) / 2)
const rowEnd = offsets[mid] + heights[mid]
function hasPageScroll() {
if (typeof window === 'undefined') {
return true
if (rowEnd >= offset) {
answer = mid
high = mid - 1
} else {
low = mid + 1
}
}
const scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight)
return scrollHeight - (window.innerHeight || document.documentElement.clientHeight) > 2
return answer
}
async function fillViewport() {
if (typeof window === 'undefined') {
function findLastRowAtOrBeforeOffset(offsets: number[], rowCount: number, offset: number) {
let low = 0
let high = rowCount - 1
let answer = 0
while (low <= high) {
const mid = Math.floor((low + high) / 2)
if (offsets[mid] <= offset) {
answer = mid
low = mid + 1
} else {
high = mid - 1
}
}
return answer
}
function getElementFromRef(element: Element | ComponentPublicInstance | null): HTMLElement | null {
if (!element || typeof HTMLElement === 'undefined') {
return null
}
if (element instanceof HTMLElement) {
return element
}
if (!('$el' in element)) {
return null
}
const componentElement = element.$el
return componentElement instanceof HTMLElement ? componentElement : null
}
function getRowHeight(row: number) {
const startIndex = row * columnCount.value
const endIndex = Math.min(startIndex + columnCount.value, props.items.length)
let rowHeight = 0
let hasUnmeasuredItem = false
for (let index = startIndex; index < endIndex; index += 1) {
const height = itemHeights.get(itemKeys.value[index])
if (height && height > 0) {
rowHeight = Math.max(rowHeight, height)
} else {
hasUnmeasuredItem = true
}
}
if (hasUnmeasuredItem) {
return Math.max(rowHeight, estimatedHeight.value)
}
return Math.max(rowHeight, 1)
}
function ensureItemResizeObserver() {
if (itemResizeObserver || typeof ResizeObserver === 'undefined') {
return
}
const maxIterations = Math.ceil(props.items.length / safeBatchSize.value)
let iterations = 0
itemResizeObserver = new ResizeObserver(entries => {
let shouldUpdate = false
let scrollAdjustment = 0
const currentViewportTop = viewportTop.value
const currentOffsets = rowMetrics.value.offsets
while (!hasPageScroll() && hasMoreItems.value && iterations < maxIterations) {
appendNextBatch()
iterations += 1
await nextTick()
}
}
entries.forEach(entry => {
const element = entry.target
if (!(element instanceof HTMLElement)) {
return
}
function queueFillViewport() {
if (typeof window === 'undefined' || animationFrameId !== null) {
return
}
const key = observedElements.get(element)
const index = key === undefined ? undefined : keyIndexMap.value.get(key)
animationFrameId = window.requestAnimationFrame(() => {
animationFrameId = null
void fillViewport()
if (key === undefined || index === undefined) {
return
}
const nextHeight = getResizeEntryHeight(entry)
const previousHeight = itemHeights.get(key)
if (!nextHeight || Math.abs((previousHeight ?? 0) - nextHeight) < 0.5) {
return
}
const row = Math.floor(index / columnCount.value)
const rowWasFullyMeasured = rowMetrics.value.measuredRows[row]
const previousRowHeight = getRowHeight(row)
const previousRowBottom = (currentOffsets[row] ?? 0) + previousRowHeight
if (
rowWasFullyMeasured &&
previousHeight !== undefined &&
previousHeight < previousRowHeight - 0.5 &&
nextHeight <= previousRowHeight + 0.5
) {
return
}
itemHeights.set(key, nextHeight)
const nextRowHeight = getRowHeight(row)
const delta = nextRowHeight - previousRowHeight
if (Math.abs(delta) >= 0.5 && previousRowBottom < currentViewportTop) {
scrollAdjustment += delta
}
shouldUpdate = true
})
if (!shouldUpdate) {
return
}
heightVersion.value += 1
if (Math.abs(scrollAdjustment) >= 0.5) {
adjustScrollTop(scrollAdjustment)
}
queueViewportSync()
})
}
function getResizeEntryHeight(entry: ResizeObserverEntry) {
const borderSize = Array.isArray(entry.borderBoxSize) ? entry.borderBoxSize[0] : entry.borderBoxSize
return borderSize?.blockSize || entry.contentRect.height
}
function setItemRef(element: Element | ComponentPublicInstance | null, key: ItemKey) {
const htmlElement = getElementFromRef(element)
const previousElement = keyElements.get(key)
if (!htmlElement) {
if (previousElement) {
itemResizeObserver?.unobserve(previousElement)
observedElements.delete(previousElement)
keyElements.delete(key)
}
return
}
if (previousElement === htmlElement) {
return
}
ensureItemResizeObserver()
if (previousElement) {
itemResizeObserver?.unobserve(previousElement)
observedElements.delete(previousElement)
}
observedElements.set(htmlElement, key)
keyElements.set(key, htmlElement)
itemResizeObserver?.observe(htmlElement)
}
function getItemRef(key: ItemKey) {
const existingCallback = itemRefCallbacks.get(key)
if (existingCallback) {
return existingCallback
}
const callback = (element: Element | ComponentPublicInstance | null) => setItemRef(element, key)
itemRefCallbacks.set(key, callback)
return callback
}
function findScrollTarget(): ScrollTarget {
let parent = containerRef.value?.parentElement ?? null
while (parent && parent !== document.body && parent !== document.documentElement) {
const overflowY = window.getComputedStyle(parent).overflowY
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') {
return parent
}
parent = parent.parentElement
}
return window
}
function addScrollListener(target: ScrollTarget) {
target.addEventListener('scroll', queueViewportSync, { passive: true })
}
function removeScrollListener(target: ScrollTarget | null) {
target?.removeEventListener('scroll', queueViewportSync)
}
function refreshScrollTarget() {
if (!mounted) {
return
}
const nextTarget = findScrollTarget()
if (scrollTarget === nextTarget) {
return
}
removeScrollListener(scrollTarget)
scrollTarget = nextTarget
addScrollListener(scrollTarget)
}
function syncLayoutWidth() {
const element = trackRef.value
if (!element) {
layoutWidth.value = 0
return
}
layoutWidth.value = element.clientWidth
}
function syncViewport() {
const element = trackRef.value
if (!element) {
viewportTop.value = 0
viewportBottom.value = 0
return
}
const trackRect = element.getBoundingClientRect()
const viewportRect =
scrollTarget && scrollTarget !== window
? (scrollTarget as HTMLElement).getBoundingClientRect()
: {
bottom: window.innerHeight,
top: 0,
}
viewportTop.value = viewportRect.top - trackRect.top
viewportBottom.value = viewportRect.bottom - trackRect.top
}
function queueLayoutSync() {
if (typeof window === 'undefined' || layoutFrameId !== null) {
return
}
layoutFrameId = window.requestAnimationFrame(() => {
layoutFrameId = null
syncLayoutWidth()
refreshScrollTarget()
syncViewport()
flushPendingReveal()
})
}
function queueViewportSync() {
if (typeof window === 'undefined' || scrollFrameId !== null) {
return
}
scrollFrameId = window.requestAnimationFrame(() => {
scrollFrameId = null
syncViewport()
})
}
function getTrackScrollTop() {
const element = trackRef.value
if (!element || !scrollTarget || scrollTarget === window) {
return (element?.getBoundingClientRect().top ?? 0) + window.scrollY
}
const scrollElement = scrollTarget as HTMLElement
const trackRect = element.getBoundingClientRect()
const scrollRect = scrollElement.getBoundingClientRect()
return trackRect.top - scrollRect.top + scrollElement.scrollTop
}
function adjustScrollTop(delta: number) {
if (!scrollTarget || Math.abs(delta) < 0.5) {
return
}
if (scrollTarget === window) {
window.scrollBy({
behavior: 'auto',
top: delta,
})
} else {
const scrollElement = scrollTarget as HTMLElement
scrollElement.scrollTop += delta
}
}
function scrollToRelativeTop(top: number) {
if (!scrollTarget) {
return
}
const targetTop = getTrackScrollTop() + top
if (scrollTarget === window) {
window.scrollTo({
behavior: 'auto',
top: targetTop,
})
} else {
;(scrollTarget as HTMLElement).scrollTo({
behavior: 'auto',
top: targetTop,
})
}
queueViewportSync()
}
async function revealItem(index: number) {
if (typeof window === 'undefined' || index < 0 || index >= props.items.length) {
return
}
const minRenderedCount = Math.ceil((index + 1) / safeBatchSize.value) * safeBatchSize.value
renderedCount.value = Math.min(props.items.length, Math.max(renderedCount.value, minRenderedCount))
await nextTick()
const target = containerRef.value?.querySelector(`[data-progressive-grid-index="${index}"]`)
if (target instanceof HTMLElement) {
target.scrollIntoView({
behavior: 'auto',
block: 'start',
inline: 'nearest',
})
}
const row = Math.floor(index / columnCount.value)
const top = rowMetrics.value.offsets[row] ?? 0
scrollToRelativeTop(top)
}
function resetVisibleItems() {
renderedCount.value = Math.min(props.items.length, safeInitialCount.value)
nextTick(() => {
if (props.scrollToIndex !== undefined && props.scrollToIndex >= 0) {
void revealItem(props.scrollToIndex)
return
}
queueFillViewport()
})
}
function didItemsAppend(nextItems: any[], previousItems: any[]) {
if (!previousItems.length || nextItems.length < previousItems.length) {
return false
}
return previousItems.every((item, index) => getComparableKey(item, index) === getComparableKey(nextItems[index], index))
}
function syncVisibleItems(nextItems: any[], previousItems: any[] = []) {
if (didItemsAppend(nextItems, previousItems)) {
renderedCount.value = Math.min(nextItems.length, Math.max(renderedCount.value, previousItems.length))
nextTick(() => {
if (props.scrollToIndex !== undefined && props.scrollToIndex >= 0) {
void revealItem(props.scrollToIndex)
return
}
queueFillViewport()
})
function requestRevealItem(index: number) {
pendingRevealIndex = index
if (!mounted) {
return
}
resetVisibleItems()
queueLayoutSync()
}
const { stop } = useIntersectionObserver(
sentinelRef,
([entry]) => {
if (!entry?.isIntersecting || !hasMoreItems.value) {
return
}
function flushPendingReveal() {
if (pendingRevealIndex === null || !mounted || !scrollTarget || layoutWidth.value <= 0) {
return
}
appendNextBatch()
queueFillViewport()
},
{
rootMargin: '1200px 0px',
},
)
const index = pendingRevealIndex
pendingRevealIndex = null
void revealItem(index)
}
function pruneMeasurements() {
const keys = new Set(itemKeys.value)
let changed = false
Array.from(itemHeights.keys()).forEach(key => {
if (!keys.has(key)) {
itemHeights.delete(key)
changed = true
}
})
Array.from(keyElements.entries()).forEach(([key, element]) => {
if (!keys.has(key)) {
itemResizeObserver?.unobserve(element)
observedElements.delete(element)
keyElements.delete(key)
}
})
Array.from(itemRefCallbacks.keys()).forEach(key => {
if (!keys.has(key)) {
itemRefCallbacks.delete(key)
}
})
if (changed) {
heightVersion.value += 1
}
}
function didKeysAppend(nextKeys: ItemKey[], previousKeys: ItemKey[] = []) {
if (!previousKeys.length || nextKeys.length < previousKeys.length) {
return false
}
return previousKeys.every((key, index) => key === nextKeys[index])
}
function syncMeasurementsForItems(nextKeys: ItemKey[], previousKeys: ItemKey[] = []) {
if (!didKeysAppend(nextKeys, previousKeys) && itemHeights.size) {
itemHeights.clear()
heightVersion.value += 1
}
pruneMeasurements()
}
function invalidateMeasurementsForLayoutChange() {
const nextColumnCount = columnCount.value
const nextColumnWidth = columnWidth.value
if (
lastMeasuredColumnCount === nextColumnCount &&
Math.abs(lastMeasuredColumnWidth - nextColumnWidth) < 1
) {
return
}
lastMeasuredColumnCount = nextColumnCount
lastMeasuredColumnWidth = nextColumnWidth
if (!itemHeights.size) {
return
}
itemHeights.clear()
heightVersion.value += 1
}
onMounted(() => {
window.addEventListener('resize', queueFillViewport, { passive: true })
mounted = true
scrollTarget = findScrollTarget()
addScrollListener(scrollTarget)
resizeObserver = new ResizeObserver(queueLayoutSync)
if (trackRef.value) {
resizeObserver.observe(trackRef.value)
}
window.addEventListener('resize', queueLayoutSync, { passive: true })
queueLayoutSync()
})
onActivated(() => {
mounted = true
refreshScrollTarget()
queueLayoutSync()
})
onDeactivated(() => {
mounted = false
removeScrollListener(scrollTarget)
scrollTarget = null
})
onUnmounted(() => {
stop()
window.removeEventListener('resize', queueFillViewport)
mounted = false
removeScrollListener(scrollTarget)
scrollTarget = null
if (animationFrameId !== null) {
window.cancelAnimationFrame(animationFrameId)
animationFrameId = null
window.removeEventListener('resize', queueLayoutSync)
resizeObserver?.disconnect()
resizeObserver = null
itemResizeObserver?.disconnect()
itemResizeObserver = null
if (layoutFrameId !== null) {
window.cancelAnimationFrame(layoutFrameId)
layoutFrameId = null
}
if (scrollFrameId !== null) {
window.cancelAnimationFrame(scrollFrameId)
scrollFrameId = null
}
})
watch(
itemKeys,
(nextKeys, previousKeys) => {
syncMeasurementsForItems(nextKeys, previousKeys)
queueLayoutSync()
},
{ immediate: true },
)
watch(
[
() => props.minItemWidth,
() => props.initialCount,
() => props.batchSize,
() => props.gap,
() => props.estimatedItemHeight,
() => props.itemAspectRatio,
() => props.columns,
],
() => {
queueFillViewport()
queueLayoutSync()
},
{ immediate: true },
)
watch(
() => props.items,
(nextItems, previousItems) => {
syncVisibleItems(nextItems, previousItems)
[columnCount, columnWidth],
() => {
invalidateMeasurementsForLayoutChange()
queueViewportSync()
},
{ immediate: true },
)
watch(
[() => props.scrollToIndex, () => props.items.length],
[() => props.scrollToIndex, () => props.items.length, columnCount],
([scrollToIndex]) => {
if (scrollToIndex === undefined || scrollToIndex < 0) {
if (scrollToIndex === undefined || scrollToIndex < 0 || scrollToIndex >= props.items.length) {
return
}
nextTick(() => {
void revealItem(scrollToIndex)
})
requestRevealItem(scrollToIndex)
},
{ immediate: true },
)
@@ -222,17 +773,31 @@ watch(
<template>
<div ref="containerRef" class="progressive-card-grid">
<div class="grid" :style="gridStyle">
<div ref="trackRef" class="progressive-card-grid__track">
<div
v-for="(item, index) in visibleItems"
:key="resolveItemKey(item, index)"
class="progressive-card-grid__item"
:data-progressive-grid-index="index"
>
<slot :item="item" :index="index" />
v-if="topSpacerHeight > 0"
class="progressive-card-grid__spacer"
:style="{ blockSize: `${topSpacerHeight}px` }"
aria-hidden="true"
/>
<div v-if="visibleCells.length > 0" class="progressive-card-grid__grid" :style="gridStyle">
<div
v-for="cell in visibleCells"
:key="cell.key"
:ref="getItemRef(cell.key)"
class="progressive-card-grid__item"
:data-progressive-grid-index="cell.index"
>
<slot :item="cell.item" :index="cell.index" />
</div>
</div>
<div
v-if="bottomSpacerHeight > 0"
class="progressive-card-grid__spacer"
:style="{ blockSize: `${bottomSpacerHeight}px` }"
aria-hidden="true"
/>
</div>
<div v-if="hasMoreItems" ref="sentinelRef" class="progressive-card-grid__sentinel" aria-hidden="true" />
</div>
</template>
@@ -241,12 +806,23 @@ watch(
inline-size: 100%;
}
.progressive-card-grid__track {
inline-size: 100%;
min-block-size: 1px;
overflow-anchor: none;
}
.progressive-card-grid__grid {
display: grid;
}
.progressive-card-grid__item {
inline-size: 100%;
min-inline-size: 0;
}
.progressive-card-grid__sentinel {
block-size: 1px;
.progressive-card-grid__item > :deep(*) {
block-size: 100%;
inline-size: 100%;
}
</style>

View File

@@ -57,18 +57,23 @@ export interface WizardData {
model: string
thinkingLevel: string
supportImageInput: boolean
supportAudioInputOutput: boolean
supportAudioInput: boolean
supportAudioOutput: boolean
apiKey: string
baseUrl: string
baseUrlPreset: string
maxContextTokens: number
voiceApiKey: string
voiceBaseUrl: string
voiceSttModel: string
voiceTtsModel: string
voiceTtsVoice: string
voiceLanguage: string
voiceReplyWithText: boolean
audioInputProvider: string
audioInputApiKey: string
audioInputBaseUrl: string
audioInputModel: string
audioInputLanguage: string
audioOutputProvider: string
audioOutputApiKey: string
audioOutputBaseUrl: string
audioOutputModel: string
audioOutputVoice: string
audioOutputIncludeText: boolean
jobInterval: number
retryTransfer: boolean
recommendEnabled: boolean
@@ -238,18 +243,23 @@ const wizardData = ref<WizardData>({
model: 'deepseek-chat',
thinkingLevel: 'off',
supportImageInput: true,
supportAudioInputOutput: false,
supportAudioInput: false,
supportAudioOutput: false,
apiKey: '',
baseUrl: 'https://api.deepseek.com',
baseUrlPreset: '',
maxContextTokens: 64,
voiceApiKey: '',
voiceBaseUrl: '',
voiceSttModel: 'gpt-4o-mini-transcribe',
voiceTtsModel: 'gpt-4o-mini-tts',
voiceTtsVoice: 'alloy',
voiceLanguage: 'zh',
voiceReplyWithText: false,
audioInputProvider: 'openai',
audioInputApiKey: '',
audioInputBaseUrl: '',
audioInputModel: 'gpt-4o-mini-transcribe',
audioInputLanguage: 'zh',
audioOutputProvider: 'openai',
audioOutputApiKey: '',
audioOutputBaseUrl: '',
audioOutputModel: 'gpt-4o-mini-tts',
audioOutputVoice: 'alloy',
audioOutputIncludeText: false,
jobInterval: 0,
retryTransfer: false,
recommendEnabled: false,
@@ -1430,18 +1440,23 @@ export function useSetupWizard() {
LLM_MODEL: wizardData.value.agent.model,
LLM_THINKING_LEVEL: wizardData.value.agent.thinkingLevel,
LLM_SUPPORT_IMAGE_INPUT: wizardData.value.agent.supportImageInput,
LLM_SUPPORT_AUDIO_INPUT_OUTPUT: wizardData.value.agent.supportAudioInputOutput,
LLM_SUPPORT_AUDIO_INPUT: wizardData.value.agent.supportAudioInput,
LLM_SUPPORT_AUDIO_OUTPUT: wizardData.value.agent.supportAudioOutput,
LLM_API_KEY: wizardData.value.agent.apiKey,
LLM_BASE_URL: wizardData.value.agent.baseUrl || null,
LLM_BASE_URL_PRESET: wizardData.value.agent.baseUrlPreset || null,
LLM_MAX_CONTEXT_TOKENS: wizardData.value.agent.maxContextTokens,
AI_VOICE_API_KEY: wizardData.value.agent.voiceApiKey || null,
AI_VOICE_BASE_URL: wizardData.value.agent.voiceBaseUrl || null,
AI_VOICE_STT_MODEL: wizardData.value.agent.voiceSttModel,
AI_VOICE_TTS_MODEL: wizardData.value.agent.voiceTtsModel,
AI_VOICE_TTS_VOICE: wizardData.value.agent.voiceTtsVoice,
AI_VOICE_LANGUAGE: wizardData.value.agent.voiceLanguage,
AI_VOICE_REPLY_WITH_TEXT: wizardData.value.agent.voiceReplyWithText,
AUDIO_INPUT_PROVIDER: wizardData.value.agent.audioInputProvider || 'openai',
AUDIO_INPUT_API_KEY: wizardData.value.agent.audioInputApiKey || null,
AUDIO_INPUT_BASE_URL: wizardData.value.agent.audioInputBaseUrl || null,
AUDIO_INPUT_MODEL: wizardData.value.agent.audioInputModel,
AUDIO_INPUT_LANGUAGE: wizardData.value.agent.audioInputLanguage,
AUDIO_OUTPUT_PROVIDER: wizardData.value.agent.audioOutputProvider || 'openai',
AUDIO_OUTPUT_API_KEY: wizardData.value.agent.audioOutputApiKey || null,
AUDIO_OUTPUT_BASE_URL: wizardData.value.agent.audioOutputBaseUrl || null,
AUDIO_OUTPUT_MODEL: wizardData.value.agent.audioOutputModel,
AUDIO_OUTPUT_VOICE: wizardData.value.agent.audioOutputVoice,
AUDIO_OUTPUT_INCLUDE_TEXT: wizardData.value.agent.audioOutputIncludeText,
AI_AGENT_JOB_INTERVAL: wizardData.value.agent.enabled ? wizardData.value.agent.jobInterval : 0,
AI_AGENT_RETRY_TRANSFER: wizardData.value.agent.enabled ? wizardData.value.agent.retryTransfer : false,
AI_RECOMMEND_ENABLED:
@@ -1538,18 +1553,23 @@ export function useSetupWizard() {
wizardData.value.agent.model = result.data.LLM_MODEL || ''
wizardData.value.agent.thinkingLevel = resolveThinkingLevelValue(result.data)
wizardData.value.agent.supportImageInput = result.data.LLM_SUPPORT_IMAGE_INPUT ?? true
wizardData.value.agent.supportAudioInputOutput = Boolean(result.data.LLM_SUPPORT_AUDIO_INPUT_OUTPUT)
wizardData.value.agent.supportAudioInput = Boolean(result.data.LLM_SUPPORT_AUDIO_INPUT)
wizardData.value.agent.supportAudioOutput = Boolean(result.data.LLM_SUPPORT_AUDIO_OUTPUT)
wizardData.value.agent.apiKey = result.data.LLM_API_KEY || ''
wizardData.value.agent.baseUrl = result.data.LLM_BASE_URL || ''
wizardData.value.agent.baseUrlPreset = result.data.LLM_BASE_URL_PRESET || ''
wizardData.value.agent.maxContextTokens = result.data.LLM_MAX_CONTEXT_TOKENS || 64
wizardData.value.agent.voiceApiKey = result.data.AI_VOICE_API_KEY || ''
wizardData.value.agent.voiceBaseUrl = result.data.AI_VOICE_BASE_URL || ''
wizardData.value.agent.voiceSttModel = result.data.AI_VOICE_STT_MODEL || 'gpt-4o-mini-transcribe'
wizardData.value.agent.voiceTtsModel = result.data.AI_VOICE_TTS_MODEL || 'gpt-4o-mini-tts'
wizardData.value.agent.voiceTtsVoice = result.data.AI_VOICE_TTS_VOICE || 'alloy'
wizardData.value.agent.voiceLanguage = result.data.AI_VOICE_LANGUAGE || 'zh'
wizardData.value.agent.voiceReplyWithText = Boolean(result.data.AI_VOICE_REPLY_WITH_TEXT)
wizardData.value.agent.audioInputProvider = result.data.AUDIO_INPUT_PROVIDER || 'openai'
wizardData.value.agent.audioInputApiKey = result.data.AUDIO_INPUT_API_KEY || ''
wizardData.value.agent.audioInputBaseUrl = result.data.AUDIO_INPUT_BASE_URL || ''
wizardData.value.agent.audioInputModel = result.data.AUDIO_INPUT_MODEL || 'gpt-4o-mini-transcribe'
wizardData.value.agent.audioInputLanguage = result.data.AUDIO_INPUT_LANGUAGE || 'zh'
wizardData.value.agent.audioOutputProvider = result.data.AUDIO_OUTPUT_PROVIDER || 'openai'
wizardData.value.agent.audioOutputApiKey = result.data.AUDIO_OUTPUT_API_KEY || ''
wizardData.value.agent.audioOutputBaseUrl = result.data.AUDIO_OUTPUT_BASE_URL || ''
wizardData.value.agent.audioOutputModel = result.data.AUDIO_OUTPUT_MODEL || 'gpt-4o-mini-tts'
wizardData.value.agent.audioOutputVoice = result.data.AUDIO_OUTPUT_VOICE || 'alloy'
wizardData.value.agent.audioOutputIncludeText = Boolean(result.data.AUDIO_OUTPUT_INCLUDE_TEXT)
wizardData.value.agent.jobInterval = result.data.AI_AGENT_JOB_INTERVAL || 0
wizardData.value.agent.retryTransfer = Boolean(result.data.AI_AGENT_RETRY_TRANSFER)
wizardData.value.agent.recommendEnabled = Boolean(result.data.AI_RECOMMEND_ENABLED)

View File

@@ -51,9 +51,25 @@ export const clearCachesAndServiceWorker = async (): Promise<void> => {
/**
* 清除缓存并刷新
*/
const clearCacheAndReload = async (): Promise<void> => {
await clearCachesAndServiceWorker()
reloadWithTimestamp()
export const clearCacheAndReload = async (): Promise<void> => {
let isReloading = false
const reload = () => {
if (isReloading) return
isReloading = true
reloadWithTimestamp()
}
const reloadTimer = window.setTimeout(reload, 3000)
try {
await Promise.race([
clearCachesAndServiceWorker(),
new Promise(resolve => window.setTimeout(resolve, 2500)),
])
} finally {
window.clearTimeout(reloadTimer)
reload()
}
}
/**

View File

@@ -1,13 +1,4 @@
<script lang="ts" setup>
import NameTestView from '@/views/system/NameTestView.vue'
import NetTestView from '@/views/system/NetTestView.vue'
import LoggingView from '@/views/system/LoggingView.vue'
import RuleTestView from '@/views/system/RuleTestView.vue'
import ModuleTestView from '@/views/system/ModuleTestView.vue'
import MessageView from '@/views/system/MessageView.vue'
import WordsView from '@/views/system/WordsView.vue'
import CacheView from '@/views/system/CacheView.vue'
import AccountSettingService from '@/views/system/ServiceView.vue'
import api from '@/api'
import { useDisplay } from 'vuetify'
import { getQueryValue } from '@/@core/utils'
@@ -26,6 +17,17 @@ const { t } = useI18n()
// 显示器宽度
const display = useDisplay()
// 快捷工具只在弹窗打开时使用,按需加载避免默认布局首屏带上所有 system 视图。
const NameTestView = defineAsyncComponent(() => import('@/views/system/NameTestView.vue'))
const NetTestView = defineAsyncComponent(() => import('@/views/system/NetTestView.vue'))
const LoggingView = defineAsyncComponent(() => import('@/views/system/LoggingView.vue'))
const RuleTestView = defineAsyncComponent(() => import('@/views/system/RuleTestView.vue'))
const ModuleTestView = defineAsyncComponent(() => import('@/views/system/ModuleTestView.vue'))
const MessageView = defineAsyncComponent(() => import('@/views/system/MessageView.vue'))
const WordsView = defineAsyncComponent(() => import('@/views/system/WordsView.vue'))
const CacheView = defineAsyncComponent(() => import('@/views/system/CacheView.vue'))
const AccountSettingService = defineAsyncComponent(() => import('@/views/system/ServiceView.vue'))
// App捷径
const appsMenu = ref(false)

View File

@@ -58,6 +58,8 @@ const customCSS = ref('')
// 透明度相关
const transparencyOpacity = ref(parseFloat(localStorage.getItem('transparency-opacity') || '0.3'))
const transparencyBlur = ref(parseFloat(localStorage.getItem('transparency-blur') || '10'))
const backgroundPosterOpacity = ref(parseFloat(localStorage.getItem('transparency-background-poster-opacity') || '0'))
const backgroundBlur = ref(parseFloat(localStorage.getItem('transparency-background-blur') || '16'))
const transparencyLevel = ref(localStorage.getItem('transparency-level') || 'medium')
const isTransparentTheme = computed(() => currentThemeName.value === 'transparent')
const showTransparencyDialog = ref(false)
@@ -383,6 +385,15 @@ async function saveCustomCSS() {
function applyTransparencySettings() {
const root = document.documentElement
if (!Number.isFinite(backgroundPosterOpacity.value)) {
backgroundPosterOpacity.value = 1
}
backgroundPosterOpacity.value = Math.min(1, Math.max(0, backgroundPosterOpacity.value))
if (!Number.isFinite(backgroundBlur.value)) {
backgroundBlur.value = 16
}
backgroundBlur.value = Math.min(30, Math.max(0, backgroundBlur.value))
// 设置CSS变量
root.style.setProperty('--transparent-opacity', transparencyOpacity.value.toString())
root.style.setProperty('--transparent-opacity-light', (transparencyOpacity.value * 0.67).toString())
@@ -390,10 +401,14 @@ function applyTransparencySettings() {
root.style.setProperty('--transparent-blur', `${transparencyBlur.value}px`)
root.style.setProperty('--transparent-blur-light', `${transparencyBlur.value * 0.6}px`)
root.style.setProperty('--transparent-blur-heavy', `${transparencyBlur.value * 1.6}px`)
root.style.setProperty('--transparent-background-poster-opacity', (1 - backgroundPosterOpacity.value).toString())
root.style.setProperty('--transparent-background-blur', `${backgroundBlur.value}px`)
// 保存到本地存储
localStorage.setItem('transparency-opacity', transparencyOpacity.value.toString())
localStorage.setItem('transparency-blur', transparencyBlur.value.toString())
localStorage.setItem('transparency-background-poster-opacity', backgroundPosterOpacity.value.toString())
localStorage.setItem('transparency-background-blur', backgroundBlur.value.toString())
}
// 调整透明度预设
@@ -434,10 +449,22 @@ function onBlurChange() {
transparencyLevel.value = ''
}
// 背景海报透明度变化处理
function onBackgroundPosterOpacityChange() {
applyTransparencySettings()
}
// 背景磨砂变化处理
function onBackgroundBlurChange() {
applyTransparencySettings()
}
// 重置透明度设置
function resetTransparencySettings() {
transparencyOpacity.value = 0.3
transparencyBlur.value = 10
backgroundPosterOpacity.value = 0
backgroundBlur.value = 16
transparencyLevel.value = 'medium'
applyTransparencySettings()
}
@@ -821,6 +848,38 @@ onUnmounted(() => {
/>
</div>
<!-- 背景海报透明度滑动条 -->
<div>
<div class="d-flex align-center justify-space-between mb-2">
<span class="text-body-2">{{ t('theme.backgroundPosterOpacity') }}</span>
<span class="text-caption">{{ Math.round(backgroundPosterOpacity * 100) }}%</span>
</div>
<VSlider
v-model="backgroundPosterOpacity"
:min="0"
:max="1"
:step="0.01"
color="primary"
@update:model-value="onBackgroundPosterOpacityChange"
/>
</div>
<!-- 背景磨砂滑动条 -->
<div>
<div class="d-flex align-center justify-space-between mb-2">
<span class="text-body-2">{{ t('theme.backgroundBlur') }}</span>
<span class="text-caption">{{ backgroundBlur }}px</span>
</div>
<VSlider
v-model="backgroundBlur"
:min="0"
:max="30"
:step="1"
color="primary"
@update:model-value="onBackgroundBlurChange"
/>
</div>
<!-- 预设按钮 -->
<div>
<span class="text-body-2 d-block mb-2">{{ t('common.preset') }}</span>

View File

@@ -149,6 +149,8 @@ export default {
transparencyAdjust: 'Transparency Adjustment',
transparencyOpacity: 'Opacity',
transparencyBlur: 'Blur',
backgroundPosterOpacity: 'Background Opacity',
backgroundBlur: 'Background Frosted Blur',
transparencyReset: 'Reset',
transparencyLow: 'Low Transparency',
transparencyMedium: 'Medium Transparency',
@@ -982,6 +984,8 @@ export default {
ranking: 'Ranking',
noStatisticsData: 'No share statistics data available',
bestVersion: 'Version Upgrading',
bestVersionEpisodeShort: 'Episode',
bestVersionWholeShort: 'Full',
completed: 'Completed',
subscribing: 'Subscribing',
notStarted: 'Not Started',
@@ -1416,9 +1420,12 @@ export default {
llmSupportImageInput: 'Model Supports Image Input',
llmSupportImageInputHint:
'When enabled, message images are sent to the LLM as multimodal image input. When disabled, images are saved locally as attachments and only the file path is passed to the AI assistant.',
llmSupportAudioInputOutput: 'Support Audio Input and Output',
llmSupportAudioInputOutputHint:
'When enabled, the AI assistant can transcribe incoming audio messages and reply with voice on supported channels.',
llmSupportAudioInput: 'Support Audio Input',
llmSupportAudioInputHint:
'When enabled, incoming audio messages are transcribed before being handled by the AI assistant.',
llmSupportAudioOutput: 'Support Audio Output',
llmSupportAudioOutputHint:
'When enabled, the AI assistant can send voice replies on supported channels.',
llmMaxContextTokens: 'LLM Max Context Tokens (K)',
llmMaxContextTokensHint:
'Set the maximum number of context tokens (in thousands) for the LLM. Exceeding this limit will trigger context trimming.',
@@ -1439,23 +1446,36 @@ export default {
llmProviderDeviceCode: 'Device Code',
llmProviderOpenAuthPage: 'Open Authorization Page',
llmProviderCheckAuthStatus: 'Check Authorization Status',
aiVoiceApiKey: 'Audio API Key',
aiVoiceApiKeyHint:
'API key used for audio transcription and speech synthesis. Falls back to the current LLM API key when left blank.',
aiVoiceBaseUrl: 'Audio Base URL',
aiVoiceBaseUrlHint:
'Base URL used for audio transcription and speech synthesis. Falls back to the current LLM base URL when left blank.',
aiVoiceSttModel: 'Audio Transcription Model',
aiVoiceSttModelHint: 'Model name used to convert audio content into text.',
aiVoiceTtsModel: 'Speech Synthesis Model',
aiVoiceTtsModelHint: 'Model name used to convert text content into speech.',
aiVoiceTtsVoice: 'Voice Preset',
aiVoiceTtsVoiceHint: 'Speaker or voice preset used for speech synthesis.',
aiVoiceLanguage: 'Recognition Language',
aiVoiceLanguageHint:
audioInputProvider: 'Audio Input Provider',
audioInputProviderHint:
'Service used to transcribe incoming audio messages. Supports OpenAI audio, Chat Audio compatible APIs, and Xiaomi MiMo.',
audioProviderOpenAiAudio: 'OpenAI Audio Compatible',
audioProviderChatAudio: 'Chat Audio Compatible',
audioProviderMimo: 'Xiaomi MiMo',
audioInputApiKey: 'Audio Input API Key',
audioInputApiKeyHint: 'API key used for audio transcription.',
audioInputBaseUrl: 'Audio Input Base URL',
audioInputBaseUrlHint:
'Base URL for audio input. Use the matching compatible endpoint for Chat Audio services; MiMo defaults to https://api.xiaomimimo.com/v1.',
audioInputModel: 'Audio Input Model',
audioInputModelHint: 'Model name used to convert audio content into text.',
audioInputLanguage: 'Recognition Language',
audioInputLanguageHint:
'Default language for audio transcription, such as zh or en. Leave blank to use the backend default.',
aiVoiceReplyWithText: 'Include Text with Voice Replies',
aiVoiceReplyWithTextHint: 'When sending a voice reply, also include the text version of the response.',
audioOutputProvider: 'Audio Output Provider',
audioOutputProviderHint:
'Service used to generate voice replies. Supports OpenAI audio, Chat Audio compatible APIs, and Xiaomi MiMo.',
audioOutputApiKey: 'Audio Output API Key',
audioOutputApiKeyHint: 'API key used for speech synthesis.',
audioOutputBaseUrl: 'Audio Output Base URL',
audioOutputBaseUrlHint:
'Base URL for audio output. Use the matching compatible endpoint for Chat Audio services; MiMo defaults to https://api.xiaomimimo.com/v1.',
audioOutputModel: 'Audio Output Model',
audioOutputModelHint: 'Model name used to convert text content into speech.',
audioOutputVoice: 'Voice Preset',
audioOutputVoiceHint: 'Speaker or voice preset used for speech synthesis.',
audioOutputIncludeText: 'Include Text with Voice Replies',
audioOutputIncludeTextHint: 'When sending a voice reply, also include the text version of the response.',
llmTestAction: 'Test Call',
llmTestSuccessToast: 'LLM test call succeeded',
llmTestFailedToast: 'LLM test call failed',
@@ -2525,8 +2545,6 @@ export default {
previewTotal: 'Total {count}',
previewSuccess: 'Success {count}',
previewFailed: 'Failed {count}',
previewSourcePath: 'Source Path',
previewTargetPath: 'Target Path',
previewMediaInfo: 'Media',
previewMediaName: 'Name',
previewMediaType: 'Type',
@@ -2576,6 +2594,8 @@ export default {
savePathHint: 'Specify download save path for this subscription, leave empty to use default download directory',
bestVersion: 'Version Upgrade',
bestVersionHint: 'Perform version upgrade subscription based on upgrade priorities',
bestVersionFull: 'Full Season Upgrade',
bestVersionFullHint: 'Only download full-season packs and do not split packs by episode',
searchImdbid: 'Search Using ImdbID',
searchImdbidHint: 'Use ImdbID for precise resource searching',
showEditDialog: 'Edit More Rules When Subscribing',
@@ -2725,6 +2745,7 @@ export default {
close: 'Close',
loadingDirectoryStructure: 'Loading directory structure...',
reorganize: 'Reorganize',
filterPlaceholder: 'Filter (supports * ? wildcards)',
},
person: {
alias: 'Also Known As:',

View File

@@ -149,6 +149,8 @@ export default {
transparencyAdjust: '透明度调整',
transparencyOpacity: '透明度',
transparencyBlur: '模糊度',
backgroundPosterOpacity: '背景透明度',
backgroundBlur: '背景磨砂效果',
transparencyReset: '重置',
transparencyLow: '低透明度',
transparencyMedium: '中等透明度',
@@ -976,6 +978,8 @@ export default {
ranking: '排名',
noStatisticsData: '暂无分享统计数据',
bestVersion: '洗版中',
bestVersionEpisodeShort: '分集',
bestVersionWholeShort: '全集',
completed: '订阅完成',
subscribing: '订阅中',
notStarted: '未开始',
@@ -1408,9 +1412,10 @@ export default {
llmSupportImageInput: '模型支持图片输入',
llmSupportImageInputHint:
'启用后,消息中的图片会按多模态图片发送给 LLM关闭后图片会作为附件保存到本地并将文件路径提供给智能助手处理',
llmSupportAudioInputOutput: '支持音频输入输出',
llmSupportAudioInputOutputHint:
'启用后,智能助手可以转写用户发送的音频消息,并在支持的渠道上回复语音',
llmSupportAudioInput: '支持音频输入',
llmSupportAudioInputHint: '启用后,智能助手会将用户发送的音频消息转写为文字再处理',
llmSupportAudioOutput: '支持音频输出',
llmSupportAudioOutputHint: '启用后,智能助手可以在支持的渠道上发送语音回复',
llmMaxContextTokens: 'LLM 最大上下文 Token 数量 (K)',
llmMaxContextTokensHint:
'设定 LLM 记录会话历史的最大 Token 数量上限(千),超出后将自动修整历史记录以节省 Token 消耗及防止超出 LLM 限制',
@@ -1429,20 +1434,31 @@ export default {
llmProviderDeviceCode: '设备码',
llmProviderOpenAuthPage: '打开授权页面',
llmProviderCheckAuthStatus: '检查授权状态',
aiVoiceApiKey: '音频 API密钥',
aiVoiceApiKeyHint: '音频转写与语音合成使用的 API 密钥,留空时回退到当前 LLM API 密钥',
aiVoiceBaseUrl: '音频基础URL',
aiVoiceBaseUrlHint: '音频转写与语音合成接口的基础URL留空时回退到当前 LLM 基础 URL',
aiVoiceSttModel: '音频转写模型',
aiVoiceSttModelHint: '用于将音频内容转换为文字的模型名称',
aiVoiceTtsModel: '语音合成模型',
aiVoiceTtsModelHint: '用于将文字内容转换为语音的模型名称',
aiVoiceTtsVoice: '语音音色',
aiVoiceTtsVoiceHint: '语音合成使用的发音人或音色标识',
aiVoiceLanguage: '识别语言',
aiVoiceLanguageHint: '音频转写默认语言,例如 zh、en留空时按后端默认处理',
aiVoiceReplyWithText: '语音回复附带文字',
aiVoiceReplyWithTextHint: '发送语音回复时,同时附带一份文字内容',
audioInputProvider: '音频输入提供商',
audioInputProviderHint: '用于识别用户音频消息的服务,支持 OpenAI 音频接口、Chat Audio 兼容接口和 Xiaomi MiMo',
audioProviderOpenAiAudio: 'OpenAI Audio 兼容',
audioProviderChatAudio: 'Chat Audio 兼容',
audioProviderMimo: '小米 MiMo',
audioInputApiKey: '音频输入 API密钥',
audioInputApiKeyHint: '音频输入转写使用的 API 密钥',
audioInputBaseUrl: '音频输入基础URL',
audioInputBaseUrlHint: '音频输入接口基础URLChat Audio 类服务可填写对应兼容地址MiMo 默认 https://api.xiaomimimo.com/v1',
audioInputModel: '音频输入模型',
audioInputModelHint: '用于将音频内容转换为文字的模型名称',
audioInputLanguage: '识别语言',
audioInputLanguageHint: '音频转写默认语言,例如 zh、en留空时按后端默认处理',
audioOutputProvider: '音频输出提供商',
audioOutputProviderHint: '用于生成语音回复的服务,支持 OpenAI 音频接口、Chat Audio 兼容接口和 Xiaomi MiMo',
audioOutputApiKey: '音频输出 API密钥',
audioOutputApiKeyHint: '文字转语音使用的 API 密钥',
audioOutputBaseUrl: '音频输出基础URL',
audioOutputBaseUrlHint: '音频输出接口基础URLChat Audio 类服务可填写对应兼容地址MiMo 默认 https://api.xiaomimimo.com/v1',
audioOutputModel: '音频输出模型',
audioOutputModelHint: '用于将文字内容转换为语音的模型名称',
audioOutputVoice: '语音音色',
audioOutputVoiceHint: '语音合成使用的发音人或音色标识',
audioOutputIncludeText: '语音回复附带文字',
audioOutputIncludeTextHint: '发送语音回复时,同时附带一份文字内容',
llmTestAction: '测试调用',
llmTestSuccessToast: 'LLM 调用测试成功',
llmTestFailedToast: 'LLM 调用测试失败',
@@ -2480,8 +2496,6 @@ export default {
previewTotal: '总数 {count}',
previewSuccess: '成功 {count}',
previewFailed: '失败 {count}',
previewSourcePath: '原始路径',
previewTargetPath: '目的路径',
previewMediaInfo: '媒体信息',
previewMediaName: '名称',
previewMediaType: '类型',
@@ -2531,8 +2545,10 @@ export default {
savePathHint: '指定该订阅的下载保存路径,留空自动使用设定的下载目录',
bestVersion: '洗版',
bestVersionHint: '根据洗版优先级进行洗版订阅',
bestVersionFull: '全集洗版',
bestVersionFullHint: '只下载覆盖全集的整包资源,不按单集拆包下载',
searchImdbid: '使用 ImdbID 搜索',
searchImdbidHint: '开使用 ImdbID 精确搜索资源',
searchImdbidHint: '开启后使用 ImdbID 精确搜索资源',
showEditDialog: '订阅时编辑更多规则',
showEditDialogHint: '添加订阅时显示此编辑订阅对话框',
include: '包含(关键字、正则式)',
@@ -2680,6 +2696,7 @@ export default {
close: '关闭',
loadingDirectoryStructure: '加载目录结构...',
reorganize: '整理',
filterPlaceholder: '搜索(支持 * ? 通配符)',
},
person: {
alias: '别名:',

View File

@@ -149,6 +149,8 @@ export default {
transparencyAdjust: '透明度調整',
transparencyOpacity: '透明度',
transparencyBlur: '模糊度',
backgroundPosterOpacity: '背景透明度',
backgroundBlur: '背景磨砂效果',
transparencyReset: '重置',
transparencyLow: '低透明度',
transparencyMedium: '中等透明度',
@@ -977,6 +979,8 @@ export default {
ranking: '排名',
noStatisticsData: '暫無分享統計數據',
bestVersion: '洗版中',
bestVersionEpisodeShort: '分集',
bestVersionWholeShort: '全集',
completed: '訂閱完成',
subscribing: '訂閱中',
notStarted: '未開始',
@@ -1410,9 +1414,10 @@ export default {
llmSupportImageInput: '模型支援圖片輸入',
llmSupportImageInputHint:
'啟用後,消息中的圖片會按多模態圖片發送給 LLM關閉後圖片會作為附件保存到本地並將檔案路徑提供給智能助手處理',
llmSupportAudioInputOutput: '支援音頻輸入輸出',
llmSupportAudioInputOutputHint:
'啟用後,智能助手可以轉寫用戶發送的音頻消息,並在支援的渠道上回覆語音',
llmSupportAudioInput: '支援音頻輸入',
llmSupportAudioInputHint: '啟用後,智能助手會將用戶發送的音頻消息轉寫為文字再處理',
llmSupportAudioOutput: '支援音頻輸出',
llmSupportAudioOutputHint: '啟用後,智能助手可以在支援的渠道上發送語音回覆',
llmMaxContextTokens: 'LLM 最大上下文 Token 數量 (K)',
llmMaxContextTokensHint:
'設定 LLM 記錄會話歷史的最大 Token 數量上限(千),超出後將自動修整歷史記錄以節省 Token 消耗及防止超出 LLM 限制',
@@ -1431,20 +1436,31 @@ export default {
llmProviderDeviceCode: '設備碼',
llmProviderOpenAuthPage: '開啟授權頁面',
llmProviderCheckAuthStatus: '檢查授權狀態',
aiVoiceApiKey: '音頻 API密鑰',
aiVoiceApiKeyHint: '音頻轉寫與語音合成使用的 API 密鑰,留空時回退到當前 LLM API 密鑰',
aiVoiceBaseUrl: '音頻基礎URL',
aiVoiceBaseUrlHint: '音頻轉寫與語音合成接口的基礎URL留空時回退到當前 LLM 基礎 URL',
aiVoiceSttModel: '音頻轉寫模型',
aiVoiceSttModelHint: '用於將音頻內容轉換為文字的模型名稱',
aiVoiceTtsModel: '語音合成模型',
aiVoiceTtsModelHint: '用於將文字內容轉換為語音的模型名稱',
aiVoiceTtsVoice: '語音音色',
aiVoiceTtsVoiceHint: '語音合成使用的發音人或音色標識',
aiVoiceLanguage: '識別語言',
aiVoiceLanguageHint: '音頻轉寫預設語言,例如 zh、en留空時按後端預設處理',
aiVoiceReplyWithText: '語音回覆附帶文字',
aiVoiceReplyWithTextHint: '發送語音回覆時,同時附帶一份文字內容',
audioInputProvider: '音頻輸入提供商',
audioInputProviderHint: '用於識別用戶音頻消息的服務,支援 OpenAI 音頻接口、Chat Audio 兼容接口和 Xiaomi MiMo',
audioProviderOpenAiAudio: 'OpenAI Audio 兼容',
audioProviderChatAudio: 'Chat Audio 兼容',
audioProviderMimo: '小米 MiMo',
audioInputApiKey: '音頻輸入 API密鑰',
audioInputApiKeyHint: '音頻輸入轉寫使用的 API 密鑰',
audioInputBaseUrl: '音頻輸入基礎URL',
audioInputBaseUrlHint: '音頻輸入接口基礎URLChat Audio 類服務可填寫對應兼容地址MiMo 預設 https://api.xiaomimimo.com/v1',
audioInputModel: '音頻輸入模型',
audioInputModelHint: '用於將音頻內容轉換為文字的模型名稱',
audioInputLanguage: '識別語言',
audioInputLanguageHint: '音頻轉寫預設語言,例如 zh、en留空時按後端預設處理',
audioOutputProvider: '音頻輸出提供商',
audioOutputProviderHint: '用於生成語音回覆的服務,支援 OpenAI 音頻接口、Chat Audio 兼容接口和 Xiaomi MiMo',
audioOutputApiKey: '音頻輸出 API密鑰',
audioOutputApiKeyHint: '文字轉語音使用的 API 密鑰',
audioOutputBaseUrl: '音頻輸出基礎URL',
audioOutputBaseUrlHint: '音頻輸出接口基礎URLChat Audio 類服務可填寫對應兼容地址MiMo 預設 https://api.xiaomimimo.com/v1',
audioOutputModel: '音頻輸出模型',
audioOutputModelHint: '用於將文字內容轉換為語音的模型名稱',
audioOutputVoice: '語音音色',
audioOutputVoiceHint: '語音合成使用的發音人或音色標識',
audioOutputIncludeText: '語音回覆附帶文字',
audioOutputIncludeTextHint: '發送語音回覆時,同時附帶一份文字內容',
llmTestAction: '測試調用',
llmTestSuccessToast: 'LLM 調用測試成功',
llmTestFailedToast: 'LLM 調用測試失敗',
@@ -2482,8 +2498,6 @@ export default {
previewTotal: '總數 {count}',
previewSuccess: '成功 {count}',
previewFailed: '失敗 {count}',
previewSourcePath: '原始路徑',
previewTargetPath: '目的路徑',
previewMediaInfo: '媒體資訊',
previewMediaName: '名稱',
previewMediaType: '類型',
@@ -2533,6 +2547,8 @@ export default {
savePathHint: '指定該訂閱的下載儲存路徑,留空自動使用設定的下載目錄',
bestVersion: '洗版',
bestVersionHint: '根據洗版優先級進行洗版訂閱',
bestVersionFull: '全集洗版',
bestVersionFullHint: '只下載覆蓋全集的整包資源,不按單集拆包下載',
searchImdbid: '使用 ImdbID 搜索',
searchImdbidHint: '開使用 ImdbID 精確搜索資源',
showEditDialog: '訂閱時編輯更多規則',
@@ -2682,6 +2698,7 @@ export default {
close: '關閉',
loadingDirectoryStructure: '加載目錄結構...',
reorganize: '整理',
filterPlaceholder: '搜尋(支援 * ? 萬用字元)',
},
person: {
alias: '別名:',

View File

@@ -13,32 +13,47 @@ import i18n from '@/plugins/i18n'
import App from '@/App.vue'
import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar'
// 4. 工具函数和其他辅助模块
import { loadRemoteComponents } from './utils/federationLoader'
// 5. 其他插件和功能模块
// 4. 其他插件和功能模块
import Toast from 'vue-toastification'
import ConfirmDialog from '@/composables/useConfirm'
import { configureApexChartsTheme } from '@/utils/apexCharts'
// 6. 注册自定义组件
// 5. 注册自定义组件
import DialogCloseBtn from '@/@core/components/DialogCloseBtn.vue'
import ScrollToTopBtn from '@/@core/components/ScrollToTopBtn.vue'
import PageContentTitle from './@core/components/PageContentTitle.vue'
// 7. 样式文件 - 合并为单一导入
// 6. 样式文件 - 合并为单一导入
import '@/styles/main.scss'
// 8. 状态恢复插件
// 7. 状态恢复插件
import stateRestorePlugin from '@/plugins/stateRestore'
// 9. 后台优化工具
import { backgroundManager } from '@/utils/backgroundManager'
import { sseManagerSingleton } from '@/utils/sseManager'
function runWhenBrowserIdle(callback: () => void, timeout = 1500) {
const requestIdle = globalThis.requestIdleCallback
if (requestIdle) {
requestIdle(callback, { timeout })
return
}
const iconBundlePromise = import('@/@iconify/icons-bundle').catch(error => {
console.error('Failed to load icon bundle', error)
})
globalThis.setTimeout(callback, 0)
}
function loadIconBundle() {
import('@/@iconify/icons-bundle').catch(error => {
console.error('Failed to load icon bundle', error)
})
}
function loadRemoteComponentsAfterLogin() {
import('./utils/federationLoader')
.then(({ loadRemoteComponents }) => loadRemoteComponents())
.catch(error => {
console.error('Failed to load remote components', error)
})
}
let remoteComponentsInitialized = false
const AsyncAceEditor = defineAsyncComponent(async () => {
await import('./ace-config')
@@ -70,11 +85,6 @@ const app = createApp(App)
// 1. 注册pinia
app.use(pinia)
// 异步加载远程组件(不阻塞启动)
loadRemoteComponents().catch(error => {
console.error('Failed to load remote components', error)
})
// 2. 注册 UI 框架
app.use(vuetify)
@@ -105,11 +115,20 @@ app
.use(ConfirmDialog)
.use(i18n)
await iconBundlePromise
app.mount('#app')
// 页面卸载时清理后台管理器
window.addEventListener('beforeunload', () => {
backgroundManager.destroy()
sseManagerSingleton.closeAllManagers()
// 图标全集很大,延后到首屏挂载后的空闲时间加载,避免阻塞登录页首次渲染。
runWhenBrowserIdle(loadIconBundle)
// 插件远程入口只在登录后有用,延后初始化可以减少未登录首屏请求和解析成本。
router.isReady().then(() => {
const loadIfAuthenticated = () => {
if (!remoteComponentsInitialized && pinia.state.value.auth?.token) {
remoteComponentsInitialized = true
runWhenBrowserIdle(loadRemoteComponentsAfterLogin)
}
}
loadIfAuthenticated()
router.afterEach(loadIfAuthenticated)
})

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { VForm } from 'vuetify/components/VForm'
import { useAuthStore, useUserStore, useGlobalSettingsStore } from '@/stores'
import { useAuthStore, useUserStore } from '@/stores'
import { authState, userState } from '@/stores/types'
import { requiredValidator } from '@/@validators'
import api from '@/api'
@@ -20,9 +20,6 @@ const { t } = useI18n()
const authStore = useAuthStore()
//用户 Store
const userStore = useUserStore()
// 全局设置 Store
const globalSettingsStore = useGlobalSettingsStore()
// 获取有权限的菜单
const navMenus = computed(() => getNavMenus(t))
@@ -373,9 +370,6 @@ async function handleLoginSuccess(response: any) {
authStore.login(authPayLoad)
userStore.loginUser(userPayload)
// 登录后加载用户相关的全局设置
await globalSettingsStore.loadUserSettings()
await afterLogin(userPayload.superUser, userPayload, filteredMenus)
}

View File

@@ -39,6 +39,8 @@ interface SearchParams {
sites: string
}
const resourceSearchParamsStorageKey = 'MP_ResourceSearchParams'
function createSearchParams(query: LocationQuery): SearchParams {
return {
keyword: query?.keyword?.toString() ?? '',
@@ -51,15 +53,62 @@ function createSearchParams(query: LocationQuery): SearchParams {
}
}
function getSearchParamsKey(params: SearchParams): string {
return JSON.stringify(params)
function normalizeSearchParams(params?: Partial<SearchParams> | null): SearchParams {
return {
keyword: params?.keyword?.toString() ?? '',
type: params?.type?.toString() ?? '',
area: params?.area?.toString() ?? '',
title: params?.title?.toString() ?? '',
year: params?.year?.toString() ?? '',
season: params?.season?.toString() ?? '',
sites: params?.sites?.toString() ?? '',
}
}
function hasSearchKeyword(params: SearchParams): boolean {
return params.keyword.trim().length > 0
}
function createSearchRequestToken(): string {
return `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
}
const activeSearchParams = ref<SearchParams>(createSearchParams(route.query))
function loadStoredSearchParams(): SearchParams | null {
try {
const rawParams = localStorage.getItem(resourceSearchParamsStorageKey)
if (!rawParams) return null
const params = normalizeSearchParams(JSON.parse(rawParams) as Partial<SearchParams>)
return hasSearchKeyword(params) ? params : null
} catch (error) {
console.warn('读取资源搜索参数失败:', error)
localStorage.removeItem(resourceSearchParamsStorageKey)
return null
}
}
function saveStoredSearchParams(params: SearchParams) {
if (!hasSearchKeyword(params)) return
localStorage.setItem(resourceSearchParamsStorageKey, JSON.stringify(params))
}
const initialSearchParams = createSearchParams(route.query)
const activeSearchParams = ref<SearchParams>(initialSearchParams)
const lastSearchParams = ref<SearchParams | null>(
hasSearchKeyword(initialSearchParams) ? { ...initialSearchParams } : loadStoredSearchParams(),
)
function rememberSearchParams(params: SearchParams) {
if (!hasSearchKeyword(params)) return
const nextParams = { ...params }
lastSearchParams.value = nextParams
saveStoredSearchParams(nextParams)
}
if (hasSearchKeyword(initialSearchParams)) {
rememberSearchParams(initialSearchParams)
}
// 查询TMDBID或标题
const keyword = computed(() => activeSearchParams.value.keyword)
@@ -552,13 +601,17 @@ function changeViewType(newType: string) {
}
// 获取搜索列表数据
async function fetchData(options: { force?: boolean } = {}) {
const currentSearchParams = { ...activeSearchParams.value }
async function fetchData(options: { force?: boolean; params?: SearchParams } = {}) {
const currentSearchParams = { ...(options.params ?? activeSearchParams.value) }
if (hasSearchKeyword(currentSearchParams)) {
activeSearchParams.value = { ...currentSearchParams }
rememberSearchParams(currentSearchParams)
}
const requestToken = options.force || Boolean(currentSearchParams.keyword) ? createSearchRequestToken() : undefined
try {
enableFilterAnimation.value = true
if (!currentSearchParams.keyword) {
if (!hasSearchKeyword(currentSearchParams)) {
// 查询上次搜索结果
const results = await api.get('search/last', {
params: requestToken ? { _ts: requestToken } : undefined,
@@ -593,11 +646,12 @@ async function fetchData(options: { force?: boolean } = {}) {
// 重新搜索(使用相同参数重新触发搜索)
async function refreshSearch() {
if (isRefreshing.value || progressActive.value) return
const refreshParams = lastSearchParams.value ?? activeSearchParams.value
isRefreshing.value = true
try {
// 重新搜索时退出 AI 视图,其余状态由 fetchData 内部重置
showingAiResults.value = false
await fetchData({ force: true })
await fetchData({ force: true, params: refreshParams })
} catch (error) {
console.error('重新搜索失败:', error)
} finally {
@@ -885,7 +939,7 @@ watch(
if (Object.keys(query).length === 0) return
const nextSearchParams = createSearchParams(query)
if (getSearchParamsKey(nextSearchParams) === getSearchParamsKey(activeSearchParams.value)) return
if (!hasSearchKeyword(nextSearchParams)) return
activeSearchParams.value = nextSearchParams
void fetchData()
@@ -1149,14 +1203,19 @@ onUnmounted(() => {
</div>
</div>
<div v-else-if="filteredRowDataList.length > 0" class="resource-list">
<VVirtualScroll renderless :items="filteredRowDataList" :item-height="240">
<template #default="{ item, index, itemRef }">
<div :ref="itemRef" :key="getTorrentItemKey(item, index)">
<TorrentItem :torrent="item" />
<VDivider v-if="index < filteredRowDataList.length - 1" class="my-2" />
</div>
<ProgressiveCardGrid
:items="filteredRowDataList"
:columns="1"
:gap="8"
:estimated-item-height="240"
:overscan-rows="6"
:get-item-key="getTorrentItemKey"
>
<template #default="{ item, index }">
<TorrentItem :torrent="item" />
<VDivider v-if="index < filteredRowDataList.length - 1" class="my-2" />
</template>
</VVirtualScroll>
</ProgressiveCardGrid>
</div>
</VCard>
</div>

View File

@@ -1,13 +1,6 @@
<script lang="ts" setup>
import { useRoute } from 'vue-router'
import router from '@/router'
import AccountSettingNotification from '@/views/setting/AccountSettingNotification.vue'
import AccountSettingSite from '@/views/setting/AccountSettingSite.vue'
import AccountSettingSearch from '@/views/setting/AccountSettingSearch.vue'
import AccountSettingSubscribe from '@/views/setting/AccountSettingSubscribe.vue'
import AccountSettingSystem from '@/views/setting/AccountSettingSystem.vue'
import AccountSettingDirectory from '@/views/setting/AccountSettingDirectory.vue'
import AccountSettingRule from '@/views/setting/AccountSettingRule.vue'
import { getSettingTabs } from '@/router/i18n-menu'
import { useDynamicHeaderTab } from '@/composables/useDynamicHeaderTab'
@@ -17,6 +10,15 @@ const route = useRoute()
const activeTab = ref((route.query.tab as string) || '')
const settingTabs = computed(() => getSettingTabs(t))
// 设置页的每个大类都很重,按标签页拆包,避免进入设置时一次性下载全部配置面板。
const AccountSettingSystem = defineAsyncComponent(() => import('@/views/setting/AccountSettingSystem.vue'))
const AccountSettingDirectory = defineAsyncComponent(() => import('@/views/setting/AccountSettingDirectory.vue'))
const AccountSettingSite = defineAsyncComponent(() => import('@/views/setting/AccountSettingSite.vue'))
const AccountSettingRule = defineAsyncComponent(() => import('@/views/setting/AccountSettingRule.vue'))
const AccountSettingSearch = defineAsyncComponent(() => import('@/views/setting/AccountSettingSearch.vue'))
const AccountSettingSubscribe = defineAsyncComponent(() => import('@/views/setting/AccountSettingSubscribe.vue'))
const AccountSettingNotification = defineAsyncComponent(() => import('@/views/setting/AccountSettingNotification.vue'))
// 使用动态标签页
const { registerHeaderTab } = useDynamicHeaderTab()

View File

@@ -1,10 +1,6 @@
<script setup lang="ts">
import { debounce } from 'lodash-es'
import SubscribeListView from '@/views/subscribe/SubscribeListView.vue'
import SubscribePopularView from '@/views/subscribe/SubscribePopularView.vue'
import SubscribeShareView from '@/views/subscribe/SubscribeShareView.vue'
import SubscribeEditDialog from '@/components/dialog/SubscribeEditDialog.vue'
import SubscribeShareStatisticsDialog from '@/components/dialog/SubscribeShareStatisticsDialog.vue'
import { useI18n } from 'vue-i18n'
import { useDynamicHeaderTab } from '@/composables/useDynamicHeaderTab'
import { useDynamicButton } from '@/composables/useDynamicButton'
@@ -20,6 +16,14 @@ const route = useRoute()
const userStore = useUserStore()
const { appMode } = usePWA()
// 非默认标签页和弹窗按需加载,避免进入订阅列表时同步下载分享/统计相关代码。
const SubscribePopularView = defineAsyncComponent(() => import('@/views/subscribe/SubscribePopularView.vue'))
const SubscribeShareView = defineAsyncComponent(() => import('@/views/subscribe/SubscribeShareView.vue'))
const SubscribeEditDialog = defineAsyncComponent(() => import('@/components/dialog/SubscribeEditDialog.vue'))
const SubscribeShareStatisticsDialog = defineAsyncComponent(
() => import('@/components/dialog/SubscribeShareStatisticsDialog.vue'),
)
const subType = route.meta.subType?.toString()
const subId = ref(route.query.id as string)
const activeTab = ref((route.query.tab as string) || '')

View File

@@ -11,56 +11,61 @@ export class BackgroundManager {
runInBackground?: boolean
}> = new Map()
private readonly activityEvents = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart', 'click']
private readonly handleVisibilityChange = () => {
const wasBackground = this.isBackground
this.isBackground = document.hidden
if (this.isBackground && !wasBackground) {
console.log('Background: 进入后台,暂停定时器')
this.pauseAllTimers()
} else if (!this.isBackground && wasBackground) {
console.log('Background: 回到前台,恢复定时器')
this.resumeAllTimers()
}
}
private readonly handleBeforeUnload = () => {
this.destroy()
}
private readonly updateActivity = () => {
this.lastActivityTime = Date.now()
}
private isBackground = false
private isDestroyed = false
private lastActivityTime = Date.now()
private activityTimer: ReturnType<typeof setInterval> | null = null
private isInitialized = false
constructor() {
private ensureInitialized() {
if (this.isInitialized || this.isDestroyed) return
this.isInitialized = true
this.isBackground = document.hidden
this.setupVisibilityListener()
this.setupActivityTracking()
}
private setupVisibilityListener() {
document.addEventListener('visibilitychange', () => {
const wasBackground = this.isBackground
this.isBackground = document.hidden
if (this.isBackground && !wasBackground) {
console.log('Background: 进入后台,暂停定时器')
this.pauseAllTimers()
} else if (!this.isBackground && wasBackground) {
console.log('Background: 回到前台,恢复定时器')
this.resumeAllTimers()
}
})
// 页面卸载时清理
window.addEventListener('beforeunload', () => {
this.destroy()
})
document.addEventListener('visibilitychange', this.handleVisibilityChange)
window.addEventListener('beforeunload', this.handleBeforeUnload)
}
private setupActivityTracking() {
// 跟踪用户活动
const events = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart', 'click']
const updateActivity = () => {
this.lastActivityTime = Date.now()
}
events.forEach(event => {
document.addEventListener(event, updateActivity, { passive: true })
// 按需跟踪用户活动,避免应用启动时就注册一批全局监听。
this.activityEvents.forEach(event => {
document.addEventListener(event, this.updateActivity, { passive: true })
})
}
// 定期更新活动状态
this.activityTimer = setInterval(() => {
// 如果超过5分钟没有活动可以考虑减少后台活动
const inactiveTime = Date.now() - this.lastActivityTime
if (inactiveTime > 5 * 60 * 1000) {
console.log('Background: 用户长时间不活跃')
}
}, 60000) // 每分钟检查一次
private removeLifecycleListeners() {
if (!this.isInitialized) return
document.removeEventListener('visibilitychange', this.handleVisibilityChange)
window.removeEventListener('beforeunload', this.handleBeforeUnload)
this.activityEvents.forEach(event => {
document.removeEventListener(event, this.updateActivity)
})
this.isInitialized = false
}
/**
@@ -76,6 +81,9 @@ export class BackgroundManager {
} = {}
) {
const { runInBackground = false, skipInitialRun = false } = options
if (this.isDestroyed) return
this.ensureInitialized()
this.removeTimer(id)
@@ -122,6 +130,11 @@ export class BackgroundManager {
}
this.timers.delete(id)
console.log(`Background: 移除定时器 ${id}`)
// 没有任务时释放监听,首屏只导入模块不会产生常驻开销。
if (this.timers.size === 0) {
this.removeLifecycleListeners()
}
}
}
@@ -237,11 +250,8 @@ export class BackgroundManager {
})
this.timers.clear()
// 清理活动跟踪定时器
if (this.activityTimer) {
clearInterval(this.activityTimer)
this.activityTimer = null
}
// 清理按需注册的生命周期与活动监听
this.removeLifecycleListeners()
console.log('Background: 管理器已销毁')
}
@@ -273,4 +283,4 @@ export function removeBackgroundTimer(id: string) {
export function getBackgroundTimerStatus(id: string) {
return backgroundManager.getTimerStatus(id)
}
}

View File

@@ -3,6 +3,7 @@ import { ref, onMounted } from 'vue'
import api from '@/api'
import type { MediaServerConf, MediaServerPlayItem } from '@/api/types'
import PosterCard from '@/components/cards/PosterCard.vue'
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
import { useI18n } from 'vue-i18n'
// 国际化
@@ -67,9 +68,18 @@ onActivated(() => {
<VCardTitle>{{ t('dashboard.latest') }} - {{ name }}</VCardTitle>
</VCardItem>
<div class="grid gap-4 grid-media-card mx-3 mb-3" tabindex="0">
<PosterCard v-for="item in data" :key="item.id" :media="item" />
</div>
<ProgressiveCardGrid
:items="data"
:get-item-key="item => item.id || item.link || item.title"
:min-item-width="144"
:item-aspect-ratio="1.5"
class="mx-3 mb-3"
tabindex="0"
>
<template #default="{ item }">
<PosterCard :media="item" />
</template>
</ProgressiveCardGrid>
</VCard>
</template>
</VHover>

View File

@@ -2,6 +2,7 @@
import api from '@/api'
import type { MediaServerConf, MediaServerLibrary } from '@/api/types'
import LibraryCard from '@/components/cards/LibraryCard.vue'
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
import { useI18n } from 'vue-i18n'
// 国际化
@@ -69,9 +70,18 @@ onActivated(() => {
</template>
<VCardTitle>{{ t('dashboard.library') }}</VCardTitle>
</VCardItem>
<div class="grid gap-4 grid-backdrop-card mx-3 mb-3" tabindex="0">
<LibraryCard v-for="item in libraryList" :key="item.id" :media="item" height="10rem" />
</div>
<ProgressiveCardGrid
:items="libraryList"
:get-item-key="item => item.id || item.name"
:min-item-width="240"
:estimated-item-height="160"
class="mx-3 mb-3"
tabindex="0"
>
<template #default="{ item }">
<LibraryCard :media="item" height="10rem" />
</template>
</ProgressiveCardGrid>
</VCard>
</template>
</VHover>

View File

@@ -2,6 +2,7 @@
import api from '@/api'
import type { MediaServerConf, MediaServerPlayItem } from '@/api/types'
import BackdropCard from '@/components/cards/BackdropCard.vue'
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
import { useI18n } from 'vue-i18n'
// 国际化
@@ -70,9 +71,18 @@ onActivated(() => {
<VCardTitle>{{ t('dashboard.playing') }}</VCardTitle>
</VCardItem>
<div class="grid gap-4 grid-backdrop-card mx-3 mb-3" tabindex="0">
<BackdropCard v-for="item in playingList" :key="item.id" :media="item" height="10rem" />
</div>
<ProgressiveCardGrid
:items="playingList"
:get-item-key="item => item.id || item.link || item.title"
:min-item-width="240"
:estimated-item-height="160"
class="mx-3 mb-3"
tabindex="0"
>
<template #default="{ item }">
<BackdropCard :media="item" height="10rem" />
</template>
</ProgressiveCardGrid>
</VCard>
</template>
</VHover>

View File

@@ -157,6 +157,7 @@ async function fetchData({ done }: { done: any }) {
<ProgressiveCardGrid
v-if="dataList.length > 0"
:items="dataList"
:item-aspect-ratio="1.5"
:get-item-key="item => item.tmdb_id || item.douban_id || item.bangumi_id || item.media_id || item.title"
tabindex="0"
>

View File

@@ -123,7 +123,13 @@ async function fetchData({ done }: { done: any }) {
<VInfiniteScroll mode="intersect" side="end" :items="dataList" class="overflow-visible px-3" @load="fetchData">
<template #loading />
<template #empty />
<ProgressiveCardGrid v-if="dataList.length > 0" :items="dataList" :get-item-key="item => item.id" tabindex="0">
<ProgressiveCardGrid
v-if="dataList.length > 0"
:items="dataList"
:item-aspect-ratio="1.5"
:get-item-key="item => item.id"
tabindex="0"
>
<template #default="{ item }">
<PersonCard :person="item" />
</template>

View File

@@ -1,15 +1,12 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import { useToast } from 'vue-toastification'
import api from '@/api'
import type { Plugin } from '@/api/types'
import NoDataFound from '@/components/NoDataFound.vue'
import PluginAppCard from '@/components/cards/PluginAppCard.vue'
import { getLogoUrl } from '@/utils/imageUtils'
import { useDisplay } from 'vuetify'
import { isNullOrEmptyObject } from '@/@core/utils'
import { getPluginTabs } from '@/router/i18n-menu'
import PluginMarketSettingDialog from '@/components/dialog/PluginMarketSettingDialog.vue'
import { useDynamicButton } from '@/composables/useDynamicButton'
import { useI18n } from 'vue-i18n'
import PluginMixedSortCard from '@/components/cards/PluginMixedSortCard.vue'
@@ -22,6 +19,11 @@ const { t } = useI18n()
const route = useRoute()
// 市场卡片、拖拽排序和市场设置只在对应标签/操作中需要,延迟到真正使用时加载。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const PluginAppCard = defineAsyncComponent(() => import('@/components/cards/PluginAppCard.vue'))
const PluginMarketSettingDialog = defineAsyncComponent(() => import('@/components/dialog/PluginMarketSettingDialog.vue'))
// 显示器宽度
const display = useDisplay()
@@ -1536,7 +1538,7 @@ function onDragStartPlugin(evt: any) {
<!-- 混合排序列表文件夹和插件 -->
<template v-if="!currentFolder">
<!-- 主列表使用draggable进行混合排序 -->
<draggable
<Draggable
v-if="canDragSort"
v-model="mixedSortList"
@end="saveMixedSortOrder"
@@ -1565,12 +1567,13 @@ function onDragStartPlugin(evt: any) {
@drop-to-folder="(event, folderName) => handleDropToFolder(event, folderName)"
/>
</template>
</draggable>
</Draggable>
<ProgressiveCardGrid
v-else-if="shouldVirtualizeInstalledMainList"
:items="mixedSortList"
:get-item-key="item => `${item.type}:${item.id}`"
:min-item-width="256"
:estimated-item-height="180"
:scroll-to-index="installedScrollToIndex"
>
<template #default="{ item }">
@@ -1597,7 +1600,7 @@ function onDragStartPlugin(evt: any) {
<template v-else>
<!-- 文件夹内使用draggable排序 + 移出按钮 -->
<draggable
<Draggable
v-if="canDragSort"
v-model="draggableFolderPlugins"
@end="saveFolderPluginOrder"
@@ -1623,12 +1626,13 @@ function onDragStartPlugin(evt: any) {
@remove-from-folder="removeFromFolder"
/>
</template>
</draggable>
</Draggable>
<ProgressiveCardGrid
v-else-if="shouldVirtualizeInstalledFolderList"
:items="draggableFolderPlugins"
:get-item-key="item => item.id"
:min-item-width="256"
:estimated-item-height="180"
>
<template #default="{ item }">
<PluginMixedSortCard

View File

@@ -180,9 +180,10 @@ const pageRange = [
{ title: '100', value: 100 },
{ title: '500', value: 500 },
{ title: '1000', value: 1000 },
{ title: 'All', value: -1 },
]
const pageRangeValues = pageRange.map(item => item.value)
// 数据列表
const dataList = ref<TransferHistory[]>([])
@@ -209,7 +210,7 @@ const groupBy = ref<any>([
])
// 每页条数
const itemsPerPage = ref<number>(ensureNumber(route.query.itemsPerPage, 50))
const itemsPerPage = ref<number>(ensurePageSize(route.query.itemsPerPage, 50))
// 当前页码
const currentPage = ref<number>(ensureNumber(route.query.currentPage, 1))
@@ -226,6 +227,9 @@ const progressValue = ref(0)
// 是否已刷新
const isRefreshed = ref(false)
// 是否已完成首次激活
const hasActivatedOnce = ref(false)
// 删除确认对话框
const deleteConfirmDialog = ref(false)
@@ -270,7 +274,7 @@ const TransferDict: { [key: string]: string } = {
// 分页提示
const pageTip = computed(() => {
const begin = itemsPerPage.value * (currentPage.value - 1) + 1
const end = itemsPerPage.value * currentPage.value === -1 ? 'ALL' : itemsPerPage.value * currentPage.value
const end = Math.min(itemsPerPage.value * currentPage.value, totalItems.value)
return {
begin,
end,
@@ -280,7 +284,7 @@ const pageTip = computed(() => {
// 分页总数
const totalPage = computed(() => {
const total = Math.ceil(totalItems.value / itemsPerPage.value)
return total
return Math.max(1, total)
})
// 切换页签
@@ -663,6 +667,11 @@ function ensureNumber(value: any, defaultValue: number = 0) {
return value
}
function ensurePageSize(value: any, defaultValue: number = 50) {
const pageSize = ensureNumber(value, defaultValue)
return pageRangeValues.includes(pageSize) ? pageSize : defaultValue
}
// 按标题分组后的选中数量统计,键为标题,值为对应分组的选中数
const selectedCountsGroupedByTitle = computed(() => {
return selected.value.reduce(
@@ -745,6 +754,17 @@ onMounted(() => {
fetchData()
})
onActivated(() => {
if (!hasActivatedOnce.value) {
hasActivatedOnce.value = true
return
}
if (!loading.value) {
fetchData()
}
})
onUnmounted(() => {
stopAiRedoProgress()
})

View File

@@ -1,14 +1,10 @@
<!-- eslint-disable sonarjs/no-duplicate-string -->
<script lang="ts" setup>
import { useToast } from 'vue-toastification'
import draggable from 'vuedraggable'
import { VRow } from 'vuetify/lib/components/index.mjs'
import api from '@/api'
import { TransferDirectoryConf, StorageConf } from '@/api/types'
import DirectoryCard from '@/components/cards/DirectoryCard.vue'
import StorageCard from '@/components/cards/StorageCard.vue'
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import CategoryEditDialog from '@/components/dialog/CategoryEditDialog.vue'
import { useI18n } from 'vue-i18n'
import { useTheme } from 'vuetify'
import { storageAttributes } from '@/api/constants'
@@ -16,6 +12,11 @@ import { storageAttributes } from '@/api/constants'
const { t } = useI18n()
const { global: globalTheme } = useTheme()
// 拖拽排序和分类编辑弹窗按需加载,避免设置框架预加载目录页时带上这些交互依赖。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const ProgressDialog = defineAsyncComponent(() => import('@/components/dialog/ProgressDialog.vue'))
const CategoryEditDialog = defineAsyncComponent(() => import('@/components/dialog/CategoryEditDialog.vue'))
// 所有下载目录
const directories = ref<TransferDirectoryConf[]>([])
@@ -264,7 +265,7 @@ onMounted(() => {
<VCardSubtitle>{{ t('setting.directory.storageDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="storages"
handle=".cursor-move"
item-key="name"
@@ -274,7 +275,7 @@ onMounted(() => {
<template #item="{ element }">
<StorageCard :storage="element" @close="removeStorage(element)" @done="loadStorages" />
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">
@@ -309,7 +310,7 @@ onMounted(() => {
<VCardSubtitle>{{ t('setting.directory.directoryDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="directories"
handle=".cursor-move"
item-key="pri"
@@ -331,7 +332,7 @@ onMounted(() => {
@close="removeDirectory(element)"
/>
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">

View File

@@ -1,10 +1,8 @@
<script lang="ts" setup>
import { useToast } from 'vue-toastification'
import api from '@/api'
import draggable from 'vuedraggable'
import type { NotificationConf, NotificationSwitchConf } from '@/api/types'
import NotificationChannelCard from '@/components/cards/NotificationChannelCard.vue'
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import { useI18n } from 'vue-i18n'
import { notificationSwitchDict } from '@/api/constants'
import { useTheme, useDisplay } from 'vuetify'
@@ -15,6 +13,10 @@ const display = useDisplay()
// 国际化
const { t } = useI18n()
// 通知渠道排序和进度弹窗按需加载,避免通知设置 chunk 直接包含拖拽库。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const ProgressDialog = defineAsyncComponent(() => import('@/components/dialog/ProgressDialog.vue'))
// 初始化模板配置字典
const templateConfigs = ref<Record<string, string>>({
organizeSuccess: '{}',
@@ -324,7 +326,7 @@ onMounted(() => {
<VCardSubtitle>{{ t('setting.notification.channelsDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="notifications"
handle=".cursor-move"
item-key="name"
@@ -339,7 +341,7 @@ onMounted(() => {
@close="removeNotification(element)"
/>
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">

View File

@@ -2,17 +2,19 @@
<script lang="ts" setup>
import { useToast } from 'vue-toastification'
import { copyToClipboard } from '@/@core/utils/navigator'
import draggable from 'vuedraggable'
import api from '@/api'
import { CustomRule, FilterRuleGroup } from '@/api/types'
import CustomerRuleCard from '@/components/cards/CustomRuleCard.vue'
import FilterRuleGroupCard from '@/components/cards/FilterRuleGroupCard.vue'
import ImportCodeDialog from '@/components/dialog/ImportCodeDialog.vue'
import { useI18n } from 'vue-i18n'
// 国际化
const { t } = useI18n()
// 拖拽库和导入弹窗只在规则编辑交互中需要,拆出设置页入口 chunk。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const ImportCodeDialog = defineAsyncComponent(() => import('@/components/dialog/ImportCodeDialog.vue'))
// 自定义规则列表
const customRules = ref<CustomRule[]>([])
@@ -381,7 +383,7 @@ onMounted(() => {
<VCardSubtitle>{{ t('setting.rule.customRulesDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="customRules"
handle=".cursor-move"
item-key="name"
@@ -396,7 +398,7 @@ onMounted(() => {
@change="onRuleChange"
/>
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">
@@ -432,7 +434,7 @@ onMounted(() => {
<VCardSubtitle>{{ t('setting.rule.priorityRuleGroupsDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="filterRuleGroups"
handle=".cursor-move"
item-key="name"
@@ -449,7 +451,7 @@ onMounted(() => {
@change="changeRuleGroup"
/>
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">

View File

@@ -1,14 +1,11 @@
<!-- eslint-disable sonarjs/no-duplicate-string -->
<script lang="ts" setup>
import { useToast } from 'vue-toastification'
import { VRow } from 'vuetify/lib/components/index.mjs'
import draggable from 'vuedraggable'
import api from '@/api'
import { DownloaderConf, MediaServerConf } from '@/api/types'
import DownloaderCard from '@/components/cards/DownloaderCard.vue'
import MediaServerCard from '@/components/cards/MediaServerCard.vue'
import { copyToClipboard } from '@/@core/utils/navigator'
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import { useI18n } from 'vue-i18n'
import { downloaderOptions, mediaServerOptions } from '@/api/constants'
import { useDisplay, useTheme } from 'vuetify'
@@ -22,6 +19,10 @@ const isTransparentTheme = computed(() => theme.name.value === 'transparent')
// 国际化
const { t } = useI18n()
// 下载器/媒体服务器排序和进度弹窗按需加载,降低系统设置页入口解析量。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const ProgressDialog = defineAsyncComponent(() => import('@/components/dialog/ProgressDialog.vue'))
// 系统设置项
const SystemSettings = ref<any>({
// 基础设置
@@ -43,17 +44,22 @@ const SystemSettings = ref<any>({
LLM_MODEL: 'deepseek-chat',
LLM_THINKING_LEVEL: 'off',
LLM_SUPPORT_IMAGE_INPUT: false,
LLM_SUPPORT_AUDIO_INPUT_OUTPUT: false,
LLM_SUPPORT_AUDIO_INPUT: false,
LLM_SUPPORT_AUDIO_OUTPUT: false,
LLM_API_KEY: null,
LLM_BASE_URL: 'https://api.deepseek.com',
LLM_BASE_URL_PRESET: null,
AI_VOICE_API_KEY: null,
AI_VOICE_BASE_URL: null,
AI_VOICE_STT_MODEL: 'gpt-4o-mini-transcribe',
AI_VOICE_TTS_MODEL: 'gpt-4o-mini-tts',
AI_VOICE_TTS_VOICE: 'alloy',
AI_VOICE_LANGUAGE: 'zh',
AI_VOICE_REPLY_WITH_TEXT: false,
AUDIO_INPUT_PROVIDER: 'openai',
AUDIO_INPUT_API_KEY: null,
AUDIO_INPUT_BASE_URL: null,
AUDIO_INPUT_MODEL: 'gpt-4o-mini-transcribe',
AUDIO_INPUT_LANGUAGE: 'zh',
AUDIO_OUTPUT_PROVIDER: 'openai',
AUDIO_OUTPUT_API_KEY: null,
AUDIO_OUTPUT_BASE_URL: null,
AUDIO_OUTPUT_MODEL: 'gpt-4o-mini-tts',
AUDIO_OUTPUT_VOICE: 'alloy',
AUDIO_OUTPUT_INCLUDE_TEXT: false,
AI_AGENT_RETRY_TRANSFER: false,
AI_RECOMMEND_ENABLED: false,
AI_RECOMMEND_USER_PREFERENCE: null,
@@ -110,6 +116,12 @@ const SystemSettings = ref<any>({
},
})
const audioProviderItems = computed(() => [
{ title: t('setting.system.audioProviderOpenAiAudio'), value: 'openai' },
{ title: t('setting.system.audioProviderChatAudio'), value: 'openai_chat_audio' },
{ title: t('setting.system.audioProviderMimo'), value: 'mimo' },
])
// 刮削配置
const scrapingConfig = [
{
@@ -179,6 +191,9 @@ const advancedDialog = ref(false)
const savingBasic = ref(false)
const testingLlm = ref(false)
// 智能助手配置项较多,默认收起以降低基础设置页的视觉占用。
const aiAgentSettingsCollapsed = ref(true)
type LlmSettingsSnapshot = {
AI_AGENT_ENABLE: boolean
LLM_PROVIDER: string
@@ -985,7 +1000,7 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
variant="outlined"
:class="['mt-6', isTransparentTheme ? 'ai-agent-settings-card-transparent' : 'ai-agent-settings-card']"
>
<VCardItem class="pb-2">
<VCardItem class="pb-3">
<template #prepend>
<VAvatar color="primary" variant="tonal" size="40">
<VIcon icon="mdi-robot-outline" />
@@ -997,374 +1012,457 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
<VCardSubtitle>
{{ t('setting.system.aiAgentSectionDesc') }}
</VCardSubtitle>
<template #append>
<VTooltip location="top">
<template #activator="{ props }">
<VBtn
v-bind="props"
:icon="aiAgentSettingsCollapsed ? 'mdi-chevron-down' : 'mdi-chevron-up'"
variant="text"
color="primary"
size="small"
:aria-label="aiAgentSettingsCollapsed ? t('setting.about.expand') : t('setting.about.collapse')"
@click="aiAgentSettingsCollapsed = !aiAgentSettingsCollapsed"
/>
</template>
<span>{{
aiAgentSettingsCollapsed ? t('setting.about.expand') : t('setting.about.collapse')
}}</span>
</VTooltip>
</template>
</VCardItem>
<VCardText class="pt-2">
<VRow>
<VCol cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_ENABLE"
:label="t('setting.system.aiAgentEnable')"
:hint="t('setting.system.aiAgentEnableHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_GLOBAL"
:label="t('setting.system.aiAgentGlobal')"
:hint="t('setting.system.aiAgentGlobalHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_VERBOSE"
:label="t('setting.system.aiAgentVerbose')"
:hint="t('setting.system.aiAgentVerboseHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VAutocomplete
v-model="SystemSettings.Basic.LLM_PROVIDER"
:label="t('setting.system.llmProvider')"
:hint="t('setting.system.llmProviderHint')"
persistent-hint
:items="llmProviderItems"
:loading="loadingLlmProviders"
prepend-inner-icon="mdi-robot"
@update:model-value="handleLlmProviderChanged"
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && showBaseUrlField" cols="12" md="6">
<VCombobox
:model-value="SystemSettings.Basic.LLM_BASE_URL"
@update:model-value="
(value: any) => {
if (typeof value === 'object' && value !== null) {
setBaseUrlPreset(value.id, value.value)
} else {
setBaseUrlPreset('', value || '')
}
}
"
:label="t('setting.system.llmBaseUrl')"
:hint="t('setting.system.llmBaseUrlHint')"
:placeholder="selectedLlmProvider?.default_base_url || 'https://api.deepseek.com'"
:items="llmBaseUrlPresetItems"
item-title="title"
item-value="value"
persistent-hint
prepend-inner-icon="mdi-link"
>
<template #item="{ props, item }">
<VListItem v-bind="props" :subtitle="item.raw.subtitle" />
</template>
</VCombobox>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && showApiKeyField" cols="12" md="6">
<VTextField
v-model="SystemSettings.Basic.LLM_API_KEY"
:label="selectedLlmProvider?.api_key_label || t('setting.system.llmApiKey')"
:hint="selectedLlmProvider?.api_key_hint || t('setting.system.llmApiKeyHint')"
:placeholder="t('setting.system.llmApiKeyPlaceholder')"
persistent-hint
type="password"
prepend-inner-icon="mdi-key-variant"
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && llmProviderAuthMethods.length > 0" cols="12">
<VAlert type="info" variant="tonal">
<div class="d-flex flex-column flex-md-row justify-space-between ga-3">
<div>
<div class="text-subtitle-2">{{ t('setting.system.llmProviderAuth') }}</div>
<div class="text-body-2">
{{ selectedLlmProvider?.description || t('setting.system.llmProviderAuthHint') }}
</div>
<div v-if="providerConnected" class="text-body-2 mt-2">
{{
t('setting.system.llmProviderConnectedAs', {
label: llmProviderAuthLabel || selectedLlmProvider?.name,
})
}}
</div>
</div>
<div class="d-flex flex-wrap ga-2">
<VBtn
v-for="method in llmProviderAuthMethods"
:key="method.id"
color="primary"
variant="tonal"
prepend-icon="mdi-account-arrow-right-outline"
@click="startProviderAuth(method.id)"
>
{{ method.label }}
</VBtn>
<VBtn
v-if="providerConnected"
color="error"
variant="text"
prepend-icon="mdi-link-off"
@click="disconnectProviderAuth"
>
{{ t('setting.system.llmProviderDisconnect') }}
</VBtn>
</div>
</div>
</VAlert>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<div>
<VExpandTransition>
<VCardText v-show="!aiAgentSettingsCollapsed" class="pt-2">
<VRow>
<VCol cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_ENABLE"
:label="t('setting.system.aiAgentEnable')"
:hint="t('setting.system.aiAgentEnableHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_GLOBAL"
:label="t('setting.system.aiAgentGlobal')"
:hint="t('setting.system.aiAgentGlobalHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_VERBOSE"
:label="t('setting.system.aiAgentVerbose')"
:hint="t('setting.system.aiAgentVerboseHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VAutocomplete
v-model="SystemSettings.Basic.LLM_PROVIDER"
:label="t('setting.system.llmProvider')"
:hint="t('setting.system.llmProviderHint')"
persistent-hint
:items="llmProviderItems"
:loading="loadingLlmProviders"
prepend-inner-icon="mdi-robot"
@update:model-value="handleLlmProviderChanged"
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && showBaseUrlField" cols="12" md="6">
<VCombobox
:model-value="SystemSettings.Basic.LLM_MODEL"
:model-value="SystemSettings.Basic.LLM_BASE_URL"
@update:model-value="
(val: any) => {
SystemSettings.Basic.LLM_MODEL = typeof val === 'object' && val !== null ? val.id : val
handleLlmModelChanged()
(value: any) => {
if (typeof value === 'object' && value !== null) {
setBaseUrlPreset(value.id, value.value)
} else {
setBaseUrlPreset('', value || '')
}
}
"
:label="t('setting.system.llmModel')"
:hint="t('setting.system.llmModelHint')"
:placeholder="t('setting.system.llmModelHint')"
:label="t('setting.system.llmBaseUrl')"
:hint="t('setting.system.llmBaseUrlHint')"
:placeholder="selectedLlmProvider?.default_base_url || 'https://api.deepseek.com'"
:items="llmBaseUrlPresetItems"
item-title="title"
item-value="value"
persistent-hint
:items="llmModels"
item-title="name"
item-value="id"
:loading="loadingModels"
prepend-inner-icon="mdi-brain"
prepend-inner-icon="mdi-link"
>
<template #append-inner>
<VBtn
variant="text"
icon="mdi-refresh"
size="small"
@click="refreshLlmModels(true)"
:disabled="!canRefreshModels"
/>
<template #item="{ props, item }">
<VListItem v-bind="props" :subtitle="item.raw.subtitle" />
</template>
</VCombobox>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && showApiKeyField" cols="12" md="6">
<VTextField
v-model="SystemSettings.Basic.LLM_API_KEY"
:label="selectedLlmProvider?.api_key_label || t('setting.system.llmApiKey')"
:hint="selectedLlmProvider?.api_key_hint || t('setting.system.llmApiKeyHint')"
:placeholder="t('setting.system.llmApiKeyPlaceholder')"
persistent-hint
type="password"
prepend-inner-icon="mdi-key-variant"
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && llmProviderAuthMethods.length > 0" cols="12">
<VAlert type="info" variant="tonal">
<div class="d-flex flex-column flex-md-row justify-space-between ga-3">
<div>
<div class="text-subtitle-2">{{ t('setting.system.llmProviderAuth') }}</div>
<div class="text-body-2">
{{ selectedLlmProvider?.description || t('setting.system.llmProviderAuthHint') }}
</div>
<div v-if="providerConnected" class="text-body-2 mt-2">
{{
t('setting.system.llmProviderConnectedAs', {
label: llmProviderAuthLabel || selectedLlmProvider?.name,
})
}}
</div>
</div>
<VAlert v-if="selectedLlmModelInfo" type="info" variant="tonal" density="compact" class="mt-2">
{{ selectedLlmModelInfo }}
<div class="d-flex flex-wrap ga-2">
<VBtn
v-for="method in llmProviderAuthMethods"
:key="method.id"
color="primary"
variant="tonal"
prepend-icon="mdi-account-arrow-right-outline"
@click="startProviderAuth(method.id)"
>
{{ method.label }}
</VBtn>
<VBtn
v-if="providerConnected"
color="error"
variant="text"
prepend-icon="mdi-link-off"
@click="disconnectProviderAuth"
>
{{ t('setting.system.llmProviderDisconnect') }}
</VBtn>
</div>
</div>
</VAlert>
<div class="d-flex justify-end mt-2">
<VBtn
color="info"
variant="tonal"
density="comfortable"
prepend-icon="mdi-connection"
:disabled="!canTestLlm"
:loading="testingLlm"
class="llm-test-trigger"
@click="testLlmConnection"
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<div>
<VCombobox
:model-value="SystemSettings.Basic.LLM_MODEL"
@update:model-value="
(val: any) => {
SystemSettings.Basic.LLM_MODEL = typeof val === 'object' && val !== null ? val.id : val
handleLlmModelChanged()
}
"
:label="t('setting.system.llmModel')"
:hint="t('setting.system.llmModelHint')"
:placeholder="t('setting.system.llmModelHint')"
persistent-hint
:items="llmModels"
item-title="name"
item-value="id"
:loading="loadingModels"
prepend-inner-icon="mdi-brain"
>
{{ t('setting.system.llmTestAction') }}
</VBtn>
<template #append-inner>
<VBtn
variant="text"
icon="mdi-refresh"
size="small"
@click="refreshLlmModels(true)"
:disabled="!canRefreshModels"
/>
</template>
</VCombobox>
<VAlert v-if="selectedLlmModelInfo" type="info" variant="tonal" density="compact" class="mt-2">
{{ selectedLlmModelInfo }}
</VAlert>
<div class="d-flex justify-end mt-2">
<VBtn
color="info"
variant="tonal"
density="comfortable"
prepend-icon="mdi-connection"
:disabled="!canTestLlm"
:loading="testingLlm"
class="llm-test-trigger"
@click="testLlmConnection"
>
{{ t('setting.system.llmTestAction') }}
</VBtn>
</div>
</div>
</div>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Basic.LLM_MAX_CONTEXT_TOKENS"
:label="t('setting.system.llmMaxContextTokens')"
:hint="t('setting.system.llmMaxContextTokensHint')"
persistent-hint
type="number"
prepend-inner-icon="mdi-counter"
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VSelect
v-model="SystemSettings.Basic.LLM_THINKING_LEVEL"
:label="t('setting.system.llmThinking')"
:hint="t('setting.system.llmThinkingHint')"
:items="thinkingLevelItems"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VSelect
v-model="SystemSettings.Basic.AI_AGENT_JOB_INTERVAL"
:label="t('setting.system.aiAgentJobInterval')"
:hint="t('setting.system.aiAgentJobIntervalHint')"
persistent-hint
:items="[
{ title: t('setting.system.aiAgentJobIntervalDisabled'), value: 0 },
{ title: t('setting.system.aiAgentJobInterval1h'), value: 1 },
{ title: t('setting.system.aiAgentJobInterval3h'), value: 3 },
{ title: t('setting.system.aiAgentJobInterval6h'), value: 6 },
{ title: t('setting.system.aiAgentJobInterval12h'), value: 12 },
{ title: t('setting.system.aiAgentJobInterval24h'), value: 24 },
{ title: t('setting.system.aiAgentJobInterval1w'), value: 168 },
{ title: t('setting.system.aiAgentJobInterval1M'), value: 720 },
]"
prepend-inner-icon="mdi-timer-outline"
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.LLM_SUPPORT_IMAGE_INPUT"
:label="t('setting.system.llmSupportImageInput')"
:hint="t('setting.system.llmSupportImageInputHint')"
persistent-hint
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12">
<VSwitch
v-model="SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
:label="t('setting.system.llmSupportAudioInputOutput')"
:hint="t('setting.system.llmSupportAudioInputOutputHint')"
persistent-hint
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AI_VOICE_API_KEY"
:label="t('setting.system.aiVoiceApiKey')"
:hint="t('setting.system.aiVoiceApiKeyHint')"
persistent-hint
prepend-inner-icon="mdi-key-variant"
type="password"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AI_VOICE_BASE_URL"
:label="t('setting.system.aiVoiceBaseUrl')"
:hint="t('setting.system.aiVoiceBaseUrlHint')"
persistent-hint
prepend-inner-icon="mdi-link-variant"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AI_VOICE_STT_MODEL"
:label="t('setting.system.aiVoiceSttModel')"
:hint="t('setting.system.aiVoiceSttModelHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AI_VOICE_TTS_MODEL"
:label="t('setting.system.aiVoiceTtsModel')"
:hint="t('setting.system.aiVoiceTtsModelHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AI_VOICE_TTS_VOICE"
:label="t('setting.system.aiVoiceTtsVoice')"
:hint="t('setting.system.aiVoiceTtsVoiceHint')"
persistent-hint
prepend-inner-icon="mdi-account-voice"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AI_VOICE_LANGUAGE"
:label="t('setting.system.aiVoiceLanguage')"
:hint="t('setting.system.aiVoiceLanguageHint')"
persistent-hint
prepend-inner-icon="mdi-translate"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT_OUTPUT"
cols="12"
>
<VSwitch
v-model="SystemSettings.Basic.AI_VOICE_REPLY_WITH_TEXT"
:label="t('setting.system.aiVoiceReplyWithText')"
:hint="t('setting.system.aiVoiceReplyWithTextHint')"
persistent-hint
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_RETRY_TRANSFER"
:label="t('setting.system.aiAgentRetryTransfer')"
:hint="t('setting.system.aiAgentRetryTransferHint')"
persistent-hint
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12">
<VSwitch
v-model="SystemSettings.Basic.AI_RECOMMEND_ENABLED"
:label="t('setting.system.aiRecommendEnabled')"
:hint="t('setting.system.aiRecommendEnabledHint')"
persistent-hint
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.AI_RECOMMEND_ENABLED"
cols="12"
md="6"
>
<VTextarea
v-model="SystemSettings.Basic.AI_RECOMMEND_USER_PREFERENCE"
:label="t('setting.system.aiRecommendUserPreference')"
:hint="t('setting.system.aiRecommendUserPreferenceHint')"
persistent-hint
rows="1"
auto-grow
prepend-inner-icon="mdi-account-heart"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.AI_RECOMMEND_ENABLED"
cols="12"
md="6"
>
<VTextField
v-model.number="SystemSettings.Basic.AI_RECOMMEND_MAX_ITEMS"
:label="t('setting.system.aiRecommendMaxItems')"
:hint="t('setting.system.aiRecommendMaxItemsHint')"
persistent-hint
type="number"
prepend-inner-icon="mdi-format-list-numbered"
/>
</VCol>
</VRow>
</VCardText>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Basic.LLM_MAX_CONTEXT_TOKENS"
:label="t('setting.system.llmMaxContextTokens')"
:hint="t('setting.system.llmMaxContextTokensHint')"
persistent-hint
type="number"
prepend-inner-icon="mdi-counter"
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VSelect
v-model="SystemSettings.Basic.LLM_THINKING_LEVEL"
:label="t('setting.system.llmThinking')"
:hint="t('setting.system.llmThinkingHint')"
:items="thinkingLevelItems"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VSelect
v-model="SystemSettings.Basic.AI_AGENT_JOB_INTERVAL"
:label="t('setting.system.aiAgentJobInterval')"
:hint="t('setting.system.aiAgentJobIntervalHint')"
persistent-hint
:items="[
{ title: t('setting.system.aiAgentJobIntervalDisabled'), value: 0 },
{ title: t('setting.system.aiAgentJobInterval1h'), value: 1 },
{ title: t('setting.system.aiAgentJobInterval3h'), value: 3 },
{ title: t('setting.system.aiAgentJobInterval6h'), value: 6 },
{ title: t('setting.system.aiAgentJobInterval12h'), value: 12 },
{ title: t('setting.system.aiAgentJobInterval24h'), value: 24 },
{ title: t('setting.system.aiAgentJobInterval1w'), value: 168 },
{ title: t('setting.system.aiAgentJobInterval1M'), value: 720 },
]"
prepend-inner-icon="mdi-timer-outline"
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="4">
<VSwitch
v-model="SystemSettings.Basic.LLM_SUPPORT_IMAGE_INPUT"
:label="t('setting.system.llmSupportImageInput')"
:hint="t('setting.system.llmSupportImageInputHint')"
persistent-hint
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VSwitch
v-model="SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT"
:label="t('setting.system.llmSupportAudioInput')"
:hint="t('setting.system.llmSupportAudioInputHint')"
persistent-hint
/>
</VCol>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12" md="6">
<VSwitch
v-model="SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
:label="t('setting.system.llmSupportAudioOutput')"
:hint="t('setting.system.llmSupportAudioOutputHint')"
persistent-hint
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT"
cols="12"
md="6"
>
<VSelect
v-model="SystemSettings.Basic.AUDIO_INPUT_PROVIDER"
:label="t('setting.system.audioInputProvider')"
:hint="t('setting.system.audioInputProviderHint')"
:items="audioProviderItems"
persistent-hint
prepend-inner-icon="mdi-microphone-message"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_INPUT_MODEL"
:label="t('setting.system.audioInputModel')"
:hint="t('setting.system.audioInputModelHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_INPUT_API_KEY"
:label="t('setting.system.audioInputApiKey')"
:hint="t('setting.system.audioInputApiKeyHint')"
persistent-hint
prepend-inner-icon="mdi-key-variant"
type="password"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_INPUT_BASE_URL"
:label="t('setting.system.audioInputBaseUrl')"
:hint="t('setting.system.audioInputBaseUrlHint')"
persistent-hint
prepend-inner-icon="mdi-link-variant"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_INPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_INPUT_LANGUAGE"
:label="t('setting.system.audioInputLanguage')"
:hint="t('setting.system.audioInputLanguageHint')"
persistent-hint
prepend-inner-icon="mdi-translate"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
cols="12"
md="6"
>
<VSelect
v-model="SystemSettings.Basic.AUDIO_OUTPUT_PROVIDER"
:label="t('setting.system.audioOutputProvider')"
:hint="t('setting.system.audioOutputProviderHint')"
:items="audioProviderItems"
persistent-hint
prepend-inner-icon="mdi-account-voice"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_OUTPUT_MODEL"
:label="t('setting.system.audioOutputModel')"
:hint="t('setting.system.audioOutputModelHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_OUTPUT_API_KEY"
:label="t('setting.system.audioOutputApiKey')"
:hint="t('setting.system.audioOutputApiKeyHint')"
persistent-hint
prepend-inner-icon="mdi-key-variant"
type="password"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_OUTPUT_BASE_URL"
:label="t('setting.system.audioOutputBaseUrl')"
:hint="t('setting.system.audioOutputBaseUrlHint')"
persistent-hint
prepend-inner-icon="mdi-link-variant"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
cols="12"
md="6"
>
<VTextField
v-model="SystemSettings.Basic.AUDIO_OUTPUT_VOICE"
:label="t('setting.system.audioOutputVoice')"
:hint="t('setting.system.audioOutputVoiceHint')"
persistent-hint
prepend-inner-icon="mdi-account-voice"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.LLM_SUPPORT_AUDIO_OUTPUT"
cols="12"
>
<VSwitch
v-model="SystemSettings.Basic.AUDIO_OUTPUT_INCLUDE_TEXT"
:label="t('setting.system.audioOutputIncludeText')"
:hint="t('setting.system.audioOutputIncludeTextHint')"
persistent-hint
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12">
<VSwitch
v-model="SystemSettings.Basic.AI_AGENT_RETRY_TRANSFER"
:label="t('setting.system.aiAgentRetryTransfer')"
:hint="t('setting.system.aiAgentRetryTransferHint')"
persistent-hint
/>
</VCol>
</VRow>
<VRow>
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE" cols="12">
<VSwitch
v-model="SystemSettings.Basic.AI_RECOMMEND_ENABLED"
:label="t('setting.system.aiRecommendEnabled')"
:hint="t('setting.system.aiRecommendEnabledHint')"
persistent-hint
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.AI_RECOMMEND_ENABLED"
cols="12"
md="6"
>
<VTextarea
v-model="SystemSettings.Basic.AI_RECOMMEND_USER_PREFERENCE"
:label="t('setting.system.aiRecommendUserPreference')"
:hint="t('setting.system.aiRecommendUserPreferenceHint')"
persistent-hint
rows="1"
auto-grow
prepend-inner-icon="mdi-account-heart"
/>
</VCol>
<VCol
v-if="SystemSettings.Basic.AI_AGENT_ENABLE && SystemSettings.Basic.AI_RECOMMEND_ENABLED"
cols="12"
md="6"
>
<VTextField
v-model.number="SystemSettings.Basic.AI_RECOMMEND_MAX_ITEMS"
:label="t('setting.system.aiRecommendMaxItems')"
:hint="t('setting.system.aiRecommendMaxItemsHint')"
persistent-hint
type="number"
prepend-inner-icon="mdi-format-list-numbered"
/>
</VCol>
</VRow>
</VCardText>
</VExpandTransition>
</VCard>
</VForm>
</VCardText>
@@ -1405,7 +1503,7 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
<VCardSubtitle>{{ t('setting.system.downloadersDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="downloaders"
handle=".cursor-move"
item-key="name"
@@ -1421,7 +1519,7 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
:allow-refresh="isRequest"
/>
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">
@@ -1456,7 +1554,7 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
<VCardSubtitle>{{ t('setting.system.mediaServersDesc') }}</VCardSubtitle>
</VCardItem>
<VCardText>
<draggable
<Draggable
v-model="mediaServers"
handle=".cursor-move"
item-key="name"
@@ -1471,7 +1569,7 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
@change="onMediaServerChange"
/>
</template>
</draggable>
</Draggable>
</VCardText>
<VCardText>
<VForm @submit.prevent="() => {}">

View File

@@ -116,6 +116,12 @@ const thinkingLevelItems = computed(() => [
{ title: t('setting.system.llmThinkingLevelXhigh'), value: 'xhigh' },
])
const audioProviderItems = computed(() => [
{ title: t('setting.system.audioProviderOpenAiAudio'), value: 'openai' },
{ title: t('setting.system.audioProviderChatAudio'), value: 'openai_chat_audio' },
{ title: t('setting.system.audioProviderMimo'), value: 'mimo' },
])
const providerAuthMethods = computed(() => selectedProvider.value?.oauth_methods || [])
const providerAuthLabel = computed(() => selectedProvider.value?.auth_status?.label || '')
const selectedModelInfo = computed(() => {
@@ -390,20 +396,41 @@ onMounted(async () => {
<VCol cols="12">
<VSwitch
v-model="wizardData.agent.supportAudioInputOutput"
:label="t('setting.system.llmSupportAudioInputOutput')"
:hint="t('setting.system.llmSupportAudioInputOutputHint')"
v-model="wizardData.agent.supportAudioInput"
:label="t('setting.system.llmSupportAudioInput')"
:hint="t('setting.system.llmSupportAudioInputHint')"
persistent-hint
color="primary"
/>
</VCol>
<template v-if="wizardData.agent.supportAudioInputOutput">
<template v-if="wizardData.agent.supportAudioInput">
<VCol cols="12" md="6">
<VSelect
v-model="wizardData.agent.audioInputProvider"
:label="t('setting.system.audioInputProvider')"
:hint="t('setting.system.audioInputProviderHint')"
:items="audioProviderItems"
persistent-hint
prepend-inner-icon="mdi-microphone-message"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.voiceApiKey"
:label="t('setting.system.aiVoiceApiKey')"
:hint="t('setting.system.aiVoiceApiKeyHint')"
v-model="wizardData.agent.audioInputModel"
:label="t('setting.system.audioInputModel')"
:hint="t('setting.system.audioInputModelHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.audioInputApiKey"
:label="t('setting.system.audioInputApiKey')"
:hint="t('setting.system.audioInputApiKeyHint')"
persistent-hint
prepend-inner-icon="mdi-key-variant"
type="password"
@@ -412,9 +439,9 @@ onMounted(async () => {
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.voiceBaseUrl"
:label="t('setting.system.aiVoiceBaseUrl')"
:hint="t('setting.system.aiVoiceBaseUrlHint')"
v-model="wizardData.agent.audioInputBaseUrl"
:label="t('setting.system.audioInputBaseUrl')"
:hint="t('setting.system.audioInputBaseUrlHint')"
persistent-hint
prepend-inner-icon="mdi-link-variant"
/>
@@ -422,29 +449,32 @@ onMounted(async () => {
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.voiceSttModel"
:label="t('setting.system.aiVoiceSttModel')"
:hint="t('setting.system.aiVoiceSttModelHint')"
v-model="wizardData.agent.audioInputLanguage"
:label="t('setting.system.audioInputLanguage')"
:hint="t('setting.system.audioInputLanguageHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
prepend-inner-icon="mdi-translate"
/>
</VCol>
</template>
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.voiceTtsModel"
:label="t('setting.system.aiVoiceTtsModel')"
:hint="t('setting.system.aiVoiceTtsModelHint')"
persistent-hint
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol cols="12">
<VSwitch
v-model="wizardData.agent.supportAudioOutput"
:label="t('setting.system.llmSupportAudioOutput')"
:hint="t('setting.system.llmSupportAudioOutputHint')"
persistent-hint
color="primary"
/>
</VCol>
<template v-if="wizardData.agent.supportAudioOutput">
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.voiceTtsVoice"
:label="t('setting.system.aiVoiceTtsVoice')"
:hint="t('setting.system.aiVoiceTtsVoiceHint')"
<VSelect
v-model="wizardData.agent.audioOutputProvider"
:label="t('setting.system.audioOutputProvider')"
:hint="t('setting.system.audioOutputProviderHint')"
:items="audioProviderItems"
persistent-hint
prepend-inner-icon="mdi-account-voice"
/>
@@ -452,19 +482,50 @@ onMounted(async () => {
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.voiceLanguage"
:label="t('setting.system.aiVoiceLanguage')"
:hint="t('setting.system.aiVoiceLanguageHint')"
v-model="wizardData.agent.audioOutputModel"
:label="t('setting.system.audioOutputModel')"
:hint="t('setting.system.audioOutputModelHint')"
persistent-hint
prepend-inner-icon="mdi-translate"
prepend-inner-icon="mdi-waveform"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.audioOutputApiKey"
:label="t('setting.system.audioOutputApiKey')"
:hint="t('setting.system.audioOutputApiKeyHint')"
persistent-hint
prepend-inner-icon="mdi-key-variant"
type="password"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.audioOutputBaseUrl"
:label="t('setting.system.audioOutputBaseUrl')"
:hint="t('setting.system.audioOutputBaseUrlHint')"
persistent-hint
prepend-inner-icon="mdi-link-variant"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="wizardData.agent.audioOutputVoice"
:label="t('setting.system.audioOutputVoice')"
:hint="t('setting.system.audioOutputVoiceHint')"
persistent-hint
prepend-inner-icon="mdi-account-voice"
/>
</VCol>
<VCol cols="12">
<VSwitch
v-model="wizardData.agent.voiceReplyWithText"
:label="t('setting.system.aiVoiceReplyWithText')"
:hint="t('setting.system.aiVoiceReplyWithTextHint')"
v-model="wizardData.agent.audioOutputIncludeText"
:label="t('setting.system.audioOutputIncludeText')"
:hint="t('setting.system.audioOutputIncludeTextHint')"
persistent-hint
color="primary"
/>

View File

@@ -1,12 +1,8 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import api from '@/api'
import type { Site, SiteUserData } from '@/api/types'
import SiteCard from '@/components/cards/SiteCard.vue'
import NoDataFound from '@/components/NoDataFound.vue'
import SiteAddEditDialog from '@/components/dialog/SiteAddEditDialog.vue'
import SiteStatisticsDialog from '@/components/dialog/SiteStatisticsDialog.vue'
import SiteImportDialog from '@/components/dialog/SiteImportDialog.vue'
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
import { useDynamicButton } from '@/composables/useDynamicButton'
import { useI18n } from 'vue-i18n'
@@ -25,6 +21,12 @@ const route = useRoute()
// APP 模式检测
const { appMode } = usePWA()
// 拖拽排序和站点弹窗都不是站点列表首屏必需,打开对应功能时再加载。
const Draggable = defineAsyncComponent(() => import('vuedraggable').then(module => module.default))
const SiteAddEditDialog = defineAsyncComponent(() => import('@/components/dialog/SiteAddEditDialog.vue'))
const SiteStatisticsDialog = defineAsyncComponent(() => import('@/components/dialog/SiteStatisticsDialog.vue'))
const SiteImportDialog = defineAsyncComponent(() => import('@/components/dialog/SiteImportDialog.vue'))
// 站点列表
const siteList = ref<Site[]>([])
@@ -402,7 +404,7 @@ useDynamicButton({
</VAlert>
<LoadingBanner v-if="!isRefreshed" class="mt-12" />
<draggable
<Draggable
v-if="draggableSiteList.length > 0 && canDragSort"
v-model="draggableSiteList"
@end="savaSitesPriority"
@@ -421,12 +423,13 @@ useDynamicButton({
@refresh-stats="handleRefreshStats"
/>
</template>
</draggable>
</Draggable>
<ProgressiveCardGrid
v-else-if="draggableSiteList.length > 0 && shouldVirtualizeList"
:items="draggableSiteList"
:get-item-key="item => item.id"
:min-item-width="256"
:estimated-item-height="168"
class="px-2"
>
<template #default="{ item }">

View File

@@ -518,6 +518,7 @@ defineExpose({
:items="displayList"
:get-item-key="item => item.id"
:min-item-width="240"
:estimated-item-height="300"
:scroll-to-index="scrollToIndex"
class="px-2"
>

View File

@@ -4,6 +4,7 @@ import type { User } from '@/api/types'
import NoDataFound from '@/components/NoDataFound.vue'
import UserCard from '@/components/cards/UserCard.vue'
import UserAddEditDialog from '@/components/dialog/UserAddEditDialog.vue'
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
import { useDynamicButton } from '@/composables/useDynamicButton'
import { useI18n } from 'vue-i18n'
import { usePWA } from '@/composables/usePWA'
@@ -80,17 +81,19 @@ useDynamicButton({
<!-- 加载中提示 -->
<LoadingBanner v-if="!isRefreshed" class="mt-12" />
<!-- 用户卡片网格 -->
<div v-if="allUsers.length > 0 && isRefreshed" class="grid gap-4 grid-user-card px-2">
<ProgressiveCardGrid
v-if="allUsers.length > 0 && isRefreshed"
:items="allUsers"
:min-item-width="288"
:estimated-item-height="260"
:get-item-key="user => user.id"
class="px-2"
>
<!-- 普通用户卡片 -->
<UserCard
v-for="user in allUsers"
:key="user.id"
:user="user"
:users="allUsers"
@remove="loadAllUsers"
@save="loadAllUsers"
/>
</div>
<template #default="{ item }">
<UserCard :user="item" :users="allUsers" @remove="loadAllUsers" @save="loadAllUsers" />
</template>
</ProgressiveCardGrid>
<!-- 无数据提示 -->
<div v-if="allUsers.length === 0 && isRefreshed">