Skip to content

Commit

Permalink
优化拦截规则
Browse files Browse the repository at this point in the history
  • Loading branch information
putyy authored and putyy committed Aug 19, 2024
1 parent 2981518 commit c1f0587
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
16 changes: 4 additions & 12 deletions electron/main/proxyServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export async function startServer({win, upstreamProxy, setProxyErrorCallback = f
res.string = 'ok'
res.statusCode = 200
try {
if (!req.json?.description || req.json?.media?.length <= 0) {
if (req.json?.media?.length <= 0) {
return
}
const media = req.json?.media[0]
const url_sign: string = hexMD5(media.url)
if (global.videoList.hasOwnProperty(url_sign) === true) {
if (!media?.decodeKey || global.videoList.hasOwnProperty(url_sign) === true) {
return
}
const urlInfo = urlTool.parse(media.url, true)
Expand All @@ -88,7 +88,7 @@ export async function startServer({win, upstreamProxy, setProxyErrorCallback = f
size: media?.fileSize ? toSize(media.fileSize) : 0,
type: "video/mp4",
type_str: 'video',
decode_key: media?.decodeKey ? media?.decodeKey : '',
decode_key: media.decodeKey,
description: req.json.description,
}))
} catch (e) {
Expand All @@ -114,21 +114,14 @@ export async function startServer({win, upstreamProxy, setProxyErrorCallback = f
proxy.intercept(
{
phase: 'response',
hostname: 'res.wx.qq.com',
as: 'string',
},
async (req, res) => {
if (req.url.endsWith('.js?v=' + vv)) {
res.string = res.string.replaceAll('.js"', '.js?v=' + vv + '"');
}
if (req.url.includes("web/web-finder/res/js/virtual_svg-icons-register.publish")) {
// console.log(res.string.match(/return\s*\{\s*width:([\s\S]*?)scalingInfo:([\s\S]*?)\}/))
// res.string = res.string.replace(
// /return\s*{\s*width:(.*?)scalingInfo:(.*?)\s*}/,
// `var mediaInfo = {width:$1scalingInfo:$2};
// console.log("mediaInfo", mediaInfo);
// console.log("this.objectDesc", this.objectDesc);
// return mediaInfo;`
// )
res.string = res.string.replace(/get\s*media\s*\(\)\s*\{/, `
get media(){
if(this.objectDesc){
Expand Down Expand Up @@ -231,7 +224,6 @@ export async function startServer({win, upstreamProxy, setProxyErrorCallback = f
type_str: 'm3u8',
}))
break

}
} catch (e) {
log.log(e.toString())
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "res-downloader",
"version": "2.0.0",
"version": "2.0.1",
"main": "dist-electron/main/index.js",
"description": "res-downloader(爱享素材下载器),支持视频号、小程序、抖音、快手、小红书、酷狗音乐、qq音乐下载等",
"description": "res-downloader(爱享素材下载器),支持视频号、小程序、抖音、快手、小红书、酷狗音乐、qq音乐、qq短视频等",
"author": "[email protected]",
"license": "MIT",
"private": true,
Expand Down Expand Up @@ -50,7 +50,7 @@
"vite-plugin-electron-renderer": "^0.14.5",
"vue": "^3.3.4",
"vue-router": "^4.2.4",
"vue-tsc": "^1.8.8"
"vue-tsc": "^2.0.29"
},
"dependencies": {
"axios": "^1.5.0",
Expand Down
5 changes: 4 additions & 1 deletion src/components/layout/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ el-container
Sidebar
el-container
el-main
router-view
router-view(v-slot="{ Component, route }")
keep-alive(v-if="route.meta.keepAlive")
component(:is="Component")
component(v-else :is="Component")
el-footer
Footer
</template>
Expand Down
3 changes: 3 additions & 0 deletions src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ const routes = [
{
path: '/index',
name: 'Index',
meta: {keepAlive: true},
component: () => import('./views/Index.vue'),
},
{
path: '/about',
name: 'about',
meta: {keepAlive: true},
component: () => import('./views/About.vue'),
},
{
path: '/setting',
name: 'Setting',
meta: {keepAlive: true},
component: () => import('./views/Setting.vue'),
},
]
Expand Down
11 changes: 6 additions & 5 deletions src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ el-container.container
el-main
el-table(ref="multipleTableRef" @selection-change="handleSelectionChange" :data="tableData" max-height="100%" stripe)
el-table-column(type="selection")
el-table-column(label="预览" show-overflow-tooltip width="300px")
el-table-column(label="预览" show-overflow-tooltip width="150px")
template(#default="scope")
div.show_res
video.video(v-if="scope.row.type_str === 'video'" :src="scope.row.url" controls preload="none") 您的浏览器不支持 video 标签。
video.video(v-if="scope.row.type_str === 'video'" :src="scope.row.url" controls preload="none")
img.img(v-if="scope.row.type_str === 'image'" :src="scope.row.url" crossorigin="anonymous")
audio.audio(v-if="scope.row.type_str === 'audio'" controls preload="none")
source(:src="scope.row.url" :type="scope.row.type")
Expand Down Expand Up @@ -374,12 +374,13 @@ el-container.container
}
.show_res {
width: 100%;
height: auto;
.img {
max-height: 200px;
}
.video {
width: auto;
max-height: 200px;
}
}
.actions {
Expand Down

0 comments on commit c1f0587

Please sign in to comment.