Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 当cookie consent加载失败时目录 & 回到顶部 不显示 #314

Closed
du33169 opened this issue Apr 1, 2023 · 1 comment
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@du33169
Copy link

du33169 commented Apr 1, 2023

Describe the bug 描述你遇到的错误

在开启cookieconsent的同时,如果使用I don't care about cookie之类的浏览器插件访问网站,或者因为其他原因(例如单独配置的CDN失效)导致cookieconsent.min.js无法加载时,会导致页面的目录和回到顶部按钮不显示。

根据报错可以定位到是由于theme.js中,当cookieconsent加载失败时,抛出异常导致后续步骤无法执行。

init() {
    try {
      if (this.config.encryption) {
        this.initFixItDecryptor();
      } else if (!this.config.encryption?.all) {
        this.initTwemoji();
        this.initDetails();
        this.initLightGallery();
        this.initHighlight();
        this.initTable();
        this.initHeaderLink();
        this.initMath();
        this.initMermaid();
        this.initEcharts();
        this.initTypeit();
        this.initMapbox();
        this.initPangu();
      }
      this.initThemeColor();
      this.initSVGIcon();
      this.initMenu();
      this.initSwitchTheme();
      this.initSearch();
      this.initCookieconsent();//here
      this.initSiteTime();
      this.initServiceWorker();
      this.initWatermark();
      this.initMDevtools();
      this.initAutoMark();
      this.initReward();

      window.setTimeout(() => {
        this.initComment();
        if (!this.config.encryption?.all) {
          this.initToc();
          this.initTocListener();
        }
        this.onScroll();
        this.onResize();
        this.onClickMask();
        this.beforeprint();
      }, 100);
    } catch (err) {
      console.error(err);
    }
  }

Expected behavior 期待的行为

对于cookieConsent这类提供额外功能且独立于其他部分的第三方资源的初始化过程,是否可以改为异步执行以避免某个模块的资源加载失败导致影响页面功能?

这应该也有助于提供页面加载速度。

Screenshots 屏幕截图

image

image

Build Environment 构建环境

No response

Preview Environment 预览环境

No response

Additional Information 补充信息

No response

@du33169 du33169 added the bug Something isn't working label Apr 1, 2023
@Lruihao Lruihao added this to the v1.0.0 milestone Apr 1, 2023
@Lruihao Lruihao modified the milestones: v1.x, v0.3.x Jul 24, 2024
@Lruihao Lruihao self-assigned this Jul 24, 2024
@Lruihao
Copy link
Member

Lruihao commented Jul 24, 2024

先修复 cookie consent 加载失败导致的阻断报错,第三方资源初始化改为异步执行进程延后,后续版本 JS 整体重构再考虑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants