Skip to content

Commit edac65a

Browse files
committed
feat: v1.5.5
1 parent bdc1c59 commit edac65a

File tree

7 files changed

+73
-2
lines changed

7 files changed

+73
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# 更新日志
22

3+
## 1.5.5
4+
5+
- 新增:简单支持音频(mp3、wav)、视频(mp4、mov)文件的播放
6+
- 优化:优化二进制文件的检测,避免卡死情况
7+
38
## 1.5.4
49

510
- 新增:目录支持上传文件,顶级目录同样可操作

frontend/components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export {}
1212
/* prettier-ignore */
1313
declare module 'vue' {
1414
export interface GlobalComponents {
15+
AudioView: typeof import('./src/components/AudioView.vue')['default']
1516
ClickMove: typeof import('./src/components/ClickMove.vue')['default']
1617
Code: typeof import('./src/components/icons/Code.vue')['default']
1718
ElButton: typeof import('element-plus/es')['ElButton']
@@ -42,12 +43,14 @@ declare module 'vue' {
4243
OfficeWord: typeof import('./src/components/icons/OfficeWord.vue')['default']
4344
Pdf: typeof import('./src/components/icons/Pdf.vue')['default']
4445
PdfView: typeof import('./src/components/PdfView.vue')['default']
46+
VideoView: typeof import('./src/components/VideoView.vue')['default']
4547
Zip: typeof import('./src/components/icons/Zip.vue')['default']
4648
}
4749
}
4850

4951
// For TSX support
5052
declare global {
53+
const AudioView: typeof import('./src/components/AudioView.vue')['default']
5154
const ClickMove: typeof import('./src/components/ClickMove.vue')['default']
5255
const Code: typeof import('./src/components/icons/Code.vue')['default']
5356
const ElButton: typeof import('element-plus/es')['ElButton']
@@ -78,5 +81,6 @@ declare global {
7881
const OfficeWord: typeof import('./src/components/icons/OfficeWord.vue')['default']
7982
const Pdf: typeof import('./src/components/icons/Pdf.vue')['default']
8083
const PdfView: typeof import('./src/components/PdfView.vue')['default']
84+
const VideoView: typeof import('./src/components/VideoView.vue')['default']
8185
const Zip: typeof import('./src/components/icons/Zip.vue')['default']
8286
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<div class="audio-view">
3+
<audio :src="getFullPath($props.src)" controls></audio>
4+
</div>
5+
</template>
6+
7+
<script lang="ts" setup>
8+
import { getFullPath } from '@/utils/file'
9+
10+
const $props = defineProps<{ src: string }>()
11+
</script>
12+
13+
<style lang="scss" scoped>
14+
.audio-view {
15+
height: 100%;
16+
width: 100%;
17+
display: flex;
18+
align-items: center;
19+
justify-content: center;
20+
21+
> .i {
22+
max-width: 80%;
23+
max-height: 80%;
24+
}
25+
}
26+
</style>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<div class="video-view">
3+
<video class="i" :src="getFullPath($props.src)" controls></video>
4+
</div>
5+
</template>
6+
7+
<script lang="ts" setup>
8+
import { getFullPath } from '@/utils/file'
9+
10+
const $props = defineProps<{ src: string }>()
11+
</script>
12+
13+
<style lang="scss" scoped>
14+
.video-view {
15+
height: 100%;
16+
width: 100%;
17+
display: flex;
18+
align-items: center;
19+
justify-content: center;
20+
21+
> .i {
22+
max-width: 80%;
23+
max-height: 80%;
24+
}
25+
}
26+
</style>

frontend/src/layout/ViewRight/ViewBox.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
<PdfView v-else-if="fileType === 'pdf'" :src="$props.value.path" />
1717

18+
<AudioView v-else-if="fileType === 'audio'" :src="$props.value.path" />
19+
20+
<VideoView v-else-if="fileType === 'video'" :src="$props.value.path" />
21+
1822
<MonacoEditor v-else ref="editorRef" :path="$props.value.path" @diff="(v) => $emit('diff', v)" @error="(v) => v && (error = v)" />
1923
</template>
2024
</template>
@@ -26,6 +30,8 @@ import { computed, ref } from 'vue'
2630
import MonacoEditor from '@/components/MonacoEditor.vue'
2731
import ImageView from '@/components/ImageView.vue'
2832
import PdfView from '@/components/PdfView.vue'
33+
import AudioView from '@/components/AudioView.vue'
34+
import VideoView from '@/components/VideoView.vue'
2935
3036
import { FILE_MAP } from '@/utils/option'
3137
import { getFileSuffix, getSize } from '@/utils/file'
@@ -44,7 +50,7 @@ const editorRef = ref<{ save: () => void }>()
4450
4551
const error = ref('')
4652
const fileType = computed(() => FILE_MAP[getFileSuffix($props.value.path)])
47-
const isBinaryFile = computed(() => fileType.value && !['img', 'pdf'].includes(fileType.value))
53+
const isBinaryFile = computed(() => fileType.value && !['img', 'pdf', 'audio', 'video'].includes(fileType.value))
4854
</script>
4955

5056
<style lang="scss" scoped>

frontend/src/utils/option.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export const FILE_MAP: { [x: string]: string } = {
4343
apng: 'img',
4444
ico: 'img',
4545
pdf: 'pdf',
46+
mp3: 'audio',
47+
wav: 'audio',
48+
mp4: 'video',
49+
mov: 'video',
4650
zip: 'zip',
4751
rar: 'zip',
4852
'7z': 'zip',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "code.editor",
3-
"version": "1.5.4",
3+
"version": "1.5.5",
44
"changelog": "<div>新增:文件快照功能,可随时回退文件</div><div>新增:图片查看,支持同级快速预览</div><div>新增:PDF 阅读,支持索引跳转和缩放</div><div>新增:支持刷新目录和在目录下创建文件</div><div>新增:偏好设置-启动时询问,可在桌面图标访问时不询问开启</div><div>新增:markdown 文件支持预览</div><div>新增:偏好设置支持设置打开 markdown 时默认预览</div><div>新增:显示字数、文件大小、最后更新日期</div><div>新增:独立窗口按钮</div><div>新增:加载大文件将提示是否继续加载,避免带宽浪费</div><div>新增:支持在目录进行文件上传</div>",
55
"scripts": {
66
"dev": "node src/app.js",

0 commit comments

Comments
 (0)