提交 e5c4bccf authored 作者: 蔡芬's avatar 蔡芬

2

上级 2cf1e3d8
......@@ -3,6 +3,14 @@ ul {
margin: 0;
padding: 0;
}
// 自定义滚动条
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-button{width:4px;height:0}
::-webkit-scrollbar-track{background:0 0}
::-webkit-scrollbar-thumb{background:#dadadb;-webkit-transition:.3s;transition:.3s}
::-webkit-scrollbar-thumb:hover{background-color:#b0b2b3}
::-webkit-scrollbar-thumb:active{background-color:#b0b2b3}
.displaynone {display: none;}
.visiblehide {visibility: hidden;}
.flex {
......
......@@ -4,6 +4,7 @@ import { app, protocol, BrowserWindow, shell, Menu, ipcMain, globalShortcut } fr
import path from 'path';
import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
import { downloadFile } from '@/libs/utils/backfunction.js';
const isDevelopment = process.env.NODE_ENV !== "production";
// Scheme must be registered before the app is ready
......@@ -94,6 +95,11 @@ async function createWindow() {
ipcMain.on('fromFullPage', e => {
console.log('主进程监听到渲染进程');
});
ipcMain.on('downLoadFile', (e,arg) => {
console.log('主进程监听到下载',arg);
console.log(downloadFile)
// downloadFile(arg,'E:/360Downloads/test.zip')
});
// Quit when all windows are closed.
app.on("window-all-closed", () => {
......
......@@ -6,6 +6,7 @@
</div>
<!-- <a href="https://www.baidu.com" target="_blank" @click="outerLink">baidu</a>
<button @click="$i18n.locale == 'en' ? $i18n.locale = 'zh' : $i18n.locale = 'en'">切换语言</button> -->
<button @click="downFile">下载</button>
<TopHead :detail="detail" :ruleForm="ruleForm"></TopHead>
<TopBody :list="articleList" @addArticle="addArticle"></TopBody>
<el-drawer
......@@ -136,6 +137,9 @@ export default {
this.$electron && event.preventDefault(); //浏览器 不阻止
this.$electron && this.$electron.shell.openExternal("https://www.baidu.com"); //electron 打开默认浏览器访问
},
downFile() {
this.$electron && this.$electron.ipcRenderer.send('downLoadFile','https://revolutionary.jkxuetang.com/download?path=C6EDPYre%2Bvu%2B10Ub4uYjYZEPJYjKE46z4wma6JUAOsvvm2Ki4ypAeInpzQXufiOx0ObQDs4usDE8WBNJ51cepu0IOqQ02vOCnT4H03JX0Y45hFe2GGOhuj%2F%2Fog0AkB8q3kMKNvuohAzcMeY0JI%2FYSV0a59JlYJqJ28cGJsE6r%2FfBeWI&name=C6tQONWE%2FPyixkIfoew9&corpid=B%2FNWbYuG9fm1zEMb%2FutiPb8xYJXxS8uusDKF6g&t=D%2FdXbtbfqf7nlQJcpug7fstM');
},
},
}
</script>
......
var request = require('request');
var fs = require('fs');
export const downloadFile = function(file_url , targetPath) {
// Save variable to know progress
var received_bytes = 0;
var total_bytes = 0;
var req = request({
method: 'GET', uri: file_url
});
var out = fs.createWriteStream(targetPath);
req.pipe(out);
req.on('response', function ( data ) {
// Change the total bytes value to get progress later.
total_bytes = parseInt(data.headers['content-length' ]);
});
req.on('data', function(chunk) {
// Update the received bytes
received_bytes += chunk.length;
showProgress(received_bytes, total_bytes);
});
req.on('end', function() {
alert("File succesfully downloaded");
});
}
export const showProgress = function(received, total){
var percentage = (received * 100) / total;
console.log(percentage + "% | " + received + " bytes out of " + total + " bytes.");
}
const { clipboard } = window.require('electron');
// https://revolutionary.jkxuetang.com/download?path=C6EDPYre%2Bvu%2B10Ub4uYjYZEPJYjKE46z4wma6JUAOsvvm2Ki4ypAeInpzQXufiOx0ObQDs4usDE8WBNJ51cepu0IOqQ02vOCnT4H03JX0Y45hFe2GGOhuj%2F%2Fog0AkB8q3kMKNvuohAzcMeY0JI%2FYSV0a59JlYJqJ28cGJsE6r%2FfBeWI&name=C6tQONWE%2FPyixkIfoew9&corpid=B%2FNWbYuG9fm1zEMb%2FutiPb8xYJXxS8uusDKF6g&t=D%2FdXbtbfqf7nlQJcpug7fstM
\ No newline at end of file
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论