修复导出时存在 html 标签的 bug

This commit is contained in:
fofolee 2022-04-16 10:18:14 +08:00
parent 3a7085ac31
commit 6a2254f68f
2 changed files with 18 additions and 6 deletions

View File

@ -418,6 +418,10 @@ window.htmlEncode = (value) => {
return String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;")
}
window.removeHtmlTags = value => {
return quickcommand.htmlParse(value).querySelector('body').innerText
}
window.hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
window.hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
window.base64Decode = text => Buffer.from(text, 'base64').toString('utf8')

View File

@ -85,7 +85,11 @@
<q-card-section>
<!-- logo -->
<div class="row" :class="cardStyleVars.logoPosition">
<q-img width="48px" height="48px" :src="commandInfo.features.icon" />
<q-img
width="48px"
height="48px"
:src="commandInfo.features.icon"
/>
</div>
<!-- 名称 -->
<!-- mini small 模式下命令标题字体变小 -->
@ -329,21 +333,25 @@ export default {
});
});
},
getAuthedCmd() {
getRawCommand() {
let command = _.cloneDeep(this.commandInfo);
if (!command.authorName) command.authorName = utools.getUser().nickname;
command.features.explain = window.removeHtmlTags(
command.features.explain
);
return command;
},
//
exportCommandRaw() {
utools.copyText(JSON.stringify(this.getAuthedCmd(), null, 4)) &&
utools.copyText(JSON.stringify(this.getRawCommand(), null, 4)) &&
quickcommand.showMessageBox("已复制到剪贴板");
},
//
exportCommandFile() {
window.saveFile(JSON.stringify(this.getAuthedCmd()), {
window.saveFile(JSON.stringify(this.getRawCommand()), {
title: "选择保存位置",
defaultPath: `${this.getAuthedCmd().features.explain}.json`,
defaultPath: `${window.removeHtmlTags(
this.commandInfo.features.explain
)}.json`,
filters: [{ name: "json", extensions: ["json"] }],
});
},