mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 19:31:20 +08:00
Compare commits
11 Commits
feature/ff
...
codex/fix-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abbdb224e0 | ||
|
|
37bef0b2d7 | ||
|
|
3519a41a2e | ||
|
|
ab04a8b6b1 | ||
|
|
ea079e8b8a | ||
|
|
519656359f | ||
|
|
dc64785279 | ||
|
|
9421d004d4 | ||
|
|
90bd41e740 | ||
|
|
7d5c864f64 | ||
|
|
3f35add587 |
@@ -17,8 +17,3 @@ 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 # 50MB (字节)
|
|
||||||
NUXT_PUBLIC_VIDEO_TARGET_SIZE=20971520 # 20MB (字节)
|
|
||||||
@@ -342,7 +342,7 @@ const copyCommentLink = () => {
|
|||||||
|
|
||||||
const handleContentClick = (e) => {
|
const handleContentClick = (e) => {
|
||||||
handleMarkdownClick(e)
|
handleMarkdownClick(e)
|
||||||
if (e.target.tagName === 'IMG') {
|
if (e.target.tagName === 'IMG' && !e.target.classList.contains('emoji')) {
|
||||||
const container = e.target.parentNode
|
const container = e.target.parentNode
|
||||||
const imgs = [...container.querySelectorAll('img')].map((i) => i.src)
|
const imgs = [...container.querySelectorAll('img')].map((i) => i.src)
|
||||||
lightboxImgs.value = imgs
|
lightboxImgs.value = imgs
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="message-bottom-container">
|
<div class="message-bottom-container">
|
||||||
<div class="message-submit" :class="{ disabled: isDisabled }" @click="submit">
|
<div class="message-submit" :class="{ disabled: isDisabled }" @click="submit">
|
||||||
<template v-if="!loading"> 发送 </template>
|
<template v-if="!loading">
|
||||||
|
发送
|
||||||
|
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
||||||
|
</template>
|
||||||
<template v-else> <loading-four /> 发送中... </template>
|
<template v-else> <loading-four /> 发送中... </template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -21,6 +24,8 @@ import {
|
|||||||
getEditorTheme as getEditorThemeUtil,
|
getEditorTheme as getEditorThemeUtil,
|
||||||
getPreviewTheme as getPreviewThemeUtil,
|
getPreviewTheme as getPreviewThemeUtil,
|
||||||
} from '~/utils/vditor'
|
} from '~/utils/vditor'
|
||||||
|
import { useIsMobile } from '~/utils/screen'
|
||||||
|
import { isMac } from '~/utils/device'
|
||||||
import '~/assets/global.css'
|
import '~/assets/global.css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -44,6 +49,7 @@ export default {
|
|||||||
const vditorInstance = ref(null)
|
const vditorInstance = ref(null)
|
||||||
const text = ref('')
|
const text = ref('')
|
||||||
const editorId = ref(props.editorId)
|
const editorId = ref(props.editorId)
|
||||||
|
const isMobile = useIsMobile()
|
||||||
if (!editorId.value) {
|
if (!editorId.value) {
|
||||||
editorId.value = 'editor-' + useId()
|
editorId.value = 'editor-' + useId()
|
||||||
}
|
}
|
||||||
@@ -84,6 +90,28 @@ export default {
|
|||||||
applyTheme()
|
applyTheme()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 不是手机的情况下不添加快捷键
|
||||||
|
if (!isMobile.value) {
|
||||||
|
// 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter)
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||||
|
e.preventDefault()
|
||||||
|
submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const el = document.getElementById(editorId.value)
|
||||||
|
if (el) {
|
||||||
|
el.addEventListener('keydown', handleKeydown)
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (el) {
|
||||||
|
el.removeEventListener('keydown', handleKeydown)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@@ -121,7 +149,7 @@ export default {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return { submit, isDisabled, editorId }
|
return { submit, isDisabled, editorId, isMac, isMobile }
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -168,4 +196,17 @@ export default {
|
|||||||
.message-submit:not(.disabled):hover {
|
.message-submit:not(.disabled):hover {
|
||||||
background-color: var(--primary-color-hover);
|
background-color: var(--primary-color-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 评论按钮快捷键样式 */
|
||||||
|
.shortcut-icon {
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.2;
|
||||||
|
background-color: rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
.comment-submit.disabled .shortcut-icon {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -3,53 +3,12 @@
|
|||||||
* 专注于 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: getEnvNumber('NUXT_PUBLIC_VIDEO_MAX_SIZE', 20 * 1024 * 1024), // 5MB
|
MAX_SIZE: 20 * 1024 * 1024,
|
||||||
TARGET_SIZE: getEnvNumber('NUXT_PUBLIC_VIDEO_TARGET_SIZE', 5 * 1024 * 1024), // 5MB
|
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,17 +1,5 @@
|
|||||||
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>
|
|
||||||
}
|
|
||||||
const ffmpegVersion = (
|
|
||||||
process.env.NUXT_PUBLIC_FFMPEG_VERSION ||
|
|
||||||
appPkg.dependencies?.['@ffmpeg/ffmpeg'] ||
|
|
||||||
appPkg.devDependencies?.['@ffmpeg/ffmpeg'] ||
|
|
||||||
'0.12.15'
|
|
||||||
).replace(/^[^\d]*/, '')
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
devServer: {
|
devServer: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
@@ -29,7 +17,6 @@ export default defineNuxtConfig({
|
|||||||
discordClientId: process.env.NUXT_PUBLIC_DISCORD_CLIENT_ID || '',
|
discordClientId: process.env.NUXT_PUBLIC_DISCORD_CLIENT_ID || '',
|
||||||
twitterClientId: process.env.NUXT_PUBLIC_TWITTER_CLIENT_ID || '',
|
twitterClientId: process.env.NUXT_PUBLIC_TWITTER_CLIENT_ID || '',
|
||||||
telegramBotId: process.env.NUXT_PUBLIC_TELEGRAM_BOT_ID || '',
|
telegramBotId: process.env.NUXT_PUBLIC_TELEGRAM_BOT_ID || '',
|
||||||
ffmpegVersion,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
css: [
|
css: [
|
||||||
@@ -110,26 +97,9 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
build: {
|
optimizeDeps: {
|
||||||
// increase warning limit and split large libraries into separate chunks
|
exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util'],
|
||||||
// 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: {},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
2406
frontend_nuxt/package-lock.json
generated
2406
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.15",
|
"@ffmpeg/ffmpeg": "^0.12.2",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -463,7 +463,11 @@ function minimize() {
|
|||||||
|
|
||||||
function handleContentClick(e) {
|
function handleContentClick(e) {
|
||||||
handleMarkdownClick(e)
|
handleMarkdownClick(e)
|
||||||
if (e.target.tagName === 'IMG') {
|
if (
|
||||||
|
e.target.tagName === 'IMG' &&
|
||||||
|
!e.target.classList.contains('emoji') &&
|
||||||
|
!e.target.closest('.reactions-container')
|
||||||
|
) {
|
||||||
const container = e.target.parentNode
|
const container = e.target.parentNode
|
||||||
const imgs = [...container.querySelectorAll('img')].map((i) => i.src)
|
const imgs = [...container.querySelectorAll('img')].map((i) => i.src)
|
||||||
lightboxImgs.value = imgs
|
lightboxImgs.value = imgs
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ const removeCommentFromList = (id, list) => {
|
|||||||
|
|
||||||
const handleContentClick = (e) => {
|
const handleContentClick = (e) => {
|
||||||
handleMarkdownClick(e)
|
handleMarkdownClick(e)
|
||||||
if (e.target.tagName === 'IMG') {
|
if (e.target.tagName === 'IMG' && !e.target.classList.contains('emoji')) {
|
||||||
const container = e.target.parentNode
|
const container = e.target.parentNode
|
||||||
const imgs = [...container.querySelectorAll('img')].map((i) => i.src)
|
const imgs = [...container.querySelectorAll('img')].map((i) => i.src)
|
||||||
lightboxImgs.value = imgs
|
lightboxImgs.value = imgs
|
||||||
|
|||||||
@@ -1,33 +1,21 @@
|
|||||||
import { FFmpeg } from '@ffmpeg/ffmpeg'
|
import { FFmpeg } from '@ffmpeg/ffmpeg'
|
||||||
import { toBlobURL } from '@ffmpeg/util'
|
import { toBlobURL } from '@ffmpeg/util'
|
||||||
import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'
|
import { defineNuxtPlugin } from 'nuxt/app'
|
||||||
|
|
||||||
let ffmpeg: FFmpeg | null = null
|
let ffmpeg: FFmpeg | null = null
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin(() => {
|
||||||
const {
|
|
||||||
public: { ffmpegVersion },
|
|
||||||
} = useRuntimeConfig()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
provide: {
|
provide: {
|
||||||
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 mtOk =
|
const libBase = `https://unpkg.com/@ffmpeg/ffmpeg@0.12.2/dist/esm`
|
||||||
typeof crossOriginIsolated !== 'undefined' &&
|
|
||||||
crossOriginIsolated &&
|
|
||||||
typeof SharedArrayBuffer !== 'undefined'
|
|
||||||
|
|
||||||
const pkg = mtOk ? '@ffmpeg/core-mt' : '@ffmpeg/core-st'
|
|
||||||
const base = `https://unpkg.com/${pkg}@${ffmpegVersion}/dist/umd`
|
|
||||||
|
|
||||||
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(`${base}/ffmpeg-core.worker.js`, 'text/javascript'),
|
workerURL: await toBlobURL(`${libBase}/worker.js`, 'text/javascript'),
|
||||||
})
|
})
|
||||||
|
|
||||||
return ffmpeg
|
return ffmpeg
|
||||||
|
|||||||
28
frontend_nuxt/utils/device.js
Normal file
28
frontend_nuxt/utils/device.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
export const isClient = typeof window !== 'undefined' && typeof document !== 'undefined'
|
||||||
|
|
||||||
|
export const isMac = getIsMac()
|
||||||
|
|
||||||
|
function getIsMac() {
|
||||||
|
if (!isClient) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 优先使用现代浏览器的 navigator.userAgentData API
|
||||||
|
if (navigator.userAgentData && navigator.userAgentData.platform) {
|
||||||
|
return navigator.userAgentData.platform === 'macOS'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 降级到传统的 User-Agent 检测
|
||||||
|
if (navigator.userAgent) {
|
||||||
|
return /Mac|iPhone|iPad|iPod/i.test(navigator.userAgent)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认返回false
|
||||||
|
return false
|
||||||
|
} catch (error) {
|
||||||
|
// 异常处理,记录错误并返回默认值
|
||||||
|
console.warn('检测Mac设备时发生错误:', error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -118,7 +118,7 @@ export function createVditor(editorId, options = {}) {
|
|||||||
// 如果是视频文件且需要压缩
|
// 如果是视频文件且需要压缩
|
||||||
if (isVideo && sizeCheck.needsCompression) {
|
if (isVideo && sizeCheck.needsCompression) {
|
||||||
try {
|
try {
|
||||||
vditor.tip('视频压缩中...', 0)
|
vditor.tip('开始部署ffmpeg环境... 请稍等', 0)
|
||||||
vditor.disabled()
|
vditor.disabled()
|
||||||
|
|
||||||
// 使用 FFmpeg 压缩视频
|
// 使用 FFmpeg 压缩视频
|
||||||
|
|||||||
Reference in New Issue
Block a user