Skip to content

Commit

Permalink
调整环境变量
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry committed Apr 24, 2024
1 parent 4611c8c commit b5ccc47
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 37 deletions.
6 changes: 3 additions & 3 deletions components/FriendsCommentInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const saveComment = async () => {
toast.warning('先填写评论')
return
}
if (content.value.length > parseInt(config.public.commentMaxLength)) {
if (content.value.length > parseInt(config.public.momentsCommentMaxLength)) {
toast.warning('评论超长')
return
}
Expand All @@ -86,11 +86,11 @@ const saveComment = async () => {
return
}
if (config.public.recaptchaV3SiteKey) {
if (config.public.googleRecaptchaSiteKey) {
//@ts-ignore
grecaptcha.ready(function () {
//@ts-ignore
grecaptcha.execute(config.public.recaptchaV3SiteKey, { action: 'submit' }).then(async function (token) {
grecaptcha.execute(config.public.googleRecaptchaSiteKey, { action: 'submit' }).then(async function (token) {
submitComment(token)
});
});
Expand Down
16 changes: 8 additions & 8 deletions components/FriendsMemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<div>{{ likeList.findIndex((id) => id === props.memo.id) >= 0 ? '取消' : '赞' }}</div>
</div>

<div class="flex flex-row gap-2 cursor-pointer items-center" v-if="config.public.commentEnable === 'true'"
@click="showCommentInput = !showCommentInput; showUserCommentArray = []; showToolbar = false">
<div class="flex flex-row gap-2 cursor-pointer items-center" v-if="config.public.momentsCommentEnable === 'true'"
@click="momentsShowCommentInput = !momentsShowCommentInput; showUserCommentArray = []; showToolbar = false">
<MessageSquareMore :size=14 />
<div>评论</div>
</div>
Expand All @@ -106,13 +106,13 @@
<Heart :size=14 color="#C64A4A" />
<div class="text-[#576b95]"><span class="mx-1">{{ props.memo.favCount }}</span>位访客赞过</div>
</div>
<FriendsCommentInput :memoId="props.memo.id" @commentAdded="refreshComment" v-if="showCommentInput" />
<template v-if="props.memo.comments.length > 0 && config.public.showComment === 'true'">
<FriendsCommentInput :memoId="props.memo.id" @commentAdded="refreshComment" v-if="momentsShowCommentInput" />
<template v-if="props.memo.comments.length > 0 && config.public.momentsShowComment === 'true'">
<div class="px-4 py-2 flex flex-col gap-1">
<div class="relative flex flex-col gap-2 text-sm" v-for="(comment, index) in props.memo.comments"
:key="index">
<Comment :comment="comment" @memo-update="refreshComment" :index="index"
@comment-started="showCommentInput = false" />
@comment-started="momentsShowCommentInput = false" />
</div>
<div v-if="props.memo._count.comments > 5 && props.showMore" class="text-[#576b95] cursor-pointer"
@click="navigateTo(`/detail/${props.memo.id}`)">查看更多...</div>
Expand Down Expand Up @@ -155,13 +155,13 @@ const props = withDefaults(
const config = useRuntimeConfig()
const emit = defineEmits(['memo-update'])
const maxLine = config.public.maxLine
const maxLine = config.public.momentsMaxLine
const maxHeight = ref(24 * parseInt(maxLine))
const showAll = ref(false)
const showToolbar = ref(false)
const showCommentInput = ref(false)
const momentsShowCommentInput = ref(false)
const toolbarRef = ref(null)
const showUserCommentArray = useState<Array<boolean>>('showUserCommentArray_' + props.memo.id, () => [])
const el = ref<any>(null)
Expand Down Expand Up @@ -234,7 +234,7 @@ const editMemo = async () => {
const refreshComment = async () => {
emit('memo-update', props.memo)
showUserCommentArray.value = []
showCommentInput.value = false
momentsShowCommentInput.value = false
}
Expand Down
6 changes: 3 additions & 3 deletions components/MemoInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<input type="file" id="imgUpload" class="hidden" name="file" @change="uploadImgs">
</Label>

<Popover :open="music163Open" v-if="config.public.toolbarEnableMusic163==='true'">
<Popover :open="music163Open" v-if="config.public.momentsToolbarEnableMusic163==='true'">
<PopoverTrigger as="div">
<TooltipProvider>
<Tooltip>
Expand Down Expand Up @@ -75,7 +75,7 @@
</Popover>


<Popover :open="bilibiliOpen" v-if="config.public.toolbarEnableVideo==='true'">
<Popover :open="bilibiliOpen" v-if="config.public.momentsToolbarEnableVideo==='true'">
<PopoverTrigger as="div">
<TooltipProvider>
<Tooltip>
Expand Down Expand Up @@ -117,7 +117,7 @@
</PopoverContent>
</Popover>

<Popover :open="doubanOpen" v-if="config.public.toolbarEnableDouban==='true'">
<Popover :open="doubanOpen" v-if="config.public.momentsToolbarEnableDouban==='true'">
<PopoverTrigger as="div">
<TooltipProvider>
<Tooltip>
Expand Down
15 changes: 8 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ declare module 'nuxt/schema' {
interface RuntimeConfig {
}
interface PublicRuntimeConfig {
showComment:string
commentEnable:string
commentOrderBy:string
commentMaxLength:string
toolbarEnableDouban:string
toolbarEnableMusic163:string
toolbarEnableVideo:string
momentsShowComment:string
momentsCommentEnable:string
momentsCommentOrderBy:string
momentsCommentMaxLength:string
momentsToolbarEnableDouban:string
momentsToolbarEnableMusic163:string
momentsToolbarEnableVideo:string
momentsMaxLine:string
}
}
// It is always important to ensure you import/export something when augmenting a type
Expand Down
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ useHead({
]
})
if (config.public.recaptchaV3SiteKey) {
if (config.public.googleRecaptchaSiteKey) {
useHead({
script: [
{
Expand Down
20 changes: 10 additions & 10 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
export default defineNuxtConfig({
devtools: { enabled: false },
runtimeConfig: {
recaptchaV3secretKey: process.env.NUXT_GOOGLE_RECAPTCHA_SECRET_KEY || "",
googleRecaptchaSecretKey: process.env.NUXT_GOOGLE_RECAPTCHA_SECRET_KEY || "",
public: {
commentEnable:process.env.NUXT_MOMENTS_COMMENT_ENABLE || "true",
showComment:process.env.NUXT_MOMENTS_SHOW_COMMENT || "true",
commentMaxLength: process.env.NUXT_MOMENTS_COMMENT_MAX_LENGTH || "120",
commentOrderBy: process.env.NUXT_MOMENTS_COMMENT_ORDER_BY || "desc",
toolbarEnableDouban: process.env.NUXT_MOMENTS_TOOLBAR_ENABLE_DOUBAN || "true",
toolbarEnableMusic163: process.env.NUXT_MOMENTS_TOOLBAR_ENABLE_MUSIC163 || "true",
toolbarEnableVideo: process.env.NUXT_MOMENTS_TOOLBAR_ENABLE_VIDEO || "true",
maxLine: process.env.NUXT_MOMENTS_MAX_LINE || "4",
recaptchaV3SiteKey: process.env.NUXT_GOOGLE_RECAPTCHA_SITE_KEY || "",
momentsCommentEnable: "true",
momentsShowComment:"true",
momentsCommentMaxLength: "120",
momentsCommentOrderBy: "desc",
momentsToolbarEnableDouban: "true",
momentsToolbarEnableMusic163: "true",
momentsToolbarEnableVideo: "true",
momentsMaxLine: "4",
googleRecaptchaSiteKey: "",
},
},
modules: ["@nuxtjs/tailwindcss", "shadcn-nuxt", "@nuxtjs/color-mode"],
Expand Down
8 changes: 4 additions & 4 deletions server/api/comment/save.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export default defineEventHandler(async (event) => {
const { content, email, username, website, token } = request;

const userId = event.context.userId;
if (config.recaptchaV3secretKey && !token) {
if (config.googleRecaptchaSecretKey && !token) {
return { success: false, message: "小样儿,你是不是人机?" };
}
if (content.length > parseInt(config.public.commentMaxLength)) {
if (content.length > parseInt(config.public.momentsCommentMaxLength)) {
return { success: false, message: "评论超长了,老板" };
}
if (username.length > 10) {
Expand All @@ -55,9 +55,9 @@ export default defineEventHandler(async (event) => {
return { success: false, message: "网站地址也没这么长的啊" };
}

if (config.recaptchaV3secretKey) {
if (config.googleRecaptchaSecretKey) {
const response = (await $fetch(
`https://recaptcha.net/recaptcha/api/siteverify?secret=${config.recaptchaV3secretKey}&response=${token}`
`https://recaptcha.net/recaptcha/api/siteverify?secret=${config.googleRecaptchaSecretKey}&response=${token}`
)) as any as recaptchaResponse;
if (response.score > 0.5) {
await insertComment(userId, request);
Expand Down
2 changes: 1 addition & 1 deletion server/api/memo/list.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineEventHandler(async (event) => {
comments: {
//@ts-ignore
orderBy: {
createdAt: config.public.commentOrderBy,
createdAt: config.public.momentsCommentOrderBy,
},
take: 5,
},
Expand Down

0 comments on commit b5ccc47

Please sign in to comment.