mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-17 12:30:59 +08:00
Compare commits
1 Commits
feature/ff
...
feature/ff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44642783e6 |
@@ -10,3 +10,8 @@ NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23liOlrZnPKRF7s7NN
|
|||||||
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
|
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
|
||||||
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
|
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
|
||||||
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
|
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
|
||||||
|
|
||||||
|
# 视频压缩配置 - FFmpeg.wasm 专用
|
||||||
|
# 支持 Chrome 60+ 和 Safari 11.1+
|
||||||
|
NUXT_PUBLIC_VIDEO_MAX_SIZE=52428800 # 20MB (字节)
|
||||||
|
NUXT_PUBLIC_VIDEO_TARGET_SIZE=20971520 # 5MB (字节)
|
||||||
@@ -17,3 +17,8 @@ NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23liVkO1NPAX5JyWxJ
|
|||||||
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
|
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
|
||||||
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
|
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
|
||||||
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
|
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
|
||||||
|
|
||||||
|
# 视频压缩配置 - FFmpeg.wasm 专用
|
||||||
|
# 支持 Chrome 60+ 和 Safari 11.1+
|
||||||
|
NUXT_PUBLIC_VIDEO_MAX_SIZE=52428800 # 20MB (字节)
|
||||||
|
NUXT_PUBLIC_VIDEO_TARGET_SIZE=20971520 # 5MB (字节)
|
||||||
@@ -15,3 +15,8 @@ NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23liVkO1NPAX5JyWxJ
|
|||||||
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
|
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
|
||||||
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
|
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
|
||||||
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
|
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
|
||||||
|
|
||||||
|
# 视频压缩配置 - FFmpeg.wasm 专用
|
||||||
|
# 支持 Chrome 60+ 和 Safari 11.1+
|
||||||
|
NUXT_PUBLIC_VIDEO_MAX_SIZE=52428800 # 20MB (字节)
|
||||||
|
NUXT_PUBLIC_VIDEO_TARGET_SIZE=20971520 # 5MB (字节)
|
||||||
@@ -3,12 +3,53 @@
|
|||||||
* 专注于 FFmpeg.wasm 视频压缩,支持 Chrome/Safari
|
* 专注于 FFmpeg.wasm 视频压缩,支持 Chrome/Safari
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// 声明全局变量以避免 TypeScript 错误
|
||||||
|
/* global useRuntimeConfig */
|
||||||
|
|
||||||
|
// 简化的环境变量读取功能
|
||||||
|
function getEnvNumber(key, defaultValue) {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
// 客户端:尝试从 Nuxt 环境获取
|
||||||
|
try {
|
||||||
|
// 使用 globalThis 避免直接引用未定义的变量
|
||||||
|
const nuxtApp = globalThis.$nuxt || globalThis.nuxtApp
|
||||||
|
if (nuxtApp && nuxtApp.$config) {
|
||||||
|
const value = nuxtApp.$config.public?.[key.replace('NUXT_PUBLIC_', '').toLowerCase()]
|
||||||
|
return value ? Number(value) : defaultValue
|
||||||
|
}
|
||||||
|
return defaultValue
|
||||||
|
} catch {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 服务端:从 process.env 获取
|
||||||
|
return process.env[key] ? Number(process.env[key]) : defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEnvBoolean(key, defaultValue) {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
try {
|
||||||
|
// 使用 globalThis 避免直接引用未定义的变量
|
||||||
|
const nuxtApp = globalThis.$nuxt || globalThis.nuxtApp
|
||||||
|
if (nuxtApp && nuxtApp.$config) {
|
||||||
|
const value = nuxtApp.$config.public?.[key.replace('NUXT_PUBLIC_', '').toLowerCase()]
|
||||||
|
return value === 'true' || value === true
|
||||||
|
}
|
||||||
|
return defaultValue
|
||||||
|
} catch {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const envValue = process.env[key]
|
||||||
|
return envValue ? envValue === 'true' : defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
export const UPLOAD_CONFIG = {
|
export const UPLOAD_CONFIG = {
|
||||||
// 视频文件配置 - 专为 FFmpeg.wasm 优化
|
// 视频文件配置 - 专为 FFmpeg.wasm 优化
|
||||||
VIDEO: {
|
VIDEO: {
|
||||||
// 文件大小限制 (字节)
|
// 文件大小限制 (字节)
|
||||||
MAX_SIZE: 20 * 1024 * 1024,
|
MAX_SIZE: getEnvNumber('NUXT_PUBLIC_VIDEO_MAX_SIZE', 20 * 1024 * 1024), // 5MB
|
||||||
TARGET_SIZE: 5 * 1024 * 1024, // 5MB
|
TARGET_SIZE: getEnvNumber('NUXT_PUBLIC_VIDEO_TARGET_SIZE', 5 * 1024 * 1024), // 5MB
|
||||||
|
|
||||||
// 支持的输入格式 (FFmpeg.wasm 支持更多格式)
|
// 支持的输入格式 (FFmpeg.wasm 支持更多格式)
|
||||||
SUPPORTED_FORMATS: ['mp4', 'webm', 'avi', 'mov', 'wmv', 'flv', 'mkv', 'm4v', 'ogv'],
|
SUPPORTED_FORMATS: ['mp4', 'webm', 'avi', 'mov', 'wmv', 'flv', 'mkv', 'm4v', 'ogv'],
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt/config'
|
import { defineNuxtConfig } from 'nuxt/config'
|
||||||
|
import { createRequire } from 'node:module'
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const appPkg = require('./package.json') as {
|
||||||
|
dependencies?: Record<string, string>
|
||||||
|
devDependencies?: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
devServer: {
|
devServer: {
|
||||||
@@ -97,9 +104,26 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
optimizeDeps: {
|
build: {
|
||||||
exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util'],
|
// increase warning limit and split large libraries into separate chunks
|
||||||
|
// chunkSizeWarningLimit: 1024,
|
||||||
|
// rollupOptions: {
|
||||||
|
// output: {
|
||||||
|
// manualChunks(id) {
|
||||||
|
// if (id.includes('node_modules')) {
|
||||||
|
// if (id.includes('vditor')) {
|
||||||
|
// return 'vditor'
|
||||||
|
// }
|
||||||
|
// if (id.includes('echarts')) {
|
||||||
|
// return 'echarts'
|
||||||
|
// }
|
||||||
|
// if (id.includes('highlight.js')) {
|
||||||
|
// return 'highlight'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
build: {},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
2325
frontend_nuxt/package-lock.json
generated
2325
frontend_nuxt/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@icon-park/vue-next": "^1.4.2",
|
"@icon-park/vue-next": "^1.4.2",
|
||||||
"@ffmpeg/ffmpeg": "^0.12.2",
|
"@ffmpeg/ffmpeg": "^0.12.15",
|
||||||
"@ffmpeg/util": "^0.12.2",
|
"@ffmpeg/util": "^0.12.2",
|
||||||
"@nuxt/image": "^1.11.0",
|
"@nuxt/image": "^1.11.0",
|
||||||
"@stomp/stompjs": "^7.0.0",
|
"@stomp/stompjs": "^7.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { FFmpeg } from '@ffmpeg/ffmpeg'
|
import { FFmpeg } from '@ffmpeg/ffmpeg'
|
||||||
import { toBlobURL } from '@ffmpeg/util'
|
import { toBlobURL } from '@ffmpeg/util'
|
||||||
import { defineNuxtPlugin } from 'nuxt/app'
|
import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'
|
||||||
|
|
||||||
let ffmpeg: FFmpeg | null = null
|
let ffmpeg: FFmpeg | null = null
|
||||||
|
|
||||||
@@ -10,12 +10,11 @@ export default defineNuxtPlugin(() => {
|
|||||||
ffmpeg: async () => {
|
ffmpeg: async () => {
|
||||||
if (ffmpeg) return ffmpeg
|
if (ffmpeg) return ffmpeg
|
||||||
ffmpeg = new FFmpeg()
|
ffmpeg = new FFmpeg()
|
||||||
const base = `https://unpkg.com/@ffmpeg/core@0.12.2/dist/esm`
|
const base = '~/assets/js/ffmpeg/core-mt/dist/umd'
|
||||||
const libBase = `https://unpkg.com/@ffmpeg/ffmpeg@0.12.2/dist/esm`
|
|
||||||
await ffmpeg.load({
|
await ffmpeg.load({
|
||||||
coreURL: await toBlobURL(`${base}/ffmpeg-core.js`, 'text/javascript'),
|
coreURL: await toBlobURL(`${base}/ffmpeg-core.js`, 'text/javascript'),
|
||||||
wasmURL: await toBlobURL(`${base}/ffmpeg-core.wasm`, 'application/wasm'),
|
wasmURL: await toBlobURL(`${base}/ffmpeg-core.wasm`, 'application/wasm'),
|
||||||
workerURL: await toBlobURL(`${libBase}/worker.js`, 'text/javascript'),
|
workerURL: await toBlobURL(`${base}/ffmpeg-core.worker.js`, 'text/javascript'),
|
||||||
})
|
})
|
||||||
|
|
||||||
return ffmpeg
|
return ffmpeg
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export function createVditor(editorId, options = {}) {
|
|||||||
// 如果是视频文件且需要压缩
|
// 如果是视频文件且需要压缩
|
||||||
if (isVideo && sizeCheck.needsCompression) {
|
if (isVideo && sizeCheck.needsCompression) {
|
||||||
try {
|
try {
|
||||||
vditor.tip('开始部署ffmpeg环境... 请稍等', 0)
|
vditor.tip('视频压缩中...', 0)
|
||||||
vditor.disabled()
|
vditor.disabled()
|
||||||
|
|
||||||
// 使用 FFmpeg 压缩视频
|
// 使用 FFmpeg 压缩视频
|
||||||
|
|||||||
Reference in New Issue
Block a user