lyc-dev #24

Merged
lyc merged 4 commits from lyc-dev into main 2024-07-15 19:42:14 +08:00
8 changed files with 274 additions and 72 deletions
Showing only changes of commit 7a862761f9 - Show all commits

View File

@ -8,8 +8,8 @@ File({ app, shell, BrowserWindow, ipcMain })
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 888,
height: 520,
width: 1050,
height: 650,
show: false,
frame: false,
autoHideMenuBar: true,

View File

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

View File

@ -32,3 +32,27 @@ html,body{
fill: currentColor;
overflow: hidden;
}
::-webkit-scrollbar {
width:5px;
height:5px;
background-color:#F5F5F5;
}
/* 滚动条上的滚动滑块. */
::-webkit-scrollbar-thumb {
background-color: #a3b7cb;
border-radius: 50px;
}
/* 滚动条轨道. */
::-webkit-scrollbar-track {
-webkit-box-shadow:inset 0 0 6px rgba(0, 142, 255, 1);
box-shadow:inset 0 0 6px rgba(0, 142, 255, 1);
background-color:#E7E3DF;
}
/* 滚动条没有滑块的轨道部分 */
::-webkit-scrollbar-track-piece {
background-color: #E7E3DF;
}
/* 当同时有垂直滚动条和水平滚动条时交汇的部分. */
::-webkit-scrollbar-corner {
background:transparent;
}

View File

@ -112,12 +112,7 @@ const hanleFileChange = (file) => {
if (file.status === 'ready') {
// fileData
file.fileData = {
textbookId: '123',
levelFirstId: '123',
levelSecondId: '123',
fileSource: '平台',
fileFlag: 1,
fileRoot: '资源'
fileFlag: 1
}
fileList.value.push(file)
}

View File

@ -119,7 +119,7 @@ export default {
this.uploadDatas = this.uploadNow.fileData
this.getFileMD5(this.uploadNow.raw).then((md5) => {
this.uploadDatas.md5 = md5
this.$refs.talk_uploader_core.handleStart(this.uploadNow.raw)
// this.$refs.talk_uploader_core.handleStart(this.uploadNow.raw)
this.$refs.talk_uploader_core.submit()
})
}

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

@ -1,6 +1,6 @@
<template>
<div class="page-resource flex">
<ChooseTextbook @node-click="nodeClick" />
<div class="page-resource flex" v-loading="isLoading">
<ChooseTextbook @changeBook="changeBook" @node-click="nodeClick" />
<div class="page-right">
<div class="prepare-body-header">
<div>
@ -8,62 +8,84 @@
<el-popover placement="top-start" :width="250" trigger="hover">
<template #default>
<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>
</template>
<template #reference>
<el-button size="small" text
><el-icon><Refresh /></el-icon></el-button
>
<el-icon>
<Refresh />
</el-icon>
云同步
</el-button
>
</template>
</el-popover>
</div>
<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>上传资料</el-button>
</el-upload>
<el-button type="primary" @click="changeFile">新建课件</el-button>
<el-button type="primary" @click="clearFile">crear</el-button>
<el-button @click="isDialogOpen=true">上传资料</el-button>
<el-button type="primary" style="margin-left: 10px">新建课件</el-button>
</div>
</div>
<div class="prepare-body-main">
<div v-for="index in 10" :key="index" class="prepare-body-main-item">
<div v-for="(item,index) in currentFileList" :key="index" class="prepare-body-main-item">
<div class="prepare-body-main-item-icon">
<svg class="icon" aria-hidden="true" font-size="50px" color="red" style="margin: auto">
<use xlink:href="#icon-ppt"></use>
</svg>
</div>
<div class="prepare-body-main-item-info">
<div class="prepare-item-info-title">平面向量基本定理及坐标表示</div>
<div class="prepare-item-info-title">{{ item.fileShowName }}</div>
<div class="prepare-item-info-message">
<div>
<div style="width: 80px">
<el-icon
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>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div>1.6MB</div>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div>2024-07-10</div>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div>古诗词诵读 > 静女</div>
</div>
</div>
<div class="prepare-body-main-item-tool">
<el-popover placement="left-start" popper-class="prepare-popper" trigger="click">
<template #default>
<div style="width: 100%; height: 100px; background-color: #003b94"></div>
<div style="width: 100%;">
<div class="item-popover">
<div class="item-popover-item">
<el-button text>
<i class="iconfont icon-bianji"></i>
<span>编辑</span>
</el-button>
</div>
<div class="item-popover-item">
<el-button text @click="deleteSmarttalk(item.id)">
<i class="iconfont icon-shanchu"></i>
<span>删除</span>
</el-button>
</div>
<div class="item-popover-item">
<el-button text>
<i class="iconfont icon-xiazai"></i>
<span>下载</span>
</el-button>
</div>
</div>
</div>
</template>
<template #reference>
<span class="iconfont icon-shenglvehao" style="cursor: pointer"></span>
@ -73,35 +95,45 @@
</div>
</div>
</div>
<uploadDialog v-model="isDialogOpen" @submitFile="submitFile" />
</div>
</template>
<script setup>
import { Check } from '@element-plus/icons-vue'
import ChooseTextbook from '@/components/choose-textbook/index.vue'
import { deleteSmarttalk } from '@/api/file'
</script>
<script>
import FileUpload from '@/components/file-upload/index.vue'
import ChooseTextbook from '@/components/choose-textbook/index.vue'
import ResoureList from '@/views/resource/container/resoure-list.vue'
import ResoureSearch from '@/views/resource/container/resoure-search.vue'
import uploadDialog from '@/components/upload-dialog/index.vue'
import { Refresh } from '@element-plus/icons-vue'
import uploaderState from '@/store/modules/uploader'
import { getSmarttalkPage } from '@/api/file'
import { toTimeText } from '@/utils/date'
// import { getSmarttalkPage } from '@/api/file'
const { ipcRenderer } = window.electron || {}
export default {
name: 'Prepare',
components: { ResoureSearch, ResoureList, ChooseTextbook, FileUpload, Refresh },
components: { ResoureSearch, ResoureList, ChooseTextbook, FileUpload, Refresh, uploadDialog },
data() {
return {
isLoading: false,
isDialogOpen: false,
fileList: [],
fileUrl:
'https://wzyzoss.eos-chongqing-3.cmecloud.cn/2024/7/10/117cdf208c6b4e58bf2b73369eaf3cb5.pptx',
filePath: 'C:/Users/zhuhao/Desktop/工作文档/0901高一【数学(人教A版)】集合的概念-PPT课件.pptx',
currentNode: {},
currentFileList: [],
// fileUrl:
// 'https://wzyzoss.eos-chongqing-3.cmecloud.cn/2024/7/10/117cdf208c6b4e58bf2b73369eaf3cb5.pptx',
// filePath: 'C:/Users/zhuhao/Desktop//0901(A)-PPT.pptx',
uploadData: {
textbookId: '123',
levelFirstId: '123',
levelSecondId: '123',
fileSource: '平台',
fileFlag: '课件'
textbookId: null,
levelFirstId: 39103,
levelSecondId: null,
fileSource: '个人',
fileRoot: '备课'
}
}
},
@ -112,6 +144,8 @@ export default {
})
},
mounted() {
//
// const destination = '0901(A)-PPT.pptx'
// ipcRenderer.send('open-path-app',this.filePath)
// const source = 'D:\\edufile\\0901(A)-PPT.pptx'
@ -122,6 +156,35 @@ export default {
// })
},
methods: {
formatFileSize(fileSize) {
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) {
let _this = this;
files.filter(file => {
file.fileData = Object.assign(this.uploadData, file.fileData)
file.callback = function(res) {
_this.currentFileList.unshift(res.resData);
}
})
console.log(files)
uploaderState().pushFile(files)
this.fileList = []
},
callback({ error, filePath }) {
if (error) {
console.error('An error occurred:', error)
@ -129,27 +192,36 @@ export default {
}
console.log('File copied to:', filePath)
},
changeBook(data) {
this.nodeClick(data)
},
nodeClick(data) {
console.log(data)
let cata = this.parseCataByNode(data.node)
this.currentNode = data.node
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.isLoading = true
getSmarttalkPage({
...this.uploadData,
orderByColumn: 'uploadTime',
isAsc: 'desc'
}).then(res => {
this.currentFileList = [...res.rows]
this.isLoading = false
}).catch(res => {
this.isLoading = false
})
},
chooseFile(file) {
file.fileData = {
textbookId: '123',
levelFirstId: '123',
levelSecondId: '123',
fileSource: '平台',
fileFlag: '课件'
parseCataByNode(node) {
if (node.parentNode) {
let arr = this.parseCataByNode(node.parentNode)
arr.push(node.id)
return arr
} else {
return [node.id]
}
file.callback = function(res){
console.log(res)
}
},
changeFile() {
uploaderState().pushFile(this.fileList)
this.fileList = [];
},
clearFile() {
this.fileList = [];
}
}
}
@ -160,6 +232,20 @@ export default {
min-width: 80px !important;
padding: 5px !important;
}
.item-popover-item {
padding: 5px 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
cursor: pointer;
.iconfont {
margin-right: 5px;
color: #a2a2a2;
}
}
</style>
<style scoped lang="scss">
.page-resource {
@ -167,6 +253,7 @@ export default {
height: 100%;
.page-right {
min-width: 0;
flex: 1;
margin-left: 20px;
height: 100%;
@ -175,6 +262,7 @@ export default {
box-shadow: 0px 0px 20px 0px rgba(99, 99, 99, 0.06);
display: flex;
flex-direction: column;
.prepare-body-header {
height: 60px;
width: 100%;
@ -184,44 +272,54 @@ export default {
justify-content: space-between;
padding: 0 20px;
}
.prepare-body-main {
flex: 1;
width: 100%;
overflow: auto;
padding: 0 30px;
.prepare-body-main-item {
&:hover {
background-color: rgba(144, 147, 153, 0.2);
cursor: pointer;
}
display: flex;
align-items: center;
border-bottom: 1px solid rgba(131, 131, 127, 0.17);
padding: 10px 0;
.prepare-body-main-item-icon {
width: 80px;
}
.prepare-body-main-item-tool {
font-size: 18px !important;
font-weight: bold;
flex: 1;
text-align: right;
padding-right: 30px;
}
.prepare-body-main-item-info {
display: flex;
flex-direction: column;
min-width: 0;
flex: 1;
.prepare-item-info-title {
text-align: left;
font-size: 16px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.prepare-item-info-message {
font-size: 12px;
line-height: 23px;
color: #909399;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}
}

View File

@ -60,6 +60,7 @@ const getData = (data) => {
height: 100%;
.page-right {
min-width: 0;
flex: 1;
margin-left: 20px;
height: 100%;