基础文件上传核心开发
This commit is contained in:
parent
6b369a5e12
commit
69e835a743
|
@ -22,8 +22,8 @@ export default defineConfig({
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/dev-api': {
|
'/dev-api': {
|
||||||
target: 'http://27.128.240.72:7865',
|
// target: 'http://27.128.240.72:7865',
|
||||||
// target: 'http://192.168.2.52:7863',
|
target: 'http://192.168.2.52:7863',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,3 +23,11 @@ export const updateSmarttalk = (params) => {
|
||||||
params
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const moveSmarttalk = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/smarttalk/file/moveSmarttalk',
|
||||||
|
method: 'post',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -8,16 +8,22 @@
|
||||||
<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" v-if="lastAsyncAllTime" size="small" :icon="Check" circle />
|
<el-button
|
||||||
{{lastAsyncAllTime?(toTimeText(lastAsyncAllTime) + '同步成功'):''}}
|
v-if="lastAsyncAllTime"
|
||||||
|
type="success"
|
||||||
|
size="small"
|
||||||
|
:icon="Check"
|
||||||
|
circle
|
||||||
|
/>
|
||||||
|
{{ lastAsyncAllTime ? toTimeText(lastAsyncAllTime) + '同步成功' : '' }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button size="small" @click="asyncAllFile" text>
|
<el-button size="small" text @click="asyncAllFile">
|
||||||
<el-icon v-loading="asyncAllFileVisiable">
|
<el-icon v-loading="asyncAllFileVisiable">
|
||||||
<Refresh />
|
<Refresh />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
{{asyncAllFileVisiable?'同步中':'云同步'}}
|
{{ asyncAllFileVisiable ? '同步中' : '云同步' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
|
@ -28,11 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="prepare-body-main">
|
<div class="prepare-body-main">
|
||||||
<div
|
<div v-for="(item, index) in currentFileList" :key="index" class="prepare-body-main-item">
|
||||||
v-for="(item, index) in currentFileList"
|
|
||||||
:key="index"
|
|
||||||
class="prepare-body-main-item"
|
|
||||||
>
|
|
||||||
<div class="prepare-body-main-item-icon" @click="openFileWin(item)">
|
<div class="prepare-body-main-item-icon" @click="openFileWin(item)">
|
||||||
<FileImage :size="50" :file-name="item.fileShowName" />
|
<FileImage :size="50" :file-name="item.fileShowName" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -104,8 +106,10 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-popover-item">
|
<div class="item-popover-item">
|
||||||
<el-button text>
|
<el-button text @click="isMoveDialogOpen = true">
|
||||||
<el-icon><Switch /></el-icon>
|
<el-icon>
|
||||||
|
<Switch />
|
||||||
|
</el-icon>
|
||||||
<span>移动</span>
|
<span>移动</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -120,6 +124,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<MoveFile v-model="isMoveDialogOpen" @on-submit="chooseMoveCata" />
|
||||||
<uploadDialog v-model="isDialogOpen" @submit-file="submitFile" />
|
<uploadDialog v-model="isDialogOpen" @submit-file="submitFile" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -132,16 +137,19 @@ 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 FileImage from '@/components/file-image/index.vue'
|
import FileImage from '@/components/file-image/index.vue'
|
||||||
import { deleteSmarttalk, getSmarttalkPage, updateSmarttalk } from '@/api/file'
|
import MoveFile from '@/components/move-file/index.vue'
|
||||||
|
import { deleteSmarttalk, getSmarttalkPage, updateSmarttalk, moveSmarttalk } from '@/api/file'
|
||||||
import { toTimeText } from '@/utils/date'
|
import { toTimeText } from '@/utils/date'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { isHaveLocalFile } from '@/utils/talkFile'
|
import { isHaveLocalFile } from '@/utils/talkFile'
|
||||||
|
|
||||||
const { ipcRenderer } = window.electron || {}
|
const { ipcRenderer } = window.electron || {}
|
||||||
export default {
|
export default {
|
||||||
name: 'Prepare',
|
name: 'Prepare',
|
||||||
components: { ChooseTextbook, Refresh, uploadDialog, FileImage },
|
components: { ChooseTextbook, Refresh, uploadDialog, FileImage, MoveFile },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
isMoveDialogOpen: false,
|
||||||
asyncAllFileVisiable: false,
|
asyncAllFileVisiable: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isDialogOpen: false,
|
isDialogOpen: false,
|
||||||
|
@ -180,14 +188,14 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
async asyncAllFile() {
|
async asyncAllFile() {
|
||||||
this.lastAsyncAllTime = new Date()
|
this.lastAsyncAllTime = new Date()
|
||||||
localStorage.setItem('lastAsyncAllTime',this.lastAsyncAllTime)
|
localStorage.setItem('lastAsyncAllTime', this.lastAsyncAllTime)
|
||||||
let arr = [];
|
let arr = []
|
||||||
this.asyncAllFileVisiable = true;
|
this.asyncAllFileVisiable = true
|
||||||
const test = (item) => {
|
const test = (item) => {
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject) => {
|
||||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
isHaveLocalFile(item.fileNewName).then((res) => {
|
||||||
item.async = res
|
item.async = res
|
||||||
if (res===false) {
|
if (res === false) {
|
||||||
ipcRenderer.send('download-file-default', {
|
ipcRenderer.send('download-file-default', {
|
||||||
url: item.fileFullPath,
|
url: item.fileFullPath,
|
||||||
fileName: item.fileNewName
|
fileName: item.fileNewName
|
||||||
|
@ -197,7 +205,7 @@ export default {
|
||||||
item.async = isSuccess
|
item.async = isSuccess
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
}else {
|
} else {
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -206,7 +214,7 @@ export default {
|
||||||
for (let i = 0; i < this.currentFileList.length; i++) {
|
for (let i = 0; i < this.currentFileList.length; i++) {
|
||||||
await test(this.currentFileList[i])
|
await test(this.currentFileList[i])
|
||||||
}
|
}
|
||||||
this.asyncAllFileVisiable = false;
|
this.asyncAllFileVisiable = false
|
||||||
},
|
},
|
||||||
openFileWin(item) {
|
openFileWin(item) {
|
||||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
isHaveLocalFile(item.fileNewName).then((res) => {
|
||||||
|
@ -274,6 +282,27 @@ export default {
|
||||||
closePopver(index) {
|
closePopver(index) {
|
||||||
this.$refs['popover_' + index][0].hide()
|
this.$refs['popover_' + index][0].hide()
|
||||||
},
|
},
|
||||||
|
chooseMoveCata(cataData, item) {
|
||||||
|
let params = {
|
||||||
|
id: item.id,
|
||||||
|
textBookId: cata.textBook.curBookId,
|
||||||
|
}
|
||||||
|
let cata = this.parseCataByNode(cataData.node)
|
||||||
|
if (cata.length > 0) {
|
||||||
|
params.levelFirstId = cata[0];
|
||||||
|
}
|
||||||
|
if (cata.length > 1) {
|
||||||
|
params.levelSecondId = cata[1];
|
||||||
|
}
|
||||||
|
if (cata.length > 2) {
|
||||||
|
params.levelThirdId = cata[2];
|
||||||
|
}
|
||||||
|
moveSmarttalk(params).then((res) => {
|
||||||
|
if (res.data === true) {
|
||||||
|
this.isMoveDialogOpen = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
submitFile(files) {
|
submitFile(files) {
|
||||||
let _this = this
|
let _this = this
|
||||||
files.filter((file) => {
|
files.filter((file) => {
|
||||||
|
@ -284,7 +313,7 @@ export default {
|
||||||
res.resData.levelSecondId == _this.uploadData.levelSecondId &&
|
res.resData.levelSecondId == _this.uploadData.levelSecondId &&
|
||||||
res.resData.levelThirdId == _this.uploadData.levelThirdId
|
res.resData.levelThirdId == _this.uploadData.levelThirdId
|
||||||
) {
|
) {
|
||||||
res.resData.async = true;
|
res.resData.async = true
|
||||||
_this.currentFileList.unshift(res.resData)
|
_this.currentFileList.unshift(res.resData)
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
@ -367,12 +396,14 @@ export default {
|
||||||
color: #a2a2a2;
|
color: #a2a2a2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.prepare-item-info-message {
|
.prepare-item-info-message {
|
||||||
.circular {
|
.circular {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.prepare-body-header{
|
|
||||||
|
.prepare-body-header {
|
||||||
.circular {
|
.circular {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
@ -454,6 +485,7 @@ export default {
|
||||||
line-height: 23px;
|
line-height: 23px;
|
||||||
color: #909399;
|
color: #909399;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.circular {
|
.circular {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue