mdk-skills 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,115 +0,0 @@
1
- <template>
2
- <div class="readme-view">
3
- <div class="page-header">
4
- <h2>CLAUDE.md 文档</h2>
5
- <n-button size="small" @click="loadClaudeMd">
6
- <template #icon><n-icon><RefreshOutline /></n-icon></template>
7
- 刷新
8
- </n-button>
9
- </div>
10
-
11
- <n-spin :show="loading">
12
- <transition name="fade">
13
- <div v-if="content" class="markdown-content" v-html="rendered" />
14
- <n-empty v-else-if="loaded" description="暂无 CLAUDE.md 文档" />
15
- </transition>
16
- </n-spin>
17
- </div>
18
- </template>
19
-
20
- <script setup>
21
- import { ref, onMounted, nextTick } from "vue";
22
- import { NIcon } from "naive-ui";
23
- import { RefreshOutline } from "@vicons/ionicons5";
24
- import { marked } from "marked";
25
- import hljs from "highlight.js";
26
- import { getClaudeMd } from "../api/skills";
27
-
28
- // marked 配置:代码高亮 + 外链安全
29
- marked.use({
30
- renderer: {
31
- code({ text, lang }) {
32
- const language = lang && hljs.getLanguage(lang) ? lang : "plaintext";
33
- let highlighted;
34
- try {
35
- highlighted = hljs.highlight(text, { language }).value;
36
- } catch {
37
- highlighted = hljs.highlightAuto(text).value;
38
- }
39
- return `<pre><button class="copy-btn" onclick="navigator.clipboard.writeText(this.parentNode.querySelector('code').textContent);this.textContent='已复制';setTimeout(()=>this.textContent='复制',1500)">复制</button><code class="hljs language-${language}">${highlighted}</code></pre>`;
40
- },
41
- link({ href, text }) {
42
- const isExternal = href && (href.startsWith("http://") || href.startsWith("https://"));
43
- const target = isExternal ? ' target="_blank" rel="noopener noreferrer"' : "";
44
- return `<a href="${href}"${target}>${text}</a>`;
45
- },
46
- },
47
- });
48
-
49
- const loading = ref(false);
50
- const loaded = ref(false);
51
- const content = ref(null);
52
- const rendered = ref("");
53
-
54
- function stripFrontmatter(text) {
55
- if (!text) return text;
56
- return text.replace(/^---[\s\S]*?---\s*/, "");
57
- }
58
-
59
- function renderMd(text) {
60
- if (!text) return "";
61
- const body = stripFrontmatter(text);
62
- if (!body.trim()) return "";
63
- try {
64
- return marked.parse(body);
65
- } catch {
66
- return body;
67
- }
68
- }
69
-
70
- async function loadClaudeMd() {
71
- loading.value = true;
72
- loaded.value = false;
73
- try {
74
- const res = await getClaudeMd();
75
- if (res.content) {
76
- content.value = res.content;
77
- await nextTick();
78
- rendered.value = renderMd(res.content);
79
- } else {
80
- content.value = null;
81
- }
82
- } catch {
83
- content.value = null;
84
- } finally {
85
- loading.value = false;
86
- loaded.value = true;
87
- }
88
- }
89
-
90
- onMounted(loadClaudeMd);
91
- </script>
92
-
93
- <style scoped>
94
- .page-header {
95
- display: flex;
96
- align-items: center;
97
- justify-content: space-between;
98
- margin-bottom: 20px;
99
- }
100
-
101
- .page-header h2 {
102
- font-size: 20px;
103
- font-weight: 600;
104
- }
105
-
106
- .fade-enter-active,
107
- .fade-leave-active {
108
- transition: opacity 0.2s ease;
109
- }
110
-
111
- .fade-enter-from,
112
- .fade-leave-to {
113
- opacity: 0;
114
- }
115
- </style>