Skip to content

Commit a8b12e4

Browse files
author
Taois
committed
fix: 修复猫源问题。下次更新会重构hipy逻辑
1 parent cbb2d92 commit a8b12e4

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ cookie_52pojie=
3232
QQ_EMAIL =
3333
QQ_SMTP_AUTH_CODE =
3434

35-
# 调试猫源
35+
# 调试猫源-推荐开启
3636
CAT_DEBUG=1

docs/updateRecord.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# drpyS更新记录
22

3+
### 20250818
4+
5+
更新至V1.2.14
6+
7+
1. 修复 cat源内import assets库处理逻辑错误,推荐环境变量开启 `CAT_DEBUG=1`
8+
2. 重构py源执行逻辑,确保代码健壮性和py执行性能最强。
9+
310
### 20250817
411

512
更新至V1.2.13

libs/catvod.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const loadEsmWithHash = async function (filePath, fileHash, env) {
3838
const loadEsmWithEnv = async function (filePath, env) {
3939
const rawCode = await readFile(filePath, 'utf8');
4040
let injectedCode = rawCode;
41-
// let injectedCode = rawCode.replaceAll('assets://js/lib/', '../catLib/'); // esm-rregister处理了,这里不管
41+
// 不用管这里,CAT_DEBUG=0的时候走这个逻辑也是会被esm-register处理
42+
// let injectedCode = rawCode.replaceAll('assets://js/lib/', '../catLib/'); // esm-register处理了,这里不管
4243
// console.log('loadEsmWithEnv:', env);
4344
const esm_flag1 = 'export function __jsEvalReturn';
4445
const esm_flag2 = 'export default';

spider/catvod/猫测试.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
})
99
*/
1010

11+
import {_, load} from "assets://js/lib/cat.js"; // 通用,CAT_DEBUG=0|1 都完美
12+
// import {_, load} from "../catLib/cat.js"; // 这样写在CAT_DEBUG=0模式下不行,在CAT_DEBUG=1没问题
13+
1114
function init(cfg) {
1215
const ext = cfg.ext;
1316
console.log('init');
@@ -18,6 +21,7 @@ function qjs_test() {
1821
if (typeof getProxy === 'function') {
1922
console.log('getProxy(true):', getProxy(true));
2023
}
24+
console.log(`猫依赖测试:typeof load: ${typeof load},typeof _: ${typeof _}`);
2125
const t1 = Date.now()
2226
let str = '';
2327
for (let i = 0; i < 1000_000; i++) {

utils/esm-register.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ const assets_path = path.join(__dirname, '../spider/catvod');
99
export async function load(url, context, nextLoad) {
1010
// console.log('load esm form:', url);
1111
if (url.startsWith('assets://js/lib/')) {
12-
url = url.replaceAll('assets://js/lib/', '../catLib/');
13-
const catLibJsPath = path.join(assets_path, '../catLib', 'crypto-js.js');
14-
// console.log('catLibJsPath:', catLibJsPath);
12+
const relativeUrl = url.replaceAll('assets://js/lib/', '../catLib/');
13+
const catLibJsPath = path.join(assets_path, relativeUrl);
1514
const catLibHref = pathToFileURL(catLibJsPath).href;
16-
console.log('catLibHref:', catLibHref);
15+
console.log(`[assets url]: ${url} [relativeUrl]:${relativeUrl}\n[catLibJsPath]: ${catLibJsPath} [catLibHref]:${catLibHref}`);
1716
url = catLibHref;
1817
}
18+
// 解决不了CAT_DEBUG=0模式下的相对路径依赖问题
19+
// else if(url.startsWith('.') && url.includes('/catLib/')) {
20+
// const catLibJsPath = path.join(assets_path, url);
21+
// url = pathToFileURL(catLibJsPath).href;
22+
// }
1923
// 只处理目标模块
2024
if (url.includes('/spider/catvod')) {
2125
// 正常加载模块

0 commit comments

Comments
 (0)