网站将 chunk-vendors 改为了 chunk-libs/chunk-elementUI, 且首页组件被合并到多模块组合 chunk 中。 更新正则:匹配 chunk-libs 或 chunk-elementUI 的 URL, 提取 base 路径和 hash,构造新的组合 chunk 文件 URL。
This commit is contained in:
@@ -166,13 +166,18 @@ func (c *Course) Refresh(ctx context.Context, c2 model.Course, ch model.Chapter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ParseJsUrl(str string) string {
|
func ParseJsUrl(str string) string {
|
||||||
// <script defer src="https://cdnbasic.scbdc.edu.cn/%E7%9C%81%E7%BA%A7%E8%B5%84%E6%BA%90/hd/chunk-vendors.5e79f5ce155849.js">
|
// 网站已更新,chunk-vendors 不再存在。
|
||||||
re := regexp.MustCompile(`https://[^"'\s]+chunk-vendors[^"'\s]+\.js`)
|
// 现在从 HTML 中找到任一 chunk-*.js 的 URL,提取其 base 路径和 hash,
|
||||||
match := re.FindString(str)
|
// 然后构造包含 src_views_home_index_vue 的组合 chunk 文件 URL。
|
||||||
if match == "" {
|
re := regexp.MustCompile(`(https://[^"'\s]+/)chunk-(?:libs|elementUI)\.([0-9a-f]+)\.js`)
|
||||||
|
match := re.FindStringSubmatch(str)
|
||||||
|
if len(match) < 3 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return strings.Replace(match, "chunk-vendors", "src_views_home_index_vue", 1)
|
basePath := match[1]
|
||||||
|
hash := match[2]
|
||||||
|
// 用已知的组合 chunk 名称拼出 URL:该 chunk 同时包含首页和 CourseList 组件
|
||||||
|
return basePath + "src_views_home_index_vue-src_views_noPermission_index_vue-src_views_components_CourseList_vue." + hash + ".js"
|
||||||
}
|
}
|
||||||
func (c *Course) GetCourseProcees(ctx context.Context, courseId string) (finished string, total string) {
|
func (c *Course) GetCourseProcees(ctx context.Context, courseId string) (finished string, total string) {
|
||||||
post, err := c.Client.R().SetHeader("X-Token", c.Token).SetBody(map[string]any{
|
post, err := c.Client.R().SetHeader("X-Token", c.Token).SetBody(map[string]any{
|
||||||
|
|||||||
Reference in New Issue
Block a user