From 253ded33bf236e59118d23358c2b5624bb4b8cbd Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sun, 8 Oct 2023 09:32:07 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E8=B6=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E5=A2=9E=E5=8A=A0=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Edit/components/NodeHyperlink.vue | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/web/src/pages/Edit/components/NodeHyperlink.vue b/web/src/pages/Edit/components/NodeHyperlink.vue index 0ce20506..0692b0e0 100644 --- a/web/src/pages/Edit/components/NodeHyperlink.vue +++ b/web/src/pages/Edit/components/NodeHyperlink.vue @@ -13,7 +13,14 @@ placeholder="http://xxxx.com/" @keyup.native.stop @keydown.native.stop - > + @blur="handleUrl()" + > + + + + + +
{{ $t('nodeHyperlink.name') }} @@ -46,7 +53,8 @@ export default { dialogVisible: false, link: '', linkTitle: '', - activeNodes: [] + activeNodes: [], + protocol: 'https' } }, created() { @@ -63,6 +71,7 @@ export default { if (this.activeNodes.length > 0) { let firstNode = this.activeNodes[0] this.link = firstNode.getData('hyperlink') + this.handleUrl(true) this.linkTitle = firstNode.getData('hyperlinkTitle') } else { this.link = '' @@ -70,6 +79,20 @@ export default { } }, + removeProtocol(url) { + return url.replace(/^https?:\/\//, '') + }, + + handleUrl(setProtocolNoneIfNotExist) { + const res = this.link.match(/^(https?):\/\//) + if (res && res[1]) { + this.protocol = res[1] + } else if (setProtocolNoneIfNotExist) { + this.protocol = 'none' + } + this.link = this.removeProtocol(this.link) + }, + handleShowNodeLink() { this.activeNodes[0].mindMap.keyCommand.pause() this.$bus.$emit('startTextEdit') @@ -94,7 +117,10 @@ export default { */ confirm() { this.activeNodes.forEach(node => { - node.setHyperlink(this.link, this.linkTitle) + node.setHyperlink( + (this.protocol === 'none' ? '' : this.protocol + '://') + this.link, + this.linkTitle + ) this.cancel() }) }