提交 9a568c63 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 1318a542
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"countup.js": "^2.3.2", "countup.js": "^2.3.2",
"dayjs": "^1.11.5", "dayjs": "^1.11.5",
"element-plus": "^2.2.15", "element-plus": "^2.2.15",
"file-saver": "^2.0.5",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"pinia": "^2.0.21", "pinia": "^2.0.21",
"qs": "^6.11.0", "qs": "^6.11.0",
...@@ -2295,6 +2296,11 @@ ...@@ -2295,6 +2296,11 @@
"node": "^10.12.0 || >=12.0.0" "node": "^10.12.0 || >=12.0.0"
} }
}, },
"node_modules/file-saver": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"node_modules/file-uri-to-path": { "node_modules/file-uri-to-path": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", "resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz",
...@@ -6423,6 +6429,11 @@ ...@@ -6423,6 +6429,11 @@
"flat-cache": "^3.0.4" "flat-cache": "^3.0.4"
} }
}, },
"file-saver": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"file-uri-to-path": { "file-uri-to-path": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", "resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz",
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"countup.js": "^2.3.2", "countup.js": "^2.3.2",
"dayjs": "^1.11.5", "dayjs": "^1.11.5",
"element-plus": "^2.2.15", "element-plus": "^2.2.15",
"file-saver": "^2.0.5",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"pinia": "^2.0.21", "pinia": "^2.0.21",
"qs": "^6.11.0", "qs": "^6.11.0",
......
<script setup lang="ts"> <script setup lang="ts">
import { Close } from '@element-plus/icons-vue' import { Close, Download } from '@element-plus/icons-vue'
import { onKeyStroke } from '@vueuse/core' import { onKeyStroke } from '@vueuse/core'
import { saveAs } from 'file-saver'
interface FileItem { interface FileItem {
name: string name: string
...@@ -24,6 +25,10 @@ const emit = defineEmits<{ ...@@ -24,6 +25,10 @@ const emit = defineEmits<{
onKeyStroke('Escape', () => { onKeyStroke('Escape', () => {
emit('update:modelValue', false) emit('update:modelValue', false)
}) })
// 下载
function handleDownload(item: FileItem) {
saveAs(item.url, item.name)
}
</script> </script>
<template> <template>
...@@ -33,7 +38,15 @@ onKeyStroke('Escape', () => { ...@@ -33,7 +38,15 @@ onKeyStroke('Escape', () => {
</div> </div>
<el-carousel :autoplay="false" :initial-index="index" arrow="always" height="100vh"> <el-carousel :autoplay="false" :initial-index="index" arrow="always" height="100vh">
<el-carousel-item v-for="item in items" :key="item.url"> <el-carousel-item v-for="item in items" :key="item.url">
<div class="image-viewer__pic"><img :src="item.url" /></div> <div class="image-viewer__inner">
<div class="image-viewer__pic">
<div class="image-viewer__pic-header">
<h1>{{ item.name }}</h1>
<el-button :icon="Download" @click="handleDownload(item)">下载</el-button>
</div>
<img :src="item.url" />
</div>
</div>
</el-carousel-item> </el-carousel-item>
</el-carousel> </el-carousel>
</div> </div>
...@@ -47,7 +60,7 @@ onKeyStroke('Escape', () => { ...@@ -47,7 +60,7 @@ onKeyStroke('Escape', () => {
right: 0; right: 0;
bottom: 0; bottom: 0;
z-index: 10000; z-index: 10000;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.6);
} }
.image-viewer__close { .image-viewer__close {
position: absolute; position: absolute;
...@@ -69,15 +82,33 @@ onKeyStroke('Escape', () => { ...@@ -69,15 +82,33 @@ onKeyStroke('Escape', () => {
background-color: var(--el-text-color-regular); background-color: var(--el-text-color-regular);
border-color: #fff; border-color: #fff;
} }
.image-viewer__pic { .image-viewer__inner {
width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.image-viewer__pic {
position: relative;
display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top: 60px;
max-height: calc(100vh - 60px);
img { img {
max-width: 100%; max-width: 100%;
max-height: 100%; max-height: 100%;
} }
} }
.image-viewer__pic-header {
position: absolute;
top: -40px;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
color: #fff;
}
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import type { ExperimentRecord } from '../types' import type { ExperimentRecord } from '../types'
import { ElMessageBox } from 'element-plus'
import ImageViewer from '@/components/ImageViewer.vue' import ImageViewer from '@/components/ImageViewer.vue'
import { uploadExperimentPicture } from '../api' import { uploadExperimentPicture } from '../api'
...@@ -28,10 +29,12 @@ function handlePreview(index: number) { ...@@ -28,10 +29,12 @@ function handlePreview(index: number) {
} }
// 删除 // 删除
function handleRemove(index: number) { function handleRemove(index: number) {
if (!props.experiment_id) return ElMessageBox.confirm('删除之后无法恢复,确认删除该截图吗?', '提示').then(() => {
const pictures = detail.pictures.filter((item, i) => i !== index) if (!props.experiment_id) return
uploadExperimentPicture({ experiment_id: props.experiment_id, pictures: JSON.stringify(pictures) }).then(() => { const pictures = detail.pictures.filter((item, i) => i !== index)
emit('update') uploadExperimentPicture({ experiment_id: props.experiment_id, pictures: JSON.stringify(pictures) }).then(() => {
emit('update')
})
}) })
} }
</script> </script>
...@@ -39,10 +42,15 @@ function handleRemove(index: number) { ...@@ -39,10 +42,15 @@ function handleRemove(index: number) {
<template> <template>
<el-empty description="暂无数据" v-if="isEmpty" /> <el-empty description="暂无数据" v-if="isEmpty" />
<template v-else> <template v-else>
<div class="result-score" v-if="detail.status === 2"> <div class="result-score">
<h2>我的成绩</h2> <h2>我的成绩</h2>
<p class="t1">{{ parseFloat(detail.score) }}</p> <template v-if="detail.status === 2">
<p class="t2">批改讲师:{{ detail.checker_user.real_name }}</p> <p class="t1">{{ parseFloat(detail.score) }}</p>
<p class="t2">批改讲师:{{ detail.checker_user.real_name }}</p>
</template>
<template v-else>
<p class="t1">--</p>
</template>
</div> </div>
<h3>实验过程</h3> <h3>实验过程</h3>
<ul class="picture-list"> <ul class="picture-list">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论