添加评论表情、评论图床

This commit is contained in:
Han 2025-03-25 18:57:02 +08:00
parent afe1269afd
commit c7384fae1b
4 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,6 @@
.vh-comment { .vh-comment {
box-sizing: border-box; box-sizing: border-box;
padding: 2rem 1rem 1rem; padding: 2rem 1rem 2.88rem;
width: 100%; width: 100%;
height: max-content; height: max-content;
border-radius: 0.5rem; border-radius: 0.5rem;
@ -401,7 +401,7 @@
// 图片 // 图片
img { img {
&:not(.wl-user-avatar, .wl-reaction-list img) { &:not(.wl-user-avatar, .wl-reaction-list img,.wl-panel img) {
max-height: 66px; max-height: 66px;
object-fit: contain; object-fit: contain;
cursor: zoom-in; cursor: zoom-in;

View File

@ -14,7 +14,16 @@ const WalineFn = async (commentDOM: string, walineInit: any) => {
import('@waline/client/waline.css'); import('@waline/client/waline.css');
import('@waline/client/waline-meta.css'); import('@waline/client/waline-meta.css');
const { init } = await import('@waline/client'); const { init } = await import('@waline/client');
walineInit = init({ el: commentDOM, serverURL: SITE_INFO.Comment.Waline.serverURL }); walineInit = init({
el: commentDOM, serverURL: SITE_INFO.Comment.Waline.serverURL, emoji: ['https://registry.npmmirror.com/@waline/emojis/1.3.0/files/alus', 'https://registry.npmmirror.com/@waline/emojis/1.3.0/files/bilibili', 'https://registry.npmmirror.com/@waline/emojis/1.3.0/files/bmoji', 'https://registry.npmmirror.com/@waline/emojis/1.3.0/files/qq', 'https://registry.npmmirror.com/@waline/emojis/1.3.0/files/tieba', 'https://registry.npmmirror.com/@waline/emojis/1.3.0/files/weibo', 'https://registry.npmmirror.com/@waline/emojis/1.3.0/files/soul-emoji'],
imageUploader: async (file: any) => {
const body = new FormData();
body.append('file', file);
const res = await fetch("https://wp-cdn.4ce.cn/upload", { method: "POST", body });
const resJson = await res.json();
return resJson.data.link.replace('i.imgur.com', 'wp-cdn.4ce.cn/v2');
}
});
} }
// 检查是否开启评论 // 检查是否开启评论
@ -26,10 +35,11 @@ const checkComment = () => {
// 初始化评论插件 // 初始化评论插件
const commentInit = async (key: string, walineInit: any) => { const commentInit = async (key: string, walineInit: any) => {
// 评论列表
const CommentList: any = { TwikooFn, WalineFn };
// 评论 DOM // 评论 DOM
const commentDOM = '.vh-comment>section' const commentDOM = '.vh-comment>section'
if (!document.querySelector(commentDOM)) return;
// 评论列表
const CommentList: any = { TwikooFn, WalineFn };
// 初始化评论 // 初始化评论
CommentList[`${key}Fn`](commentDOM, walineInit); CommentList[`${key}Fn`](commentDOM, walineInit);
} }

View File

@ -1,5 +1,5 @@
import vh from 'vh-plugin' import vh from 'vh-plugin';
import { fmtDate } from '@/utils/index' import { fmtDate } from '@/utils/index'
import { $GET } from '@/utils/index' import { $GET } from '@/utils/index'
// 图片懒加载 // 图片懒加载

View File

@ -10,7 +10,7 @@ const ViewImgList: string[] = [
// Twikoo 评论区图片 // Twikoo 评论区图片
".vh-comment>.twikoo>.tk-comments img:not(.tk-avatar-img,.tk-owo-emotion,.OwO-item img)", ".vh-comment>.twikoo>.tk-comments img:not(.tk-avatar-img,.tk-owo-emotion,.OwO-item img)",
// Waline 评论区图片 // Waline 评论区图片
".vh-comment div[data-waline] img:not(.wl-user-avatar,.wl-avatar img,.wl-reaction-list img)" ".vh-comment div[data-waline] img:not(.wl-user-avatar,.wl-avatar img,.wl-reaction-list img,.wl-panel img)"
]; ];
// 初始化 // 初始化
export default async () => { export default async () => {