diff --git a/ui/artalk-sidebar/auto-imports.d.ts b/ui/artalk-sidebar/auto-imports.d.ts index 7eeea359..e1ce164b 100644 --- a/ui/artalk-sidebar/auto-imports.d.ts +++ b/ui/artalk-sidebar/auto-imports.d.ts @@ -12,8 +12,6 @@ declare global { const customRef: typeof import('vue')['customRef'] const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] const defineComponent: typeof import('vue')['defineComponent'] - const defineLoader: typeof import('vue-router/auto')['defineLoader'] - const definePage: typeof import('unplugin-vue-router/runtime')['definePage'] const effectScope: typeof import('vue')['effectScope'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] const getCurrentScope: typeof import('vue')['getCurrentScope'] diff --git a/ui/artalk-sidebar/src/artalk.ts b/ui/artalk-sidebar/src/artalk.ts index b464c491..19366558 100644 --- a/ui/artalk-sidebar/src/artalk.ts +++ b/ui/artalk-sidebar/src/artalk.ts @@ -1,4 +1,4 @@ -import Artalk from 'artalk' +import Artalk, { type Context } from 'artalk' import { Router } from 'vue-router' import { bootParams } from './global' import { useUserStore } from './stores/user' @@ -16,22 +16,20 @@ export function setupArtalk() { pageKey: bootParams.pageKey, site: bootParams.site, darkMode: bootParams.darkMode, - useBackendConf: true, pvAdd: false, - remoteConfModifier: (conf) => { - conf.noComment = `
` - conf.flatMode = true - conf.pagination = { - pageSize: 20, - readMore: false, - autoLoad: false, - } - conf.listUnreadHighlight = true + noComment: `
`, + flatMode: true, + pagination: { + pageSize: 20, + readMore: false, + autoLoad: false, }, + listUnreadHighlight: true, + fetchCommentsOnInit: false, }) } -export async function syncArtalkUser(artalk: Artalk, router: Router) { +export async function syncArtalkUser(artalk: Context, router: Router) { const user = useUserStore() const logout = () => { user.logout() @@ -43,7 +41,7 @@ export async function syncArtalkUser(artalk: Artalk, router: Router) { // Access from open sidebar or directly by url if (bootParams.user?.email) { // sync user from sidebar to artalk - artalk.ctx.get('user').update(bootParams.user) + artalk.getUser().update(bootParams.user) } else { // Sync user from artalk to sidebar try { @@ -58,19 +56,19 @@ export async function syncArtalkUser(artalk: Artalk, router: Router) { checkUser(artalk, logout) } -function checkUser(artalk: Artalk, logout: () => void) { +function checkUser(artalk: Context, logout: () => void) { // Get user info from artalk - const { name, email } = artalk.ctx.get('user').getData() + const { name, email } = artalk.getUser().getData() // Remove login failed dialog if sidebar - artalk.ctx.getApiHandlers().remove('need_login') - artalk.ctx.getApiHandlers().add('need_login', async () => { + artalk.getApiHandlers().remove('need_login') + artalk.getApiHandlers().add('need_login', async () => { logout() throw new Error('Need login') }) // Check user status - artalk.ctx + artalk .getApi() .user.getUserStatus({ email, name }) .then((res) => { @@ -78,7 +76,7 @@ function checkUser(artalk: Artalk, logout: () => void) { logout() } else { // Mark all notifications as read - artalk.ctx.getApi().notifies.markAllNotifyRead({ email, name }) + artalk.getApi().notifies.markAllNotifyRead({ email, name }) } }) } diff --git a/ui/artalk-sidebar/src/components/PreferenceGrp.vue b/ui/artalk-sidebar/src/components/PreferenceGrp.vue index f3fadd67..5e33e84e 100644 --- a/ui/artalk-sidebar/src/components/PreferenceGrp.vue +++ b/ui/artalk-sidebar/src/components/PreferenceGrp.vue @@ -1,5 +1,5 @@