Merge branch 'main' into cys
This commit is contained in:
commit
fbd0f9764e
|
@ -5,13 +5,27 @@ import { dialog } from 'electron'
|
|||
const manager = new ElectronDownloadManager()
|
||||
export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
||||
const userDataPath = app.getPath('userData')
|
||||
const appRootFilePath = userDataPath + '\\selfFile\\'
|
||||
ipcMain.on('is-have-local-file', (e, fileNewName) => {
|
||||
let filePath = appRootFilePath + fileNewName
|
||||
fs.access(filePath, fs.constants.F_OK, (err) => {
|
||||
if (err) {
|
||||
e.reply('is-have-local-file-reply'+fileNewName, false)
|
||||
return
|
||||
}
|
||||
e.reply('is-have-local-file-reply'+fileNewName, true)
|
||||
})
|
||||
})
|
||||
//默认浏览器打开url
|
||||
ipcMain.on('open-url-browser', (e, url) => {
|
||||
shell.openPath(url)
|
||||
})
|
||||
//使用默认应用打开本地文件
|
||||
ipcMain.on('open-path-app', (e, path) => {
|
||||
shell.openExternal(path)
|
||||
ipcMain.on('open-path-app', (e, destination) => {
|
||||
let path = appRootFilePath + destination
|
||||
shell.openExternal(path).catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
})
|
||||
|
||||
//复制文件
|
||||
|
@ -21,32 +35,42 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
})
|
||||
})
|
||||
|
||||
//获取应用文件目录
|
||||
ipcMain.on('get-root-file-path', (e) => {
|
||||
e.reply('get-root-file-path-reply', appRootFilePath)
|
||||
})
|
||||
|
||||
//下载文件
|
||||
ipcMain.on('download-file-default', (e, url) => {
|
||||
ipcMain.on('download-file-default', (e, { url, fileName }) => {
|
||||
createFolder('selfFile').then(async () => {
|
||||
const browserWindow = BrowserWindow.fromId(e.sender.id)
|
||||
const id = await manager.download({
|
||||
window: browserWindow,
|
||||
url: url,
|
||||
directory: userDataPath + '/selfFile/',
|
||||
saveAsFilename: fileName,
|
||||
directory: appRootFilePath,
|
||||
callbacks: {
|
||||
onDownloadStarted: async ({ id, item, webContents }) => {
|
||||
// Do something with the download id
|
||||
},
|
||||
onDownloadProgress: async ({ id, item, percentCompleted }) => {
|
||||
browserWindow.webContents.invoke('download-progress', {
|
||||
id,
|
||||
percentCompleted,
|
||||
// Get the number of bytes received so far
|
||||
bytesReceived: item.getReceivedBytes()
|
||||
})
|
||||
},
|
||||
onDownloadCompleted: async ({ id, item }) => {
|
||||
console.log(item)
|
||||
console.log('完成')
|
||||
e.reply('download-file-default'+fileName,true)
|
||||
},
|
||||
onDownloadCancelled: async () => {},
|
||||
onDownloadInterrupted: async () => {},
|
||||
onError: (err, data) => {}
|
||||
onDownloadCancelled: async () => {
|
||||
console.log('取消')
|
||||
e.reply('download-file-default'+fileName,false)
|
||||
},
|
||||
onDownloadInterrupted: async () => {
|
||||
console.log('中断')
|
||||
e.reply('download-file-default'+fileName,false)
|
||||
},
|
||||
onError: (err, data) => {
|
||||
console.log(err.toString())
|
||||
e.reply('download-file-default'+fileName,false)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -59,7 +83,7 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
* @param {String} fileName 文件名称包括后缀名,例如图1.png
|
||||
*/
|
||||
ipcMain.on('save-as', function (event, url, fileName) {
|
||||
let win = BrowserWindow.getFocusedWindow();
|
||||
let win = BrowserWindow.getFocusedWindow()
|
||||
//通过扩展名识别文件类型
|
||||
let filters = [{ name: '全部文件', extensions: ['*'] }]
|
||||
let ext = path.extname(fileName) //获取扩展名
|
||||
|
@ -101,7 +125,7 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
})
|
||||
|
||||
function copyFile(source, destination, callback) {
|
||||
let path = userDataPath + '\\selfFile\\' + destination
|
||||
let path = appRootFilePath + destination
|
||||
createFolder('selfFile').then(() => {
|
||||
const readStream = fs.createReadStream(source)
|
||||
const writeStream = fs.createWriteStream(path)
|
||||
|
|
|
@ -8,8 +8,8 @@ File({ app, shell, BrowserWindow, ipcMain })
|
|||
function createWindow() {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1050,
|
||||
height: 650,
|
||||
width: 888,
|
||||
height: 520,
|
||||
show: false,
|
||||
frame: false,
|
||||
autoHideMenuBar: true,
|
||||
|
@ -107,4 +107,5 @@ ipcMain.on('close-window', () => {
|
|||
ipcMain.on('set-winsize', (e, {x, y})=>{
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
win.setSize(x,y);
|
||||
win.center()
|
||||
})
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { ref } from 'vue'
|
||||
|
||||
const size = ref('default')
|
||||
// const size = computed(() => store.state.app.elementSize)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -16,6 +16,13 @@ export function deleteSmarttalk(id) {
|
|||
})
|
||||
}
|
||||
|
||||
export function deleteSmarttalkBatch(ids) {
|
||||
return request({
|
||||
url: '/smarttalk/file/' + ids,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export const updateSmarttalk = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/file/updateSmarttalk',
|
||||
|
@ -23,3 +30,11 @@ export const updateSmarttalk = (params) => {
|
|||
params
|
||||
})
|
||||
}
|
||||
|
||||
export const moveSmarttalk = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/file/moveSmarttalk',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,3 +8,12 @@ export const listEvaluation = (params)=> {
|
|||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export const addFileToPrepare = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/file/addFileToPrepare',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
|
|
@ -38,3 +38,12 @@ export function getUserProfile() {
|
|||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改用户,这个不涉及到用户的权限、角色更新
|
||||
export function updateUserInfo(data) {
|
||||
return request({
|
||||
url: '/system/user/updateUserInfo',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
|
@ -305,6 +305,7 @@ onMounted(() => {
|
|||
border-bottom: solid #f4f5f7 1px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
border-radius: 10px 10px 0 0;
|
||||
}
|
||||
|
||||
.book-list {
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
<template>
|
||||
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="500"
|
||||
top="25vh"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
style="border-radius: 5px;padding-top: 0;">
|
||||
<div class="dialog-title flex">
|
||||
<span>选择你的年级、学科</span>
|
||||
</div>
|
||||
<div class="dialog-content">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="年级">
|
||||
<el-select v-model="gradeVal" style="width: 120px;" @change="changeGrade">
|
||||
<el-option v-for="item in gradeList" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="学科">
|
||||
<el-select v-model="subjectVal" style="width: 130px;">
|
||||
<el-option v-for="item in subjectList" :key="item.id" :label="item.itemtitle" :value="item.itemtitle" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="editUserInfo">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch, defineProps, defineEmits } from 'vue'
|
||||
import { listEvaluation } from '@/api/subject'
|
||||
import { updateUserInfo } from '@/api/system/user'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const { userId, userName } = userStore.user
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
})
|
||||
|
||||
// 定义要发送的emit事件
|
||||
const emit = defineEmits(['update:modelValue', 'onSuccess'])
|
||||
|
||||
const gradeList = ref([
|
||||
{
|
||||
label: '高中',
|
||||
value: '高中'
|
||||
},
|
||||
{
|
||||
label: '初中',
|
||||
value: '初中'
|
||||
},
|
||||
{
|
||||
label: '小学',
|
||||
value: '小学'
|
||||
},
|
||||
{
|
||||
label: '幼儿园',
|
||||
value: '幼儿园'
|
||||
},
|
||||
]
|
||||
)
|
||||
const subjectVal = ref('')
|
||||
const gradeVal = ref('')
|
||||
// 默认第一项
|
||||
gradeVal.value = gradeList.value[0].value
|
||||
//学科列表数据
|
||||
const subjectList = ref([])
|
||||
const allSubject = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
dialogVisible.value = newVal
|
||||
})
|
||||
|
||||
//切换年级
|
||||
const changeGrade = ()=>{
|
||||
// 切换年级 过滤出对应学科数据
|
||||
subjectList.value = allSubject.value.filter( item => item.edustage == gradeVal.value)
|
||||
if(!subjectList.value.length){
|
||||
subjectVal.value = ''
|
||||
return
|
||||
}
|
||||
// 默认选中第一个学科
|
||||
subjectVal.value = subjectList.value[0].itemtitle
|
||||
}
|
||||
// 获取学科数据
|
||||
|
||||
const getSubject = async ()=>{
|
||||
const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 })
|
||||
// 所有学科
|
||||
allSubject.value = rows;
|
||||
// 根据默认第一个年级(gradeVal) 拿到学科数据
|
||||
subjectList.value = rows.filter( item => item.edustage == gradeVal.value)
|
||||
if(!subjectList.value.length) return
|
||||
// 默认选中第一个学科
|
||||
subjectVal.value = subjectList.value[0].itemtitle
|
||||
}
|
||||
|
||||
// 修改用户年级 学科
|
||||
const editUserInfo = async () =>{
|
||||
const data = {
|
||||
userId,
|
||||
userName,
|
||||
edustage: gradeVal.value,
|
||||
edusubject: subjectVal.value
|
||||
}
|
||||
await updateUserInfo(data)
|
||||
await userStore.getInfo()
|
||||
emit('onSuccess')
|
||||
}
|
||||
|
||||
|
||||
onMounted(getSubject)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dialog-title {
|
||||
justify-content: space-between;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #000;
|
||||
|
||||
.icon-close {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
padding: 30px 20px 10px 30px;
|
||||
}
|
||||
|
||||
.dialog-footer{
|
||||
text-align: center;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
|
@ -16,7 +16,7 @@
|
|||
<div class="file-list-item flex" v-for="(item, index) in fileList" :key="item.uid">
|
||||
<div class="file-name">
|
||||
<span class="name">标题:</span>
|
||||
<FileImage :fileName="item.name" size="50"/>
|
||||
<FileImage :fileName="item.name" :size="50"/>
|
||||
<el-input class="file-input" v-model="item.fileData.name" placeholder="请输入文件名" />
|
||||
<span>.{{ getFileSuffix(item.name) }}</span>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<el-popover placement="left-end" width="300px" title="文件上传" trigger="click">
|
||||
<el-popover placement="left-end" width="300px" title="文件上传" trigger="hover">
|
||||
<template #default>
|
||||
<el-upload
|
||||
ref="talk_uploader_core"
|
||||
|
@ -38,8 +38,6 @@
|
|||
<div class="prepare-item-info-title">{{ item.raw.name }}</div>
|
||||
<div class="prepare-item-info-message">
|
||||
<div>{{ formatFileSize(item.raw.size) }}</div>
|
||||
<!-- | -->
|
||||
<!-- <div>古诗词诵读 > 静女</div>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="prepare-body-main-item-tool" @click="removeUploadFile(item.uid)">
|
||||
|
@ -63,19 +61,14 @@ import uploaderState from '@/store/modules/uploader'
|
|||
import { getToken } from '@/utils/auth'
|
||||
import CryptoJS from 'crypto-js'
|
||||
import { DeleteFilled } from '@element-plus/icons-vue'
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
export default {
|
||||
name: 'Uploader',
|
||||
components: { DeleteFilled },
|
||||
data() {
|
||||
return {
|
||||
timer: null,
|
||||
uploadDatas: {
|
||||
textbookId: '123',
|
||||
levelFirstId: '123',
|
||||
levelSecondId: '123',
|
||||
fileSource: '平台',
|
||||
fileFlag: '课件'
|
||||
},
|
||||
uploadDatas: {},
|
||||
uploadUrl: import.meta.env.VITE_APP_BASE_API + '/smarttalk/file/upload',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + getToken()
|
||||
|
@ -98,6 +91,12 @@ export default {
|
|||
this.runNowJob()
|
||||
}, 1000)
|
||||
},
|
||||
mounted() {
|
||||
ipcRenderer.send('get-root-file-path')
|
||||
ipcRenderer.once('get-root-file-path-reply', (e, path) => {
|
||||
window.rootTalkFilePath = path
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
formatFileSize(fileSize) {
|
||||
if (fileSize < 1024) {
|
||||
|
@ -118,6 +117,10 @@ export default {
|
|||
},
|
||||
onSuccess(res, file, files) {
|
||||
this.removeUploadFile(file.uid)
|
||||
ipcRenderer.send('copy-file-default', {
|
||||
source: file.raw.path,
|
||||
destination: res.resData.fileNewName
|
||||
})
|
||||
file.callback(res)
|
||||
},
|
||||
beforeUpload(file) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<el-main>
|
||||
<AppMain />
|
||||
</el-main>
|
||||
<Uploader/>
|
||||
<Uploader v-if="uploaderStore.uploadList && uploaderStore.uploadList.length > 0" />
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
|
@ -14,6 +14,12 @@
|
|||
import Header from './components/Header.vue'
|
||||
import AppMain from './components/AppMain.vue'
|
||||
import Uploader from './components/Uploader.vue'
|
||||
import uploaderState from '@/store/modules/uploader'
|
||||
import { ref } from 'vue'
|
||||
let uploaderStore = ref(uploaderState())
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
ipcRenderer ? ipcRenderer .send('set-winsize', { x: 1200, y: 700 }) : ''
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -12,7 +12,7 @@ export const constantRoutes = [
|
|||
{
|
||||
path: '/',
|
||||
component: Layout,
|
||||
redirect: '/resource',
|
||||
redirect: '/login',
|
||||
children: [
|
||||
{
|
||||
path: '/resource',
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
const { ipcRenderer } = window.electron || {}
|
||||
|
||||
export const isHaveLocalFile = async (fileNewName)=>{
|
||||
return new Promise((resolve, reject)=>{
|
||||
ipcRenderer.send('is-have-local-file', fileNewName);
|
||||
ipcRenderer.once('is-have-local-file-reply'+fileNewName,(e, isHave)=>{
|
||||
resolve(isHave);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const parseCataByNode = (node) => {
|
||||
if (node.parentNode) {
|
||||
let arr = parseCataByNode(node.parentNode)
|
||||
arr.push(node.id)
|
||||
return arr
|
||||
} else {
|
||||
return [node.id]
|
||||
}
|
||||
}
|
|
@ -33,6 +33,8 @@
|
|||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<!--选择学科-->
|
||||
<SelectSubject v-model="isSubject" v-if="isSubject" class="select-subject" @onSuccess="successEditSubject" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
|
@ -42,13 +44,15 @@ import Cookies from 'js-cookie'
|
|||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import leftBg2 from '@/assets/images/login/left-bg2.png'
|
||||
import SelectSubject from '@/components/select-subject/index.vue'
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const formRef = ref()
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const isMaxSize = ref(false)
|
||||
const btnLoading = ref(false)
|
||||
const isSubject = ref(false)
|
||||
//表单
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
|
@ -61,6 +65,8 @@ const rules = reactive({
|
|||
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }]
|
||||
})
|
||||
|
||||
ipcRenderer ? ipcRenderer.send('set-winsize', { x: 888, y: 520 }) : ''
|
||||
|
||||
//登录
|
||||
const submitForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
|
@ -81,8 +87,14 @@ const submitForm = async (formEl) => {
|
|||
try{
|
||||
await userStore.login(loginForm)
|
||||
await userStore.getInfo()
|
||||
if(userStore.user.edustage || userStore.user.edusubject){
|
||||
ElMessage.success('登录成功')
|
||||
router.push('/resource')
|
||||
}
|
||||
else{
|
||||
isSubject.value = true
|
||||
}
|
||||
|
||||
|
||||
}finally{
|
||||
btnLoading.value = false
|
||||
|
@ -91,6 +103,12 @@ const submitForm = async (formEl) => {
|
|||
})
|
||||
}
|
||||
|
||||
const successEditSubject = ()=>{
|
||||
isSubject.value = false
|
||||
ElMessage.success('登录成功')
|
||||
router.push('/resource')
|
||||
}
|
||||
|
||||
const getCookie = () => {
|
||||
const username = Cookies.get('username')
|
||||
const password = Cookies.get('password')
|
||||
|
@ -101,7 +119,6 @@ const getCookie = () => {
|
|||
}
|
||||
|
||||
onMounted(()=>{
|
||||
// ipcRenderer.send('set-winsize',{x:888,y: 520})
|
||||
getCookie()
|
||||
})
|
||||
// 最小化
|
||||
|
@ -206,4 +223,7 @@ const closeWindow = () => {
|
|||
.el-form-item {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.select-subject{
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
<template>
|
||||
<div class="prepare-body-main-item">
|
||||
<div class="prepare-body-main-item-icon">
|
||||
<slot name="default"></slot>
|
||||
<FileImage :size="50" :file-name="item.fileShowName" @click="openFileWin(item)" />
|
||||
</div>
|
||||
<div class="prepare-body-main-item-info">
|
||||
<div class="prepare-item-info-title" :title="item.fileShowName">
|
||||
{{ item.fileShowName }}
|
||||
</div>
|
||||
<div class="prepare-item-info-message" @click="openFileWin(item)">
|
||||
<div style="width: 60px">
|
||||
<el-icon
|
||||
v-loading="item.async === 'on'"
|
||||
style="background-color: green; border-radius: 20px; color: white; top: 2px"
|
||||
>
|
||||
<Check v-if="item.async === true" />
|
||||
<UploadFilled v-if="!item.async" />
|
||||
</el-icon>
|
||||
{{ item.async === true ? '已同步' : '' }}
|
||||
{{ !item.async ? '待同步' : '' }}
|
||||
{{ item.async === 'on' ? '同步中' : '' }}
|
||||
</div>
|
||||
|
|
||||
<div style="width: 70px">{{ formatFileSize(item.fileSize) }}</div>
|
||||
|
|
||||
<div style="width: 70px">{{ toTimeText(item.uploadTime, true) }}</div>
|
||||
|
|
||||
<div
|
||||
style="
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
"
|
||||
:title="
|
||||
item.levelFirstName +
|
||||
(item.levelSecondName ? ' > ' + item.levelSecondName : '') +
|
||||
(item.levelThirdNmae ? ' > ' + item.levelThirdNmae : '')
|
||||
"
|
||||
>
|
||||
{{
|
||||
item.levelFirstName +
|
||||
(item.levelSecondName ? ' > ' + item.levelSecondName : '') +
|
||||
(item.levelThirdNmae ? ' > ' + item.levelThirdNmae : '')
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="prepare-body-main-item-tool">
|
||||
<el-popover
|
||||
:ref="'popover_' + index"
|
||||
placement="left-start"
|
||||
:hide-after="100"
|
||||
popper-class="prepare-popper"
|
||||
trigger="click"
|
||||
>
|
||||
<template #default>
|
||||
<div style="width: 100%">
|
||||
<div class="item-popover" @click="closePopver(index)">
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="editTalk(item, index)">
|
||||
<i class="iconfont icon-bianji"></i>
|
||||
<span>重命名</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="deleteTalk(item)">
|
||||
<i class="iconfont icon-shanchu"></i>
|
||||
<span>删除</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="downloadFile(item)">
|
||||
<i class="iconfont icon-xiazai"></i>
|
||||
<span>下载</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="moveSmarttalkFun(item)">
|
||||
<el-icon>
|
||||
<Switch />
|
||||
</el-icon>
|
||||
<span>移动</span>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #reference>
|
||||
<span class="iconfont icon-shenglvehao" style="cursor: pointer" @click.stop></span>
|
||||
</template>
|
||||
</el-popover>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Check, UploadFilled, Switch } from '@element-plus/icons-vue'
|
||||
</script>
|
||||
<script>
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
import { isHaveLocalFile } from '@/utils/talkFile'
|
||||
import { toTimeText } from '@/utils/date'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { deleteSmarttalk, updateSmarttalk } from '@/api/file'
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
export default {
|
||||
name: 'FileListItem',
|
||||
components: { FileImage },
|
||||
props: {
|
||||
item: {
|
||||
type: Object,
|
||||
default: function() {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: function() {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
},
|
||||
emits: { 'on-move': null, 'on-delete': null },
|
||||
methods: {
|
||||
editTalk(item) {
|
||||
ElMessageBox.prompt('请输入新的名称', '重命名', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
inputValue: item.fileShowName.substring(0, item.fileShowName.lastIndexOf('.'))
|
||||
})
|
||||
.then(({ value }) => {
|
||||
item.fileShowName = value + '.' + item.fileSuffix
|
||||
updateSmarttalk({ id: item.id, fileShowName: item.fileShowName }).then((res) => {
|
||||
if (res.data === true) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: `修改成功!`
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
},
|
||||
downloadFile(item) {
|
||||
ipcRenderer.send('save-as', item.fileFullPath, item.fileShowName)
|
||||
},
|
||||
deleteTalk(item) {
|
||||
deleteSmarttalk(item.id).then((res) => {
|
||||
if (res.data === true) {
|
||||
this.$emit('on-delete', item)
|
||||
}
|
||||
})
|
||||
},
|
||||
closePopver(index) {
|
||||
console.log(this.$refs['popover_' + index])
|
||||
this.$refs['popover_' + index].hide()
|
||||
},
|
||||
moveSmarttalkFun(item) {
|
||||
this.$emit('on-move', item)
|
||||
},
|
||||
formatFileSize(fileSize) {
|
||||
if (fileSize < 1024) {
|
||||
return fileSize + 'B'
|
||||
} else if (fileSize < 1024 * 1024) {
|
||||
let temp = fileSize / 1024
|
||||
temp = temp.toFixed(2)
|
||||
return temp + 'KB'
|
||||
} else if (fileSize < 1024 * 1024 * 1024) {
|
||||
let temp = fileSize / (1024 * 1024)
|
||||
temp = temp.toFixed(2)
|
||||
return temp + 'MB'
|
||||
} else {
|
||||
let temp = fileSize / (1024 * 1024 * 1024)
|
||||
temp = temp.toFixed(2)
|
||||
return temp + 'GB'
|
||||
}
|
||||
},
|
||||
openFileWin(item) {
|
||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
||||
if (res === true) {
|
||||
ipcRenderer.send('open-path-app', item.fileNewName)
|
||||
} else {
|
||||
item.async = 'on'
|
||||
ipcRenderer.once('download-file-default' + item.fileNewName, (e, isSuccess) => {
|
||||
item.async = isSuccess
|
||||
})
|
||||
ipcRenderer.send('download-file-default', {
|
||||
url: item.fileFullPath,
|
||||
fileName: item.fileNewName
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.prepare-item-info-message {
|
||||
.circular {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style scoped lang="scss">
|
||||
.prepare-body-main-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid rgba(131, 131, 127, 0.17);
|
||||
padding: 10px 0;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(144, 147, 153, 0.2);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prepare-body-main-item-icon {
|
||||
width: 80px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.prepare-body-main-item-tool {
|
||||
font-size: 18px !important;
|
||||
font-weight: bold;
|
||||
width: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.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;
|
||||
|
||||
.circular {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,81 @@
|
|||
<template>
|
||||
<div class="file-oper-batch-wrap">
|
||||
<div style="margin: 0 20px; line-height: 40px">
|
||||
<el-checkbox
|
||||
v-model="isCheckAll"
|
||||
:indeterminate="indeterminate"
|
||||
@change="handleCheckAllChange"
|
||||
/> 已选{{ choose.length }}个
|
||||
</div>
|
||||
<el-button>导出</el-button>
|
||||
<el-button @click="moveFile">移动</el-button>
|
||||
<el-button @click="deleteFile">删除</el-button> |
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { deleteSmarttalkBatch } from '@/api/file'
|
||||
|
||||
export default {
|
||||
name: 'FileOperBatch',
|
||||
props: {
|
||||
indeterminate: {
|
||||
type: Boolean,
|
||||
default: function () {
|
||||
return false
|
||||
}
|
||||
},
|
||||
checkAll: {
|
||||
type: Boolean,
|
||||
default: function () {
|
||||
return false
|
||||
}
|
||||
},
|
||||
choose: {
|
||||
type: Array,
|
||||
default: function () {
|
||||
return []
|
||||
}
|
||||
}
|
||||
},
|
||||
emits: { 'click-choose': null, cancel: null, 'click-delete': null, 'click-move': null },
|
||||
computed: {
|
||||
isCheckAll: {
|
||||
get() {
|
||||
return this.checkAll
|
||||
},
|
||||
set() {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleCheckAllChange(value) {
|
||||
this.$emit('click-choose', value)
|
||||
},
|
||||
cancel() {
|
||||
this.$emit('cancel')
|
||||
},
|
||||
deleteFile() {
|
||||
let ids = this.choose.map((item) => item.id)
|
||||
deleteSmarttalkBatch(ids).then((res) => {
|
||||
this.$emit('click-delete', res, ids)
|
||||
})
|
||||
},
|
||||
moveFile() {
|
||||
this.$emit('click-move')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.file-oper-batch-wrap {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
background-color: white;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
z-index: 9;
|
||||
box-shadow: 0 -2px 10px #aaa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
|
@ -1,27 +1,30 @@
|
|||
<template>
|
||||
<div class="page-resource flex" v-loading="isLoading">
|
||||
<ChooseTextbook @changeBook="changeBook" @node-click="nodeClick" />
|
||||
<div v-loading="isLoading" class="page-resource flex">
|
||||
<ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" />
|
||||
<div class="page-right">
|
||||
<div class="prepare-body-header">
|
||||
<div>
|
||||
<label style="font-size: 15px">共52个文件</label>
|
||||
<label style="font-size: 15px">共{{ currentFileList.length }}个文件</label>
|
||||
<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
|
||||
v-if="lastAsyncAllTime"
|
||||
type="success"
|
||||
size="small"
|
||||
:icon="Check"
|
||||
circle
|
||||
/>
|
||||
{{ lastAsyncAllTime ? toTimeText(lastAsyncAllTime) + '同步成功' : '' }}
|
||||
</div>
|
||||
</template>
|
||||
<template #reference>
|
||||
<el-button size="small" text
|
||||
>
|
||||
<el-icon>
|
||||
<el-button size="small" text @click="asyncAllFile">
|
||||
<el-icon v-loading="asyncAllFileVisiable">
|
||||
<Refresh />
|
||||
</el-icon>
|
||||
云同步
|
||||
</el-button
|
||||
>
|
||||
{{ asyncAllFileVisiable ? '同步中' : '云同步' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popover>
|
||||
</div>
|
||||
|
@ -30,106 +33,69 @@
|
|||
<el-button type="primary" style="margin-left: 10px">新建课件</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="prepare-body-main">
|
||||
<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">{{ item.fileShowName }}</div>
|
||||
<div class="prepare-item-info-message">
|
||||
<div style="width: 80px">
|
||||
<el-icon
|
||||
style="background-color: green; border-radius: 20px; color: white; top: 2px"
|
||||
<el-checkbox-group
|
||||
v-model="checkFileList"
|
||||
class="prepare-body-main"
|
||||
:style="{ 'margin-bottom': checkFileList.length > 0 ? '40px' : '0' }"
|
||||
>
|
||||
<Check />
|
||||
</el-icon
|
||||
<file-list-item
|
||||
v-for="(item, index) in currentFileList"
|
||||
:key="index"
|
||||
:item="item"
|
||||
:index="index"
|
||||
@on-move="onMoveSingleFile"
|
||||
@on-delete="deleteTalk"
|
||||
>
|
||||
已同步
|
||||
<el-checkbox label="" :value="item" />
|
||||
</file-list-item>
|
||||
</el-checkbox-group>
|
||||
<file-oper-batch
|
||||
v-show="checkFileList.length > 0"
|
||||
:indeterminate="checkFileList.length > 0 && checkFileList.length < currentFileList.length"
|
||||
:choose="checkFileList"
|
||||
:check-all="isCheckAll"
|
||||
@click-delete="clickDelete"
|
||||
@click-move="clickMove"
|
||||
@cancel="checkFileList = []"
|
||||
@click-choose="clickChoose"
|
||||
></file-oper-batch>
|
||||
</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>
|
||||
</div>
|
||||
<div class="prepare-body-main-item-tool">
|
||||
<el-popover placement="left-start" :hide-after="100" :ref="'popover_'+index" popper-class="prepare-popper" trigger="click">
|
||||
<template #default>
|
||||
<div style="width: 100%;">
|
||||
<div class="item-popover">
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="editTalk(item,index)">
|
||||
<i class="iconfont icon-bianji"></i>
|
||||
<span>重命名</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="deleteTalk(item);closePopver(index)">
|
||||
<i class="iconfont icon-shanchu"></i>
|
||||
<span>删除</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="downloadFile(item)">
|
||||
<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>
|
||||
</template>
|
||||
</el-popover>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<uploadDialog v-model="isDialogOpen" @submitFile="submitFile" />
|
||||
<MoveFile v-model="isMoveDialogOpen" @on-submit="chooseMoveCata" />
|
||||
<uploadDialog v-model="isDialogOpen" @submit-file="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 { deleteSmarttalk, getSmarttalkPage, updateSmarttalk } from '@/api/file'
|
||||
import MoveFile from '@/components/move-file/index.vue'
|
||||
import FileListItem from '@/views/prepare/container/file-list-item.vue'
|
||||
import { getSmarttalkPage, moveSmarttalk } from '@/api/file'
|
||||
import { toTimeText } from '@/utils/date'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
// import { getSmarttalkPage } from '@/api/file'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { isHaveLocalFile, parseCataByNode } from '@/utils/talkFile'
|
||||
import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue'
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
export default {
|
||||
name: 'Prepare',
|
||||
components: { ResoureSearch, ResoureList, ChooseTextbook, FileUpload, Refresh, uploadDialog },
|
||||
components: { ChooseTextbook, Refresh, uploadDialog, FileListItem, FileOperBatch, MoveFile },
|
||||
data() {
|
||||
return {
|
||||
moveFile: [],
|
||||
isMoveDialogOpen: false,
|
||||
checkFileList: [],
|
||||
asyncAllFileVisiable: false,
|
||||
isLoading: false,
|
||||
isDialogOpen: false,
|
||||
showToolVisible: false,
|
||||
fileList: [],
|
||||
currentNode: {},
|
||||
currentFileList: [],
|
||||
// fileUrl:
|
||||
// 'https://wzyzoss.eos-chongqing-3.cmecloud.cn/2024/7/10/117cdf208c6b4e58bf2b73369eaf3cb5.pptx',
|
||||
// filePath: 'C:/Users/zhuhao/Desktop/工作文档/0901高一【数学(人教A版)】集合的概念-PPT课件.pptx',
|
||||
lastAsyncAllTime: '',
|
||||
uploadData: {
|
||||
textbookId: null,
|
||||
levelFirstId: 39103,
|
||||
|
@ -139,15 +105,21 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isCheckAll() {
|
||||
return (
|
||||
this.checkFileList.length > 0 && this.checkFileList.length === this.currentFileList.length
|
||||
)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
ipcRenderer.removeAllListeners('copy-file-default-reply')
|
||||
ipcRenderer.on('copy-file-default-reply', (e, param) => {
|
||||
this.callback(param)
|
||||
})
|
||||
this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime')
|
||||
},
|
||||
mounted() {
|
||||
//查询所有选中目录下的所有文件
|
||||
|
||||
// const destination = '0901高一【数学(人教A版)】集合的概念-PPT课件.pptx'
|
||||
// ipcRenderer.send('open-path-app',this.filePath)
|
||||
// const source = 'D:\\edufile\\0901高一【数学(人教A版)】集合的概念-PPT课件.pptx'
|
||||
|
@ -156,66 +128,115 @@ export default {
|
|||
// getSmarttalkPage({nowPage:1,pageSize:2}).then(res=>{
|
||||
// console.log(res)
|
||||
// })
|
||||
// let filePath = window.rootTalkFilePath + item.fileNewName
|
||||
},
|
||||
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'
|
||||
}
|
||||
onMoveSingleFile(item) {
|
||||
this.moveFile = [item]
|
||||
this.isMoveDialogOpen = true
|
||||
},
|
||||
editTalk(item) {
|
||||
ElMessageBox.prompt('请输入新的名称', '重命名', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
inputValue: item.fileShowName.substring(0,item.fileShowName.lastIndexOf('.')),
|
||||
})
|
||||
.then(({ value }) => {
|
||||
item.fileShowName = value;
|
||||
updateSmarttalk({id:item.id,fileShowName:item.fileShowName}).then(res=>{
|
||||
clickMove() {
|
||||
this.moveFile = this.checkFileList
|
||||
this.isMoveDialogOpen = true
|
||||
},
|
||||
clickDelete(res, ids) {
|
||||
if (res.data === true) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: `修改成功!`,
|
||||
ids.filter((id) => {
|
||||
let index = this.currentFileList.findIndex(item=>{
|
||||
return item.id === id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
},
|
||||
downloadFile(item) {
|
||||
ipcRenderer.send('save-as',item.fileFullPath,item.fileShowName)
|
||||
},
|
||||
deleteTalk(item) {
|
||||
deleteSmarttalk(item.id).then(res=>{
|
||||
let index = this.currentFileList.indexOf(item);
|
||||
this.currentFileList.splice(index, 1)
|
||||
})
|
||||
this.checkFileList = []
|
||||
}
|
||||
},
|
||||
closePopver(index){
|
||||
this.$refs['popover_'+index][0].hide();
|
||||
clickChoose(value) {
|
||||
this.checkFileList = value ? this.currentFileList : []
|
||||
},
|
||||
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);
|
||||
async asyncAllFile() {
|
||||
this.lastAsyncAllTime = new Date()
|
||||
localStorage.setItem('lastAsyncAllTime', this.lastAsyncAllTime)
|
||||
this.asyncAllFileVisiable = true
|
||||
const test = (item) => {
|
||||
return new Promise((resolve) => {
|
||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
||||
item.async = res
|
||||
if (res === false) {
|
||||
ipcRenderer.send('download-file-default', {
|
||||
url: item.fileFullPath,
|
||||
fileName: item.fileNewName
|
||||
})
|
||||
item.async = 'on'
|
||||
ipcRenderer.once('download-file-default' + item.fileNewName, (e, isSuccess) => {
|
||||
item.async = isSuccess
|
||||
resolve()
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
for (let i = 0; i < this.currentFileList.length; i++) {
|
||||
await test(this.currentFileList[i])
|
||||
}
|
||||
this.asyncAllFileVisiable = false
|
||||
},
|
||||
deleteTalk(item) {
|
||||
let index = this.currentFileList.indexOf(item)
|
||||
this.currentFileList.splice(index, 1)
|
||||
},
|
||||
chooseMoveCata(cataData) {
|
||||
let ids = this.moveFile.map((item) => item.id)
|
||||
let params = {
|
||||
id: ids.join(),
|
||||
textbookId: cataData.textBook.curBookId
|
||||
}
|
||||
let cata = parseCataByNode(cataData.node)
|
||||
if (
|
||||
this.uploadData.levelFirstId == cata[0] &&
|
||||
this.uploadData.levelSecondId == cata[1] &&
|
||||
this.uploadData.levelThirdId == cata[2]
|
||||
) {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: `不能移动到现在的章节!`
|
||||
})
|
||||
return
|
||||
}
|
||||
params.levelFirstId = cata[0]
|
||||
params.levelSecondId = cata[1]
|
||||
params.levelThirdId = cata[2]
|
||||
moveSmarttalk(params).then((res) => {
|
||||
if (res.data === true) {
|
||||
ids.filter((id) => {
|
||||
let index = this.currentFileList.findIndex((item)=>{
|
||||
return item.id === id
|
||||
})
|
||||
this.currentFileList.splice(index, 1)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
submitFile(files) {
|
||||
let _this = this
|
||||
files.filter((file) => {
|
||||
file.fileData = Object.assign(JSON.parse(JSON.stringify(this.uploadData)), file.fileData)
|
||||
file.callback = function (res) {
|
||||
if (
|
||||
res.resData.levelFirstId == _this.uploadData.levelFirstId &&
|
||||
res.resData.levelSecondId == _this.uploadData.levelSecondId &&
|
||||
res.resData.levelThirdId == _this.uploadData.levelThirdId
|
||||
) {
|
||||
res.resData.async = true
|
||||
_this.currentFileList.unshift(res.resData)
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: `${res.resData.fileShowName}上传成功!`
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(files)
|
||||
uploaderState().pushFile(files)
|
||||
this.fileList = []
|
||||
},
|
||||
|
@ -226,36 +247,35 @@ export default {
|
|||
}
|
||||
console.log('File copied to:', filePath)
|
||||
},
|
||||
changeBook(data) {
|
||||
this.nodeClick(data)
|
||||
},
|
||||
nodeClick(data) {
|
||||
let cata = this.parseCataByNode(data.node)
|
||||
if (this.currentNode.id === data.node.id) return
|
||||
this.checkFileList = []
|
||||
let cata = 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.levelFirstId = cata[0]
|
||||
this.uploadData.levelSecondId = cata[1]
|
||||
this.uploadData.levelThirdId = cata[2]
|
||||
this.uploadData.textbookId = data.textBook.curBookId
|
||||
this.isLoading = true
|
||||
getSmarttalkPage({
|
||||
...this.uploadData,
|
||||
orderByColumn: 'uploadTime',
|
||||
isAsc: 'desc'
|
||||
}).then(res => {
|
||||
isAsc: 'desc',
|
||||
pageSize: 500
|
||||
})
|
||||
.then((res) => {
|
||||
this.currentFileList = [...res.rows]
|
||||
this.isLoading = false
|
||||
}).catch(res => {
|
||||
this.currentFileList.filter((item) => {
|
||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
||||
item.async = res
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch((res) => {
|
||||
console.log(res)
|
||||
this.isLoading = false
|
||||
})
|
||||
},
|
||||
parseCataByNode(node) {
|
||||
if (node.parentNode) {
|
||||
let arr = this.parseCataByNode(node.parentNode)
|
||||
arr.push(node.id)
|
||||
return arr
|
||||
} else {
|
||||
return [node.id]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,13 +300,21 @@ export default {
|
|||
color: #a2a2a2;
|
||||
}
|
||||
}
|
||||
|
||||
.prepare-body-header {
|
||||
.circular {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style scoped lang="scss">
|
||||
.page-resource {
|
||||
user-select: none;
|
||||
padding-top: 20px;
|
||||
height: 100%;
|
||||
|
||||
.page-right {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
margin-left: 20px;
|
||||
|
@ -312,51 +340,7 @@ export default {
|
|||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
line-height: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
<el-scrollbar height="400px">
|
||||
<el-empty description="暂无数据" v-if="!sourceStore.result.list.length" />
|
||||
<ul>
|
||||
<li class="list-item" v-for="item in sourceStore.result.list" :key="item.id">
|
||||
<li class="list-item" v-for="item in sourceStore.result.list" :key="item.id" @click="handleRow">
|
||||
<div class="item-left flex">
|
||||
<FileImage :fileName="item.fileName" :size="50" />
|
||||
<FileImage :fileName="item.fileShowName" :size="50" />
|
||||
<div class="flex item-left-content">
|
||||
<div class="name flex">{{ item.fileShowName }}</div>
|
||||
<div class="item-tags flex">
|
||||
<el-tag type="info" class="mr-10">{{ item.fileFlag }}</el-tag>
|
||||
<el-tag type="info" class="mr-10">{{ getFileSuffix(item.fileName) }}</el-tag>
|
||||
<el-tag type="info" class="mr-10">{{ getFileSuffix(item.fileShowName) }}</el-tag>
|
||||
<span class="gray-text mr-10">{{ item.uploadTime }}上传</span>
|
||||
<!-- <span class="line mr-10"></span>
|
||||
<span class="gray-text mr-10">下载3次</span> -->
|
||||
|
@ -37,15 +37,11 @@
|
|||
<i class="iconfont icon-xiazai"></i>
|
||||
<span>下载</span>
|
||||
</div>
|
||||
<div class="item-popover-item" @click="moveFile(item)">
|
||||
<i class="iconfont icon-xiazai"></i>
|
||||
<span>移动至</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
</el-popover>
|
||||
|
||||
<el-button size="small" plain round type="primary">
|
||||
<el-button size="small" plain round type="primary" @click="addLesson(item)">
|
||||
<i class="iconfont icon-jiahao"></i>
|
||||
备课</el-button>
|
||||
</div>
|
||||
|
@ -63,23 +59,32 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { toRaw } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
import { deleteSmarttalk, updateSmarttalk } from '@/api/file'
|
||||
import { addFileToPrepare } from '@/api/subject'
|
||||
import { getFileSuffix } from '@/utils/ruoyi'
|
||||
import useResoureStore from '../store'
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const sourceStore = useResoureStore()
|
||||
const handleSizeChange = () => { }
|
||||
const handleCurrentChange = () => { }
|
||||
|
||||
// 分页change
|
||||
const handleSizeChange = (limit) => {
|
||||
sourceStore.query.pageSize = limit
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
const handleCurrentChange = (page) => {
|
||||
sourceStore.query.pageNum = page
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
|
||||
// 下载文件
|
||||
const downloadFile = (item) => {
|
||||
ipcRenderer.send('save-as', item.fileFullPath, item.fileShowName)
|
||||
}
|
||||
|
||||
// 编辑行
|
||||
const editRow = (item) => {
|
||||
console.log(item.fileShowName.substring(0, item.fileShowName.lastIndexOf('.')))
|
||||
ElMessageBox.prompt('请输入新的名称', '重命名', {
|
||||
|
@ -114,11 +119,35 @@ const delRow = (item) => {
|
|||
}
|
||||
}
|
||||
|
||||
// 移动
|
||||
const moveFile = (item) => {
|
||||
moveDialogVisible.value = true
|
||||
// 加入备课
|
||||
const addLesson = ({ id }) => {
|
||||
let data = {
|
||||
id,
|
||||
fileRoot: '备课',
|
||||
...(toRaw(sourceStore.nodeData)),
|
||||
}
|
||||
// 过滤空值
|
||||
for (let key in data) {
|
||||
if (!data[key]) {
|
||||
delete data[key]
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
sourceStore.loading = true
|
||||
addFileToPrepare(data).then(() => {
|
||||
ElMessage.success('操作成功')
|
||||
})
|
||||
}
|
||||
finally {
|
||||
sourceStore.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
const handleRow = () =>{
|
||||
ElMessage.warning('请先加入备课,在备课里面进行预览!')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
}}</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12" class="search-box flex">
|
||||
<el-input v-model="sourceStore.searchKey" style="width: 240px" placeholder="请输入关键词" />
|
||||
<el-input v-model="sourceStore.query.fileName" @input="sourceStore.changeName" style="width: 240px" placeholder="请输入关键词" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="resoure-btns">
|
||||
<el-col :span="24" class="query-row flex">
|
||||
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix"
|
||||
style="width: 100px">
|
||||
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix"
|
||||
style="width: 110px">
|
||||
<el-option v-for="item in sourceStore.resourceFormatList" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
|
@ -36,7 +36,6 @@
|
|||
import useResoureStore from '../store'
|
||||
|
||||
const sourceStore = useResoureStore()
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.resoure-search {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="page-resource flex">
|
||||
<!--左侧 教材 目录-->
|
||||
<ChooseTextbook @changeBook="changeBook" @nodeClick="nodeClick" />
|
||||
<ChooseTextbook @changeBook="getData" @nodeClick="getData" />
|
||||
|
||||
<div class="page-right">
|
||||
<!-- 搜索 -->
|
||||
|
@ -16,7 +16,6 @@
|
|||
</div>
|
||||
<!-- 上传弹窗 -->
|
||||
<uploadDialog v-model="isDialogOpen" @submitFile="submitFile" />
|
||||
<!-- <MoveFile v-model="isDialogOpen" @onSubmit="onSubmit" /> -->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
@ -26,43 +25,35 @@ import ChooseTextbook from '@/components/choose-textbook/index.vue'
|
|||
import ResoureSearch from './container/resoure-search.vue'
|
||||
import ResoureList from './container/resoure-list.vue'
|
||||
import uploadDialog from '@/components/upload-dialog/index.vue'
|
||||
import MoveFile from '@/components/move-file/index.vue'
|
||||
import uploaderState from '@/store/modules/uploader'
|
||||
|
||||
const sourceStore = useResoureStore()
|
||||
const isDialogOpen = ref(false)
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
// ipcRenderer.send('set-winsize',{x:1100,y: 700})
|
||||
|
||||
|
||||
const openDialog = () => {
|
||||
isDialogOpen.value = true
|
||||
}
|
||||
|
||||
const onSubmit = (data)=>{
|
||||
console.log(data)
|
||||
}
|
||||
|
||||
// 切换教材
|
||||
const changeBook = (data) => {
|
||||
getData(data)
|
||||
}
|
||||
// 节点点击
|
||||
const nodeClick = (data) => {
|
||||
getData(data)
|
||||
}
|
||||
|
||||
// 查询
|
||||
const getData = (data) => {
|
||||
const { textBook, node } = data
|
||||
let textBookId = textBook.curBookId
|
||||
let levelFirstId = node.id
|
||||
let levelSecondId = node.parentNode ? node.parentNode.id : ''
|
||||
sourceStore.query = {
|
||||
textBookId,
|
||||
let textbookId = textBook.curBookId
|
||||
let levelSecondId = node.id
|
||||
let levelFirstId
|
||||
if(node.parentNode){
|
||||
levelFirstId = node.parentNode.id
|
||||
}
|
||||
else{
|
||||
levelFirstId = node.id
|
||||
levelSecondId = ''
|
||||
}
|
||||
sourceStore.query.levelFirstId = levelFirstId
|
||||
sourceStore.query.levelSecondId = levelSecondId
|
||||
sourceStore.query.textbookId = textbookId
|
||||
sourceStore.nodeData = {
|
||||
textbookId,
|
||||
levelFirstId,
|
||||
levelSecondId,
|
||||
...sourceStore.query
|
||||
}
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
|
@ -70,9 +61,9 @@ const getData = (data) => {
|
|||
// 提交文件
|
||||
const submitFile = (data) => {
|
||||
let fileList = toRaw(data)
|
||||
const { textBookId, levelFirstId, levelSecondId, fileSource, fileRoot } = sourceStore.query
|
||||
const { textbookId, levelFirstId, levelSecondId, fileSource, fileRoot } = sourceStore.query
|
||||
// 给每个文件添加属性
|
||||
let fileData = { textBookId, levelFirstId, levelSecondId, fileSource, fileRoot }
|
||||
let fileData = { textbookId, levelFirstId, levelSecondId, fileSource, fileRoot }
|
||||
fileList.forEach(item => {
|
||||
fileData.fileShowName = item.fileData.fileShowName
|
||||
fileData.fileFlag = item.fileData.fileFlag
|
||||
|
|
|
@ -15,7 +15,7 @@ const resourceTypeList = [
|
|||
const resourceFormatList = [
|
||||
{
|
||||
label: '资源格式',
|
||||
value: ''
|
||||
value: -1
|
||||
},
|
||||
...resourceFormat
|
||||
]
|
||||
|
@ -38,17 +38,21 @@ export default defineStore('resource', {
|
|||
resourceTypeList,
|
||||
resourceFormatList,
|
||||
|
||||
curFormat: -1,
|
||||
searchKey: '',
|
||||
// 新建资源
|
||||
isCreate: false,
|
||||
|
||||
//节点数据
|
||||
nodeData:{},
|
||||
loading: false,
|
||||
//查询条件
|
||||
query: {
|
||||
textbookId: '',
|
||||
fileSource: '平台',
|
||||
fileSuffix: '',
|
||||
//资源格式 mp3 ppt ...
|
||||
fileSuffix: -1,
|
||||
// 资源类型 课件 素材 教案
|
||||
fileFlag: '',
|
||||
fileRoot: '资源',
|
||||
fileName: '',
|
||||
orderByColumn: 'uploadTime',
|
||||
isAsc: 'desc',
|
||||
...structQuery
|
||||
|
@ -62,7 +66,11 @@ export default defineStore('resource', {
|
|||
handleQuery() {
|
||||
try {
|
||||
this.loading = true
|
||||
getSmarttalkPage(this.query).then((res) => {
|
||||
let data = {...this.query}
|
||||
if(data.fileSuffix == -1){
|
||||
data.fileSuffix = ''
|
||||
}
|
||||
getSmarttalkPage(data).then((res) => {
|
||||
this.result.total = res.total
|
||||
this.result.list = res.rows
|
||||
})
|
||||
|
@ -77,6 +85,15 @@ export default defineStore('resource', {
|
|||
changeType(val) {
|
||||
this.query.fileFlag = val
|
||||
this.handleQuery()
|
||||
}
|
||||
},
|
||||
changeSuffix(val){
|
||||
this.query.fileSuffix = val
|
||||
this.handleQuery()
|
||||
},
|
||||
// 关键词搜索
|
||||
changeName(){
|
||||
console.log(this.query.fileName)
|
||||
this.handleQuery()
|
||||
},
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue