将前端配色从散落的硬编码/双命名体系(--claude-* / --theme-*)重构为 两层 token 结构(原始层 + 中性语义层),并按"经典抄 Claude、浅色抄 ChatGPT、深色自研"的定位完成三主题填色,同时建立 stylelint 防回退栏杆。 代码大量由 AI 生成的历史遗留配色问题(同语义多值、跨主题塌缩、强调色 撞文字色、fallback 第二真相源等)在此一并收口。 == 一、Token 结构重构(_tokens.scss)== - 重写为两层:原始层 + 语义层;组件只引用中性语义名 (--surface-* / --text-* / --border-* / --accent* / --state-* 等)。 - --claude-* / --theme-* 降级为兼容别名(41 个转发),迁移完成后删除。 - 三主题(classic / light / dark)+ 首屏回退(:root:not([data-theme]), 与经典同值)全部补齐,结构对齐、不再缺项。 == 二、三主题填色 == - 经典 = Claude 官网亮色盘:暖奶油表面阶梯 canvas #faf9f5 < soft #f5f0e8 < card #efe9de < cream-strong #e8e0d2 < 纯白浮起;文字 #141413;hairline #e6dfd8;暖橙 primary #cc785c。 - 浅色 = ChatGPT 亮色盘:冷白 #ffffff / 侧栏 #f9f9f9 / 嵌套 #f3f3f3, 中性灰文字,近黑 primary #181818。 - 深色 = 自研中性灰阶,本轮完全不动(原样保留)。 - 修复塌缩 bug:强调色在 light/dark 原被误填成灰(CTA 失去品牌色), 现统一回品牌 primary;light 表面原全塌成 #ffffff(过于平面), 现按灰阶拉开层次。 - 强调色克制(CTA-only voltage):primary 仅用于发送按钮/logo 等极少 数处;hover / 选中 / 运行态一律走中性灰(运行态指示器从 amber 改灰)。 - 对话区背景从纯白改为暖奶油 canvas;个人空间下拉菜单、git 状态条、 二级菜单等收口到统一语义色。 == 三、全面去半透明 == - 所有实体面板/二级菜单背景改为不透明(surface token 由半透明白改实色, --mobile-menu 三亮色主题改实色)。 - 移除已不透明面板上失效的 backdrop-filter 磨砂(移动端菜单、右键菜单、 模型模式下拉等)。 - 遮罩 scrim(--overlay-scrim)与刻意玻璃质感装饰保留半透明。 == 四、块展开底色统一 == - 思考/工具块展开区底色统一为对话背景色:.collapsible-block 及其 header 背景由 --surface-soft 改 transparent,与堆叠块(stacked-block)一致, 消除"单块奶油底 vs 多块透明"的不一致。 == 五、布局修复 == - 工作区隐藏后残留空白:.workspace-panel--collapsed 补 flex-basis:0 + width/min-width:0,修正 flex-basis:auto 被子元素内容宽度撑开导致内联 width:0 失效、collapsed 后仍占 ~300px 的问题。 == 六、防回退栏杆(新增)== - 新增 .stylelintrc.cjs:三条规则拦截裸 hex / rgb()|hsl() 字面色 / var(--x, fallback) 兜底 / prefers-color-scheme;存量未清理文件用 BASELINE_EXEMPT 临时豁免(现仅剩 5 个 admin 页面,本轮按用户要求不处理), 清理一个移除一个、不再回退。 - package.json:build 脚本接入 stylelint(tsc → stylelint → vite), 新增 lint:css 脚本及 stylelint/postcss-scss/postcss-html 依赖。 - 修复 25 处 \!important 笔误(zsh 历史扩展污染导致的无效 CSS)。 == 七、辅助脚本(新增 scripts/)== - lint_check.py:Node 环境不可用时的 stylelint 替身(复刻三规则 + 括号 校验,支持多行声明检测)。 - color_map.py:硬编码色 → token 反查,判定可映射/野色。 - strip_fallback.py:安全剥离已定义 token 的冗余 fallback。 == 八、文档 == - CLAUDE.md / AGENTS.md 前端设计规范更新:颜色规则扩写为三主题定位 + 两层 token + 表面层次 + 强调色克制 + color-mix 派生 + stylelint 栏杆; 新增"实体面板禁止半透明"规则;"禁止边缘光晕"补充"仅在用户明确允许 或要求时才可使用"。 注:前端构建验证(npm run build / lint:css)由用户本机完成;AI 工具 上下文 Node v24 段错误无法运行 node/npm/vite/stylelint。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
387 lines
10 KiB
Vue
387 lines
10 KiB
Vue
<template>
|
||
<div
|
||
class="host-workspace-dialog-overlay"
|
||
role="dialog"
|
||
aria-modal="true"
|
||
:aria-label="workspaceKind === 'project' ? '管理项目' : '管理工作区'"
|
||
@click.self="handleOverlayClose"
|
||
>
|
||
<form class="host-workspace-dialog host-workspace-manage" @submit.prevent="submitCreate">
|
||
<div class="host-workspace-dialog__header">
|
||
<div class="host-workspace-dialog__title">
|
||
{{ workspaceKind === 'project' ? '管理项目' : '管理工作区' }}
|
||
</div>
|
||
<button
|
||
type="button"
|
||
class="host-workspace-dialog__close"
|
||
:disabled="busy"
|
||
@click="$emit('close')"
|
||
>
|
||
关闭
|
||
</button>
|
||
</div>
|
||
|
||
<div class="host-workspace-dialog__body">
|
||
<section class="workspace-manage-section">
|
||
<div class="workspace-manage-section__title">
|
||
{{ workspaceKind === 'project' ? '新建项目' : '新建工作区' }}
|
||
</div>
|
||
<label v-if="workspaceKind !== 'project'" class="host-workspace-dialog__field">
|
||
<span class="host-workspace-dialog__label">工作区路径</span>
|
||
<input
|
||
v-model="createPath"
|
||
type="text"
|
||
class="host-workspace-dialog__input"
|
||
placeholder="请输入绝对路径或相对仓库路径"
|
||
autocomplete="off"
|
||
:disabled="busy"
|
||
/>
|
||
</label>
|
||
<label class="host-workspace-dialog__field">
|
||
<span class="host-workspace-dialog__label">
|
||
{{ workspaceKind === 'project' ? '项目名称' : '工作区名称(可选)' }}
|
||
</span>
|
||
<input
|
||
v-model="createLabel"
|
||
type="text"
|
||
class="host-workspace-dialog__input"
|
||
:placeholder="workspaceKind === 'project' ? '例如:客户 A 项目' : '例如:客户A项目'"
|
||
autocomplete="off"
|
||
:disabled="busy"
|
||
/>
|
||
</label>
|
||
<button type="submit" class="host-workspace-dialog__btn primary" :disabled="busy">
|
||
{{ createSubmitting ? '创建中...' : (workspaceKind === 'project' ? '新建项目' : '新建工作区') }}
|
||
</button>
|
||
</section>
|
||
|
||
<section class="workspace-manage-section">
|
||
<div class="workspace-manage-section__title">
|
||
{{ workspaceKind === 'project' ? '已有项目' : '已有工作区' }}
|
||
</div>
|
||
<div v-if="workspaces.length" class="workspace-manage-list">
|
||
<div
|
||
v-for="item in workspaces"
|
||
:key="item.workspace_id"
|
||
class="workspace-manage-row"
|
||
:class="{ current: item.workspace_id === currentWorkspaceId }"
|
||
>
|
||
<div class="workspace-manage-main">
|
||
<input
|
||
class="host-workspace-dialog__input workspace-manage-name"
|
||
:value="renameDrafts[item.workspace_id] ?? item.label"
|
||
:disabled="busy"
|
||
@input="setRenameDraft(item.workspace_id, ($event.target as HTMLInputElement).value)"
|
||
/>
|
||
<div v-if="workspaceKind !== 'project'" class="workspace-manage-path">
|
||
{{ item.path || '(未配置路径)' }}
|
||
</div>
|
||
<div class="workspace-manage-badges">
|
||
<span v-if="Number(item.running_task_count || 0) > 0" class="workspace-manage-badge running">
|
||
运行中
|
||
</span>
|
||
</div>
|
||
</div>
|
||
<div class="workspace-manage-actions">
|
||
<button
|
||
type="button"
|
||
class="host-workspace-dialog__btn ghost"
|
||
:disabled="busy || !hasRenameChange(item)"
|
||
@click="submitRename(item)"
|
||
>
|
||
重命名
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="host-workspace-dialog__btn danger"
|
||
:disabled="busy || !canDelete(item)"
|
||
@click="$emit('delete', item)"
|
||
>
|
||
删除
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div v-else class="workspace-manage-empty">
|
||
{{ workspaceKind === 'project' ? '暂无项目' : '暂无工作区' }}
|
||
</div>
|
||
</section>
|
||
|
||
<div v-if="errorMessage" class="host-workspace-dialog__error">{{ errorMessage }}</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { reactive, ref, watch } from 'vue';
|
||
|
||
defineOptions({ name: 'HostWorkspaceManageDialog' });
|
||
|
||
type WorkspaceItem = {
|
||
workspace_id: string;
|
||
label: string;
|
||
path?: string;
|
||
running_task_count?: number;
|
||
};
|
||
|
||
const props = defineProps<{
|
||
workspaces: WorkspaceItem[];
|
||
currentWorkspaceId?: string;
|
||
defaultWorkspaceId?: string;
|
||
workspaceKind?: 'workspace' | 'project';
|
||
busy?: boolean;
|
||
createSubmitting?: boolean;
|
||
errorMessage?: string;
|
||
}>();
|
||
|
||
const emits = defineEmits<{
|
||
(event: 'close'): void;
|
||
(event: 'create', payload: { path: string; label: string }): void;
|
||
(event: 'rename', payload: { workspace_id: string; label: string }): void;
|
||
(event: 'delete', item: WorkspaceItem): void;
|
||
}>();
|
||
|
||
const workspaceKind = props.workspaceKind || 'workspace';
|
||
const createPath = ref('');
|
||
const createLabel = ref('');
|
||
const renameDrafts = reactive<Record<string, string>>({});
|
||
|
||
watch(
|
||
() => props.workspaces,
|
||
(items) => {
|
||
for (const item of items || []) {
|
||
renameDrafts[item.workspace_id] = item.label || item.workspace_id;
|
||
}
|
||
},
|
||
{ immediate: true }
|
||
);
|
||
|
||
const handleOverlayClose = () => {
|
||
if (props.busy) return;
|
||
emits('close');
|
||
};
|
||
|
||
const setRenameDraft = (workspaceId: string, value: string) => {
|
||
renameDrafts[workspaceId] = value;
|
||
};
|
||
|
||
const hasRenameChange = (item: WorkspaceItem) => {
|
||
const draft = String(renameDrafts[item.workspace_id] ?? '').trim();
|
||
return !!draft && draft !== String(item.label || '').trim();
|
||
};
|
||
|
||
const canDelete = (item: WorkspaceItem) => {
|
||
if (Number(item.running_task_count || 0) > 0) return false;
|
||
if (workspaceKind === 'project' && item.workspace_id === 'default') return false;
|
||
return true;
|
||
};
|
||
|
||
const submitCreate = () => {
|
||
emits('create', {
|
||
path: createPath.value.trim(),
|
||
label: createLabel.value.trim()
|
||
});
|
||
};
|
||
|
||
const submitRename = (item: WorkspaceItem) => {
|
||
emits('rename', {
|
||
workspace_id: item.workspace_id,
|
||
label: String(renameDrafts[item.workspace_id] ?? '').trim()
|
||
});
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.host-workspace-dialog-overlay {
|
||
position: fixed;
|
||
inset: 0;
|
||
z-index: 1300;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 20px;
|
||
background: var(--theme-overlay-scrim);
|
||
backdrop-filter: blur(10px);
|
||
}
|
||
|
||
.host-workspace-dialog {
|
||
width: min(680px, 96vw);
|
||
height: min(760px, 92vh);
|
||
border-radius: 18px;
|
||
border: 1px solid var(--theme-control-border-strong);
|
||
background: var(--theme-surface-card);
|
||
box-shadow: var(--theme-shadow-soft);
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.host-workspace-dialog__header,
|
||
.host-workspace-dialog__actions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
padding: 16px 18px;
|
||
border-bottom: 1px solid var(--theme-control-border);
|
||
}
|
||
|
||
.host-workspace-dialog__title {
|
||
font-size: 16px;
|
||
font-weight: 700;
|
||
color: var(--claude-text);
|
||
}
|
||
|
||
.host-workspace-dialog__close,
|
||
.host-workspace-dialog__btn {
|
||
border: 1px solid var(--theme-control-border-strong);
|
||
background: transparent;
|
||
color: var(--claude-text-secondary);
|
||
border-radius: 10px;
|
||
padding: 7px 12px;
|
||
cursor: pointer;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.host-workspace-dialog__close:disabled,
|
||
.host-workspace-dialog__btn:disabled {
|
||
opacity: 0.6;
|
||
cursor: not-allowed;
|
||
}
|
||
|
||
.host-workspace-dialog__body {
|
||
padding: 16px 18px;
|
||
display: grid;
|
||
grid-template-rows: auto minmax(0, 1fr) auto;
|
||
gap: 16px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.workspace-manage-section {
|
||
display: grid;
|
||
gap: 10px;
|
||
}
|
||
|
||
.workspace-manage-section__title {
|
||
font-size: 13px;
|
||
font-weight: 700;
|
||
color: var(--claude-text-secondary);
|
||
}
|
||
|
||
.host-workspace-dialog__field {
|
||
display: grid;
|
||
gap: 6px;
|
||
}
|
||
|
||
.host-workspace-dialog__label,
|
||
.workspace-manage-path {
|
||
font-size: 12px;
|
||
color: var(--claude-text-secondary);
|
||
}
|
||
|
||
.host-workspace-dialog__input {
|
||
border: 1px solid var(--theme-control-border-strong);
|
||
border-radius: 10px;
|
||
background: var(--theme-surface-soft);
|
||
color: var(--claude-text);
|
||
padding: 9px 11px;
|
||
font-size: 14px;
|
||
line-height: 1.4;
|
||
outline: none;
|
||
}
|
||
|
||
.host-workspace-dialog__input:focus {
|
||
border-color: var(--claude-accent);
|
||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--claude-accent) 20%, transparent);
|
||
}
|
||
|
||
.host-workspace-dialog__btn.primary {
|
||
justify-self: flex-start;
|
||
background: var(--claude-accent);
|
||
border-color: var(--claude-accent-strong);
|
||
color: var(--on-accent);
|
||
}
|
||
|
||
.host-workspace-dialog__btn.danger {
|
||
color: var(--state-danger);
|
||
border-color: color-mix(in srgb, var(--state-danger) 45%, var(--theme-control-border-strong));
|
||
}
|
||
|
||
.workspace-manage-list {
|
||
display: grid;
|
||
align-content: start;
|
||
gap: 8px;
|
||
min-height: 0;
|
||
max-height: 100%;
|
||
overflow: auto;
|
||
scrollbar-width: none;
|
||
-ms-overflow-style: none;
|
||
}
|
||
|
||
.workspace-manage-list::-webkit-scrollbar {
|
||
display: none;
|
||
}
|
||
|
||
.workspace-manage-row {
|
||
display: grid;
|
||
grid-template-columns: minmax(0, 1fr) auto;
|
||
gap: 10px;
|
||
padding: 10px;
|
||
border: 1px solid var(--theme-control-border);
|
||
border-radius: 12px;
|
||
background: var(--theme-surface-soft);
|
||
}
|
||
|
||
.workspace-manage-row.current {
|
||
border-color: color-mix(in srgb, var(--claude-accent) 45%, var(--theme-control-border));
|
||
box-shadow: 0 0 0 1px color-mix(in srgb, var(--claude-accent) 18%, transparent);
|
||
}
|
||
|
||
.workspace-manage-main {
|
||
display: grid;
|
||
gap: 6px;
|
||
min-width: 0;
|
||
}
|
||
|
||
.workspace-manage-name {
|
||
width: 100%;
|
||
}
|
||
|
||
.workspace-manage-actions,
|
||
.workspace-manage-badges {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
}
|
||
|
||
.workspace-manage-badge {
|
||
font-size: 11px;
|
||
color: var(--claude-text-secondary);
|
||
border: 1px solid var(--theme-control-border);
|
||
border-radius: 999px;
|
||
padding: 2px 7px;
|
||
}
|
||
|
||
.workspace-manage-badge.running {
|
||
color: var(--claude-accent);
|
||
}
|
||
|
||
.workspace-manage-empty {
|
||
font-size: 13px;
|
||
color: var(--claude-text-secondary);
|
||
}
|
||
|
||
.host-workspace-dialog__error {
|
||
font-size: 13px;
|
||
color: var(--state-danger);
|
||
}
|
||
|
||
@media (max-width: 640px) {
|
||
.workspace-manage-row {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
}
|
||
</style>
|