Skip to content

Commit af2abf3

Browse files
authored
Merge pull request #294 from dinphy/beta
feat: 添加评论者网址链接
2 parents 0a86dce + b67f392 commit af2abf3

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

front/components/Comment.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
{{ props.comment.username }}
55
<UBadge color="gray" variant="solid" size="xs">作者</UBadge>
66
</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>
813
<template v-if="props.comment.replyTo">
914
<span class="mx-1">回复</span>
1015
<span class="text-[#576b95] text-nowrap">{{props.comment.replyTo}}</span>
@@ -49,6 +54,12 @@ const removeComment = async () => {
4954
toast.success("删除成功!")
5055
memoChangedEvent.emit(props.memoId)
5156
}
57+
const formatWebsite = (website: string) => {
58+
if (/^https?:\/\//i.test(website)) {
59+
return website;
60+
}
61+
return `http://${website}`
62+
}
5263
</script>
5364

5465
<style scoped>

front/pages/user/reg.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</template>
2727

2828
<script setup lang="ts">
29-
import type {UserVO} from "~/types";
29+
import type {UserVO, SysConfigVO} from "~/types";
3030
import {toast} from "vue-sonner";
3131
3232
const state = reactive({
@@ -36,6 +36,14 @@ const state = reactive({
3636
})
3737
const pending = ref(false)
3838
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+
3947
const doReg = async () => {
4048
if (state.username.length < 3) {
4149
toast.warning("用户名最少3个字符")

front/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type CommentVO = {
1414
id: number
1515
content: string
1616
username: string
17+
website?: string
1718
replyTo: string
1819
createdAt: string
1920
updatedAt: string

0 commit comments

Comments
 (0)