feat: 新增视频床与文件床,视频支持 HLS 转码
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
文件床 - 新增 files/ 存储前缀与 media_type 索引列,图片、视频、文件三类资源独立 - 新增文件上传、列表、删除、批量删除接口,禁止 html/htm/svg - 支持公开直链与 Token 访问两种模式,后台可切换,直链强制附件下载 视频床 - 新增 videos/ 存储前缀与视频上传接口,单文件上限 500MB - 接入 ffmpeg 转码队列,并发数与单任务核心数可配,默认串行 - 五档转码质量:直接封装 / 速度 / 平衡 / 质量 / 压缩(压缩档可调码率比例) - 码率控制避免转码后体积反超源文件,音频跟随源音轨不放大不压缩 - 转码进度实时上报,成功后删除源文件,失败时保留源文件与可用链接 - 上传时自动抽帧生成封面,视频与封面各有独立链接 - 删除视频时中断转码并清理切片、封面与源文件 媒体库 - 图库、视频库、文件库三套独立统计,含趋势、占用与来源分布 - 统一筛选、多选、批量删除、批量标签、网格/列表切换,显示方式按类型分别记忆 - 视频详情对齐图片详情,视频库支持在线播放(hls.js,兼容回退原文件) 修复 - 清理无主的切片、封面与开发期遗留的 ffmpeg 进程 - 源文件按设计删除后,索引不再被启动孤儿清理误删 - 视频统计口径与列表一致,转码中的视频不计入统计 - 转码失败时回收已写入的部分切片,避免残留 - 设置页停用检查更新(与上游版本号已不对应) 其他 - Docker 镜像安装 ffmpeg - git remote 指向内网仓库
This commit is contained in:
1 parent
05cc3895f1
commit
89ea2fb25d
61 files changed
+6637
-154
No files matched your search
@@ -0,0 +1,40 @@
|
||||
const STORAGE_KEY = 'pichost.library-view'
|
||||
export type LibraryViewKind = 'image' | 'video' | 'file'
|
||||
|
||||
export type LibraryViewMode = 'grid' | 'list'
|
||||
|
||||
function storageKeyFor(kind: LibraryViewKind): string {
|
||||
return `${STORAGE_KEY}.${kind}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 图库 / 视频库 / 文件库各自的显示方式。
|
||||
* 三个库分别记住(互不影响),且页面切换后保持,不用重新点。
|
||||
*/
|
||||
export function useLibraryView(kind: LibraryViewKind = 'image') {
|
||||
const viewMode = useState<LibraryViewMode>(`library-view-mode-${kind}`, () => 'grid')
|
||||
const loaded = useState(`library-view-loaded-${kind}`, () => false)
|
||||
|
||||
if (import.meta.client && !loaded.value) {
|
||||
try {
|
||||
const stored = localStorage.getItem(storageKeyFor(kind))
|
||||
if (stored === 'grid' || stored === 'list') {
|
||||
viewMode.value = stored
|
||||
}
|
||||
} catch {
|
||||
// 读取失败保持默认
|
||||
}
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
watch(viewMode, (value) => {
|
||||
if (!import.meta.client) return
|
||||
try {
|
||||
localStorage.setItem(storageKeyFor(kind), value)
|
||||
} catch {
|
||||
// 写入失败不影响使用
|
||||
}
|
||||
})
|
||||
|
||||
return { viewMode }
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
import type { UploadProgressItem } from '~/types/image'
|
||||
import type { FileItem, FileListResponse, FileUploadResponse } from '~/types/file'
|
||||
import type { CopyFormat, UploadMediaKind } from './useUploadPreferences'
|
||||
import { isUnauthorizedError } from './useAuth'
|
||||
|
||||
const MAX_FILES = 10
|
||||
|
||||
function buildCopyText(item: FileItem, format: CopyFormat): string {
|
||||
switch (format) {
|
||||
case 'url':
|
||||
return item.url
|
||||
case 'html':
|
||||
return `<a href="${item.url}">${item.originalName}</a>`
|
||||
case 'bbcode':
|
||||
return `[url=${item.url}]${item.originalName}[/url]`
|
||||
default:
|
||||
return `[${item.originalName}](${item.url})`
|
||||
}
|
||||
}
|
||||
|
||||
async function copyToClipboard(text: string): Promise<boolean> {
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
return true
|
||||
}
|
||||
} catch {
|
||||
// 内网 http:// 等非安全上下文继续走回退方案
|
||||
}
|
||||
|
||||
try {
|
||||
const textarea = document.createElement('textarea')
|
||||
textarea.value = text
|
||||
textarea.style.position = 'fixed'
|
||||
textarea.style.left = '-9999px'
|
||||
document.body.appendChild(textarea)
|
||||
textarea.select()
|
||||
const ok = document.execCommand('copy')
|
||||
document.body.removeChild(textarea)
|
||||
return ok
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** 视频床 / 文件床的上传:走文件床接口,偏好按类型独立 */
|
||||
export function useMediaUpload(kind: UploadMediaKind) {
|
||||
const toast = useToast()
|
||||
const { t } = useI18n()
|
||||
const {
|
||||
autoCopyMarkdown,
|
||||
copyFormat,
|
||||
transcodeToHls,
|
||||
loadPreferences
|
||||
} = useUploadPreferences(kind)
|
||||
|
||||
const uploading = ref(false)
|
||||
const progressItems = ref<UploadProgressItem[]>([])
|
||||
const lastResult = ref<FileUploadResponse | null>(null)
|
||||
/** 本次会话内上传的条目,页面刷新后清空 */
|
||||
const sessionItems = ref<FileItem[]>([])
|
||||
const accessMode = ref<'public' | 'token'>('public')
|
||||
const apiToken = ref('')
|
||||
|
||||
const endpoint = kind === 'video' ? '/api/videos/upload' : '/api/files/upload'
|
||||
|
||||
loadPreferences()
|
||||
|
||||
async function loadApiToken() {
|
||||
try {
|
||||
const data = await $fetch<{ apiUploadToken: string }>('/api/user/api-token', {
|
||||
credentials: 'include'
|
||||
})
|
||||
apiToken.value = data.apiUploadToken ?? ''
|
||||
} catch {
|
||||
apiToken.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
/** Token 模式下复制出的链接需要带上令牌 */
|
||||
function linkUrl(item: FileItem): string {
|
||||
// 转码完成后优先给出 m3u8 播放地址
|
||||
const base = item.hlsUrl ?? item.url
|
||||
if (accessMode.value !== 'token' || !apiToken.value) return base
|
||||
const separator = base.includes('?') ? '&' : '?'
|
||||
return `${base}${separator}token=${encodeURIComponent(apiToken.value)}`
|
||||
}
|
||||
|
||||
/** 封面缩略图地址(同样按访问模式拼接) */
|
||||
function thumbLink(item: FileItem): string {
|
||||
const base = item.thumbUrl
|
||||
if (!base) return ''
|
||||
if (accessMode.value !== 'token' || !apiToken.value) return base
|
||||
const separator = base.includes('?') ? '&' : '?'
|
||||
return `${base}${separator}token=${encodeURIComponent(apiToken.value)}`
|
||||
}
|
||||
|
||||
let statusTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
function stopStatusPolling() {
|
||||
if (statusTimer) {
|
||||
clearInterval(statusTimer)
|
||||
statusTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
function hasPendingTranscode(): boolean {
|
||||
return sessionItems.value.some(
|
||||
item => item.transcodeStatus === 'pending' || item.transcodeStatus === 'running'
|
||||
)
|
||||
}
|
||||
|
||||
/** 转码是异步的,轮询列表把状态与 m3u8 地址同步回来 */
|
||||
async function refreshTranscodeStatus() {
|
||||
if (!hasPendingTranscode()) {
|
||||
stopStatusPolling()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const [active, finished] = await Promise.all([
|
||||
$fetch<FileListResponse>('/api/files', {
|
||||
credentials: 'include',
|
||||
query: { kind: 'video', limit: 100, processing: '1' }
|
||||
}),
|
||||
$fetch<FileListResponse>('/api/files', {
|
||||
credentials: 'include',
|
||||
query: { kind: 'video', limit: 100 }
|
||||
})
|
||||
])
|
||||
const latest = new Map(
|
||||
[...active.items, ...finished.items].map(item => [item.key, item])
|
||||
)
|
||||
sessionItems.value = sessionItems.value.map(item => latest.get(item.key) ?? item)
|
||||
} catch {
|
||||
// 轮询失败保持现状,下个周期重试
|
||||
}
|
||||
|
||||
if (!hasPendingTranscode()) stopStatusPolling()
|
||||
}
|
||||
|
||||
function startStatusPolling() {
|
||||
if (kind !== 'video' || statusTimer) return
|
||||
statusTimer = setInterval(() => {
|
||||
void refreshTranscodeStatus()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
onUnmounted(stopStatusPolling)
|
||||
|
||||
/** 刷新或换页后仍要显示还在排队/转码中的视频 */
|
||||
async function loadActiveTranscodes() {
|
||||
if (kind !== 'video') return
|
||||
|
||||
try {
|
||||
const response = await $fetch<FileListResponse>('/api/files', {
|
||||
credentials: 'include',
|
||||
query: { kind: 'video', limit: 100, processing: '1' }
|
||||
})
|
||||
if (!response.items.length) return
|
||||
|
||||
const known = new Set(sessionItems.value.map(item => item.key))
|
||||
const missing = response.items.filter(item => !known.has(item.key))
|
||||
const latest = new Map(response.items.map(item => [item.key, item]))
|
||||
|
||||
sessionItems.value = [
|
||||
...missing,
|
||||
...sessionItems.value.map(item => latest.get(item.key) ?? item)
|
||||
]
|
||||
startStatusPolling()
|
||||
} catch {
|
||||
// 拉取失败时保持现状
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadFiles(files: File[]) {
|
||||
if (!files.length || uploading.value) return
|
||||
|
||||
if (files.length > MAX_FILES) {
|
||||
toast.add({ title: t('files.maxFiles', { n: MAX_FILES }), color: 'warning' })
|
||||
return
|
||||
}
|
||||
|
||||
uploading.value = true
|
||||
progressItems.value = files.map(file => ({
|
||||
name: file.name,
|
||||
status: 'pending',
|
||||
progress: 0
|
||||
}))
|
||||
|
||||
try {
|
||||
const formData = new FormData()
|
||||
for (const file of files) {
|
||||
formData.append('files', file, file.name)
|
||||
}
|
||||
|
||||
if (kind === 'video' && transcodeToHls.value) {
|
||||
formData.append('transcode', '1')
|
||||
}
|
||||
|
||||
progressItems.value = progressItems.value.map(item => ({
|
||||
...item,
|
||||
status: 'uploading',
|
||||
progress: 50
|
||||
}))
|
||||
|
||||
const response = await $fetch<FileUploadResponse>(endpoint, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
|
||||
lastResult.value = response
|
||||
accessMode.value = response.accessMode
|
||||
if (response.accessMode === 'token' && !apiToken.value) {
|
||||
await loadApiToken()
|
||||
}
|
||||
|
||||
progressItems.value = files.map((file) => {
|
||||
const failed = response.errors.find(error => error.name === file.name)
|
||||
return {
|
||||
name: file.name,
|
||||
status: failed ? 'error' : 'success',
|
||||
progress: 100,
|
||||
error: failed?.error.message
|
||||
}
|
||||
})
|
||||
|
||||
if (response.items.length) {
|
||||
const wantsTranscode = kind === 'video' && transcodeToHls.value
|
||||
const uploaded = wantsTranscode
|
||||
? response.items.map(item => ({ ...item, transcodeStatus: 'pending' as const }))
|
||||
: response.items
|
||||
|
||||
sessionItems.value = [...uploaded, ...sessionItems.value]
|
||||
if (wantsTranscode) startStatusPolling()
|
||||
|
||||
toast.add({
|
||||
title: t('files.uploadSuccess', { n: response.items.length }),
|
||||
color: 'success'
|
||||
})
|
||||
|
||||
const first = response.items[0]
|
||||
if (autoCopyMarkdown.value && first) {
|
||||
const text = buildCopyText(first, copyFormat.value)
|
||||
if (text && await copyToClipboard(text)) {
|
||||
toast.add({ title: t('copy.copied'), color: 'success' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const failure of response.errors.slice(0, 3)) {
|
||||
toast.add({
|
||||
title: `${failure.name}:${failure.error.message}`,
|
||||
color: 'error'
|
||||
})
|
||||
}
|
||||
|
||||
return response
|
||||
} catch (error: unknown) {
|
||||
if (!isUnauthorizedError(error)) {
|
||||
progressItems.value = progressItems.value.map(item => ({
|
||||
...item,
|
||||
status: 'error',
|
||||
progress: 100,
|
||||
error: t('files.uploadFailed')
|
||||
}))
|
||||
toast.add({ title: t('files.uploadFailed'), color: 'error' })
|
||||
}
|
||||
throw error
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
uploading,
|
||||
progressItems,
|
||||
lastResult,
|
||||
sessionItems,
|
||||
accessMode,
|
||||
linkUrl,
|
||||
thumbLink,
|
||||
loadActiveTranscodes,
|
||||
uploadFiles
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
interface TranscodeSettingsResponse {
|
||||
concurrency: number
|
||||
threads: number
|
||||
preset: string
|
||||
bitratePercent: number
|
||||
maxConcurrency: number
|
||||
maxThreads: number
|
||||
minBitratePercent: number
|
||||
maxBitratePercent: number
|
||||
presets: string[]
|
||||
}
|
||||
|
||||
/** 服务端转码参数:并发任务数与单任务 CPU 核心数(仅管理员可改) */
|
||||
export function useTranscodeSettings() {
|
||||
const { isAuthenticated, isAdmin, handleAuthError } = useAuth()
|
||||
const toast = useToast()
|
||||
const { t } = useI18n()
|
||||
|
||||
const concurrency = ref(1)
|
||||
const threads = ref(1)
|
||||
const maxConcurrency = ref(8)
|
||||
const maxThreads = ref(64)
|
||||
const preset = ref('veryfast')
|
||||
const presets = ref<string[]>(['veryfast', 'medium', 'slow'])
|
||||
const bitratePercent = ref(80)
|
||||
const minBitratePercent = ref(10)
|
||||
const maxBitratePercent = ref(100)
|
||||
const loaded = ref(false)
|
||||
const hydrated = ref(false)
|
||||
|
||||
let saveTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
function apply(data: TranscodeSettingsResponse) {
|
||||
hydrated.value = false
|
||||
concurrency.value = data.concurrency
|
||||
threads.value = data.threads
|
||||
preset.value = data.preset
|
||||
bitratePercent.value = data.bitratePercent
|
||||
minBitratePercent.value = data.minBitratePercent ?? 10
|
||||
maxBitratePercent.value = data.maxBitratePercent ?? 100
|
||||
if (data.presets?.length) presets.value = data.presets
|
||||
maxConcurrency.value = data.maxConcurrency
|
||||
maxThreads.value = data.maxThreads
|
||||
loaded.value = true
|
||||
nextTick(() => {
|
||||
hydrated.value = true
|
||||
})
|
||||
}
|
||||
|
||||
async function load() {
|
||||
if (!isAuthenticated.value) return
|
||||
try {
|
||||
apply(await $fetch<TranscodeSettingsResponse>('/api/videos/transcode-settings', {
|
||||
credentials: 'include'
|
||||
}))
|
||||
} catch (error: unknown) {
|
||||
handleAuthError(error)
|
||||
if (isAuthenticated.value) {
|
||||
toast.add({ title: t('preferences.transcodeLoadFailed'), color: 'error' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!hydrated.value || !isAdmin.value) return
|
||||
try {
|
||||
const data = await $fetch<TranscodeSettingsResponse>('/api/videos/transcode-settings', {
|
||||
method: 'PATCH',
|
||||
credentials: 'include',
|
||||
body: {
|
||||
concurrency: concurrency.value,
|
||||
threads: threads.value,
|
||||
preset: preset.value,
|
||||
bitratePercent: bitratePercent.value
|
||||
}
|
||||
})
|
||||
hydrated.value = false
|
||||
concurrency.value = data.concurrency
|
||||
threads.value = data.threads
|
||||
preset.value = data.preset
|
||||
bitratePercent.value = data.bitratePercent
|
||||
nextTick(() => {
|
||||
hydrated.value = true
|
||||
})
|
||||
} catch (error: unknown) {
|
||||
handleAuthError(error)
|
||||
if (isAuthenticated.value) {
|
||||
toast.add({ title: t('preferences.transcodeSaveFailed'), color: 'error' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
watch([concurrency, threads, preset, bitratePercent], () => {
|
||||
if (!hydrated.value || !isAdmin.value) return
|
||||
if (saveTimer) clearTimeout(saveTimer)
|
||||
saveTimer = setTimeout(() => {
|
||||
void save()
|
||||
}, 600)
|
||||
})
|
||||
|
||||
return {
|
||||
concurrency,
|
||||
threads,
|
||||
preset,
|
||||
bitratePercent,
|
||||
minBitratePercent,
|
||||
maxBitratePercent,
|
||||
presets,
|
||||
maxConcurrency,
|
||||
maxThreads,
|
||||
loaded,
|
||||
load
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
const STORAGE_KEY = 'pichost.upload-preferences'
|
||||
|
||||
export type CopyFormat = 'url' | 'markdown' | 'html' | 'bbcode'
|
||||
export type UploadMediaKind = 'image' | 'video' | 'file'
|
||||
|
||||
/** 每种上传页各存一份偏好,互不影响 */
|
||||
function storageKeyFor(kind: UploadMediaKind): string {
|
||||
return kind === 'image' ? STORAGE_KEY : `${STORAGE_KEY}.${kind}`
|
||||
}
|
||||
|
||||
export interface UploadPreferences {
|
||||
compressEnabled: boolean
|
||||
@@ -8,6 +14,8 @@ export interface UploadPreferences {
|
||||
copyFormat: CopyFormat
|
||||
clientWebpQuality: number
|
||||
lastTagIds: number[]
|
||||
/** 视频床专属:上传后转码为 HLS(m3u8 + 分片) */
|
||||
transcodeToHls: boolean
|
||||
}
|
||||
|
||||
const DEFAULTS: UploadPreferences = {
|
||||
@@ -15,7 +23,8 @@ const DEFAULTS: UploadPreferences = {
|
||||
autoCopyMarkdown: false,
|
||||
copyFormat: 'markdown',
|
||||
clientWebpQuality: 80,
|
||||
lastTagIds: []
|
||||
lastTagIds: [],
|
||||
transcodeToHls: false
|
||||
}
|
||||
|
||||
function clampQuality(value: unknown): number {
|
||||
@@ -28,11 +37,11 @@ function isCopyFormat(value: unknown): value is CopyFormat {
|
||||
return value === 'url' || value === 'markdown' || value === 'html' || value === 'bbcode'
|
||||
}
|
||||
|
||||
function readStored(): UploadPreferences {
|
||||
function readStored(kind: UploadMediaKind): UploadPreferences {
|
||||
if (import.meta.server) return { ...DEFAULTS }
|
||||
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY)
|
||||
const raw = localStorage.getItem(storageKeyFor(kind))
|
||||
if (!raw) return { ...DEFAULTS }
|
||||
const parsed = JSON.parse(raw) as Partial<UploadPreferences>
|
||||
return {
|
||||
@@ -42,33 +51,36 @@ function readStored(): UploadPreferences {
|
||||
clientWebpQuality: clampQuality(parsed.clientWebpQuality),
|
||||
lastTagIds: Array.isArray(parsed.lastTagIds)
|
||||
? parsed.lastTagIds.filter(id => Number.isInteger(id) && id > 0)
|
||||
: DEFAULTS.lastTagIds
|
||||
: DEFAULTS.lastTagIds,
|
||||
transcodeToHls: parsed.transcodeToHls === true
|
||||
}
|
||||
} catch {
|
||||
return { ...DEFAULTS }
|
||||
}
|
||||
}
|
||||
|
||||
function writeStored(prefs: UploadPreferences) {
|
||||
function writeStored(kind: UploadMediaKind, prefs: UploadPreferences) {
|
||||
if (import.meta.server) return
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(prefs))
|
||||
localStorage.setItem(storageKeyFor(kind), JSON.stringify(prefs))
|
||||
}
|
||||
|
||||
export function useUploadPreferences() {
|
||||
const compressEnabled = useState('upload-pref-compress', () => DEFAULTS.compressEnabled)
|
||||
const autoCopyMarkdown = useState('upload-pref-auto-md', () => DEFAULTS.autoCopyMarkdown)
|
||||
const copyFormat = useState<CopyFormat>('upload-pref-copy-format', () => DEFAULTS.copyFormat)
|
||||
const clientWebpQuality = useState('upload-pref-webp-quality', () => DEFAULTS.clientWebpQuality)
|
||||
const lastTagIds = useState<number[]>('upload-pref-last-tag-ids', () => DEFAULTS.lastTagIds)
|
||||
const loaded = useState('upload-pref-loaded', () => false)
|
||||
export function useUploadPreferences(kind: UploadMediaKind = 'image') {
|
||||
const compressEnabled = useState(`upload-pref-compress-${kind}`, () => DEFAULTS.compressEnabled)
|
||||
const autoCopyMarkdown = useState(`upload-pref-auto-md-${kind}`, () => DEFAULTS.autoCopyMarkdown)
|
||||
const copyFormat = useState<CopyFormat>(`upload-pref-copy-format-${kind}`, () => DEFAULTS.copyFormat)
|
||||
const clientWebpQuality = useState(`upload-pref-webp-quality-${kind}`, () => DEFAULTS.clientWebpQuality)
|
||||
const lastTagIds = useState<number[]>(`upload-pref-last-tag-ids-${kind}`, () => DEFAULTS.lastTagIds)
|
||||
const transcodeToHls = useState(`upload-pref-transcode-${kind}`, () => DEFAULTS.transcodeToHls)
|
||||
const loaded = useState(`upload-pref-loaded-${kind}`, () => false)
|
||||
|
||||
function loadPreferences() {
|
||||
const stored = readStored()
|
||||
const stored = readStored(kind)
|
||||
compressEnabled.value = stored.compressEnabled
|
||||
autoCopyMarkdown.value = stored.autoCopyMarkdown
|
||||
copyFormat.value = stored.copyFormat
|
||||
clientWebpQuality.value = stored.clientWebpQuality
|
||||
lastTagIds.value = stored.lastTagIds
|
||||
transcodeToHls.value = stored.transcodeToHls
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
@@ -77,12 +89,13 @@ export function useUploadPreferences() {
|
||||
}
|
||||
|
||||
function savePreferences() {
|
||||
writeStored({
|
||||
writeStored(kind, {
|
||||
compressEnabled: compressEnabled.value,
|
||||
autoCopyMarkdown: autoCopyMarkdown.value,
|
||||
copyFormat: copyFormat.value,
|
||||
clientWebpQuality: clampQuality(clientWebpQuality.value),
|
||||
lastTagIds: lastTagIds.value
|
||||
lastTagIds: lastTagIds.value,
|
||||
transcodeToHls: transcodeToHls.value
|
||||
})
|
||||
}
|
||||
|
||||
@@ -91,21 +104,27 @@ export function useUploadPreferences() {
|
||||
autoCopyMarkdown.value = DEFAULTS.autoCopyMarkdown
|
||||
copyFormat.value = DEFAULTS.copyFormat
|
||||
clientWebpQuality.value = DEFAULTS.clientWebpQuality
|
||||
transcodeToHls.value = DEFAULTS.transcodeToHls
|
||||
savePreferences()
|
||||
}
|
||||
|
||||
watch([compressEnabled, autoCopyMarkdown, copyFormat, clientWebpQuality, lastTagIds], () => {
|
||||
if (loaded.value) {
|
||||
savePreferences()
|
||||
watch(
|
||||
[compressEnabled, autoCopyMarkdown, copyFormat, clientWebpQuality, lastTagIds, transcodeToHls],
|
||||
() => {
|
||||
if (loaded.value) {
|
||||
savePreferences()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
kind,
|
||||
compressEnabled,
|
||||
autoCopyMarkdown,
|
||||
copyFormat,
|
||||
clientWebpQuality,
|
||||
lastTagIds,
|
||||
transcodeToHls,
|
||||
loaded,
|
||||
loadPreferences,
|
||||
savePreferences,
|
||||
|
||||
Reference in new issue
Block a user