1 Commits

Author SHA1 Message Date
hackrobot
c9d4450a7c uopdate
Some checks failed
Test / test (macos-latest) (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
Test / test (windows-latest) (push) Has been cancelled
2024-08-12 08:58:18 +08:00

View File

@@ -42,18 +42,12 @@ import TextArea from 'antd/es/input/TextArea';
const createDecoratedTitleHTML = (text: any) => { const createDecoratedTitleHTML = (text: any) => {
const padding = 2; // 内容左右两边的空格数 const padding = 2; // 内容左右两边的空格数
const lineChar = '─'; // 水平线字符 const lineChar = '─'; // 水平线字符
const edgeChar = ''; // 边框装饰字符 const edgeChar = ''; // 边框装饰字符
// const edgeChar = '━'; // 边框装饰字符 const cornerTopLeft = '╔';
// const cornerTopLeft = '╔'; const cornerTopRight = '╗';
// const cornerTopRight = '╗'; const cornerBottomLeft = '╚';
// const cornerBottomLeft = '╚'; const cornerBottomRight = '╝';
// const cornerBottomRight = '╝';
const cornerTopLeft = '╭'; // 顶部左角
const cornerTopRight = '╮'; // 顶部右角
const cornerBottomLeft = '╰'; // 底部左角
const cornerBottomRight = '╯'; // 底部右角
// 计算标题长度 // 计算标题长度
const titleLength = text.length + padding * 2; const titleLength = text.length + padding * 2;
@@ -64,11 +58,9 @@ const createDecoratedTitleHTML = (text: any) => {
const topBorder = `${cornerTopLeft}${edgeLength}${cornerTopRight}`; const topBorder = `${cornerTopLeft}${edgeLength}${cornerTopRight}`;
const bottomBorder = `${cornerBottomLeft}${edgeLength}${cornerBottomRight}`; const bottomBorder = `${cornerBottomLeft}${edgeLength}${cornerBottomRight}`;
const middleLine = ` 📢 ${text}`; const middleLine = ` 📢 ${text}`;
// const middleLine = ` ⚡ ${text}`;
// return `<div>${topBorder}\n${middleLine}\n${bottomBorder}</div>\n`;
return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div>`; return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div>\n`;
// return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div><br/>`;
}; };
marked.setOptions({ marked.setOptions({
@@ -108,74 +100,60 @@ renderer.image = function (href, title, text) {
return `<img width="300px" src="${href}" alt="${text}"/>`; return `<img width="300px" src="${href}" alt="${text}"/>`;
}; };
// let listSinbal="▫️ "
let listSinbal = '🔸'; let listSinbal = '🔸';
// 有序列表 // 有序列表
renderer.list = function (body, ordered, start) { renderer.list = function (body, ordered, start) {
// console.log("body,ordered, start", body, ordered, start);
const type = ordered ? 'ol' : 'ul'; const type = ordered ? 'ol' : 'ul';
// console.log("type===>", type);
const startatt = ordered && start !== 1 ? ' start="' + start + '"' : ''; const startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
// 移除 `<div>` 和 `</div>` 标签
const cleanedBody = body.replace(/<\/?div>/g, '');
// 正则表达式匹配每个以 <br/> 结尾的列表项
const regex = /([^<]*)<br\/?>/g;
const input = cleanedBody;
// 正则取值 // 正则取值
// // const regex = /▫️\s*(.*?)<br\/?>/g; // const regex = /▫️\s*(.*?)<br\/?>/g;
// const regex = /([^<]*)<br\/?>/g; // const regex = /([^<]*)<br\/?>/g;
// const input = body; const regex = /([^\n]*)\n/g;
// console.log('input--', input);
const input = body;
const matches = [...input.matchAll(regex)]; const matches = [...input.matchAll(regex)];
console.log('matches--', matches);
const texts = matches.map((match) => match[1]); const texts = matches.map((match) => match[1]);
console.log('texts===>', texts); // 输出: ["测试111", "测试222", "if"] // 不含▫️的元素数量
// const diffcCount=texts.length-texts.filter(item => item.includes('▫️')).length;
// console.log("texts===>", texts); // 输出: ["测试111", "测试222", "if"]
const newArray = texts.filter((item) => item.includes(listSinbal)); const newArray = texts.filter((item) => item.includes(listSinbal));
// 0⃣',
const numbers = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🔟']; const numbers = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🔟'];
// ┊ │ ╏
const string = texts const string = texts
.map((value, index) => { .map((value, index) => {
console.log('value--', value); // console.log("value, index==>", value, index);
// 判断是否是任务 // ${ value.indexOf("▫️ ") === -1 ? '<br/><span>111</sapn>' : ""}
let task = false;
if (value.includes('🔸⬜') || value.includes('🔸✅')) {
task = true;
}
return value.indexOf(listSinbal) !== -1 return value.indexOf(listSinbal) !== -1
? `<div>${ ? `<div>${
type === 'ol' type === 'ol' ? numbers[newArray.indexOf(value)] : listSinbal
? numbers[newArray.indexOf(value)]
: task
? ''
: listSinbal
}${value.replace(listSinbal, '')} </div>` }${value.replace(listSinbal, '')} </div>`
: `<div style="white-space:pre;">&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;┊ ${value}</div>`; : `<div style="white-space:pre;">\t${value}</div>`;
}) })
.join(''); .join('');
// return `1⃣`
// console.log("string===>", string);
return `${string}`; return `${string}`;
}; };
// 示例输入
const input = `🔸11<br/>🔸22<br/><br/>🔸33`;
console.log(renderer.list(input, false, 1));
// 无序列表 ▫️ // 无序列表 ▫️
renderer.listitem = function (text, task, checked) { renderer.listitem = function (text, task, checked) {
// return `<li>${text}</li>\n`; // return `<li>${text}</li>\n`;
return `${listSinbal}${text}<br/>`; // return `${listSinbal}${text}<br/>`;
return `${listSinbal}${text}\n`; return `${listSinbal}${text}\n`;
// return `${listSinbal}${text}\n`;
// return `${text}<br/>`; // return `${text}<br/>`;
}; };
// 任务列表 // 任务列表
renderer.checkbox = function (checked) { renderer.checkbox = function (checked) {
// ✅❌ // ✅❌
return !!checked ? '✅' : ''; return !!checked ? '✅' : '';
return ( return (
'<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox">' '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox">'
); );
@@ -190,16 +168,13 @@ renderer.heading = function (text, level, raw) {
if (level == 1) { if (level == 1) {
return createDecoratedTitleHTML(text); return createDecoratedTitleHTML(text);
} else if (level == 2) { } else if (level == 2) {
return `<div>📝${text}</div>\n`; return `<div>🔥${text}</div>\n`;
// return `<div>🔥${text}</div><br>`;
} else { } else {
return `<div>📝${text}</div>\n`; return `<div>🔥${text}</div>\n`;
// return `<div>🔥${text}</div><br>`;
} }
return `<div>╔═━──────━═╗<br/>
🔥 ${text}<br/>
╚═━──────━═╝
</div>\n`;
// return `<div>* * * * * * * * * * *<br/> // return `<div>* * * * * * * * * * *<br/>
// * ${text} *<br/> // * ${text} *<br/>
// * * * * * * * * * * * // * * * * * * * * * * *
@@ -251,8 +226,8 @@ renderer.blockquote = function (quote) {
// &nbsp; // &nbsp;
// return `<span style="white-space:pre;" class="blockquote">\t 👉${content}</span><br/> ` // return `<span style="white-space:pre;" class="blockquote">\t 👉${content}</span><br/> `
// return `<div style="white-space:pre;" class="blockquote">\t 📌${content}</div>\n`; //ok // return `<div style="white-space:pre;" class="blockquote">\t 📌${content}</div>\n`; //ok
// ├─ // ├─
return `<div style="white-space:pre;" class="blockquote">&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;└─${content}</div>`; return `<div style="white-space:pre;" class="blockquote">&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;&#8239;└─📌${content}</div>`;
}; };
renderer.table = function (header, body) { renderer.table = function (header, body) {
@@ -293,22 +268,22 @@ renderer.link = function (href, title, text) {
return text; return text;
} }
href = cleanHref; href = cleanHref;
console.log('href-', href);
let out = '<a href="' + href + '"'; let out = '<a href="' + href + '"';
if (title) { if (title) {
out += ' title="' + title + '"'; out += ' title="' + title + '"';
} }
out += '>' + `🔗` + text + '</a>'; out += '>' + `🌐` + text + '</a>';
// out += ">" +`🔗`+ text + "</a>"+`(${href})`; // out += ">" +`🌐`+ text + "</a>"+`(${href})`;
// console.log('out-',out)
return out + `: ${href}`; return out;
}; };
renderer.paragraph = function (text) { renderer.paragraph = function (text) {
// return `<p>${text}</p>\n`; // return `<p>${text}</p>\n`;
// return `<p>${text}</p>`; // return `<p>${text}</p>`;
return `<div>${text}</div>`; // return `<div>${text}</div>`;
// return `<div>${text}</div><br>`;
return `<div>${text}</div>\n`;
}; };
renderer.br = function () { renderer.br = function () {
return '<br>'; return '<br>';
@@ -357,36 +332,34 @@ const Index = () => {
// ` // `
// │ 💬 随时欢迎聊天 // │ 💬 随时欢迎聊天
// let contactMe = `<br>╭────────────────╮ // let contactMe = `<br>╭────────────────╮
// │ 🟩【wΞ𝗫𝗜𝗡】➡联系我【🅥】 // │ 🟩【wΞ𝗫𝗜𝗡】➡联系我【🅥】
// │ // │
// │ 🆔 hackrobot // │ 🆔 hackrobot
// ╰────────────────╯<br>💬 随时欢迎聊天`; // ╰────────────────╯<br>💬 随时欢迎聊天`;
// let contactMe = `<br><br>💬 欢迎交流<br>后台私信发送关键词: 加群`; // let contactMe = `<br>\n💬 后台发送关键词: 加群`;
let contactMe = `<br><br>©️ 本文使用🔗『mdemoji.com』 编辑 `; let contactMe = `\n💬 后台发送关键词: 加群`;
// setmarkText(value);
// setmarkText(value + contactMe);
if (value?.length < 10) { setmarkText(value + contactMe);
setmarkText(value); // if (value?.length < 10) {
} else { // setmarkText(value);
setmarkText(value + contactMe); // } else {
} // setmarkText(value + contactMe);
// }
}; };
useEffect(() => {}, []); useEffect(() => {}, []);
const copyToClipboard = () => { const copyToClipboard = () => {
if (divRef.current) { if (divRef.current) {
const htmlContentinnerHTML = divRef.current.innerHTML; // const htmlContentinnerHTML = divRef.current.innerHTML;
console.log('htmlContentinnerHTML', htmlContentinnerHTML); // console.log('htmlContentinnerHTML', htmlContentinnerHTML);
const htmlContentouterHTML = divRef.current.outerHTML; // const htmlContentouterHTML = divRef.current.outerHTML;
console.log('htmlContentouterHTML', htmlContentouterHTML); // console.log('htmlContentouterHTML', htmlContentouterHTML);
const htmlContent = divRef.current.innerText; const htmlContent = divRef.current.innerText;
// const htmlContent = divRef.current.outerHTML;
// const htmlContent = divRef.current.textContent; // const htmlContent = divRef.current.textContent;
navigator.clipboard navigator.clipboard
.writeText(htmlContent) .writeText(htmlContent)
.then(() => { .then(() => {