File tree 3 files changed +22
-2
lines changed
3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 4
4
{{ props.comment.username }}
5
5
<UBadge color =" gray" variant =" solid" size =" xs" >作者</UBadge >
6
6
</span >
7
- <span v-else class =" text-[#576b95] text-nowrap" >{{ props.comment.username }}</span >
7
+ <span v-else class =" text-[#576b95] text-nowrap" >
8
+ <a v-if =" props.comment.website" :href =" formatWebsite(props.comment.website)" target =" _blank" >
9
+ {{ props.comment.username }}
10
+ </a >
11
+ <span v-else >{{ props.comment.username }}</span >
12
+ </span >
8
13
<template v-if =" props .comment .replyTo " >
9
14
<span class =" mx-1" >回复</span >
10
15
<span class =" text-[#576b95] text-nowrap" >{{props.comment.replyTo}}</span >
@@ -49,6 +54,12 @@ const removeComment = async () => {
49
54
toast .success (" 删除成功!" )
50
55
memoChangedEvent .emit (props .memoId )
51
56
}
57
+ const formatWebsite = (website : string ) => {
58
+ if (/ ^ https? :\/\/ / i .test (website )) {
59
+ return website ;
60
+ }
61
+ return ` http://${website } `
62
+ }
52
63
</script >
53
64
54
65
<style scoped>
Original file line number Diff line number Diff line change 26
26
</template >
27
27
28
28
<script setup lang="ts">
29
- import type {UserVO } from " ~/types" ;
29
+ import type {UserVO , SysConfigVO } from " ~/types" ;
30
30
import {toast } from " vue-sonner" ;
31
31
32
32
const state = reactive ({
@@ -36,6 +36,14 @@ const state = reactive({
36
36
})
37
37
const pending = ref (false )
38
38
const currentUser = useState <UserVO >(' userinfo' )
39
+ const sysConfig = useState <SysConfigVO >(' sysConfig' )
40
+
41
+ onMounted (async () => {
42
+ if (! sysConfig .value ?.enableRegister ) {
43
+ await navigateTo (' /' )
44
+ }
45
+ })
46
+
39
47
const doReg = async () => {
40
48
if (state .username .length < 3 ) {
41
49
toast .warning (" 用户名最少3个字符" )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export type CommentVO = {
14
14
id : number
15
15
content : string
16
16
username : string
17
+ website ?: string
17
18
replyTo : string
18
19
createdAt : string
19
20
updatedAt : string
You can’t perform that action at this time.
0 commit comments