Skip to content

Commit

Permalink
支持设置在线的favicon地址
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry committed Jul 15, 2024
1 parent b02bdd4 commit ab49d89
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/XPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function doSupport() {
>
<div>
<span class="mr-4">{{ title }}</span>
<span v-if="props.readRole > 0 && props.readRole <= 999" class="text-red-500 text-sm">
<span v-if="props.readRole && props.readRole > 0 && props.readRole <= 999" class="text-red-500 text-sm">
<UIcon class="align-middle" name="i-carbon-locked" />
<span class="align-middle">{{ props.readRole < 999 ? props.readRole : '私有' }}</span>
</span>
Expand Down
11 changes: 11 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ if (sysconfig.js) {
})
}
if (sysconfig.favicon) {
useHead({
link: [
{
rel: 'shortcut icon',
href: sysconfig.favicon,
},
],
})
}
if (userinfo.value.css) {
useHead({
style: [
Expand Down
11 changes: 9 additions & 2 deletions pages/manage/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const state = reactive({
webBgimage: '',
websiteKeywords: '极简,论坛,极简论坛',
websiteDescription: '极简论坛',
favicon: '',
pointPerPost: 5,
pointPerPostByDay: 20,
pointPerComment: 1,
Expand Down Expand Up @@ -176,17 +177,23 @@ async function copyWebhook() {
<UFormGroup label="论坛地址" name="websiteUrl">
<UInput v-model="state.websiteUrl" autocomplete="off" />
</UFormGroup>
</div>
<div class="flex flex-row space-x-2">
<UFormGroup label="论坛背景图" name="webBgimage">
<UInput v-model="state.webBgimage" autocomplete="off" />
</UFormGroup>
<UFormGroup label="论坛关键词" name="websiteKeywords">
<UInput v-model="state.websiteKeywords" autocomplete="off" />
</UFormGroup>
</div>
<div class="flex flex-row space-x-2">
<UFormGroup label="论坛描述" name="websiteDescription">
<UInput v-model="state.websiteDescription" autocomplete="off" />
</UFormGroup>
<UFormGroup label="favicon" name="favicon">
<UInput v-model="state.favicon" autocomplete="off" />
</UFormGroup>
</div>

<div class="flex flex-row space-x-2">
<UFormGroup label="站点公告" name="websiteAnnouncement">
<ClientOnly>
Expand All @@ -199,7 +206,7 @@ async function copyWebhook() {
</div>

<div class="flex flex-row space-x-2">
<UFormGroup label="帖子链接格式定义" name="type">
<UFormGroup label="帖子链接格式定义" name="type" class="w-[225px]">
<USelectMenu
v-model="state.postUrlFormat.type" :options="postUrlFormatOptions" value-attribute="value"
option-attribute="label"
Expand Down
4 changes: 2 additions & 2 deletions pages/member/[username].vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ watch(() => route.fullPath, (fullPath: string) => {
<NuxtLink class="flex flex-row gap-1 items-center" :to="`/member/${userinfo.username}`">
<UBadge size="lg" :color="selectedTab === 'post' ? 'primary' : 'white'" variant="solid" class="space-x-1">
<UIcon name="i-carbon-add-comment" />
<span>帖子({{ userinfo._count.posts }})</span>
<span>帖子({{ userinfo._count ? userinfo._count.posts : 0 }})</span>
</UBadge>
</NuxtLink>

Expand Down Expand Up @@ -133,7 +133,7 @@ watch(() => route.fullPath, (fullPath: string) => {
<NuxtLink v-if="currentUser.username === userinfo.username && token" class="flex flex-row gap-1 items-center" :to="`/member/${userinfo.username}/message`">
<UBadge size="lg" :color="selectedTab === 'message' ? 'primary' : 'white'" variant="solid" class="space-x-1">
<UIcon name="i-carbon-notification" />
<span :class="[userinfo.unreadMessageCount > 0 ? 'text-red-500' : '']">消息({{ userinfo._count.ReceiveMessage }})</span>
<span :class="[userinfo.unreadMessageCount > 0 && selectedTab !== 'message' ? 'text-red-500' : '']">消息({{ userinfo._count.ReceiveMessage }})</span>
</UBadge>
</NuxtLink>
<NuxtLink
Expand Down
14 changes: 11 additions & 3 deletions server/api/manage/testEmail.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ interface TestEmailRequest {
export default defineEventHandler(async (event) => {
const request = (await readBody(event)) as TestEmailRequest
const message = await sendMailWithParams({ ...request.email, subject: 'Discussion 测试邮件 Test Email', html: '这是一封测试邮件 This is a test email' }, request.url)
return {
success: message === '',
message,
if (message) {
return {
success: false,
message,
}
}
else {
return {
success: true,
message: '发送成功',
}
}
})
5 changes: 3 additions & 2 deletions server/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ export async function sendTgMessage(sysConfigDTO: SysConfigDTO, chatId: string |
url = url.substring(0, url.length - 1)
}
const target = `${url}/bot${sysConfigDTO.notify.tgBotToken}/sendMessage`
console.log(new Date(), '开始发送tg消息通知,chatId:', chatId, 'message:', message, target)
const escapeMessage = message.replace(/[_*[\]()~`>#+=|{}.!-]/g, '\\$&')
console.log(new Date(), '开始发送tg消息通知,chatId:', chatId, 'message:', escapeMessage, target)
try {
const res = await fetch(target, {
method: 'POST',
body: JSON.stringify({
chat_id: chatId,
text: message,
text: escapeMessage,
parse_mode: 'MarkdownV2',
}),
headers: {
Expand Down
1 change: 1 addition & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export interface PostDTO {

export interface SysConfigDTO {
websiteName: string
favicon: string
websiteUrl: string
webBgimage: string
websiteKeywords: string
Expand Down

0 comments on commit ab49d89

Please sign in to comment.