From 0f6e8179665db08fb42eb0465e10e2c644a8b7c6 Mon Sep 17 00:00:00 2001 From: Miao_Spring <539943419@qq.com> Date: Mon, 2 Sep 2024 21:04:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201.=E4=BC=98=E5=8C=96images=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=A1=A8=E7=8E=B0=E3=80=822.=E5=A2=9E=E5=8A=A0markdow?= =?UTF-8?q?n=E6=B5=8F=E8=A7=88=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 + pnpm-lock.yaml | 71 ++++++++++++++++ src/hooks/init.ts | 17 ++++ src/views/miaoIframe.vue | 4 +- src/views/miaoImages.vue | 169 +++++++++++++++++++++---------------- src/views/miaoMarkdown.vue | 64 ++++++++++++++ 6 files changed, 250 insertions(+), 77 deletions(-) create mode 100644 src/views/miaoMarkdown.vue diff --git a/package.json b/package.json index 4f1e8df..a554571 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "axios": "^1.7.3", "codemirror": "^6.0.1", "lodash": "^4.17.21", + "markdown-it": "^14.1.0", "naive-ui": "^2.39.0", "pdfjs-dist": "^4.5.136", "sass": "^1.77.8", @@ -37,6 +38,7 @@ }, "devDependencies": { "@types/lodash": "^4.17.7", + "@types/markdown-it": "^14.1.2", "@types/node": "^22.1.0", "@types/pdfjs-dist": "^2.10.378", "@vitejs/plugin-vue": "^5.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dfdad0b..ace6331 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,9 @@ importers: lodash: specifier: ^4.17.21 version: 4.17.21 + markdown-it: + specifier: ^14.1.0 + version: 14.1.0 naive-ui: specifier: ^2.39.0 version: 2.39.0(vue@3.4.37(typescript@5.5.4)) @@ -78,6 +81,9 @@ importers: '@types/lodash': specifier: ^4.17.7 version: 4.17.7 + '@types/markdown-it': + specifier: ^14.1.2 + version: 14.1.2 '@types/node': specifier: ^22.1.0 version: 22.1.0 @@ -480,12 +486,21 @@ packages: '@types/katex@0.16.7': resolution: {integrity: sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==} + '@types/linkify-it@5.0.0': + resolution: {integrity: sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==} + '@types/lodash-es@4.17.12': resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} '@types/lodash@4.17.7': resolution: {integrity: sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==} + '@types/markdown-it@14.1.2': + resolution: {integrity: sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==} + + '@types/mdurl@2.0.0': + resolution: {integrity: sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==} + '@types/node@22.1.0': resolution: {integrity: sha512-AOmuRF0R2/5j1knA3c6G3HOk523Ga+l+ZXltX8SF1+5oqcXijjfTd8fY3XRZqSihEu9XhtQnKYLmkFaoxgsJHw==} @@ -575,6 +590,9 @@ packages: engines: {node: '>=10'} deprecated: This package is no longer supported. + argparse@2.0.1: + resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + async-validator@4.2.5: resolution: {integrity: sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==} @@ -700,6 +718,10 @@ packages: emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + entities@4.5.0: + resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} + engines: {node: '>=0.12'} + entities@5.0.0: resolution: {integrity: sha512-BeJFvFRJddxobhvEdm5GqHzRV/X+ACeuw0/BuuxsCh1EUZcAIz8+kYmBp/LrQuloy6K1f3a0M7+IhmZ7QnkISA==} engines: {node: '>=0.12'} @@ -826,6 +848,9 @@ packages: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} + linkify-it@5.0.0: + resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} + lodash-es@4.17.21: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} @@ -839,6 +864,13 @@ packages: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} + markdown-it@14.1.0: + resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==} + hasBin: true + + mdurl@2.0.0: + resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==} + micromatch@4.0.7: resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} engines: {node: '>=8.6'} @@ -959,6 +991,10 @@ packages: proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + punycode.js@2.3.1: + resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==} + engines: {node: '>=6'} + readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -1056,6 +1092,9 @@ packages: engines: {node: '>=14.17'} hasBin: true + uc.micro@2.1.0: + resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==} + undici-types@6.13.0: resolution: {integrity: sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==} @@ -1566,12 +1605,21 @@ snapshots: '@types/katex@0.16.7': {} + '@types/linkify-it@5.0.0': {} + '@types/lodash-es@4.17.12': dependencies: '@types/lodash': 4.17.7 '@types/lodash@4.17.7': {} + '@types/markdown-it@14.1.2': + dependencies: + '@types/linkify-it': 5.0.0 + '@types/mdurl': 2.0.0 + + '@types/mdurl@2.0.0': {} + '@types/node@22.1.0': dependencies: undici-types: 6.13.0 @@ -1701,6 +1749,8 @@ snapshots: readable-stream: 3.6.2 optional: true + argparse@2.0.1: {} + async-validator@4.2.5: {} asynckit@0.4.0: {} @@ -1840,6 +1890,8 @@ snapshots: emoji-regex@8.0.0: optional: true + entities@4.5.0: {} + entities@5.0.0: {} es5-ext@0.10.64: @@ -1999,6 +2051,10 @@ snapshots: is-number@7.0.0: {} + linkify-it@5.0.0: + dependencies: + uc.micro: 2.1.0 + lodash-es@4.17.21: {} lodash@4.17.21: {} @@ -2012,6 +2068,17 @@ snapshots: semver: 6.3.1 optional: true + markdown-it@14.1.0: + dependencies: + argparse: 2.0.1 + entities: 4.5.0 + linkify-it: 5.0.0 + mdurl: 2.0.0 + punycode.js: 2.3.1 + uc.micro: 2.1.0 + + mdurl@2.0.0: {} + micromatch@4.0.7: dependencies: braces: 3.0.3 @@ -2143,6 +2210,8 @@ snapshots: proxy-from-env@1.1.0: {} + punycode.js@2.3.1: {} + readable-stream@3.6.2: dependencies: inherits: 2.0.4 @@ -2261,6 +2330,8 @@ snapshots: typescript@5.5.4: {} + uc.micro@2.1.0: {} + undici-types@6.13.0: {} util-deprecate@1.0.2: diff --git a/src/hooks/init.ts b/src/hooks/init.ts index 358db3c..a141b5c 100644 --- a/src/hooks/init.ts +++ b/src/hooks/init.ts @@ -157,4 +157,21 @@ export default function init() { return false } }) + + + pluginCenter.registerComponent({ + key: 'miaoMarkdown', + name: 'markdown浏览', + icon: DocumentText, + getComponent: async () => (await import('@/views/miaoMarkdown.vue')).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false + } + if (vFiles.length !== 1) { + return false + } + return vFiles[0].name.endsWith('md') + } + }) } diff --git a/src/views/miaoIframe.vue b/src/views/miaoIframe.vue index 75938ff..dd377aa 100644 --- a/src/views/miaoIframe.vue +++ b/src/views/miaoIframe.vue @@ -1,5 +1,5 @@