diff --git a/plugins/plugin-copy-code/package.json b/plugins/plugin-copy-code/package.json index 6ac38e16..733ee396 100644 --- a/plugins/plugin-copy-code/package.json +++ b/plugins/plugin-copy-code/package.json @@ -30,12 +30,12 @@ "ts": "tsc -b tsconfig.build.json" }, "dependencies": { + "@vuepress-plume/plugin-content-update": "workspace:*", "@vuepress/client": "2.0.0-rc.0", "@vuepress/core": "2.0.0-rc.0", "@vuepress/shared": "2.0.0-rc.0", "@vuepress/utils": "2.0.0-rc.0", - "vue": "^3.3.13", - "vue-router": "4.2.5" + "vue": "^3.3.13" }, "publishConfig": { "access": "public" diff --git a/plugins/plugin-copy-code/src/client/setupCopyCode.ts b/plugins/plugin-copy-code/src/client/setupCopyCode.ts index 2ca7b951..18e5360c 100644 --- a/plugins/plugin-copy-code/src/client/setupCopyCode.ts +++ b/plugins/plugin-copy-code/src/client/setupCopyCode.ts @@ -1,5 +1,5 @@ -import { nextTick, onMounted, watch } from 'vue' -import { usePageData } from '@vuepress/client' +import { nextTick, onMounted } from 'vue' +import { onContentUpdated } from '@vuepress-plume/plugin-content-update/client' import type { CopyCodeOptions } from '../shared/index.js' declare const __COPY_CODE_OPTIONS__: CopyCodeOptions @@ -23,8 +23,6 @@ function sleep(ms: number): Promise { } export function setupCopyCode(): void { - const page = usePageData() - const insertBtn = (codeBlockEl: HTMLElement): void => { if (codeBlockEl.hasAttribute('has-copy-code')) return @@ -92,13 +90,10 @@ export function setupCopyCode(): void { } }) - watch( - () => page.value.path, - () => { - if (!isMobile() || options.showInMobile) - generateButton() - }, - ) + onContentUpdated(() => { + if (!isMobile() || options.showInMobile) + generateButton() + }) } async function copyToClipboard(text: string) { diff --git a/theme/package.json b/theme/package.json index b221a64c..297b3f5c 100644 --- a/theme/package.json +++ b/theme/package.json @@ -48,6 +48,7 @@ "@vuepress-plume/plugin-baidu-tongji": "workspace:*", "@vuepress-plume/plugin-blog-data": "workspace:*", "@vuepress-plume/plugin-caniuse": "workspace:*", + "@vuepress-plume/plugin-content-update": "workspace:*", "@vuepress-plume/plugin-copy-code": "workspace:*", "@vuepress-plume/plugin-iconify": "workspace:*", "@vuepress-plume/plugin-notes-data": "workspace:*", @@ -74,11 +75,11 @@ "ts-debounce": "^4.0.0", "vue": "^3.3.13", "vue-router": "4.2.5", - "vuepress-plugin-comment2": "2.0.0-rc.6", - "vuepress-plugin-md-enhance": "2.0.0-rc.6", - "vuepress-plugin-reading-time2": "2.0.0-rc.6", - "vuepress-plugin-seo2": "2.0.0-rc.6", - "vuepress-plugin-sitemap2": "2.0.0-rc.6" + "vuepress-plugin-comment2": "2.0.0-rc.7", + "vuepress-plugin-md-enhance": "2.0.0-rc.7", + "vuepress-plugin-reading-time2": "2.0.0-rc.7", + "vuepress-plugin-seo2": "2.0.0-rc.7", + "vuepress-plugin-sitemap2": "2.0.0-rc.7" }, "devDependencies": { "@types/lodash.merge": "^4.6.9" diff --git a/theme/src/client/components/PageAside.vue b/theme/src/client/components/PageAside.vue index 04ae2b31..637de599 100644 --- a/theme/src/client/components/PageAside.vue +++ b/theme/src/client/components/PageAside.vue @@ -1,6 +1,7 @@