@@ -14,7 +14,8 @@ function createWindow() { | |||||
// javascript: true, | // javascript: true, | ||||
// plugins: true, | // plugins: true, | ||||
preload: path.join(__dirname, 'electron-main', 'preload.js'), | preload: path.join(__dirname, 'electron-main', 'preload.js'), | ||||
} | |||||
}, | |||||
// frame: false, | |||||
}) | }) | ||||
// const startUrl = url.format({ | // const startUrl = url.format({ | ||||
@@ -24,8 +25,11 @@ function createWindow() { | |||||
// }); | // }); | ||||
// console.log('startUrl:', startUrl) | // console.log('startUrl:', startUrl) | ||||
// and load the index.html of the app. | // and load the index.html of the app. | ||||
mainWindow.loadFile('./dist/index.html') | |||||
// mainWindow.loadFile('./dist/index.html') | |||||
// mainWindow.loadURL('http://47.104.91.134:9000'); | |||||
mainWindow.loadURL('http://localhost:8081'); | |||||
// 隐藏菜单栏 | |||||
mainWindow.setMenuBarVisibility(false); | |||||
// Open the DevTools. | // Open the DevTools. | ||||
mainWindow.webContents.openDevTools() | mainWindow.webContents.openDevTools() | ||||
} | } | ||||
@@ -4,7 +4,7 @@ | |||||
*/ | */ | ||||
import { fetchApi } from '@/utils/request'; | import { fetchApi } from '@/utils/request'; | ||||
export const isClient = process.env.IS_CLIENT; | |||||
export const isClient = !!global.electron; // process.env.IS_CLIENT; | |||||
let socket; | let socket; | ||||
const noop = () => {}; | const noop = () => {}; | ||||
@@ -70,15 +70,16 @@ const system = { | |||||
/** | /** | ||||
* 下载文件到工作空间 | * 下载文件到工作空间 | ||||
*/ | */ | ||||
downloadFile: safeCall((fileIpfsId, projectName, fileName, dirName) => { | |||||
downloadFile: safeCall((fileIpfsId, projectName, fileName, dirName, onProcessHandler) => { | |||||
const socket = io('download'); | const socket = io('download'); | ||||
socket.on('open', () => { | socket.on('open', () => { | ||||
socket.send([fileIpfsId, projectName, fileName, dirName].join('|')); | socket.send([fileIpfsId, projectName, fileName, dirName].join('|')); | ||||
}); | }); | ||||
socket.on('message', (...args) => { | |||||
console.log('receive download file message:', args); | |||||
socket.on('message', (e) => { | |||||
// console.log('receive download file message:', e); | |||||
onProcessHandler(e, socket); | |||||
// todo 输出下载进度 | // todo 输出下载进度 | ||||
socket.close(); | |||||
// socket.close(); | |||||
}); | }); | ||||
// socket.on('error') | // socket.on('error') | ||||
}), | }), | ||||
@@ -253,7 +253,7 @@ export default { | |||||
checkPwdTip: "", //检测提示 | checkPwdTip: "", //检测提示 | ||||
phoneCode: "", //手机验证码 | phoneCode: "", //手机验证码 | ||||
isRemember: false, //记住密码 | isRemember: false, //记住密码 | ||||
isClient: process.env.IS_CLIENT, //是否是客户端 | |||||
isClient: system.isClient, //是否是客户端 | |||||
}; | }; | ||||
}, | }, | ||||
beforeRouteLeave(to, from, next) { | beforeRouteLeave(to, from, next) { | ||||
@@ -416,7 +416,7 @@ | |||||
mapAddress:'北京天安门', | mapAddress:'北京天安门', | ||||
showImage:false, | showImage:false, | ||||
imageUrl:'', | imageUrl:'', | ||||
isClient:process.env.IS_CLIENT, //是否是客户端 | |||||
isClient: back.isClient, //是否是客户端 | |||||
//结束 | //结束 | ||||
// end | // end | ||||
}; | }; | ||||
@@ -75,6 +75,8 @@ | |||||
</template> | </template> | ||||
<script> | <script> | ||||
import officeview from "../components/officeview/officeview.vue"; | import officeview from "../components/officeview/officeview.vue"; | ||||
import system from '@/services/system'; | |||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
@@ -85,7 +87,7 @@ | |||||
showOffice: false, // 预览Office文件 | showOffice: false, // 预览Office文件 | ||||
officeUrl: "", // PDF URL | officeUrl: "", // PDF URL | ||||
isShowDefault:false, | isShowDefault:false, | ||||
isClient: process.env.IS_CLIENT,//是否是客户端 | |||||
isClient: system.isClient,//是否是客户端 | |||||
}; | }; | ||||
}, | }, | ||||
mounted: function () { | mounted: function () { | ||||
@@ -20,7 +20,19 @@ export async function fetchWorkFlow(projectId, userId) { | |||||
*/ | */ | ||||
export async function fetchFolderFileList(folderId, userId) { | export async function fetchFolderFileList(folderId, userId) { | ||||
const res = await fetchApi('folder/queryFileListByFolderId', {folderId, userId}); | const res = await fetchApi('folder/queryFileListByFolderId', {folderId, userId}); | ||||
return res; | |||||
wrapErrorHint(res); | |||||
if(res.Code !== 0) return null; | |||||
const data = res.Data || {}; | |||||
const outputObj = { | |||||
folder: data.folder.map(firstCharToLowerCase), | |||||
myFile: data.myFile.map(f => { | |||||
const obj = firstCharToLowerCase(f); | |||||
obj.isShowFile = true; | |||||
return obj; | |||||
}), | |||||
workFile: data.workFile.map(firstCharToLowerCase), | |||||
} | |||||
return outputObj; | |||||
} | } | ||||
export async function createSubFolder(folderGroupData) { | export async function createSubFolder(folderGroupData) { | ||||
@@ -4571,78 +4571,93 @@ export default { | |||||
* type :1 为文件,2位协作文件 | * type :1 为文件,2位协作文件 | ||||
*/ | */ | ||||
clientDownLoad: function (file, type) { | clientDownLoad: function (file, type) { | ||||
var thisApp = this; | |||||
if (this.isClient) { | |||||
this.$axios({ | |||||
method: "put", | |||||
url: encodeURI( | |||||
process.env.API_HOST + | |||||
"projects/download/" + | |||||
file.archID + | |||||
"/" + | |||||
sessionStorage.userId + | |||||
"/" + | |||||
type | |||||
), | |||||
}) | |||||
.then((response) => { | |||||
if (response.data.state == 1) { | |||||
file.downloadStatus = 1; | |||||
file.isDownload = true; | |||||
var archid = file.archID; | |||||
var alias = file.alias; | |||||
var filename = file.archName + "." + file.extension; | |||||
if (file.version > 1) { | |||||
filename = file.archName + file.version + "." + file.extension; | |||||
} | |||||
var folderID = file.folderID; | |||||
const folderName = | |||||
thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; | |||||
var projID = file.projID; | |||||
if (type == 1) { | |||||
system.downloadFile( | |||||
archid, | |||||
filename, | |||||
folderID, | |||||
sessionStorage.userId, | |||||
sessionStorage.companyId, | |||||
alias | |||||
); | |||||
} else { | |||||
const folderName = | |||||
thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; | |||||
system.downloadFile( | |||||
archid, | |||||
filename, | |||||
folderID, | |||||
sessionStorage.userId, | |||||
sessionStorage.companyId, | |||||
alias, | |||||
sessionStorage.projName, | |||||
folderName, | |||||
sessionStorage.projId | |||||
); | |||||
} | |||||
} else { | |||||
this.$notify({ | |||||
title: "温馨提示", | |||||
message: response.data.message, | |||||
type: "error", | |||||
offset: 30, | |||||
duration: 2000, | |||||
}); | |||||
} | |||||
}) | |||||
.catch((error) => { | |||||
this.$notify({ | |||||
title: "温馨提示", | |||||
message: "下载失败", | |||||
type: "error", | |||||
offset: 30, | |||||
duration: 2000, | |||||
}); | |||||
}); | |||||
} | |||||
if(!this.isClient) return; | |||||
const { ipfsCid, archName: fileName, } = file; | |||||
const { folderName, levelId, id: folderId } = this.nowFolder; | |||||
system.downloadFile(ipfsCid, sessionStorage.projName, fileName, folderName, (resMessage, socketIns) => { | |||||
console.log('receive download file message:', resMessage, socketIns); | |||||
// {"size":"11","currentSize":"11","unit":"B","process":100,"hash":""} | |||||
try { | |||||
const out = JSON.parse(resMessage.data); | |||||
if(out.process !== 100) return; | |||||
socketIns.close(); | |||||
file.downloadStatus = 1; | |||||
file.isDownload = true; | |||||
this.$forceUpdate(); | |||||
} catch (e) { | |||||
console.error('socket-download-file parse data have error:', e); | |||||
} | |||||
}); | |||||
// var thisApp = this; | |||||
// this.$axios({ | |||||
// method: "put", | |||||
// url: encodeURI( | |||||
// process.env.API_HOST + | |||||
// "projects/download/" + | |||||
// file.archID + | |||||
// "/" + | |||||
// sessionStorage.userId + | |||||
// "/" + | |||||
// type | |||||
// ), | |||||
// }) | |||||
// .then((response) => { | |||||
// if (response.data.state == 1) { | |||||
// file.downloadStatus = 1; | |||||
// file.isDownload = true; | |||||
// var archid = file.archID; | |||||
// var alias = file.alias; | |||||
// var filename = file.archName + "." + file.extension; | |||||
// if (file.version > 1) { | |||||
// filename = file.archName + file.version + "." + file.extension; | |||||
// } | |||||
// var folderID = file.folderID; | |||||
// const folderName = | |||||
// thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; | |||||
// var projID = file.projID; | |||||
// if (type == 1) { | |||||
// system.downloadFile( | |||||
// archid, | |||||
// filename, | |||||
// folderID, | |||||
// sessionStorage.userId, | |||||
// sessionStorage.companyId, | |||||
// alias | |||||
// ); | |||||
// } else { | |||||
// const folderName = | |||||
// thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; | |||||
// system.downloadFile( | |||||
// archid, | |||||
// filename, | |||||
// folderID, | |||||
// sessionStorage.userId, | |||||
// sessionStorage.companyId, | |||||
// alias, | |||||
// sessionStorage.projName, | |||||
// folderName, | |||||
// sessionStorage.projId | |||||
// ); | |||||
// } | |||||
// } else { | |||||
// this.$notify({ | |||||
// title: "温馨提示", | |||||
// message: response.data.message, | |||||
// type: "error", | |||||
// offset: 30, | |||||
// duration: 2000, | |||||
// }); | |||||
// } | |||||
// }) | |||||
// .catch((error) => { | |||||
// this.$notify({ | |||||
// title: "温馨提示", | |||||
// message: "下载失败", | |||||
// type: "error", | |||||
// offset: 30, | |||||
// duration: 2000, | |||||
// }); | |||||
// }); | |||||
}, | }, | ||||
/** | /** | ||||
* 客户端上传文件 | * 客户端上传文件 | ||||