diff --git a/mini-program/src/components/Markdown.vue b/mini-program/src/components/Markdown.vue index a2d82c9..1da3f11 100644 --- a/mini-program/src/components/Markdown.vue +++ b/mini-program/src/components/Markdown.vue @@ -4,7 +4,10 @@ - + + {{ block.content }} + + {{ block.content }} @@ -13,8 +16,10 @@ {{ block.content }} - - {{ block.content }} + + + {{ segment.text }} + @@ -48,6 +53,13 @@ const parsedBlocks = computed(() => { continue } + // 三级标题 ### + const h3Match = trimmed.match(/^###\s+(.+)/) + if (h3Match) { + blocks.push({ type: 'h3', content: h3Match[1] }) + continue + } + // 四级标题 #### const h4Match = trimmed.match(/^####\s+(.+)/) if (h4Match) { @@ -62,12 +74,43 @@ const parsedBlocks = computed(() => { continue } - // 普通段落 - blocks.push({ type: 'p', content: trimmed }) + // 普通段落(处理粗体 **text**) + const segments = parseBoldText(trimmed) + blocks.push({ type: 'p', content: trimmed, segments }) } return blocks }) + +// 解析粗体文本 **text** +const parseBoldText = (text) => { + const segments = [] + const boldRegex = /\*\*(.+?)\*\*/g + let lastIndex = 0 + let match + + while ((match = boldRegex.exec(text)) !== null) { + // 添加粗体前的普通文本 + if (match.index > lastIndex) { + segments.push({ text: text.slice(lastIndex, match.index), bold: false }) + } + // 添加粗体文本(去掉 ** 标记) + segments.push({ text: match[1], bold: true }) + lastIndex = match.index + match[0].length + } + + // 添加剩余的普通文本 + if (lastIndex < text.length) { + segments.push({ text: text.slice(lastIndex), bold: false }) + } + + // 如果没有粗体,返回单个段落 + if (segments.length === 0) { + segments.push({ text, bold: false }) + } + + return segments +} diff --git a/mini-program/src/pages.json b/mini-program/src/pages.json index ff2cc17..37c18e3 100644 --- a/mini-program/src/pages.json +++ b/mini-program/src/pages.json @@ -24,6 +24,13 @@ "navigationStyle": "custom" } }, + { + "path": "pages/main/ScriptDetailView", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "剧本详情" + } + }, { "path": "pages/profile/index", "style": { diff --git a/mini-program/src/pages/main/ScriptDetailView.vue b/mini-program/src/pages/main/ScriptDetailView.vue new file mode 100644 index 0000000..9c2b1cc --- /dev/null +++ b/mini-program/src/pages/main/ScriptDetailView.vue @@ -0,0 +1,226 @@ + + + + + diff --git a/mini-program/src/pages/main/ScriptView.vue b/mini-program/src/pages/main/ScriptView.vue index 35b5b28..ffe61b1 100644 --- a/mini-program/src/pages/main/ScriptView.vue +++ b/mini-program/src/pages/main/ScriptView.vue @@ -2,7 +2,7 @@ 剧本生成器 - + 我的基础人设 可自由修改 @@ -36,6 +36,24 @@ placeholder="如:巅峰重现、治愈之旅、赛博觉醒..." v-model="scriptConfig.theme" /> + + + + + 灵感气泡 + + + + {{ hint }} + + + @@ -127,17 +145,20 @@ :key="script.id" class="script-card glass-card" :class="{ selected: script.isSelected }" + @click="viewScriptDetail(script)" > {{ script.title }} {{ script.theme || '追光者' }} - {{ getScriptSummary(script) }} + + + {{ script.style || '风格' }} - @@ -159,6 +180,7 @@