-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
619 additions
and
25 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 以下内容来自 https://github.com/xiyuesaves/LiteLoaderQQNT-lite_tools/blob/v4/src/render_modules/openChangeLog.js | ||
const updateMsgBox = ` | ||
<div class="lite-tools-mask"> | ||
<div class="lite-tools-update-msg-box"> | ||
<div class="title" title="{{title}}">{{title}}</div> | ||
<div class="context">{{context}}</div> | ||
<div class="bottom-solt"> | ||
<button class="q-button q-button--small q-button--primary update-btn">更新</button> | ||
<!-- <button class="q-button q-button--small q-button--secondary detail-btn">详情</button> --> | ||
<button class="q-button q-button--small q-button--secondary quite-btn">返回</button> | ||
</div> | ||
</div> | ||
</div>`; | ||
|
||
/** | ||
* 显示更新日志,该模块只能在设置页面使用 | ||
* @param {String} html html字符串 | ||
* @param {Boolean} showDownloadBtn 是否显示下载按钮 | ||
*/ | ||
function openChangeLog(html) { | ||
const newMsgBox = updateMsgBox.replace(/\{\{([^}]+)\}\}/g, (match, name) => { | ||
switch (name) { | ||
case "title": | ||
return "更新日志"; | ||
case "context": | ||
return html; | ||
default: | ||
return name; | ||
} | ||
}); | ||
document.querySelector(".update-view.plugininstaller").insertAdjacentHTML("beforeend", newMsgBox); | ||
const showMsgBox = document.querySelector(".lite-tools-mask"); | ||
showMsgBox.offsetHeight; | ||
showMsgBox.classList.add("show"); | ||
showMsgBox.querySelector(".quite-btn").addEventListener("click", () => { | ||
showMsgBox.addEventListener("transitionend", () => { | ||
showMsgBox.remove(); | ||
}); | ||
showMsgBox.classList.remove("show"); | ||
}); | ||
showMsgBox.querySelector(".update-btn").addEventListener("click", () => { | ||
showMsgBox.addEventListener("transitionend", () => { | ||
showMsgBox.remove(); | ||
}); | ||
showMsgBox.classList.remove("show"); | ||
plugininstaller.openPluginInfoWindow(); | ||
//lite_tools.updatePlugins(updateUrl); | ||
}); | ||
//showMsgBox.querySelector(".detail-btn").addEventListener("click", () => { | ||
// lite_tools.openWeb(detailUrl); | ||
//}); | ||
} | ||
export { openChangeLog }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// 以下内容来自 https://github.com/xiyuesaves/LiteLoaderQQNT-lite_tools/blob/v4/src/render_modules/simpleMarkdownToHTML.js | ||
/** | ||
* markdown转换为html | ||
* @param {String} markdown markdown字符串 | ||
* @returns | ||
*/ | ||
function simpleMarkdownToHTML(markdown, repository) { | ||
const strs = markdown.split("\n"); | ||
let ulStack = 0; | ||
let inBlockquote = 0; | ||
|
||
return strs | ||
.map((md) => { | ||
// Headers | ||
md = md.replace(/^# (.*$)/gim, "<h1>$1</h1>"); | ||
md = md.replace(/^## (.*$)/gim, "<h2>$1</h2>"); | ||
md = md.replace(/^### (.*$)/gim, "<h3>$1</h3>"); | ||
md = md.replace(/^#### (.*$)/gim, "<h4>$1</h4>"); | ||
|
||
// Inline code | ||
md = md.replace(/`(.*?)`/g, "<code>$1</code>"); | ||
|
||
// Bold and Italic | ||
md = md.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>"); | ||
md = md.replace(/\*(.*?)\*/g, "<em>$1</em>"); | ||
|
||
// Strikethrough | ||
md = md.replace(/~~(.*?)~~/g, "<del>$1</del>"); | ||
|
||
// Images | ||
md = md.replace(/!\[(.*?)\]\((.*?)\)/g, '<img src="$2" alt="$1">'); | ||
|
||
// Links | ||
md = md.replace(/\[(.*?)\]\((.*?)\)/g, '<a data-href="$2">$1</a>'); | ||
|
||
// GitHub Issue Links | ||
md = md.replace(/#(\d+)/g, `<a data-href="https://github.com/${repository}/issues/$1">#$1</a>`); | ||
|
||
md = md.replace(/@(\S+)/g, '<a data-href="https://github.com/$1">@$1</a>'); | ||
|
||
md = md.replace(/^\s*-\s(.*)$/gim, "<li>$1</li>"); | ||
|
||
if (md.includes("<li>") && ulStack) { | ||
md = `<ul>\n${md}`; | ||
ulStack++; | ||
} | ||
|
||
if (!md.includes("</li>") && !ulStack) { | ||
md = `</ul>\n${md}`; | ||
ulStack--; | ||
} | ||
|
||
// 引用 | ||
if (/^\s*>/.test(md)) { | ||
const str = md.replace(/^\s*> ?/, "").replace(/\\/, ""); | ||
if (!inBlockquote) { | ||
md = `<div class="markdown-alert ${getAlertType(str)}">\n${isTitle(str)}`; | ||
inBlockquote++; | ||
} else { | ||
md = "<br>" + str; | ||
} | ||
} else if (inBlockquote) { | ||
md = `</div>\n${md}`; | ||
inBlockquote--; | ||
} | ||
|
||
return md; | ||
}) | ||
.join(""); | ||
} | ||
|
||
function getAlertType(str) { | ||
const alertTypeMap = { | ||
"[!NOTE]": "markdown-alert-note", | ||
"[!IMPORTANT]": "markdown-alert-important", | ||
"[!WARNING]": "markdown-alert-warning", | ||
"[!TIP]": "markdown-alert-tip", | ||
"[!CAUTION]": "markdown-alert-caution", | ||
}; | ||
|
||
return alertTypeMap[str.trim()] || ""; | ||
} | ||
|
||
function isTitle(str) { | ||
const titleMap = { | ||
"[!NOTE]": "Note", | ||
"[!IMPORTANT]": "Important", | ||
"[!WARNING]": "Warning", | ||
"[!TIP]": "Tip", | ||
"[!CAUTION]": "Caution", | ||
}; | ||
|
||
const trimmedStr = str.trim(); | ||
const title = titleMap[trimmedStr]; | ||
|
||
if (title) { | ||
return `<p class="markdown-alert-title">${title}</p>`; | ||
} | ||
|
||
return str; | ||
} | ||
|
||
export { simpleMarkdownToHTML }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.