zhuhao_dev #23

Merged
zhuhao merged 3 commits from zhuhao_dev into main 2024-07-15 18:22:45 +08:00
3 changed files with 185 additions and 53 deletions
Showing only changes of commit 48501e9195 - Show all commits

View File

@ -8,3 +8,9 @@ export const getSmarttalkPage = (params) => {
params params
}) })
} }
export function deleteSmarttalk(id) {
return request({
url: '/smarttalk/file/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,78 @@
// 判断是不是昨天
const isYestday = (date) => {
var yesterday = new Date(new Date() - 1000 * 60 * 60 * 24)
return (
yesterday.getYear() === date.getYear() &&
yesterday.getMonth() === date.getMonth() &&
yesterday.getDate() === date.getDate()
)
}
// 判断是不是今年
const isYear = (date) => {
return date.getYear() === new Date().getYear()
}
//将时间转为 yy/mm/dd hh:mm:ss
const formatDateTime = (date) => {
if (!date) {
return ''
}
var dateObject = new Date(date)
var y = dateObject.getFullYear()
var m = dateObject.getMonth() + 1
m = m < 10 ? '0' + m : m
var d = dateObject.getDate()
d = d < 10 ? '0' + d : d
var h = dateObject.getHours()
h = h < 10 ? '0' + h : h
var minute = dateObject.getMinutes()
minute = minute < 10 ? '0' + minute : minute
var second = dateObject.getSeconds()
second = second < 10 ? '0' + second : second
return y + '/' + m + '/' + d + ' ' + h + ':' + minute + ':' + second
}
/**
* 将时间戳转换为文本描述
*
* 此函数旨在将时间戳转换为更易读的文本格式以便用户可以更直观地理解时间信息
* 通过传入的时间函数将生成对应的时间文本"刚刚""5分钟前""昨天"
* 如果设置了simple参数为true则会返回更简单的23/06/25只显示年月日如果是今年只返回月和日
*
* @param {string} timeStamp - 需要转换的时间
* @param {boolean} simple - 是否使用简单的格式默认为false23/06/2506/25
* @returns {string} - 转换后的时间文本
*/
export const toTimeText = (timeStamp, simple) => {
if (!timeStamp) {
return ''
}
var dateTime = new Date(timeStamp)
var currentTime = Date.parse(new Date()) //当前时间
var timeDiff = currentTime - dateTime //与当前时间误差
var timeText = ''
if (timeDiff <= 60000) {
//一分钟内
timeText = '刚刚'
} else if (timeDiff > 60000 && timeDiff < 3600000) {
//1小时内
timeText = Math.floor(timeDiff / 60000) + '分钟前'
} else if (timeDiff >= 3600000 && timeDiff < 86400000 && !isYestday(dateTime)) {
//今日
timeText = formatDateTime(dateTime).substr(11, 5)
} else if (isYestday(dateTime)) {
//昨天
timeText = '昨天' + formatDateTime(dateTime).substr(11, 5)
} else if (isYear(dateTime)) {
//今年
timeText = formatDateTime(dateTime).substr(5, simple ? 5 : 14)
} else {
//不属于今年
timeText = formatDateTime(dateTime)
if (simple) {
timeText = timeText.substr(2, 8)
}
}
return timeText
}

View File

@ -8,30 +8,24 @@
<el-popover placement="top-start" :width="250" trigger="hover"> <el-popover placement="top-start" :width="250" trigger="hover">
<template #default> <template #default>
<div> <div>
<el-button type="success" size="small" :icon="Check" circle /> 2024-07-11 16:15 <el-button type="success" size="small" :icon="Check" circle />
2024-07-11 16:15
同步成功 同步成功
</div> </div>
</template> </template>
<template #reference> <template #reference>
<el-button size="small" text <el-button size="small" text
><el-icon><Refresh /></el-icon></el-button >
<el-icon>
<Refresh />
</el-icon>
云同步
</el-button
> >
</template> </template>
</el-popover> </el-popover>
</div> </div>
<div style="display: flex"> <div style="display: flex">
<!-- <el-upload
ref="choosefile"
v-model:file-list="fileList"
name="file"
:show-file-list="false"
:auto-upload="false"
:multiple="true"
:on-change="chooseFile"
class="editor-img-uploader"
>
<el-button @click="isDialogOpen=true">上传资料</el-button>
</el-upload>-->
<el-button @click="isDialogOpen=true">上传资料</el-button> <el-button @click="isDialogOpen=true">上传资料</el-button>
<el-button type="primary" style="margin-left: 10px">新建课件</el-button> <el-button type="primary" style="margin-left: 10px">新建课件</el-button>
</div> </div>
@ -46,36 +40,49 @@
<div class="prepare-body-main-item-info"> <div class="prepare-body-main-item-info">
<div class="prepare-item-info-title">{{ item.fileShowName }}</div> <div class="prepare-item-info-title">{{ item.fileShowName }}</div>
<div class="prepare-item-info-message"> <div class="prepare-item-info-message">
<div> <div style="width: 80px">
<el-icon <el-icon
style="background-color: green; border-radius: 20px; color: white; top: 2px" style="background-color: green; border-radius: 20px; color: white; top: 2px"
><Check /></el-icon >
>已同步 <Check />
</el-icon
>
已同步
</div>
|
<div style="width: 80px">{{ formatFileSize(item.fileSize) }}</div>
|
<div style="width: 100px">{{ toTimeText(item.uploadTime, true) }}</div>
|
<div style="white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;" :title="item.levelFirstName + (item.levelSecondName ? ' > ' + item.levelSecondName : '') + (item.levelThirdNmae ? ' > ' + item.levelThirdNmae : '')">
{{ item.levelFirstName + (item.levelSecondName ? ' > ' + item.levelSecondName : '') + (item.levelThirdNmae ? ' > ' + item.levelThirdNmae : '') }}
</div> </div>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div>{{item.fileSize}}</div>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div>{{item.uploadTime}}</div>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div>古诗词诵读 > 静女</div>
</div> </div>
</div> </div>
<div class="prepare-body-main-item-tool"> <div class="prepare-body-main-item-tool">
<el-popover placement="left-start" popper-class="prepare-popper" trigger="click"> <el-popover placement="left-start" popper-class="prepare-popper" trigger="click">
<template #default> <template #default>
<div style="width: 100%; height: 100px;"> <div style="width: 100%;">
<div class="item-popover"> <div class="item-popover">
<div class="item-popover-item"> <div class="item-popover-item">
<el-button text>
<i class="iconfont icon-bianji"></i> <i class="iconfont icon-bianji"></i>
<span>编辑</span> <span>编辑</span>
</el-button>
</div> </div>
<div class="item-popover-item"> <div class="item-popover-item">
<el-button text @click="deleteSmarttalk(item.id)">
<i class="iconfont icon-shanchu"></i> <i class="iconfont icon-shanchu"></i>
<span>删除</span> <span>删除</span>
</el-button>
</div> </div>
<div class="item-popover-item"> <div class="item-popover-item">
<el-button text>
<i class="iconfont icon-xiazai"></i> <i class="iconfont icon-xiazai"></i>
<span>下载</span> <span>下载</span>
</el-button>
</div> </div>
</div> </div>
</div> </div>
@ -94,6 +101,7 @@
<script setup> <script setup>
import { Check } from '@element-plus/icons-vue' import { Check } from '@element-plus/icons-vue'
import ChooseTextbook from '@/components/choose-textbook/index.vue' import ChooseTextbook from '@/components/choose-textbook/index.vue'
import { deleteSmarttalk } from '@/api/file'
</script> </script>
<script> <script>
import FileUpload from '@/components/file-upload/index.vue' import FileUpload from '@/components/file-upload/index.vue'
@ -104,6 +112,7 @@ import uploadDialog from '@/components/upload-dialog/index.vue'
import { Refresh } from '@element-plus/icons-vue' import { Refresh } from '@element-plus/icons-vue'
import uploaderState from '@/store/modules/uploader' import uploaderState from '@/store/modules/uploader'
import { getSmarttalkPage } from '@/api/file' import { getSmarttalkPage } from '@/api/file'
import { toTimeText } from '@/utils/date'
// import { getSmarttalkPage } from '@/api/file' // import { getSmarttalkPage } from '@/api/file'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
export default { export default {
@ -124,7 +133,7 @@ export default {
levelFirstId: 39103, levelFirstId: 39103,
levelSecondId: null, levelSecondId: null,
fileSource: '个人', fileSource: '个人',
fileRoot: "备课" fileRoot: '备课'
} }
} }
}, },
@ -147,21 +156,34 @@ export default {
// }) // })
}, },
methods: { methods: {
getFileByCata() { formatFileSize(fileSize) {
getSmarttalkPage({}).then(res=>{ if (fileSize < 1024) {
return fileSize + 'B'
}) } else if (fileSize < (1024 * 1024)) {
var temp = fileSize / 1024
temp = temp.toFixed(2)
return temp + 'KB'
} else if (fileSize < (1024 * 1024 * 1024)) {
var temp = fileSize / (1024 * 1024)
temp = temp.toFixed(2)
return temp + 'MB'
} else {
var temp = fileSize / (1024 * 1024 * 1024)
temp = temp.toFixed(2)
return temp + 'GB'
}
}, },
submitFile(files) { submitFile(files) {
let _this = this;
files.filter(file => { files.filter(file => {
file.fileData = Object.assign(this.uploadData, file.fileData) file.fileData = Object.assign(this.uploadData, file.fileData)
file.callback = function(res) { file.callback = function(res) {
console.log(res) _this.currentFileList.unshift(res.resData);
} }
}) })
console.log(files) console.log(files)
uploaderState().pushFile(files) uploaderState().pushFile(files)
this.fileList = []; this.fileList = []
}, },
callback({ error, filePath }) { callback({ error, filePath }) {
if (error) { if (error) {
@ -171,20 +193,35 @@ export default {
console.log('File copied to:', filePath) console.log('File copied to:', filePath)
}, },
changeBook(data) { changeBook(data) {
console.log(data) this.nodeClick(data)
}, },
nodeClick(data) { nodeClick(data) {
console.log(data) let cata = this.parseCataByNode(data.node)
this.currentNode = data.node; this.currentNode = data.node
this.uploadData.levelFirstId = data.node.id; this.uploadData.levelFirstId = cata.length > 0 ? cata[0] : null
this.uploadData.levelSecondId = cata.length > 1 ? cata[1] : null
this.uploadData.levelThirdId = cata.length > 2 ? cata[2] : null
this.uploadData.textbookId = data.textBook.curBookId this.uploadData.textbookId = data.textBook.curBookId
this.isLoading = true; this.isLoading = true
getSmarttalkPage({...this.uploadData,orderByColumn:'uploadTime',isAsc:'desc',fileSuffix:'mp4'}).then(res=>{ getSmarttalkPage({
...this.uploadData,
orderByColumn: 'uploadTime',
isAsc: 'desc'
}).then(res => {
this.currentFileList = [...res.rows] this.currentFileList = [...res.rows]
this.isLoading = false; this.isLoading = false
}).catch(res => { }).catch(res => {
this.isLoading = false; this.isLoading = false
}) })
},
parseCataByNode(node) {
if (node.parentNode) {
let arr = this.parseCataByNode(node.parentNode)
arr.push(node.id)
return arr
} else {
return [node.id]
}
} }
} }
} }
@ -195,6 +232,7 @@ export default {
min-width: 80px !important; min-width: 80px !important;
padding: 5px !important; padding: 5px !important;
} }
.item-popover-item { .item-popover-item {
padding: 5px 0; padding: 5px 0;
display: flex; display: flex;
@ -202,6 +240,7 @@ export default {
justify-content: center; justify-content: center;
font-size: 12px; font-size: 12px;
cursor: pointer; cursor: pointer;
.iconfont { .iconfont {
margin-right: 5px; margin-right: 5px;
color: #a2a2a2; color: #a2a2a2;
@ -223,6 +262,7 @@ export default {
box-shadow: 0px 0px 20px 0px rgba(99, 99, 99, 0.06); box-shadow: 0px 0px 20px 0px rgba(99, 99, 99, 0.06);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.prepare-body-header { .prepare-body-header {
height: 60px; height: 60px;
width: 100%; width: 100%;
@ -232,34 +272,41 @@ export default {
justify-content: space-between; justify-content: space-between;
padding: 0 20px; padding: 0 20px;
} }
.prepare-body-main { .prepare-body-main {
flex: 1; flex: 1;
width: 100%; width: 100%;
overflow: auto; overflow: auto;
padding: 0 30px; padding: 0 30px;
.prepare-body-main-item { .prepare-body-main-item {
&:hover { &:hover {
background-color: rgba(144, 147, 153, 0.2); background-color: rgba(144, 147, 153, 0.2);
cursor: pointer; cursor: pointer;
} }
display: flex; display: flex;
align-items: center; align-items: center;
border-bottom: 1px solid rgba(131, 131, 127, 0.17); border-bottom: 1px solid rgba(131, 131, 127, 0.17);
padding: 10px 0; padding: 10px 0;
.prepare-body-main-item-icon { .prepare-body-main-item-icon {
width: 80px; width: 80px;
} }
.prepare-body-main-item-tool { .prepare-body-main-item-tool {
font-size: 18px !important; font-size: 18px !important;
font-weight: bold; font-weight: bold;
text-align: right; text-align: right;
padding-right: 30px; padding-right: 30px;
} }
.prepare-body-main-item-info { .prepare-body-main-item-info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-width: 0; min-width: 0;
flex: 1; flex: 1;
.prepare-item-info-title { .prepare-item-info-title {
text-align: left; text-align: left;
font-size: 16px; font-size: 16px;
@ -267,6 +314,7 @@ export default {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.prepare-item-info-message { .prepare-item-info-message {
font-size: 12px; font-size: 12px;
line-height: 23px; line-height: 23px;