chore: 集成设计系统和完善范式相关组件

## 主要改进
- index.html:引入设计系统样式文件
- package.json:添加 playwright 依赖用于测试
- ParadigmSelectorModal.vue:添加"新建范式"按钮
- 其他组件:更新以支持自定义范式功能

## 技术改进
- 统一设计 token 和组件样式
- 完善范式选择和创建流程

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2026-01-11 14:03:01 +08:00
parent 5a3cec6600
commit d1c9a4a5dd
12 changed files with 2474 additions and 439 deletions

View File

@@ -1,87 +1,87 @@
<template>
<aside class="w-[400px] h-screen flex flex-col border-r border-slate-700 bg-slate-800 shrink-0">
<aside class="writer-panel">
<!-- 头部 -->
<header class="p-4 border-b border-slate-700 flex items-center justify-between">
<h1 class="font-bold text-lg text-white flex items-center gap-2">
<span class="text-2xl"></span> AI 写作工坊
<header class="writer-header">
<h1 class="writer-header-title">
<span style="font-size: var(--text-xl)"></span> AI 写作工坊
</h1>
<span class="text-xs px-2 py-1 rounded bg-blue-900 text-blue-300 border border-blue-700">Pro版</span>
<span class="badge badge-default">Pro版</span>
</header>
<!-- 内容区 -->
<div class="flex-1 overflow-y-auto p-4 space-y-6 min-h-0">
<div class="writer-content">
<!-- 写作任务 -->
<section>
<section class="writer-section">
<div class="flex justify-between items-center mb-2">
<label class="text-sm font-medium text-slate-400">1. 写作任务 (User Input)</label>
<div class="flex bg-slate-900 rounded p-0.5 border border-slate-700">
<button
<label class="writer-label">1. 写作任务 (User Input)</label>
<div class="input-type-toggle">
<button
@click="inputType = 'text'"
:class="['text-xs px-2 py-0.5 rounded transition', inputType === 'text' ? 'bg-slate-700 text-white' : 'text-slate-500 hover:text-slate-300']"
:class="['input-type-btn', { active: inputType === 'text' }]"
>自由文本</button>
<button
<button
@click="inputType = 'outline'"
:class="['text-xs px-2 py-0.5 rounded transition', inputType === 'outline' ? 'bg-slate-700 text-white' : 'text-slate-500 hover:text-slate-300']"
:class="['input-type-btn', { active: inputType === 'outline' }]"
>大纲模式</button>
</div>
</div>
<div v-if="inputType === 'text'">
<textarea
v-model="inputTask"
class="w-full h-32 bg-slate-900 border border-slate-700 rounded-lg p-3 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition placeholder-slate-600 resize-none"
<textarea
v-model="inputTask"
class="writer-textarea"
placeholder="请输入具体的写作要求、主题、核心观点..."
></textarea>
<div class="text-right mt-1">
<span class="text-xs text-slate-500">{{ inputTask.length }} </span>
<span class="text-xs text-muted">{{ inputTask.length }} </span>
</div>
</div>
<div v-else class="space-y-2">
<input v-model="outlinePoints.topic" placeholder="核心主题" class="w-full bg-slate-900 border border-slate-700 rounded px-3 py-2 text-xs outline-none focus:border-blue-500">
<input v-model="outlinePoints.audience" placeholder="目标受众" class="w-full bg-slate-900 border border-slate-700 rounded px-3 py-2 text-xs outline-none focus:border-blue-500">
<textarea v-model="outlinePoints.keyPoints" placeholder="关键观点(每行一个)" class="w-full h-20 bg-slate-900 border border-slate-700 rounded px-3 py-2 text-xs outline-none focus:border-blue-500 resize-none"></textarea>
<input v-model="outlinePoints.topic" placeholder="核心主题" class="writer-input">
<input v-model="outlinePoints.audience" placeholder="目标受众" class="writer-input">
<textarea v-model="outlinePoints.keyPoints" placeholder="关键观点(每行一个)" class="writer-textarea" style="height: 80px"></textarea>
</div>
</section>
<!-- 参考案例 -->
<section>
<section class="writer-section">
<div class="flex justify-between items-center mb-2">
<label class="text-sm font-medium text-slate-400">2. 参考案例 (Style Ref)</label>
<button @click="showRefInput = !showRefInput" class="text-xs text-blue-400 hover:text-blue-300">
<label class="writer-label">2. 参考案例 (Style Ref)</label>
<button @click="showRefInput = !showRefInput" class="text-accent hover:opacity-80" style="font-size: var(--text-xs)">
{{ showRefInput ? '取消' : '+ 添加案例' }}
</button>
</div>
<div v-if="showRefInput" class="mb-3 p-3 bg-slate-900 rounded-lg border border-blue-500/30">
<input v-model="newRefTitle" placeholder="案例标题" class="w-full mb-2 bg-slate-800 border border-slate-700 rounded px-2 py-1 text-xs outline-none">
<textarea v-model="newRefContent" placeholder="粘贴优秀的参考文本..." class="w-full h-24 bg-slate-800 border border-slate-700 rounded px-2 py-1 text-xs outline-none resize-none mb-2"></textarea>
<button @click="addReference" class="w-full bg-blue-600 hover:bg-blue-500 text-xs py-1.5 rounded text-white">确认添加</button>
<div v-if="showRefInput" class="mb-3 p-3 bg-primary border border-accent rounded-lg" style="border-color: var(--accent-primary)">
<input v-model="newRefTitle" placeholder="案例标题" class="writer-input mb-2">
<textarea v-model="newRefContent" placeholder="粘贴优秀的参考文本..." class="writer-textarea mb-2" style="height: 96px"></textarea>
<button @click="addReference" class="btn btn-primary w-full text-xs">确认添加</button>
</div>
<div class="space-y-2">
<div v-for="(ref, index) in references" :key="index" class="group flex flex-col bg-slate-700/50 p-2 rounded border border-slate-700 hover:border-slate-600 transition">
<div class="flex items-center justify-between mb-1">
<div class="flex items-center gap-2 overflow-hidden">
<span class="text-lg">📄</span>
<span class="text-xs font-medium text-slate-200 truncate">{{ ref.title }}</span>
<div v-for="(ref, index) in references" :key="index" class="ref-card">
<div class="ref-card-header">
<div class="ref-card-title">
<span style="font-size: var(--text-base)">📄</span>
<span class="ref-card-title-text">{{ ref.title }}</span>
</div>
<button @click="removeReference(index)" class="text-slate-500 hover:text-red-400 opacity-0 group-hover:opacity-100 transition px-2">×</button>
<button @click="removeReference(index)" class="ref-remove-btn px-2">×</button>
</div>
<div class="pl-7">
<p class="text-[10px] text-slate-500 truncate mb-1.5">{{ ref.content.substring(0, 30) }}...</p>
<div style="padding-left: var(--space-5)">
<p class="text-xs text-muted truncate mb-1">{{ ref.content.substring(0, 30) }}...</p>
<!-- 风格分析结果 -->
<div v-if="ref.isAnalyzing" class="flex items-center gap-1 text-[10px] text-indigo-400 animate-pulse">
<span class="w-1 h-1 rounded-full bg-indigo-400"></span>
<div v-if="ref.isAnalyzing" class="flex items-center gap-1 text-xs animate-pulse" style="color: var(--accent-primary)">
<span style="width: 4px; height: 4px; background: var(--accent-primary); border-radius: 50%"></span>
正在分析风格特征...
</div>
<div v-else-if="ref.styleTags && ref.styleTags.length > 0" class="flex flex-wrap gap-1">
<span
v-for="tag in ref.styleTags"
<span
v-for="tag in ref.styleTags"
:key="tag"
class="text-[10px] px-1.5 py-0.5 rounded bg-indigo-500/20 text-indigo-300 border border-indigo-500/30"
class="style-tag"
>
{{ tag }}
</span>
@@ -92,33 +92,33 @@
</section>
<!-- 专家指令范式预设时显示 -->
<section v-if="activeParadigm">
<section v-if="activeParadigm" class="writer-section">
<div class="flex justify-between items-center mb-2">
<label class="text-sm font-medium text-amber-400 flex items-center gap-1">
<label class="writer-label writer-label-alt">
专家指令 (Expert Guidelines)
</label>
<button
<button
@click="clearParadigm"
class="text-[10px] text-slate-500 hover:text-red-400 transition"
class="text-xs text-muted hover:text-danger transition"
>
清除范式
</button>
</div>
<div class="bg-amber-950/20 border border-amber-500/30 rounded-lg p-3 space-y-2">
<div class="expert-section">
<div class="flex items-center gap-2 mb-2">
<span class="text-amber-400">{{ activeParadigm.icon }}</span>
<span class="text-xs font-medium text-amber-300">已加载{{ activeParadigm.name }}专家标准</span>
<span class="text-accent">{{ activeParadigm.icon }}</span>
<span class="text-xs font-medium text-accent" style="color: var(--accent-warning)">已加载{{ activeParadigm.name }}专家标准</span>
</div>
<div class="space-y-1.5">
<div
v-for="(guideline, idx) in expertGuidelines"
<div
v-for="(guideline, idx) in expertGuidelines"
:key="idx"
class="text-[11px] text-slate-400 flex items-start gap-2"
class="expert-item"
>
<span class="text-amber-500/70 shrink-0">{{ idx + 1 }}.</span>
<span style="color: var(--accent-warning); opacity: 0.7;" class="shrink-0">{{ idx + 1 }}.</span>
<div>
<span class="text-amber-300/80 font-medium">{{ guideline.title }}</span>
<span class="text-slate-500">{{ guideline.description }}</span>
<span class="font-medium" style="color: var(--accent-warning); opacity: 0.8;">{{ guideline.title }}</span>
<span class="text-secondary">{{ guideline.description }}</span>
</div>
</div>
</div>
@@ -126,78 +126,77 @@
</section>
<!-- 输出规范 -->
<section>
<label class="block text-sm font-medium text-slate-400 mb-2">3. 输出规范 (Constraints)</label>
<section class="writer-section">
<label class="writer-label block mb-2">3. 输出规范 (Constraints)</label>
<div class="flex flex-wrap gap-2 mb-3">
<button
v-for="tag in presetTags"
<button
v-for="tag in presetTags"
:key="tag"
@click="toggleTag(tag)"
:class="['px-2 py-1 rounded text-xs border transition',
selectedTags.includes(tag)
? 'bg-blue-600/20 border-blue-500 text-blue-300'
: 'bg-slate-900 border-slate-700 text-slate-500 hover:border-slate-500']"
:class="['tag-button', { selected: selectedTags.includes(tag) }]"
>
{{ tag }}
</button>
</div>
<input
v-model="customConstraint"
type="text"
class="w-full bg-slate-900 border border-slate-700 rounded px-3 py-2 text-xs focus:border-blue-500 outline-none"
<input
v-model="customConstraint"
type="text"
class="writer-input"
placeholder="补充其他要求"
>
<!-- 深度模式开关 -->
<div class="mt-4 flex items-center justify-between bg-slate-900/50 p-3 rounded border border-indigo-500/30">
<div class="deep-mode-toggle mt-4">
<div class="flex flex-col">
<span class="text-sm font-bold text-indigo-300 flex items-center gap-1">
<span class="text-sm font-bold flex items-center gap-1" style="color: var(--accent-primary)">
🧠 深度模式 (Deep Mode)
</span>
<span class="text-[10px] text-slate-500">模拟人类初稿-反思-润色的思维链</span>
<span class="text-[10px] text-muted">模拟人类"初稿-反思-润色"的思维链</span>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" v-model="isDeepMode" class="sr-only peer">
<div class="w-9 h-5 bg-slate-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-indigo-600"></div>
<input type="checkbox" v-model="isDeepMode" class="hidden peer">
<div style="width: 36px; height: 20px; background: var(--bg-elevated); border-radius: 9999px; position: relative; transition: all var(--transition-normal);" class="peer-checked:bg-indigo-600">
<div style="width: 16px; height: 16px; background: white; border-radius: 50%; position: absolute; top: 2px; left: 2px; transition: all var(--transition-normal);" class="peer-checked:translate-x-4"></div>
</div>
</label>
</div>
</section>
</div>
<!-- 底部操作区 -->
<footer class="p-4 bg-slate-800 border-t border-slate-700 space-y-3">
<footer class="writer-footer">
<div class="flex items-center justify-between">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" v-model="showPromptDebug" class="hidden">
<div class="w-8 h-4 bg-slate-900 rounded-full border border-slate-600 relative transition-colors" :class="{'bg-blue-900 border-blue-500': showPromptDebug}">
<div class="w-2 h-2 bg-slate-400 rounded-full absolute top-1 left-1 transition-transform" :class="{'translate-x-4 bg-blue-400': showPromptDebug}"></div>
<div class="toggle-switch" :class="{'active': showPromptDebug}">
<div class="toggle-thumb" :class="{'active': showPromptDebug}"></div>
</div>
<span class="text-xs text-slate-500 select-none">预览构建的 Prompt</span>
<span class="text-xs text-muted select-none">预览构建的 Prompt</span>
</label>
<span class="text-xs text-slate-600">deepseek</span>
<span class="text-xs text-muted">deepseek</span>
</div>
<!-- API配置 -->
<div class="space-y-2">
<input
v-model="apiUrl"
type="text"
class="w-full bg-slate-900 border border-slate-700 rounded px-3 py-2 text-xs focus:border-blue-500 outline-none"
<input
v-model="apiUrl"
type="text"
class="writer-input"
placeholder="API 地址"
>
<input
v-model="apiKey"
type="password"
class="w-full bg-slate-900 border border-slate-700 rounded px-3 py-2 text-xs focus:border-blue-500 outline-none"
<input
v-model="apiKey"
type="password"
class="writer-input"
placeholder="API Key"
>
</div>
<button
@click="generateContent"
<button
@click="generateContent"
:disabled="!canGenerate"
class="w-full py-3 rounded-lg font-bold text-white shadow-lg shadow-blue-900/20 flex items-center justify-center gap-2 transition-all transform active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed"
:class="isGenerating ? 'bg-slate-700' : 'bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500'"
class="generate-button primary"
:class="{'generating': isGenerating}"
>
<span v-if="isGenerating" class="animate-spin text-lg"></span>
{{ isGenerating ? '正在思考与撰写...' : '开始生成文稿' }}
@@ -276,3 +275,325 @@ const canGenerate = computed(() => {
}
})
</script>
<style scoped>
/* ========== 使用设计令牌系统 ========== */
/* 侧边栏容器 */
.writer-panel {
width: 400px;
height: 100vh;
display: flex;
flex-direction: column;
border-right: 1px solid var(--border-default);
background: var(--bg-secondary);
flex-shrink: 0;
}
/* 头部 */
.writer-header {
padding: var(--space-4);
border-bottom: 1px solid var(--border-default);
display: flex;
align-items: center;
justify-content: space-between;
}
.writer-header-title {
font-weight: var(--font-semibold);
font-size: var(--text-lg);
color: var(--text-primary);
display: flex;
align-items: center;
gap: var(--space-2);
}
/* 内容区 */
.writer-content {
flex: 1;
overflow-y: auto;
padding: var(--space-4);
}
.writer-section {
margin-bottom: var(--space-6);
}
.writer-section:last-child {
margin-bottom: 0;
}
/* 标签 */
.writer-label {
font-size: var(--text-sm);
font-weight: var(--font-medium);
color: var(--text-secondary);
margin-bottom: var(--space-2);
}
.writer-label-alt {
color: var(--accent-warning);
}
/* 输入框样式 */
.writer-textarea {
width: 100%;
height: 128px;
background: var(--bg-primary);
border: 1px solid var(--border-default);
border-radius: var(--radius-lg);
padding: var(--space-3);
font-size: var(--text-sm);
color: var(--text-primary);
transition: all var(--transition-fast);
}
.writer-textarea::placeholder {
color: var(--text-muted);
}
.writer-textarea:focus {
outline: none;
border-color: var(--accent-primary);
box-shadow: 0 0 0 2px var(--info-bg);
}
.writer-input {
width: 100%;
background: var(--bg-primary);
border: 1px solid var(--border-default);
border-radius: var(--radius-md);
padding: var(--space-3);
font-size: var(--text-xs);
color: var(--text-primary);
}
.writer-input::placeholder {
color: var(--text-muted);
}
.writer-input:focus {
outline: none;
border-color: var(--accent-primary);
}
/* 参考案例卡片 */
.ref-card {
display: flex;
flex-direction: column;
background: var(--bg-elevated);
padding: var(--space-2);
border-radius: var(--radius-md);
border: 1px solid var(--border-default);
transition: all var(--transition-fast);
}
.ref-card:hover {
border-color: var(--border-strong);
}
.ref-card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: var(--space-1);
}
.ref-card-title {
display: flex;
align-items: center;
gap: var(--space-2);
overflow: hidden;
}
.ref-card-title-text {
font-size: var(--text-xs);
font-weight: var(--font-medium);
color: var(--text-primary);
}
.ref-remove-btn {
color: var(--text-muted);
opacity: 0;
transition: all var(--transition-fast);
}
.ref-card:hover .ref-remove-btn {
opacity: 1;
}
.ref-remove-btn:hover {
color: var(--accent-danger);
}
/* 风格标签 */
.style-tag {
font-size: 10px;
padding: 2px 6px;
border-radius: var(--radius-sm);
background: var(--info-bg);
color: var(--accent-primary);
border: 1px solid rgba(96, 165, 250, 0.3);
}
/* 专家指令区域 */
.expert-section {
background: var(--warning-bg);
border: 1px solid rgba(245, 158, 11, 0.3);
border-radius: var(--radius-lg);
padding: var(--space-3);
}
.expert-item {
font-size: 11px;
color: var(--text-secondary);
display: flex;
align-items: flex-start;
gap: var(--space-2);
}
/* 标签按钮 */
.tag-button {
padding: var(--space-1) var(--space-2);
border-radius: var(--radius-md);
font-size: var(--text-xs);
border: 1px solid var(--border-default);
transition: all var(--transition-fast);
cursor: pointer;
}
.tag-button.selected {
background: var(--info-bg);
border-color: var(--accent-primary);
color: var(--accent-primary);
}
.tag-button:not(.selected) {
background: var(--bg-primary);
color: var(--text-muted);
}
.tag-button:not(.selected):hover {
border-color: var(--border-strong);
}
/* 深度模式开关 */
.deep-mode-toggle {
display: flex;
align-items: center;
justify-content: space-between;
background: var(--bg-primary);
padding: var(--space-3);
border-radius: var(--radius-md);
border: 1px solid var(--accent-primary);
}
/* 底部操作区 */
.writer-footer {
padding: var(--space-4);
background: var(--bg-secondary);
border-top: 1px solid var(--border-default);
}
/* 切换开关 */
.toggle-switch {
width: 32px;
height: 16px;
background: var(--bg-primary);
border-radius: var(--radius-full);
border: 1px solid var(--border-default);
position: relative;
transition: all var(--transition-normal);
}
.toggle-switch.active {
background: var(--info-bg);
border-color: var(--accent-primary);
}
.toggle-thumb {
width: 10px;
height: 10px;
background: var(--text-muted);
border-radius: 50%;
position: absolute;
top: 2px;
left: 2px;
transition: all var(--transition-normal);
}
.toggle-thumb.active {
transform: translateX(16px);
background: var(--accent-primary);
}
/* 生成按钮 */
.generate-button {
width: 100%;
padding: var(--space-3);
border-radius: var(--radius-lg);
font-weight: var(--font-semibold);
color: var(--text-inverse);
box-shadow: var(--shadow-md);
display: flex;
align-items: center;
justify-content: center;
gap: var(--space-2);
transition: all var(--transition-normal);
transform: translateY(0);
border: none;
cursor: pointer;
}
.generate-button:not(:disabled):active {
transform: translateY(1px);
}
.generate-button.primary {
background: linear-gradient(135deg, var(--accent-primary), #6366f1);
}
.generate-button.primary:hover:not(:disabled) {
background: linear-gradient(135deg, var(--accent-primary-hover), #4f46e5);
}
.generate-button.generating {
background: var(--bg-elevated);
color: var(--text-muted);
cursor: wait;
}
.generate-button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* 切换器 */
.input-type-toggle {
display: flex;
background: var(--bg-primary);
padding: var(--space-1);
border-radius: var(--radius-md);
border: 1px solid var(--border-default);
}
.input-type-btn {
padding: var(--space-2) var(--space-3);
font-size: var(--text-xs);
border-radius: var(--radius-sm);
transition: all var(--transition-fast);
}
.input-type-btn.active {
background: var(--bg-elevated);
color: var(--text-primary);
}
.input-type-btn:not(.active) {
color: var(--text-muted);
}
.input-type-btn:not(.active):hover {
color: var(--text-secondary);
}
</style>