Browse Source

12.8

master
lichong 2 weeks ago
parent
commit
b712fd835d
  1. 2
      package.json
  2. 12
      src/main/index.js
  3. 2
      src/renderer/src/App.vue
  4. 7
      src/renderer/src/components/treecomponent.vue
  5. 38
      src/renderer/src/views/dangan.vue

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "electron", "name": "electron",
"version": "1.0.0", "version": "1.0.1",
"description": "An Electron application with Vue", "description": "An Electron application with Vue",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "lichong", "author": "lichong",

12
src/main/index.js

@ -63,6 +63,7 @@ app.whenReady().then(() => {
for (let index = 0; index < pathList.length; index++) { for (let index = 0; index < pathList.length; index++) {
let element = pathList[index]; let element = pathList[index];
let folderPath = path.join("D:\\test\\", element); let folderPath = path.join("D:\\test\\", element);
folderPath = Buffer.from(folderPath, 'utf8').toString('utf8');
try { try {
fs.mkdirSync(`${folderPath}\\`, { recursive: true }); fs.mkdirSync(`${folderPath}\\`, { recursive: true });
successList.push(element) successList.push(element)
@ -80,6 +81,8 @@ app.whenReady().then(() => {
let errorList = [] let errorList = []
let oldfolderPath = path.join("D:\\test\\", pathObj.oldPath); let oldfolderPath = path.join("D:\\test\\", pathObj.oldPath);
let newfolderPath = path.join("D:\\test\\", pathObj.newPath); let newfolderPath = path.join("D:\\test\\", pathObj.newPath);
oldfolderPath = Buffer.from(oldfolderPath, 'utf8').toString('utf8');
newfolderPath = Buffer.from(newfolderPath, 'utf8').toString('utf8');
try { try {
fs.rename(`${oldfolderPath}\\`, `${newfolderPath}\\`, error => { fs.rename(`${oldfolderPath}\\`, `${newfolderPath}\\`, error => {
if (error) { if (error) {
@ -118,6 +121,8 @@ app.whenReady().then(() => {
let element = pathList[index]; let element = pathList[index];
let destinationFilePath = path.join("D:\\test\\", element.path); let destinationFilePath = path.join("D:\\test\\", element.path);
let sourceFilePath = element.prePath; let sourceFilePath = element.prePath;
destinationFilePath = Buffer.from(destinationFilePath, 'utf8').toString('utf8');
sourceFilePath = Buffer.from(sourceFilePath, 'utf8').toString('utf8');
try { try {
fs.copyFileSync(sourceFilePath, destinationFilePath); fs.copyFileSync(sourceFilePath, destinationFilePath);
successList.push(element) successList.push(element)
@ -144,9 +149,9 @@ app.whenReady().then(() => {
}) })
// 下载文件 // 下载文件
ipcMain.on('downloadFile', (e, pathStr) => { ipcMain.on('downloadFile', (e, pathStr) => {
let filePath = path.join("D:\\test\\", pathStr); let filePath = path.join("D:\\test\\", pathStr.replace("D:\\test\\", ""));
// 读取文件后传给前端 // 读取文件后传给前端
fs.readFile(filePath, function (err, data) { fs.readFile(filePath, 'utf8', function (err, data) {
if (err) { if (err) {
console.error('读取文件时出错:', err); console.error('读取文件时出错:', err);
mainWindow.webContents.send(`downloadFileResult`, { success: false, error: err.message }); mainWindow.webContents.send(`downloadFileResult`, { success: false, error: err.message });
@ -164,6 +169,7 @@ app.whenReady().then(() => {
for (let index = 0; index < pathList.length; index++) { for (let index = 0; index < pathList.length; index++) {
let element = pathList[index]; let element = pathList[index];
let folderPath = path.join("D:\\test\\", element); let folderPath = path.join("D:\\test\\", element);
folderPath = Buffer.from(folderPath, 'utf8').toString('utf8');
try { try {
fs.mkdirSync(`${folderPath}\\`, { recursive: true }); fs.mkdirSync(`${folderPath}\\`, { recursive: true });
successFolderList.push(element) successFolderList.push(element)
@ -178,6 +184,8 @@ app.whenReady().then(() => {
let element = tableList[index]; let element = tableList[index];
let destinationFilePath = path.join("D:\\test\\", element.path.replace("D:\\test\\", "")); let destinationFilePath = path.join("D:\\test\\", element.path.replace("D:\\test\\", ""));
let sourceFilePath = element.prePath; let sourceFilePath = element.prePath;
destinationFilePath = Buffer.from(destinationFilePath, 'utf8').toString('utf8');
sourceFilePath = Buffer.from(sourceFilePath, 'utf8').toString('utf8');
// 读取文件大小 // 读取文件大小
let fileSize = fs.statSync(sourceFilePath).size; let fileSize = fs.statSync(sourceFilePath).size;
element.size = fileSize element.size = fileSize

2
src/renderer/src/App.vue

@ -27,7 +27,7 @@ export default {
computed: {}, computed: {},
methods: {}, methods: {},
async mounted() { async mounted() {
let fiveDay = dayjs('2024-12-05T00:00:00').valueOf() let fiveDay = dayjs('2024-12-14T00:00:00').valueOf()
if (!this.isVip) { if (!this.isVip) {
if (dayjs().valueOf() > fiveDay) { if (dayjs().valueOf() > fiveDay) {
this.isVip = false this.isVip = false

7
src/renderer/src/components/treecomponent.vue

@ -3,13 +3,14 @@
<el-auto-resizer style="height: calc(100vh - 70px);"> <el-auto-resizer style="height: calc(100vh - 70px);">
<template #default="{ height, width }"> <template #default="{ height, width }">
<el-tree-v2 :data="treeData" :props="treeProps" class="bgColor" @node-click="nodeClick" ref="treeRef" <el-tree-v2 :data="treeData" :props="treeProps" class="bgColor" @node-click="nodeClick" ref="treeRef"
:height="height" :expand-on-click-node="false"> :height="height" :expand-on-click-node="true">
<template #default="{ node }"> <template #default="{ node }">
<div style="width: 100%;text-align-last:left;" :class="node.data.id === nodeClickId ? 'selectedNode' : ''"> <div style="width: 100%;text-align-last:left;" :class="node.data.id === nodeClickId ? 'selectedNode' : ''">
<el-tooltip effect="dark" :content="node.label" placement="right" v-if="node.label.length > textLength"> <!-- <el-tooltip effect="dark" :content="node.label" placement="right" v-if="node.label.length > textLength">
<span>{{ node.label.slice(0, textLength) }}</span> <span>{{ node.label.slice(0, textLength) }}</span>
</el-tooltip> </el-tooltip>
<span v-else>{{ node.label }}</span> <span v-else>{{ node.label }}</span> -->
<span>{{ node.label }}</span>
<span style="position: absolute;right: 8px;" v-if="node.level === 1"> <span style="position: absolute;right: 8px;" v-if="node.level === 1">
<el-button :type="node.data.id === nodeClickId ? 'success' : 'primary'" link <el-button :type="node.data.id === nodeClickId ? 'success' : 'primary'" link
@click="e => editxiangmu(e, node)"> @click="e => editxiangmu(e, node)">

38
src/renderer/src/views/dangan.vue

@ -60,7 +60,8 @@
<div style="margin-bottom: 8px;"> <div style="margin-bottom: 8px;">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="4"> <el-col :span="4">
<el-button type="primary" plain @click="addFile" :disabled="_.get(treeNode, 'level') !== 3"> <!-- <el-button type="primary" plain @click="addFile" :disabled="_.get(treeNode, 'level') !== 3"> -->
<el-button type="primary" plain @click="addFile" :disabled="[1].includes(_.get(treeNode, 'level', 1))">
<el-icon> <el-icon>
<Plus /> <Plus />
</el-icon> </el-icon>
@ -490,20 +491,22 @@ export default {
this.tableLoading = true this.tableLoading = true
let collection = myDatabase.fileList let collection = myDatabase.fileList
if (!_.isEmpty(this.treeNode)) { if (!_.isEmpty(this.treeNode)) {
if (this.treeNode.level === 1) { collection = collection.filter((equip) => equip.treeId === this.treeNode.currentId)
collection = collection.filter((equip) => equip.prepretreeId === this.treeNode.currentId) // if (this.treeNode.level === 1) {
} else if (this.treeNode.level === 2) { // collection = collection.filter((equip) => equip.prepretreeId === this.treeNode.currentId)
collection = collection.filter((equip) => equip.pretreeId === this.treeNode.currentId) // } else if (this.treeNode.level === 2) {
} else if (this.treeNode.level === 3) { // collection = collection.filter((equip) => equip.pretreeId === this.treeNode.currentId)
collection = collection.filter((equip) => equip.treeId === this.treeNode.currentId) // } else if (this.treeNode.level === 3) {
} // collection = collection.filter((equip) => equip.treeId === this.treeNode.currentId)
// }
} else { } else {
let fileCurrentIdList = [] collection = collection.filter((equip) => equip.treeId === false)
for (let i = 0; i < this.treeData.length; i++) { // let fileCurrentIdList = []
let treeItem = this.treeData[i]; // for (let i = 0; i < this.treeData.length; i++) {
fileCurrentIdList.push(treeItem.currentId) // let treeItem = this.treeData[i];
} // fileCurrentIdList.push(treeItem.currentId)
collection = collection.filter((equip) => fileCurrentIdList.includes(equip.prepretreeId)) // }
// collection = collection.filter((equip) => fileCurrentIdList.includes(equip.prepretreeId))
} }
if (!_.isEmpty(this.wenjianObj)) { if (!_.isEmpty(this.wenjianObj)) {
let wenjianName = _.trim(this.wenjianObj.wenjianName) let wenjianName = _.trim(this.wenjianObj.wenjianName)
@ -626,7 +629,7 @@ export default {
"一级卷名": _.split(listItem.juanName, "_")[0], "一级卷名": _.split(listItem.juanName, "_")[0],
"二级卷名": _.split(listItem.juanName, "_")[1], "二级卷名": _.split(listItem.juanName, "_")[1],
"文件名": listItem.fileName, "文件名": listItem.fileName,
"文件路径": `D:\\test\\${listItem.path}`, "文件路径": `D:\\test\\${listItem.path.replace("D:\\test\\", "")}`,
"文件类型": _.find(this.fileList, { value: listItem.fileType }).label, "文件类型": _.find(this.fileList, { value: listItem.fileType }).label,
"文件大小": this.genSize(listItem.size), "文件大小": this.genSize(listItem.size),
"文件状态": listItem.status, "文件状态": listItem.status,
@ -675,7 +678,7 @@ export default {
}, },
// //
async addFile() { async addFile() {
if (_.get(this.treeNode, 'level') !== 3) { if (_.get(this.treeNode, 'level') === 1) {
ElMessage({ ElMessage({
message: '请选择项目', message: '请选择项目',
type: 'warning' type: 'warning'
@ -945,7 +948,7 @@ export default {
pretreeId: this.treeNode.preId, pretreeId: this.treeNode.preId,
prepretreeId: this.treeNode.prepreId, prepretreeId: this.treeNode.prepreId,
xiangmuName: filePathList[0], xiangmuName: filePathList[0],
juanName: `${filePathList[1]}_${filePathList[2]}`, juanName: `${filePathList[1]}${filePathList[2] ? "_" + filePathList[2] : ""}`,
fileName: fileItem.raw.name, fileName: fileItem.raw.name,
fileType: fileItem.raw.type, fileType: fileItem.raw.type,
uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@ -982,6 +985,7 @@ export default {
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
} }
await myDatabase.fileList.put({ ...fileItem }) await myDatabase.fileList.put({ ...fileItem })
window.electron.ipcRenderer.send('createFile', JSON.stringify([{ ...fileItem }]))
} }
await this.searchTable() await this.searchTable()
this.cancelFileDialog() this.cancelFileDialog()

Loading…
Cancel
Save