Skip to content

Commit

Permalink
增加批量下载、修改md、去除无用更新代码
Browse files Browse the repository at this point in the history
  • Loading branch information
putyy committed Sep 6, 2023
1 parent 73f5025 commit 05eb23d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ yarn run build --win

## 参考项目

- [WeChatVideoDownloader](https://github.com/lecepin/WeChatVideoDownloader) 原项目是react写的,且有段时间未更新,本项目参考原项目用vue3重写了一下,核心逻辑没什么变化,主要是增加了一些新的功能,再次感谢!
- [WeChatVideoDownloader](https://github.com/lecepin/WeChatVideoDownloader) 原项目是react写的,本项目参考原项目用vue3重写了一下,核心逻辑没什么变化,主要是增加了一些新的功能,再次感谢!
1 change: 0 additions & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ declare module 'vue' {
ElOption: typeof import('element-plus/es')['ElOption']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
Footer: typeof import('./src/components/layout/Footer.vue')['default']
Index: typeof import('./src/components/layout/Index.vue')['default']
Expand Down
31 changes: 1 addition & 30 deletions electron/main/utils.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
import {app, dialog, shell} from 'electron'
import semver from 'semver'
import fs from 'fs'

const axios = require('axios')

// packageUrl 需要包含 { "version": "1.0.0" } 结构
function checkUpdate(
// 可以使用加速地址 https://cdn.jsdelivr.net/gh/lecepin/electron-react-tpl/package.json
packageUrl = 'https://raw.githubusercontent.com/lecepin/electron-react-tpl/master/package.json',
downloadUrl = 'https://github.com/lecepin/electron-react-tpl/releases',
) {
axios.get(packageUrl)
.then(({data}) => {
if (semver.gt(data?.version, app.getVersion())) {
const result = dialog.showMessageBoxSync({
message: '发现新版本,是否更新?',
type: 'question',
cancelId: 1,
defaultId: 0,
buttons: ['进入新版本下载页面', '取消'],
});

if (result === 0 && downloadUrl) {
shell.openExternal(downloadUrl).then(r => {
})
}
}
})
.catch(err => {
})
}

function downloadFile(url, fullFileName, progressCallback) {
return axios.get(url, {
responseType: 'stream',
Expand Down Expand Up @@ -62,4 +33,4 @@ function downloadFile(url, fullFileName, progressCallback) {
});
}

export {checkUpdate, downloadFile}
export {downloadFile}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "res-downloader",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist-electron/main/index.js",
"description": "Really simple Electron + Vue + Vite boilerplate.",
"description": "Electron + Vue + Vite 实现的资源下载软件,支持微信视频号下载、抖音视频下载、快手视频下载、酷狗音乐下载等",
"author": "[email protected]",
"license": "MIT",
"private": true,
Expand Down
Binary file modified public/show.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/components/layout/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ const jump = (scene: number)=>{
</script>
<template lang="pug">
div.line
a.item 版本号: {{v}} 站长邮箱: [email protected]
a.item(@click="jump(1)") 软件源码
a.item 当前版本: {{v}}
a.item 站长邮箱: [email protected]
a.item(@click="jump(1)") 获取更新
a.item(@click="jump(2)") 云盘资源
a.item(@click="jump(3)") chatgpt
a.item(@click="jump(4)") 问题反馈
Expand Down
87 changes: 69 additions & 18 deletions src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
import {ref, onMounted} from "vue"
import {ipcRenderer} from 'electron'
import {onUnmounted} from "@vue/runtime-core"
import {ElMessage} from "element-plus"
import {ElMessage, ElLoading, ElTable} from "element-plus"
import localStorageCache from "../common/localStorage"
import {ElLoading} from 'element-plus'
const tableData = ref<{
interface resData {
url_sign: string,
url: string,
size: any,
platform: string,
progress_bar: any,
save_path: string,
downing: boolean
}[]>([])
}
const tableData = ref<resData[]>([])
const resType = ref({
video: true,
Expand All @@ -26,15 +27,8 @@ const resType = ref({
const isInitApp = ref(false)
const toSize = (size: number) => {
if (size > 1048576) {
return (size / 1048576).toFixed(2) + "MB"
}
if (size > 1024) {
return (size / 1024).toFixed(2) + "KB"
}
return size + 'b'
}
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref<resData[]>([])
onMounted(() => {
let resTypeCache = localStorageCache.get("res-type")
Expand Down Expand Up @@ -91,6 +85,60 @@ onUnmounted(() => {
localStorageCache.set("res-type", resType.value, -1)
})
const handleSelectionChange = (val: resData[]) => {
multipleSelection.value = val
}
const handleBatchDown = async () => {
if (multipleSelection.value.length <= 0) {
return
}
let save_dir = localStorageCache.get("save_dir")
if (!save_dir) {
ElMessage({
message: '请设置保存目录',
type: 'warning'
})
return
}
let loading = ElLoading.service({
lock: true,
text: '下载中',
background: 'rgba(0, 0, 0, 0.7)',
})
for (const item of multipleSelection.value) {
let result = await ipcRenderer.invoke('invoke_file_exists', {
save_path: save_dir,
url: item.url,
})
if (result.is_file) {
item.progress_bar = "100%"
item.save_path = result.fileName
continue
}
let downRes = await ipcRenderer.invoke('invoke_down_file', {
index: 0,
data: Object.assign({}, item),
save_path: save_dir,
high: false
})
if (downRes !== false) {
item.progress_bar = "100%"
item.save_path = downRes.fullFileName
}
}
loading.close()
multipleTableRef.value!.clearSelection()
}
const handleDown = async (index: number, row: any, high: boolean) => {
Expand All @@ -106,7 +154,7 @@ const handleDown = async (index: number, row: any, high: boolean) => {
let loading = ElLoading.service({
lock: true,
text: 'Loading',
text: '下载中',
background: 'rgba(0, 0, 0, 0.7)',
})
Expand Down Expand Up @@ -216,23 +264,25 @@ el-container.container
el-header
el-row
div
el-button(type="primary" @click="handleBatchDown") 批量下载
el-button(v-if="isInitApp" @click="handleInitApp")
el-icon
Promotion
p 安装检测(如果看到此按钮说明软件安装未完成则需要手动点击此按钮)
el-button(@click="handleClear")
el-icon
Delete
p 清空
p 清空列表
el-button(@click="resType.video=!resType.video" :type="resType.video ? 'primary' : 'info'" ) 视频
el-button(@click="resType.audio=!resType.audio" :type="resType.audio ? 'primary' : 'info'" ) 音频
el-button(@click="resType.image=!resType.image" :type="resType.image ? 'primary' : 'info'" ) 图片
el-button(@click="resType.m3u8=!resType.m3u8" :type="resType.m3u8 ? 'primary' : 'info'" ) m3u8
a(style="color: red") &nbsp;&nbsp;&nbsp;点击左边选项,选择需要拦截的资源类型
el-main
el-table(:data="tableData" max-height="100%" stripe style="max-content")
el-table-column(label="预览" show-overflow-tooltip width="350px" )
template(#default="scope" )
el-table(ref="multipleTableRef" @selection-change="handleSelectionChange" :data="tableData" max-height="100%" stripe style="max-content")
el-table-column(type="selection" width="55")
el-table-column(label="预览" show-overflow-tooltip width="350px")
template(#default="scope")
div.show_res
video(v-if="scope.row.type_str === 'video'" :src="scope.row.down_url" controls preload="none" style="width: 100%;height: auto;") 您的浏览器不支持 video 标签。
img.img(v-if="scope.row.type_str === 'image'" :src="scope.row.down_url")
Expand All @@ -242,6 +292,7 @@ el-container.container
el-table-column(prop="platform" label="主机地址")
el-table-column(prop="size" label="资源大小")
el-table-column(prop="save_path" label="保存目录")
el-table-column(prop="progress_bar" label="下载进度")
el-table-column(label="操作")
template(#default="scope")
template(v-if="scope.row.type_str !== 'm3u8'" )
Expand Down

0 comments on commit 05eb23d

Please sign in to comment.