mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-07-04 14:19:19 +00:00
优化html
This commit is contained in:
parent
8e431210b4
commit
dff78a21d1
@ -5,6 +5,7 @@ import screenshot from '../lib/rss/screenshot.js';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import rssCache from '../lib/rss/rssCache.js';
|
import rssCache from '../lib/rss/rssCache.js';
|
||||||
import schedule from 'node-schedule';
|
import schedule from 'node-schedule';
|
||||||
|
import tools from '../components/tool.js';
|
||||||
|
|
||||||
export default class RssPlugin extends plugin {
|
export default class RssPlugin extends plugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -149,6 +150,15 @@ export default class RssPlugin extends plugin {
|
|||||||
const post = newItems[0];
|
const post = newItems[0];
|
||||||
const tempPath = path.join(process.cwd(), 'data', `rss-${Date.now()}.png`);
|
const tempPath = path.join(process.cwd(), 'data', `rss-${Date.now()}.png`);
|
||||||
if (feed.screenshot) {
|
if (feed.screenshot) {
|
||||||
|
await Bot.pickGroup(groupId)?.sendMsg(
|
||||||
|
`${configControl.get('nickName')}发现了一条新的rss推送!`
|
||||||
|
);
|
||||||
|
await tools.sleep(1000);
|
||||||
|
//await Bot.pickGroup(groupId)?.sendMsg(`让${configControl.get('nickName')}看看内容是什么..`);
|
||||||
|
// TODO 通过人工智能查看内容
|
||||||
|
await Bot.pickGroup(groupId)?.sendMsg(
|
||||||
|
`[标题] ${post.title}\n[作者] ${post.author}\n[来源} ${post.feedTitle}\n正在努力截图..`
|
||||||
|
);
|
||||||
await screenshot.generateScreenshot(post, tempPath);
|
await screenshot.generateScreenshot(post, tempPath);
|
||||||
await Bot.pickGroup(groupId)?.sendMsg([segment.image(tempPath)]);
|
await Bot.pickGroup(groupId)?.sendMsg([segment.image(tempPath)]);
|
||||||
fs.unlinkSync(tempPath);
|
fs.unlinkSync(tempPath);
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
|
||||||
|
<script>hljs.highlightAll();</script>
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-family: "Helvetica Neue", sans-serif;
|
font-family: "Helvetica Neue", sans-serif;
|
||||||
color: #fff;
|
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,9 +37,24 @@
|
|||||||
backdrop-filter: blur(18px);
|
backdrop-filter: blur(18px);
|
||||||
-webkit-backdrop-filter: blur(18px);
|
-webkit-backdrop-filter: blur(18px);
|
||||||
box-shadow: 0 10px 25px rgba(0,0,0,0.4);
|
box-shadow: 0 10px 25px rgba(0,0,0,0.4);
|
||||||
border: 1.5px solid rgba(76, 175, 80, 0.7); /* 绿色边框 */
|
border: 1.5px solid rgba(76, 175, 80, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container pre code {
|
||||||
|
font-family: 'Fira Code', 'Courier New', monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 16px;
|
||||||
|
display: block;
|
||||||
|
overflow-x: auto;
|
||||||
|
background: rgba(0, 0, 0, 0.11);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
color: #f8f8f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
font-size: 26px;
|
font-size: 26px;
|
||||||
|
@ -26,7 +26,7 @@ const screenshot = {
|
|||||||
});
|
});
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.setContent(html, { waitUntil: 'networkidle0' });
|
await page.setContent(html, { waitUntil: 'networkidle0' });
|
||||||
await page.setViewport({ width: 800, height: 600 });
|
await page.setViewport({ width: 800, height: 600, deviceScaleFactor: 1.5 });
|
||||||
await page.screenshot({ path: savePath, fullPage: true });
|
await page.screenshot({ path: savePath, fullPage: true });
|
||||||
await browser.close();
|
await browser.close();
|
||||||
return savePath;
|
return savePath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user