3.0.0原版

This commit is contained in:
anian
2026-03-16 00:03:35 +08:00
commit ac569b2a57
105 changed files with 14437 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
{
"scripts": {
"build": "tsc && rslib build",
"dev": "rslib build --watch"
},
"dependencies": {
"@halo-dev/comment-widget": "workspace:*"
},
"devDependencies": {
"@rslib/core": "^0.12.1"
}
}
+32
View File
@@ -0,0 +1,32 @@
import { fileURLToPath } from 'node:url';
import { defineConfig } from '@rslib/core';
const PLUGIN_NAME = 'PluginCommentWidget';
export default defineConfig({
lib: [
{
format: 'esm',
autoExternal: false,
},
],
output: {
target: 'web',
minify: true,
cleanDistPath: true,
filename: {
js: (pathData) => {
if (pathData.chunk.name === 'index') {
return 'comment-widget.js';
}
return '[name].[contenthash:8].js';
},
},
publicPath: `/plugins/${PLUGIN_NAME}/assets/static/`,
distPath: {
root: fileURLToPath(
new URL('../../src/main/resources/static', import.meta.url)
),
},
},
});
+1
View File
@@ -0,0 +1 @@
/// <reference types="@rslib/core/types" />
+41
View File
@@ -0,0 +1,41 @@
import { CommentWidget } from '@halo-dev/comment-widget';
import '@halo-dev/comment-widget/var.css';
export { CommentWidget };
interface Props {
group: string;
kind: string;
name: string;
}
export function init(el: string, props: Props) {
const parent = document.querySelector(el) as HTMLElement;
if (!parent) {
console.error('Element not found', el);
}
const commentWidget = document.createElement(
'comment-widget'
) as CommentWidget;
commentWidget.kind = props.kind;
commentWidget.group = props.group;
commentWidget.version = 'v1alpha1';
commentWidget.name = props.name;
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting && parent.childElementCount === 0) {
parent.appendChild(commentWidget);
parent.animate([{ opacity: 0 }, { opacity: 1 }], {
duration: 300,
fill: 'forwards',
});
}
});
});
observer.observe(parent as Element);
}
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src"]
}