1
1
<script lang="ts" setup>
2
2
import { VButton , VAvatar , VLoading } from " @halo-dev/components" ;
3
- import LoginModal from " ./LoginModal.vue" ;
4
3
import MdiStickerEmoji from " ~icons/mdi/sticker-emoji" ;
5
4
import MdiSendCircleOutline from " ~icons/mdi/send-circle-outline" ;
6
5
import type {
@@ -51,8 +50,6 @@ const allowAnonymousComments = inject<Ref<boolean | undefined>>(
51
50
" allowAnonymousComments"
52
51
);
53
52
54
- const loginModal = ref (false );
55
-
56
53
const raw = ref (" " );
57
54
const allowNotification = ref (true );
58
55
const saving = ref (false );
@@ -243,6 +240,20 @@ watchEffect(() => {
243
240
handleSubmit ();
244
241
}
245
242
});
243
+
244
+ // login
245
+
246
+ const parentDomId = ` #comment-${[group ?.replaceAll (" ." , " -" ), kind , name ]
247
+ .join (" -" )
248
+ .replaceAll (/ -+ / g , " -" )} ` ;
249
+
250
+ const loginUrl = ` /console/login?redirect_uri=${encodeURIComponent (
251
+ window .location .href + parentDomId
252
+ )} ` ;
253
+
254
+ function handleOpenLoginPage() {
255
+ window .location .href = loginUrl ;
256
+ }
246
257
</script >
247
258
248
259
<template >
@@ -280,12 +291,12 @@ watchEffect(() => {
280
291
placeholder =" 网站"
281
292
/>
282
293
283
- <div
284
- class =" cursor-pointer select-none text-xs text-gray-600 transition-all hover:text-gray-900 dark:text-slate-200 dark:hover:text-slate-400"
285
- @click = " loginModal = true "
294
+ <a
295
+ class =" select-none text-xs text-gray-600 transition-all hover:text-gray-900 dark:text-slate-200 dark:hover:text-slate-400"
296
+ :href = " loginUrl "
286
297
>
287
298
(已有该站点的账号)
288
- </div >
299
+ </a >
289
300
</div >
290
301
291
302
<div class =" flex items-center justify-between" >
@@ -303,7 +314,7 @@ watchEffect(() => {
303
314
<VButton size =" sm" @click =" handleLogout" >注销</VButton >
304
315
</template >
305
316
<template v-if =" ! currentUser && ! allowAnonymousComments " >
306
- <VButton size =" sm" @click =" loginModal = true " >登录</VButton >
317
+ <VButton size =" sm" @click =" handleOpenLoginPage " >登录</VButton >
307
318
</template >
308
319
</div >
309
320
<div class =" flex flex-row items-center gap-3" >
@@ -349,6 +360,5 @@ watchEffect(() => {
349
360
</div >
350
361
</div >
351
362
</div >
352
- <LoginModal v-model:visible =" loginModal" />
353
363
</div >
354
364
</template >
0 commit comments