我似乎让服务工作者正在运行 . The Docs说我只需要将配置中的 serviceWorker 布尔值设置为 true . 所以我做到了,它为我创造了一个服务工作者 . 但它不会注册 .

经过一段时间挖掘缩小的代码并设置一些断点后,我找到了注册服务工作者的行 .

Go.router.onReady(function () {
    Qo.$mount("#app"),
        "https:" === window.location.protocol && Xo("/vuepress-blog/service-worker.js", {
            ready: function () {
                console.log("[vuepress:sw] Service worker is active."),
                    Qo.$refs.layout.$emit("sw-ready")
            },
            cached: function () {
                console.log("[vuepress:sw] Content has been cached for offline use."),
                    Qo.$refs.layout.$emit("sw-cached")
            },
            updated: function () {
                console.log("[vuepress:sw] Content updated."),
                    Qo.$refs.layout.$emit("sw-updated")
            },
            offline: function () {
                console.log("[vuepress:sw] No internet connection found. App is running in offline mode."),
                    Qo.$refs.layout.$emit("sw-offline")
            },
            error: function (t) {
                console.error("[vuepress:sw] Error during service worker registration:", t),
                    Qo.$refs.layout.$emit("sw-error", t)
            }
        })
})

它's been obfuscated, so I'我不完全确定 GoQo 变量是什么,但它似乎尝试在路由器的 onReady 事件被触发时注册服务工作者 . 但是,此事件永远不会被解雇 .

这是我被卡住的地方 . 我完全不知道为什么不会触发这个函数 .

该项目的回购公开on GitLab,并部署在GitLab Pages上 . 我真的很感激这方面的一些帮助 .