feat: 统一两端界面并扩展受权限约束的AI助手

This commit is contained in:
LoveChengke committed 2026-11-07 16:27:38 +08:00
1 parent 79a31ebe9d
commit 0b35a58f07
141 files changed
+7999 -2213

No files matched your search

+4 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@classhelper/web-admin",
"version": "1.4.3",
"version": "1.4.4",
"private": true,
"description": "ClassHelper Web 管理端(Vue 3 + Vite + Element Plus)",
"type": "module",
@@ -19,7 +19,9 @@
"pinia": "^4.0.3",
"socket.io-client": "^4.8.3",
"vue": "^3.5.42",
"vue-router": "^5.3.1"
"vue-router": "^5.3.1",
"@classhelper/ui": "workspace:*",
"@noble/hashes": "2.4.0"
},
"devDependencies": {
"@types/node": "^22.20.2",
+29
View File
@@ -1,7 +1,10 @@
import type { AiExecutionRequest } from '@classhelper/shared';
import axios, { type AxiosError, type AxiosRequestConfig } from 'axios';
import { ElMessage } from 'element-plus';
import { STORAGE_KEYS, type ApiErrorResponse, type ApiResponse } from '@classhelper/shared';
import { API_BASE_URL } from '@/config';
import { clearCalendarCache } from '@/composables/calendarCache';
import { allowsAiExecution } from '@/composables/assistantRequests';
/**
* Axios 封装:
@@ -37,6 +40,7 @@ instance.interceptors.response.use(
const message = error.response?.data?.message ?? error.message ?? '网络请求失败';
if (status === 401) {
clearCalendarCache();
localStorage.removeItem(STORAGE_KEYS.token);
localStorage.removeItem(STORAGE_KEYS.user);
ElMessage.warning('登录状态已失效,请重新登录');
@@ -56,6 +60,31 @@ async function request<T>(config: AxiosRequestConfig): Promise<T> {
}
export const api = {
executeAi: <T>(
stepId: string,
action: AiExecutionRequest,
file?: File,
signal?: AbortSignal,
progress?: (percent: number) => void,
): Promise<T> => {
if (!allowsAiExecution(action)) throw new Error('助手不允许执行此请求');
return request<T>({
method: action.method,
url: action.path,
params: action.query,
data: file ?? action.body,
signal,
timeout: file || action.path === '/update/client/fetch' ? 600000 : 120000,
headers: {
'x-classhelper-ai-step': stepId,
...(file
? { 'content-type': 'application/octet-stream', 'x-classhelper-ai-sha256': action.sha256 }
: {}),
},
onUploadProgress: (event) =>
progress?.(Math.min(100, Math.round(100 * (event.loaded / (event.total || file?.size || 1))))),
});
},
get: <T>(url: string, params?: Record<string, unknown>): Promise<T> =>
request<T>({ method: 'GET', url, params }),
post: <T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> =>
+58 -6
View File
@@ -1,3 +1,9 @@
import type {
AiCapability,
AiConversationRequest,
AiConversationResult,
AiPlanStep,
} from '@classhelper/shared';
import {
API_PATHS,
type AiAuditDto,
@@ -13,6 +19,8 @@ import {
type AutoTermWeeksRequest,
type ClassPlanImportResultDto,
type ClassPlanPreviewDto,
type ClassPlanYamlImportResultDto,
type ClassPlanYamlPreviewDto,
type ClassStatusDto,
type ClientDeviceDto,
type ClientPushResult,
@@ -191,8 +199,15 @@ export const homeworkApi = {
date?: string;
}): Promise<HomeworkDto[]> => api.get(API_PATHS.homeworks, params),
/** 哪些天有作业(日期选择器高亮) */
days: (params: { classId?: string; from?: string; to?: string; days?: number }): Promise<HomeworkDaysDto> =>
api.get(`${API_PATHS.homeworks}/days`, params),
days: (params: {
classId?: string;
courseId?: string;
keyword?: string;
pendingOnly?: boolean;
from?: string;
to?: string;
days?: number;
}): Promise<HomeworkDaysDto> => api.get(`${API_PATHS.homeworks}/days`, params),
detail: (id: string): Promise<HomeworkDto> => api.get(`${API_PATHS.homeworks}/${id}`),
create: (payload: CreateHomeworkRequest): Promise<HomeworkDto> => api.post(API_PATHS.homeworks, payload),
/** 一次给多个班级布置同一份作业(服务端逐班判定并返回逐班结果) */
@@ -228,6 +243,7 @@ export const notificationApi = {
days: (params: {
classId?: string;
priority?: string;
keyword?: string;
createdBy?: string;
from?: string;
to?: string;
@@ -482,6 +498,23 @@ export const importApi = {
mode?: 'replace' | 'merge';
payload: unknown;
}): Promise<ClassPlanImportResultDto> => api.post(`${API_PATHS.imports}/class-plan`, payload),
/**
* 课表 YAML 解析预览(不写库)。
* YAML 面向手写 / 大模型生成:`enable_day` 1=周一 … 7=周日,`weeks` 取 all/odd/even。
*/
previewYamlClassPlan: (payload: {
classId: string;
mode?: 'replace' | 'merge';
text: string;
}): Promise<ClassPlanYamlPreviewDto> => api.post(`${API_PATHS.imports}/class-plan/yaml/preview`, payload),
/** 导入课表 YAML(支持单双周:replace 覆盖 / merge 合并;解析失败会抛错且不改动原课表) */
importYamlClassPlan: (payload: {
classId: string;
mode?: 'replace' | 'merge';
text: string;
}): Promise<ClassPlanYamlImportResultDto> => api.post(`${API_PATHS.imports}/class-plan/yaml`, payload),
};
/* ------------------------------------------------------------------ 数据库管理(仅管理员) */
@@ -635,8 +668,7 @@ const AI_BASE = API_PATHS.ai;
*
* 权限:`settings` / `audit` 要 `ai:manage`(仅管理员);`interpret` 要 `ai:use`(教师也有)。
*
* ⚠️ **助手只解析、不落库**:`interpret` 只是把一句中文换成结构化参数,
* 真正写数据仍然由前端在老师确认后调既有的发布接口(作业 / 通知 / 叫人)。
* 解释和附件预览只保存计划与审计;确认后由绑定的原业务接口执行写入。
*/
export const aiApi = {
/**
@@ -656,8 +688,28 @@ export const aiApi = {
updateSettings: (payload: UpdateAiSettingsRequest): Promise<AiSettingsDto> =>
api.put(`${AI_BASE}/settings`, payload),
/** 把一句话解析成待确认的操作;`text` 上限 500 字(超出由服务端 400) */
interpret: (payload: { text: string; classId?: string }): Promise<AiInterpretResult> =>
api.post(`${AI_BASE}/interpret`, payload),
interpret: (
payload: AiConversationRequest,
signal?: AbortSignal,
): Promise<AiInterpretResult & AiConversationResult> =>
api.post(`${AI_BASE}/interpret`, payload, { timeout: 120000, signal }),
capabilities: (): Promise<AiCapability[]> => api.get(`${AI_BASE}/capabilities`),
plan: (id: string): Promise<AiPlanStep[]> => api.get(`${AI_BASE}/plans/${id}`),
prepare: (
id: string,
files: Record<string, { contentBase64: string }>,
mappings?: Record<string, Record<string, string>>,
): Promise<AiPlanStep[]> => api.post(`${AI_BASE}/plans/${id}/prepare`, { files, mappings }),
confirm: (
id: string,
body: {
confirmed: true;
extraConfirmed?: boolean;
urgentConfirmed?: boolean;
secrets?: Record<string, Record<string, string>>;
},
): Promise<AiPlanStep[]> => api.post(`${AI_BASE}/plans/${id}/confirm`, body),
discard: (id: string): Promise<null> => api.delete(`${AI_BASE}/plans/${id}`),
/** 使用记录(谁、什么时候、说了什么、解析成什么、结果如何),倒序 */
audit: (limit = 50): Promise<AiAuditDto[]> => api.get(`${AI_BASE}/audit`, { limit }),
};
@@ -0,0 +1,232 @@
<script setup lang="ts">
import { computed } from 'vue';
import { PERMISSION_LABELS, type PermissionKey } from '@classhelper/shared';
const props = withDefaults(defineProps<{ value: unknown; depth?: number }>(), { depth: 0 });
const labels: Record<string, string> = {
id: '记录标识',
name: '名称',
version: '版本',
fileName: '文件',
notes: '说明',
current: '当前登记',
file: '缓存文件',
fileReady: '文件可用',
title: '标题',
content: '内容',
classId: '班级',
className: '班级',
courseId: '科目',
courseName: '科目',
studentId: '学生',
studentName: '学生',
teacherId: '教师',
username: '工号',
role: '角色',
grade: '年级',
studentNo: '学号',
examName: '考试',
score: '分数',
level: '等级',
startTime: '开始',
endTime: '结束',
date: '日期',
assignDate: '所属日期',
archiveDate: '归档日期',
points: '时间点',
entries: '课程安排',
columns: '列',
rows: '数据',
previewRows: '预览',
suggestedMapping: '字段对应',
warnings: '提示',
errors: '问题',
size: '大小',
mode: '方式',
priority: '优先级',
classIds: '目标班级',
count: '数量',
totalRows: '总行数',
countInTotal: '计入总分',
isEnabled: '启用',
weekday: '星期',
weekStart: '起始周',
weekEnd: '结束周',
timeLayoutId: '时间表',
timeLayoutItemId: '时间点',
kind: '类型',
message: '结果',
createdAt: '创建时间',
keys: '功能权限',
scope: '范围',
scopeValue: '范围值',
assignments: '岗位分配',
teacher: '教师',
classes: '可见班级',
nameBefore: '修改前',
nameAfter: '修改后',
};
const hidden =
/password|secret|token|api.?key|storagePath|contentBase64|sha256|^id$|Ids?$|^fields$|^mapping$|^suggestedMapping$|^templateCsv$/i;
const fileTable = computed(() => {
const value = props.value as
| { columns?: string[]; rows?: string[][]; errors?: string[]; warnings?: string[]; totalRows?: number }
| undefined;
return value && Array.isArray(value.columns) && Array.isArray(value.rows)
? {
columns: value.columns,
rows: value.rows.map((row) =>
Object.fromEntries(value.columns!.map((key, i) => [key, row[i] ?? ''])),
),
errors: value.errors ?? [],
warnings: value.warnings ?? [],
total: value.totalRows,
}
: null;
});
const entries = computed(() =>
props.value && typeof props.value === 'object' && !Array.isArray(props.value)
? Object.entries(props.value).filter(
([key, value]) => !hidden.test(key) && value !== undefined && value !== null,
)
: [],
);
const rows = computed(() => (Array.isArray(props.value) ? props.value : []));
const columns = computed(() =>
[
...new Set(
rows.value.slice(0, 20).flatMap((row) => (row && typeof row === 'object' ? Object.keys(row) : [])),
),
]
.filter(
(key) =>
key !== 'id' &&
!key.endsWith('Id') &&
!hidden.test(key) &&
rows.value.some(
(row) =>
row && typeof row === 'object' && ['string', 'number', 'boolean'].includes(typeof row[key]),
),
)
.slice(0, 8),
);
function text(value: unknown): string {
if (value === true) return '是';
if (value === false) return '否';
if (value === null || value === undefined) return '—';
if (typeof value === 'object')
return Array.isArray(value) ? `${value.length} 项` : 'name' in value ? String(value.name) : '详情';
const label = (
{
ADMIN: '管理员',
shutdown: '关机',
restart: '重启',
logoff: '注销',
lock: '锁屏',
TEACHER: '教师',
TEACHING: '任教班级',
HEAD: '班主任班级',
ALL: '全校',
GRADE: '年级',
DIVISION: '部',
URGENT: '紧急',
NORMAL: '普通',
HIGH: '重要',
LOW: '低',
push: '推送',
cloud: '云端保存',
merge: '合并',
replace: '覆盖',
upsert: '更新或新增',
append: '新增',
} as Record<string, string>
)[String(value)];
return label ?? PERMISSION_LABELS[String(value) as PermissionKey] ?? String(value);
}
</script>
<template>
<div class="assistant-data">
<template v-if="fileTable">
<p v-if="fileTable.total">共 {{ fileTable.total }} 行</p>
<el-alert
v-for="message in fileTable.errors"
:key="message"
:title="message"
type="warning"
:closable="false"
/>
<el-alert
v-for="message in fileTable.warnings"
:key="message"
:title="message"
type="info"
:closable="false"
/>
<el-table :data="fileTable.rows" max-height="360">
<el-table-column
v-for="key in fileTable.columns"
:key="key"
:prop="key"
:label="key"
min-width="110"
/>
</el-table>
</template>
<template v-else-if="Array.isArray(value)">
<el-table v-if="columns.length" :data="rows.slice(0, 100)" max-height="360" empty-text="暂无记录">
<el-table-column
v-for="key in columns"
:key="key"
:label="labels[key] || key"
min-width="100"
show-overflow-tooltip
>
<template #default="{ row }">{{ text(row[key]) }}</template>
</el-table-column>
</el-table>
<ul v-else>
<li v-for="(row, n) in rows.slice(0, 100)" :key="n">{{ text(row) }}</li>
</ul>
<span v-if="rows.length > 100" class="text-muted">共 {{ rows.length }} 项,展示前 100 项</span>
</template>
<dl v-else-if="entries.length" class="assistant-fields">
<template v-for="[key, item] in entries" :key="key">
<dt>{{ labels[key] || key }}</dt>
<dd>
<details v-if="item && typeof item === 'object' && depth < 3">
<summary>{{ Array.isArray(item) ? `${item.length} 项` : '查看' }}</summary>
<AssistantData :value="item" :depth="depth + 1" />
</details>
<span v-else>{{ text(item) }}</span>
</dd>
</template>
</dl>
<span v-else>{{ text(value) }}</span>
</div>
</template>
<style scoped>
.assistant-data {
overflow: auto;
font-size: var(--el-font-size-base);
}
.assistant-fields {
display: grid;
grid-template-columns: minmax(80px, 120px) minmax(0, 1fr);
gap: 10px 16px;
margin: 8px 0;
}
dt {
color: var(--ch-ui-muted);
}
dd {
margin: 0;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
summary {
cursor: pointer;
color: var(--el-color-primary);
}
ul {
padding-left: 20px;
}
</style>
@@ -1,20 +1,31 @@
<script setup lang="ts">
/**
* ClassIsland 课程表(ClassPlan)导入弹窗,支持单双周。
* 课表导入弹窗:ClassIsland 档案 JSON + 课表 YAML 两种格式。
*
* 流程:粘贴 JSON / 选择 .json 文件(整份 ClassIsland 档案)
* → 解析预览(后端解析 TimeLayouts + ClassPlans + Subjects,单双周取 WeekCountDiv/WeekCountDivTotal)
* → 查看解析出的课程、缺失科目与校验结果 → 选择覆盖(replace) / 合并(merge) → 导入。
* 流程:粘贴文本 / 选择 .json、.yaml、.yml 文件
* → 自动识别格式(JSON 能解析走 ClassIsland 档案接口,否则走 YAML 接口)
* → 解析预览(课程、单双周、缺失科目、校验结果)→ 覆盖(replace) / 合并(merge) → 导入。
*
* YAML 是给「手写 / 大模型生成」准备的简化格式,弹窗里内置可复制的 AI 提示词、
* 示例 YAML(来自 shared,与服务端解析器共用同一份)与下载入口。
*
* 安全与一致性:
* - JSON 语法错误、结构无法识别、没有解析出任何课程时后端返回 errors(或 400),
* - 语法错误、结构无法识别、没有解析出任何课程时后端返回 errors(导入接口返回 400),
* 导入按钮会被禁用/阻止,原课表不会被改成"导入一半"的脏状态;
* - 缺失的科目在导入时由后端自动补建(预览里提前列出,避免意外建课);
* - 权限与课表管理一致(管理员或本班班主任),科任老师看不到入口,后端亦会二次校验。
*/
import { computed, ref, watch } from 'vue';
import { ElMessage } from 'element-plus';
import { WEEK_PARITY_LABELS, type ClassPlanEntryDto, type ClassPlanPreviewDto } from '@classhelper/shared';
import {
CLASS_PLAN_YAML_AI_PROMPT,
CLASS_PLAN_YAML_SAMPLE,
WEEK_PARITY_LABELS,
type ClassPlanEntryDto,
type ClassPlanPreviewDto,
type ClassPlanYamlEntryDto,
type ClassPlanYamlPreviewDto,
} from '@classhelper/shared';
import { importApi } from '@/api';
const props = defineProps<{
@@ -79,23 +90,48 @@ const CLASS_PLAN_SAMPLE = `{
/** 输入框提示(用常量避免模板里的引号破坏 lint 规则) */
const TEXTAREA_PLACEHOLDER =
'粘贴 ClassIsland 导出的档案 JSON(含 TimeLayouts / ClassPlans / Subjects),或点击「选择 .json 文件」';
'粘贴 ClassIsland 档案 JSON(含 TimeLayouts / ClassPlans / Subjects),或课表 YAML(含 version / subjects / schedules);也可以点击「选择文件」';
const jsonText = ref('');
const sourceText = ref('');
const mode = ref<'replace' | 'merge'>('replace');
const preview = ref<ClassPlanPreviewDto | null>(null);
/** 预览时识别到的格式;导入按钮据此决定调哪个接口 */
const previewFormat = ref<'json' | 'yaml' | null>(null);
/** 文件扩展名给出的格式提示:.json 强制走 JSON 以便报"JSON 解析失败",粘贴文本时清空 */
const sourceHint = ref<'json' | 'yaml' | null>(null);
const aiPanel = ref<string[]>([]);
const parsing = ref(false);
const importing = ref(false);
const fileInputRef = ref<HTMLInputElement>();
let previewRevision = 0;
watch(visible, (value) => {
if (value) {
jsonText.value = '';
sourceText.value = '';
preview.value = null;
previewFormat.value = null;
sourceHint.value = null;
mode.value = 'replace';
aiPanel.value = [];
}
});
// 输入内容一旦变化,旧预览即失效:避免"改了文本却仍按旧预览导入"。
watch(
[sourceText, mode, () => props.classId, visible],
() => {
previewRevision += 1;
preview.value = null;
previewFormat.value = null;
},
{ flush: 'sync' },
);
/** 文件选择后提示文件来源格式;手动输入时清空提示,回到内容自动识别 */
function onManualInput(): void {
sourceHint.value = null;
}
function pickFile(): void {
fileInputRef.value?.click();
}
@@ -104,22 +140,34 @@ async function onFileChange(event: Event): Promise<void> {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
if (!file) return;
if (!/\.json$/i.test(file.name)) {
ElMessage.warning('请选择 ClassIsland 导出的 .json 文件');
input.value = '';
if (file.size > 8 * 1024 * 1024) {
ElMessage.warning('课表文件不能超过 8 MB');
return;
}
const lower = file.name.toLowerCase();
if (!/\.(json|ya?ml)$/i.test(lower)) {
ElMessage.warning('请选择 .json / .yaml / .yml 文件');
input.value = '';
return;
}
jsonText.value = await file.text();
sourceText.value = await file.text();
preview.value = null;
ElMessage.success(`已读取 ${file.name}(${jsonText.value.length} 字符),请点击「解析预览」`);
previewFormat.value = null;
sourceHint.value = lower.endsWith('.json') ? 'json' : 'yaml';
ElMessage.success(
`已读取 ${file.name}(${sourceText.value.length} 字符),请点击「解析预览」(自动识别 JSON / YAML)`,
);
}
/** JSON 语法错误由后端统一报错,这里保留原文让后端给出精确原因 */
function parseJsonOrText(text: string): unknown {
/** JSON 能解析就按 ClassIsland 档案处理,否则按 YAML;文件扩展名优先。 */
function resolveFormat(): 'json' | 'yaml' {
if (sourceHint.value) return sourceHint.value;
try {
return JSON.parse(text);
JSON.parse(sourceText.value);
return 'json';
} catch {
return text;
return 'yaml';
}
}
@@ -134,10 +182,20 @@ const parityCount = computed(() => {
return parts.join(' / ');
});
/** 解析预览:把 JSON 文本或对象交给后端解析(不写库) */
/** YAML 预览里的课表张数(同一天的单周/双周各算一张) */
const yamlPlanCount = computed(() =>
previewFormat.value === 'yaml' ? ((preview.value as ClassPlanYamlPreviewDto | null)?.planCount ?? 0) : 0,
);
/** 有科目教室时表格才显示「地点」列,避免 JSON 预览多一列空白 */
const showLocationColumn = computed(
() => preview.value?.entries.some((item) => Boolean((item as ClassPlanYamlEntryDto).location)) ?? false,
);
/** 解析预览:JSON / YAML 自动分流(只解析不写库) */
async function doPreview(): Promise<void> {
if (!jsonText.value.trim()) {
ElMessage.warning('请先粘贴 JSON 或选择 .json 文件');
if (!sourceText.value.trim()) {
ElMessage.warning('请先粘贴课表内容或选择文件');
return;
}
if (!props.classId) {
@@ -145,22 +203,37 @@ async function doPreview(): Promise<void> {
return;
}
const format = resolveFormat();
const revision = previewRevision;
const input = { classId: props.classId, mode: mode.value, text: sourceText.value };
parsing.value = true;
try {
preview.value = await importApi.previewClassPlan({
classId: props.classId,
mode: mode.value,
payload: parseJsonOrText(jsonText.value),
});
let result: ClassPlanPreviewDto;
if (format === 'json') {
result = await importApi.previewClassPlan({
classId: input.classId,
mode: input.mode,
payload: JSON.parse(input.text),
});
} else {
result = await importApi.previewYamlClassPlan(input);
}
if (revision !== previewRevision) return;
preview.value = result;
previewFormat.value = format;
if (preview.value.errors.length > 0) {
ElMessage.warning(`解析发现 ${preview.value.errors.length} 个问题,请修正后再导入`);
} else {
const extra = format === 'yaml' ? ` / ${yamlPlanCount.value} 张课表` : '';
ElMessage.success(
`解析成功:共 ${preview.value.entries.length} 节课${parityCount.value ? `(${parityCount.value})` : ''}`,
`解析成功:共 ${preview.value.entries.length} 节课${extra}${parityCount.value ? `(${parityCount.value})` : ''}`,
);
}
} catch {
} catch (error) {
if (revision !== previewRevision) return;
if (error instanceof SyntaxError) ElMessage.error('JSON 格式不正确,请检查文件内容');
preview.value = null;
previewFormat.value = null;
} finally {
parsing.value = false;
}
@@ -176,14 +249,27 @@ async function doImport(): Promise<void> {
return;
}
const format = previewFormat.value ?? resolveFormat();
importing.value = true;
try {
const result = await importApi.importClassPlan({
classId: props.classId,
mode: mode.value,
payload: parseJsonOrText(jsonText.value),
});
ElMessage.success(`${result.created} 新增 / ${result.updated} 更新`);
if (format === 'yaml') {
const result = await importApi.importYamlClassPlan({
classId: props.classId,
mode: mode.value,
text: sourceText.value,
});
ElMessage.success(
`${result.created} 新增 / ${result.updated} 更新` +
`${result.warnings.length > 0 ? `(另有 ${result.warnings.length} 条提示)` : ''}`,
);
} else {
const result = await importApi.importClassPlan({
classId: props.classId,
mode: mode.value,
payload: JSON.parse(sourceText.value),
});
ElMessage.success(`${result.created} 新增 / ${result.updated} 更新`);
}
emit('imported');
visible.value = false;
} finally {
@@ -192,22 +278,87 @@ async function doImport(): Promise<void> {
}
function fillSample(): void {
jsonText.value = CLASS_PLAN_SAMPLE;
sourceHint.value = 'json';
sourceText.value = CLASS_PLAN_SAMPLE;
preview.value = null;
previewFormat.value = null;
}
function fillYamlSample(): void {
sourceHint.value = 'yaml';
sourceText.value = CLASS_PLAN_YAML_SAMPLE;
preview.value = null;
previewFormat.value = null;
ElMessage.success('已填入示例 YAML,可直接点击「解析预览」');
}
/** 复制文本:优先 Clipboard API,失败时退回隐藏 textarea(HTTP 内网环境也能复制) */
async function copyText(text: string): Promise<boolean> {
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text);
return true;
}
} catch {
/* 浏览器拒绝时走下面的兜底 */
}
try {
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
const ok = document.execCommand('copy');
document.body.removeChild(textarea);
return ok;
} catch {
return false;
}
}
async function copyAiPrompt(): Promise<void> {
const ok = await copyText(CLASS_PLAN_YAML_AI_PROMPT);
if (ok) ElMessage.success('AI 提示词已复制,粘贴给大模型并附上课表内容即可');
else ElMessage.warning('复制失败,请手动全选提示词复制');
}
/** 下载示例 YAML(与「填入示例 YAML」、服务端验收解析的是同一份内容) */
function downloadYamlSample(): void {
const blob = new Blob([CLASS_PLAN_YAML_SAMPLE], { type: 'text/yaml;charset=utf-8' });
const url = URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = url;
anchor.download = '课表导入示例.yaml';
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
URL.revokeObjectURL(url);
ElMessage.success('示例 YAML 已下载');
}
function parityLabel(item: ClassPlanEntryDto): string {
return WEEK_PARITY_LABELS[item.weekParity] ?? item.weekParity;
}
function entryLocation(item: ClassPlanEntryDto): string {
return (item as ClassPlanYamlEntryDto).location ?? '';
}
</script>
<template>
<el-dialog v-model="visible" title="导入 ClassIsland 课程表(支持单双周)" width="860px" top="5vh">
<el-dialog
v-model="visible"
title="导入课表(ClassIsland JSON / YAML)"
width="860px"
top="5vh"
class="class-plan-import-dialog"
>
<el-alert type="info" :closable="false" show-icon class="mb-12">
<template #title>
支持 ClassIsland 档案 JSON(含 TimeLayouts / ClassPlans / Subjects 的 Guid 字典)。单双周由 ClassPlan
的 WeekCountDiv / WeekCountDivTotal 决定(两条 ClassPlan = 单周 +
双周各一节);课间(TimeType=1)会自动跳过。解析失败不会修改原有课表。
支持两种格式,粘贴或选择文件后自动识别:① ClassIsland 档案 JSON(含 TimeLayouts / ClassPlans /
Subjects 的 Guid 字典);② 课表 YAML(version / subjects / schedules,enable_day 1=周一 … 7=周日,
weeks 取 all / odd / even)。单双周各一条课表,同一天的单周与双周拆成两条;解析失败不会修改原有课表。
</template>
</el-alert>
@@ -225,16 +376,47 @@ function parityLabel(item: ClassPlanEntryDto): string {
<div class="toolbar mb-8">
<el-button size="small" :loading="parsing" type="primary" @click="doPreview">解析预览</el-button>
<el-button size="small" @click="pickFile">选择 .json 文件</el-button>
<el-button size="small" @click="fillSample">填入示例</el-button>
<input ref="fileInputRef" type="file" accept=".json" class="hidden-input" @change="onFileChange" />
<el-button size="small" @click="pickFile">选择文件(.json / .yaml / .yml)</el-button>
<el-button size="small" @click="fillSample">填入示例 JSON</el-button>
<input
ref="fileInputRef"
type="file"
accept=".json,.yaml,.yml"
class="hidden-input"
@change="onFileChange"
/>
</div>
<el-input v-model="jsonText" type="textarea" :rows="7" :placeholder="TEXTAREA_PLACEHOLDER" />
<el-collapse v-model="aiPanel" class="ai-panel mb-8">
<el-collapse-item name="ai" title="不会写 YAML?复制 AI 提示词,让大模型按格式生成课表">
<div class="ai-actions mb-8">
<el-button size="small" type="primary" @click="copyAiPrompt">复制 AI 提示词</el-button>
<el-button size="small" @click="fillYamlSample">填入示例 YAML</el-button>
<el-button size="small" @click="downloadYamlSample">下载示例 YAML</el-button>
</div>
<el-input
:model-value="CLASS_PLAN_YAML_AI_PROMPT"
type="textarea"
:rows="7"
readonly
class="prompt-box"
/>
</el-collapse-item>
</el-collapse>
<el-input
v-model="sourceText"
type="textarea"
:rows="7"
:placeholder="TEXTAREA_PLACEHOLDER"
@input="onManualInput"
/>
<template v-if="preview">
<div class="preview-meta">
<span>识别格式:{{ previewFormat === 'yaml' ? '课表 YAML' : 'ClassIsland JSON' }}</span>
<span>解析课程:{{ preview.entries.length }} 节</span>
<span v-if="yamlPlanCount">课表:{{ yamlPlanCount }} 张</span>
<span v-if="parityCount">单双周分布:{{ parityCount }}</span>
<span>识别科目:{{ preview.subjects.length }} 个</span>
<span v-if="preview.layoutNames.length">时间表:{{ preview.layoutNames.join('、') }}</span>
@@ -281,6 +463,9 @@ function parityLabel(item: ClassPlanEntryDto): string {
<template #default="{ row }">{{ row.startTime }}-{{ row.endTime }}</template>
</el-table-column>
<el-table-column prop="subject" label="科目" min-width="110" />
<el-table-column v-if="showLocationColumn" label="地点" min-width="110">
<template #default="{ row }">{{ entryLocation(row) }}</template>
</el-table-column>
<el-table-column label="单双周" width="100">
<template #default="{ row }">
<el-tag v-if="row.weekParity !== 'ALL'" size="small" effect="plain">
@@ -308,24 +493,52 @@ function parityLabel(item: ClassPlanEntryDto): string {
</template>
<style scoped>
:global(.el-dialog.class-plan-import-dialog) {
display: flex;
flex-direction: column;
max-height: 90dvh;
}
:global(.class-plan-import-dialog .el-dialog__header),
:global(.class-plan-import-dialog .el-dialog__footer) {
flex-shrink: 0;
}
:global(.class-plan-import-dialog .el-dialog__body) {
min-height: 0;
overflow-y: auto;
}
.hidden-input {
display: none;
}
.preview-meta {
display: flex;
flex-wrap: wrap;
gap: 16px;
margin-top: 10px;
gap: var(--ch-space-4);
margin-top: var(--ch-space-3);
color: var(--ch-text-secondary);
font-size: 13px;
}
.ai-panel {
border: 1px solid var(--el-border-color-lighter);
border-radius: var(--ch-radius-sm);
padding: 0 var(--ch-space-3);
}
.ai-actions {
display: flex;
flex-wrap: wrap;
gap: var(--ch-space-2);
}
.prompt-box :deep(.el-textarea__inner) {
font-family: var(--ch-font-mono, Consolas, 'Courier New', monospace);
font-size: 12px;
line-height: 1.6;
}
.mb-8 {
margin-bottom: 8px;
margin-bottom: var(--ch-space-2);
}
.mb-12 {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
}
.mt-8 {
margin-top: 8px;
margin-top: var(--ch-space-2);
}
</style>
@@ -60,7 +60,7 @@ const mb = (bytes: number) => `${(bytes / 1048576).toFixed(1)} MB`;
<style scoped>
.update-status {
display: grid;
gap: 6px;
gap: var(--ch-space-2);
padding-block: 6px;
overflow-wrap: anywhere;
}
@@ -53,12 +53,12 @@ watch(
flex: 1;
min-height: 0;
overflow: auto;
padding: 12px 8px;
padding: var(--ch-space-3) var(--ch-space-2);
}
.management-group-title {
display: flex;
align-items: center;
gap: 10px;
gap: var(--ch-space-3);
width: 100%;
height: 100%;
overflow: hidden;
@@ -68,10 +68,10 @@ watch(
margin: 0;
}
.management-menu :deep(.el-sub-menu__title) {
padding: 0 14px;
padding: 0 var(--ch-space-4);
height: 46px;
margin-bottom: 4px;
border-radius: 10px;
margin-bottom: var(--ch-space-1);
border-radius: var(--ch-radius-sm);
color: var(--ch-text-secondary);
font-weight: 600;
}
@@ -83,9 +83,9 @@ watch(
}
.management-menu :deep(.el-menu-item) {
height: 42px;
padding-left: 26px;
margin: 3px 0 3px 10px;
border-radius: 8px;
padding-left: var(--ch-space-7);
margin: var(--ch-space-1) 0 var(--ch-space-1) var(--ch-space-3);
border-radius: var(--ch-radius-sm);
min-width: 0;
color: var(--ch-text-secondary);
}
@@ -104,7 +104,7 @@ watch(
}
.management-menu.menu-rail :deep(.el-sub-menu__title) {
padding: 0 !important;
margin: 4px 0 !important;
margin: var(--ch-space-1) 0 !important;
width: 48px;
height: 44px;
justify-content: center;
@@ -95,12 +95,12 @@ const emit = defineEmits<{
.plan-details {
display: flex;
flex-direction: column;
gap: 12px;
gap: var(--ch-space-3);
}
.detail-field {
display: flex;
flex-direction: column;
gap: 6px;
gap: var(--ch-space-2);
color: var(--ch-text-secondary);
font-size: var(--el-font-size-small);
}
@@ -122,7 +122,7 @@ const emit = defineEmits<{
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
}
.inline-fields :deep(.el-input-number) {
width: 74px;
@@ -134,8 +134,8 @@ const emit = defineEmits<{
display: inline-flex;
align-items: center;
align-self: flex-start;
gap: 5px;
padding: 4px 0;
gap: var(--ch-space-1);
padding: var(--ch-space-1) 0;
border: 0;
background: transparent;
color: var(--el-color-primary);
@@ -147,7 +147,7 @@ const emit = defineEmits<{
height: 16px;
}
.save-plan {
margin-top: 4px;
margin-top: var(--ch-space-1);
width: 100%;
}
</style>
@@ -143,7 +143,7 @@ onMounted(load);
<el-input-number v-model="status.config.hour" :min="0" :max="23" />
</el-form-item>
<el-form-item label="新学期开学日(空则当年 9 月 1 日)">
<el-date-picker
<ch-date-picker
v-model="status.plan.termStartDate"
type="date"
value-format="YYYY-MM-DD"
@@ -122,7 +122,7 @@ function formatValue(value: number): string {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 18px 0 28px;
padding: var(--ch-space-5) 0 var(--ch-space-7);
}
.tick {
@@ -130,7 +130,7 @@ function formatValue(value: number): string {
display: flex;
align-items: center;
justify-content: flex-end;
padding-right: 8px;
padding-right: var(--ch-space-2);
font-size: 11px;
line-height: 1;
white-space: nowrap;
@@ -159,9 +159,9 @@ function formatValue(value: number): string {
.bars {
display: flex;
align-items: stretch;
gap: 8px;
gap: var(--ch-space-2);
height: 100%;
padding: 0 6px;
padding: 0 var(--ch-space-2);
}
.bar-col {
@@ -194,14 +194,14 @@ function formatValue(value: number): string {
.bar {
width: 46%;
max-width: 46px;
border-radius: 4px 4px 0 0;
border-radius: var(--ch-radius-xs) var(--ch-radius-xs) 0 0;
transition: height 0.2s ease;
}
.bar-label {
flex: none;
height: 28px;
padding-top: 6px;
padding-top: var(--ch-space-2);
font-size: 11px;
line-height: 1.3;
text-align: center;
@@ -179,7 +179,7 @@ function formatValue(value: number): string {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 18px 0 28px;
padding: var(--ch-space-5) 0 var(--ch-space-7);
}
.tick {
@@ -187,7 +187,7 @@ function formatValue(value: number): string {
display: flex;
align-items: center;
justify-content: flex-end;
padding-right: 8px;
padding-right: var(--ch-space-2);
font-size: 11px;
line-height: 1;
white-space: nowrap;
@@ -256,7 +256,7 @@ function formatValue(value: number): string {
.x-label {
flex: 1 1 0;
min-width: 0;
padding-top: 6px;
padding-top: var(--ch-space-2);
font-size: 11px;
line-height: 1.3;
text-align: center;
@@ -432,7 +432,7 @@ async function submit(): Promise<void> {
.import-toolbar {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
flex-wrap: wrap;
}
.file-name {
@@ -444,14 +444,14 @@ async function submit(): Promise<void> {
}
.import-meta {
display: flex;
gap: 16px;
gap: var(--ch-space-4);
flex-wrap: wrap;
margin: 12px 0 4px;
margin: var(--ch-space-3) 0 var(--ch-space-1);
color: var(--ch-text-secondary);
font-size: 13px;
}
.required-hint {
margin-left: 8px;
margin-left: var(--ch-space-2);
color: var(--el-color-danger);
font-size: 12px;
}
@@ -462,7 +462,7 @@ async function submit(): Promise<void> {
}
.result-stats {
display: flex;
gap: 16px;
gap: var(--ch-space-4);
flex-wrap: wrap;
font-size: 13px;
}
@@ -476,15 +476,15 @@ async function submit(): Promise<void> {
color: var(--el-color-danger);
}
.mb-8 {
margin-bottom: 8px;
margin-bottom: var(--ch-space-2);
}
.mb-12 {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
}
.mt-8 {
margin-top: 8px;
margin-top: var(--ch-space-2);
}
.mt-12 {
margin-top: 12px;
margin-top: var(--ch-space-3);
}
</style>
@@ -65,6 +65,7 @@ const nowMinutes = ref(currentMinutes());
let nowTimer: ReturnType<typeof setInterval> | null = null;
let reorderFrom = '';
let reorderTo = '';
let draftSequence = 0;
const visibleLayouts = computed(() => props.layouts.filter((item) => item.name.includes(search.value)));
const points = computed(() => layout.value?.points ?? []);
@@ -164,7 +165,8 @@ function addPoint(type: TimePointType): void {
? '分割线'
: '行动';
const point: TimePointDto = {
id: `draft-${crypto.randomUUID()}`,
// 草稿 id 只用于本次编辑;HTTP 内网没有 randomUUID,不能依赖安全上下文 API。
id: `draft-${Date.now()}-${draftSequence++}`,
position: points.value.length,
name,
startTime: toTime(start),
@@ -385,7 +387,12 @@ onUnmounted(() => {
</header>
<div class="tl-body">
<div class="layout-canvas" :inert="saving">
<!--
只在保存过程中置为 inert。不能写成 :inert="saving":旧内核没有 inert DOM property,
Vue 会把 false 落成 inert="false" 属性,而 inert 属性只要存在就整块不可交互。
undefined 会让 Vue 直接移除属性,现代浏览器与旧内核行为一致。
-->
<div class="layout-canvas" :inert="saving ? true : undefined">
<div v-if="!layout" class="panel-empty">
<ArchiveIcon name="clock" />
<p>新建一份时间表开始编辑</p>
@@ -739,14 +746,14 @@ onUnmounted(() => {
flex: 0 0 210px;
width: 210px;
flex-direction: column;
gap: 8px;
padding: 12px;
gap: var(--ch-space-2);
padding: var(--ch-space-3);
overflow: auto;
border-right: 1px solid var(--ch-border);
}
.explorer-actions {
display: flex;
gap: 4px;
gap: var(--ch-space-1);
}
.layout-explorer .command {
flex: 1;
@@ -756,11 +763,11 @@ onUnmounted(() => {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 3px;
gap: var(--ch-space-1);
width: 100%;
padding: 9px 10px;
padding: var(--ch-space-2) var(--ch-space-3);
border: 1px solid transparent;
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: transparent;
color: var(--ch-text);
font: inherit;
@@ -799,20 +806,20 @@ onUnmounted(() => {
flex-shrink: 0;
flex-wrap: wrap;
align-items: center;
gap: 4px;
gap: var(--ch-space-1);
min-height: 48px;
padding: 6px 12px;
padding: var(--ch-space-2) var(--ch-space-3);
border-bottom: 1px solid var(--ch-border);
}
.command {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
gap: var(--ch-space-2);
min-height: 32px;
padding: 6px 9px;
padding: var(--ch-space-2) var(--ch-space-2);
border: 0;
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: transparent;
color: var(--ch-text-secondary);
font: inherit;
@@ -844,7 +851,7 @@ onUnmounted(() => {
}
.command.small {
min-height: 28px;
padding: 3px 6px;
padding: var(--ch-space-1) var(--ch-space-2);
}
.command.wide {
justify-content: flex-start;
@@ -854,7 +861,7 @@ onUnmounted(() => {
.command-separator {
flex: 0 0 1px;
height: 22px;
margin: 0 3px;
margin: 0 var(--ch-space-1);
background: var(--ch-border);
}
.tl-body {
@@ -877,22 +884,22 @@ onUnmounted(() => {
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
gap: var(--ch-space-2);
min-height: 240px;
color: var(--ch-text-muted);
}
.point-list {
flex: 1;
min-height: 0;
padding: 8px 12px 16px;
padding: var(--ch-space-2) var(--ch-space-3) var(--ch-space-4);
overflow: auto;
}
.time-point-row {
display: flex;
align-items: center;
gap: 10px;
gap: var(--ch-space-3);
min-height: 46px;
padding: 6px 8px;
padding: var(--ch-space-2) var(--ch-space-2);
border-bottom: 1px solid var(--ch-border);
cursor: pointer;
}
@@ -906,7 +913,7 @@ onUnmounted(() => {
color: var(--ch-text-secondary);
}
.drag {
padding: 6px 2px;
padding: var(--ch-space-2) 2px;
border: 0;
background: transparent;
color: var(--ch-text-muted);
@@ -934,9 +941,9 @@ onUnmounted(() => {
white-space: nowrap;
}
.point-badge {
padding: 1px 6px;
padding: 1px var(--ch-space-2);
border: 1px solid var(--ch-border);
border-radius: 999px;
border-radius: var(--ch-radius-pill);
color: var(--ch-text-muted);
font-size: var(--el-font-size-extra-small);
white-space: nowrap;
@@ -946,7 +953,7 @@ onUnmounted(() => {
color: var(--el-color-primary);
}
.list-hint {
padding: 24px 8px;
padding: var(--ch-space-6) var(--ch-space-2);
color: var(--ch-text-muted);
}
.timeline {
@@ -962,7 +969,7 @@ onUnmounted(() => {
position: relative;
display: flex;
min-height: 100%;
padding-right: 8px;
padding-right: var(--ch-space-2);
}
.timeline-ruler {
position: relative;
@@ -983,7 +990,7 @@ onUnmounted(() => {
position: relative;
flex: 1;
min-width: 0;
margin-left: 8px;
margin-left: var(--ch-space-2);
border-left: 1px solid var(--ch-border);
}
.time-block {
@@ -993,9 +1000,9 @@ onUnmounted(() => {
display: flex;
overflow: visible;
align-items: center;
padding: 2px 8px;
padding: 2px var(--ch-space-2);
border: 1px solid transparent;
border-radius: 4px;
border-radius: var(--ch-radius-xs);
background: var(--el-color-primary-light-8);
color: var(--el-color-primary-dark-2);
cursor: pointer;
@@ -1081,8 +1088,8 @@ onUnmounted(() => {
flex: 0 0 300px;
width: 300px;
flex-direction: column;
gap: 12px;
padding: 14px;
gap: var(--ch-space-3);
padding: var(--ch-space-4);
overflow: auto;
border-left: 1px solid var(--ch-border);
background: var(--ch-surface-alt);
@@ -1095,7 +1102,7 @@ onUnmounted(() => {
.inspector-field {
display: flex;
flex-direction: column;
gap: 6px;
gap: var(--ch-space-2);
color: var(--ch-text-secondary);
font-size: var(--el-font-size-small);
}
@@ -1105,7 +1112,7 @@ onUnmounted(() => {
.time-parts {
display: flex;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
}
.time-parts :deep(.el-input-number) {
width: 76px;
@@ -1117,17 +1124,17 @@ onUnmounted(() => {
.type-switch {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 6px;
gap: var(--ch-space-2);
}
.type-switch button {
display: flex;
align-items: center;
justify-content: center;
gap: 5px;
gap: var(--ch-space-1);
min-height: 34px;
padding: 4px 6px;
padding: var(--ch-space-1) var(--ch-space-2);
border: 1px solid var(--ch-border);
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: var(--ch-surface);
color: var(--ch-text);
font: inherit;
@@ -1163,26 +1170,26 @@ onUnmounted(() => {
flex-shrink: 0;
align-items: flex-end;
justify-content: space-between;
gap: 10px;
padding: 8px 12px;
gap: var(--ch-space-3);
padding: var(--ch-space-2) var(--ch-space-3);
border-top: 1px solid var(--ch-border);
}
.durations {
min-width: 210px;
padding: 8px 10px;
padding: var(--ch-space-2) var(--ch-space-3);
border: 1px solid var(--ch-border);
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: var(--ch-surface);
}
.durations.collapsed {
padding: 4px 8px;
padding: var(--ch-space-1) var(--ch-space-2);
}
.durations-toggle {
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
gap: 8px;
gap: var(--ch-space-2);
padding: 2px;
border: 0;
background: transparent;
@@ -1202,13 +1209,13 @@ onUnmounted(() => {
.duration-fields {
display: flex;
flex-direction: column;
gap: 6px;
padding-top: 6px;
gap: var(--ch-space-2);
padding-top: var(--ch-space-2);
}
.duration-fields label {
display: flex;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
color: var(--ch-text-secondary);
font-size: var(--el-font-size-small);
}
@@ -1218,7 +1225,7 @@ onUnmounted(() => {
.view-switch {
display: flex;
align-items: center;
gap: 4px;
gap: var(--ch-space-1);
}
.icon-command {
display: inline-flex;
@@ -1226,9 +1233,9 @@ onUnmounted(() => {
justify-content: center;
width: 32px;
height: 32px;
padding: 4px;
padding: var(--ch-space-1);
border: 0;
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: transparent;
color: var(--ch-text-secondary);
cursor: pointer;
@@ -1255,7 +1262,7 @@ onUnmounted(() => {
}
.import-row {
display: flex;
gap: 8px;
gap: var(--ch-space-2);
width: 100%;
}
.import-row :deep(.el-select) {
@@ -1269,7 +1276,7 @@ onUnmounted(() => {
.point-inspector {
flex-basis: 260px;
width: 260px;
padding: 10px;
padding: var(--ch-space-3);
}
.point-duration,
.point-badge {
@@ -291,21 +291,21 @@ function fillSample(): void {
}
.preview-meta {
display: flex;
gap: 16px;
margin-top: 10px;
gap: var(--ch-space-4);
margin-top: var(--ch-space-3);
color: var(--ch-text-secondary);
font-size: 13px;
}
.mb-8 {
margin-bottom: 8px;
margin-bottom: var(--ch-space-2);
}
.mb-12 {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
}
.mt-8 {
margin-top: 8px;
margin-top: var(--ch-space-2);
}
.mt-12 {
margin-top: 12px;
margin-top: var(--ch-space-3);
}
</style>
@@ -137,21 +137,21 @@ watch(
}
.update-name {
margin-top: 12px;
margin-top: var(--ch-space-3);
font-size: 13px;
font-weight: 600;
color: var(--el-text-color-primary);
}
.update-notes-label {
margin: 12px 0 6px;
margin: var(--ch-space-3) 0 var(--ch-space-2);
font-size: 12px;
color: var(--el-text-color-secondary);
}
.update-notes {
margin: 0;
padding: 10px 12px;
padding: var(--ch-space-3) var(--ch-space-3);
max-height: 200px;
overflow: auto;
background: var(--el-fill-color-light);
@@ -166,14 +166,14 @@ watch(
.update-assets {
margin: 0;
padding-left: 18px;
padding-left: var(--ch-space-5);
font-size: 12px;
line-height: 1.9;
color: var(--el-text-color-regular);
}
.update-asset-size {
margin-left: 6px;
margin-left: var(--ch-space-2);
color: var(--el-text-color-secondary);
}
</style>
@@ -160,8 +160,8 @@ function handleConfirm(): void {
.urgent-card {
width: 520px;
max-width: calc(100vw - 48px);
padding: 28px 30px 22px;
border-radius: 16px;
padding: var(--ch-space-7) var(--ch-space-8) var(--ch-space-6);
border-radius: var(--ch-radius-lg);
background: var(--ch-surface);
border-top: 4px solid #f56c6c;
box-shadow: 0 24px 60px rgba(120, 20, 20, 0.35);
@@ -171,7 +171,7 @@ function handleConfirm(): void {
.urgent-icon {
width: 64px;
height: 64px;
margin: 0 auto 12px;
margin: 0 auto var(--ch-space-3);
border-radius: 50%;
display: flex;
align-items: center;
@@ -194,13 +194,13 @@ function handleConfirm(): void {
}
.urgent-title {
margin: 0 0 8px;
margin: 0 0 var(--ch-space-2);
font-size: 22px;
color: var(--ch-text);
}
.urgent-subtitle {
margin: 0 0 18px;
margin: 0 0 var(--ch-space-5);
font-size: 14px;
line-height: 1.7;
color: var(--ch-text-secondary);
@@ -214,10 +214,10 @@ function handleConfirm(): void {
.urgent-preview {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
border-radius: 10px;
margin-bottom: 10px;
gap: var(--ch-space-3);
padding: var(--ch-space-3) var(--ch-space-4);
border-radius: var(--ch-radius-sm);
margin-bottom: var(--ch-space-3);
text-align: left;
font-size: 13px;
}
@@ -250,16 +250,16 @@ function handleConfirm(): void {
.urgent-actions {
display: flex;
gap: 12px;
gap: var(--ch-space-3);
justify-content: center;
margin: 18px 0 12px;
margin: var(--ch-space-5) 0 var(--ch-space-3);
}
.urgent-progress {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
gap: var(--ch-space-3);
min-height: 52px;
}
@@ -0,0 +1,34 @@
import { sha256 } from '@noble/hashes/sha2.js';
import type { AiAttachment } from '@classhelper/shared';
export async function hashAttachment(file: File, signal?: AbortSignal): Promise<AiAttachment> {
const hash = sha256.create();
const reader = file.stream().getReader();
try {
while (true) {
if (signal?.aborted) throw new DOMException('已取消', 'AbortError');
const chunk = await reader.read();
if (chunk.done) break;
hash.update(chunk.value);
}
} finally {
await reader.cancel().catch(() => undefined);
reader.releaseLock();
}
return {
id: crypto.randomUUID(),
name: file.name,
size: file.size,
sha256: [...hash.digest()].map((value) => value.toString(16).padStart(2, '0')).join(''),
};
}
export async function importFileBase64(file: File): Promise<string> {
if (file.size > 8 * 1024 * 1024) throw new Error('结构化导入文件不能超过 8 MB');
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = () => reject(new Error('文件读取失败'));
reader.onload = () => resolve(String(reader.result).split(',')[1] ?? '');
reader.readAsDataURL(file);
});
}
@@ -0,0 +1,18 @@
import type { AiExecutionRequest } from '@classhelper/shared';
export function allowsAiExecution(action: Pick<AiExecutionRequest, 'method' | 'path'>): boolean {
if (
action.path === '/auth/password' ||
/^\/(?:homeworks|notifications|calls|courseware|classes|courses|students|teachers|grades|class-plans|class-plan-groups|time-layouts|term|archives|permissions|clients|imports|schedules)(?:\/|$)/.test(
action.path,
)
)
return true;
if (action.method === 'POST' && ['/update/client/fetch', '/update/client/releases'].includes(action.path))
return true;
return (
action.method === 'DELETE' &&
/^\/update\/client\/releases\/[A-Za-z0-9][A-Za-z0-9._-]{0,39}$/.test(action.path) &&
!action.path.includes('..')
);
}
@@ -0,0 +1,80 @@
import { isAxiosError } from 'axios';
import type { DateMark } from '@classhelper/ui';
const prefix = 'classhelper.calendar.';
type CalendarStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem' | 'key' | 'length'>;
function browserStorage(): CalendarStorage | undefined {
try {
return globalThis.sessionStorage;
} catch {
return undefined;
}
}
export function calendarCacheScope(
principal: {
user: { id: string; role: string } | null;
permissions: readonly string[];
classScopes: object;
allScopeKeys: readonly string[];
},
server = location.origin,
): string {
return JSON.stringify([
server,
principal.user?.id,
principal.user?.role,
principal.permissions,
principal.classScopes,
principal.allScopeKeys,
]);
}
export function clearCalendarCache(storage: CalendarStorage | undefined = browserStorage()): void {
if (!storage) return;
try {
for (let i = storage.length - 1; i >= 0; i--) {
const key = storage.key(i);
if (key?.startsWith(prefix)) storage.removeItem(key);
}
} catch {
/* 缓存不可用不阻断登录和在线读取。 */
}
}
export async function cachedCalendarMarks(
scope: string,
filters: object,
load: () => Promise<DateMark[]>,
storage: CalendarStorage | undefined = browserStorage(),
): Promise<DateMark[]> {
const key = prefix + JSON.stringify([scope, filters]);
try {
const marks = await load();
try {
if (storage && storage.length >= 100) clearCalendarCache(storage);
storage?.setItem(key, JSON.stringify(marks));
} catch {
/* 配额或隐私设置不影响在线结果。 */
}
return marks;
} catch (error) {
// 服务端拒绝、校验错误与撤权不能降级读取缓存。
if (isAxiosError(error) && [401, 403].includes(error.response?.status ?? 0)) clearCalendarCache(storage);
if (!isAxiosError(error) || error.response) throw error;
try {
const cached: unknown = JSON.parse(storage?.getItem(key) ?? 'null');
if (
Array.isArray(cached) &&
cached.every(
(item) =>
item && /^\d{4}-\d{2}-\d{2}$/.test(item.date) && Number.isInteger(item.count) && item.count > 0,
)
)
return cached;
} catch {
/* 损坏缓存交给原请求错误处理。 */
}
throw error;
}
}
+4
View File
@@ -9,6 +9,8 @@ import {
ElCheckbox,
ElCheckboxGroup,
ElCol,
ElCollapse,
ElCollapseItem,
ElContainer,
ElDatePicker,
ElDescriptions,
@@ -74,6 +76,8 @@ export function registerElementPlus(app: App): void {
ElCheckbox,
ElCheckboxGroup,
ElCol,
ElCollapse,
ElCollapseItem,
ElContainer,
ElDatePicker,
ElDescriptions,
+58 -82
View File
@@ -4,6 +4,7 @@ import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
import { STORAGE_KEYS, type PermissionKey } from '@classhelper/shared';
import { authApi } from '@/api';
import { FullScreenGuide, ONBOARDING_VERSION } from '@classhelper/ui';
import ManagementMenu from '@/components/ManagementMenu.vue';
import { MANAGEMENT_GROUPS, type ManagementMenuItem } from '@/config/navigation';
import UpdateCheckDialog from '@/components/UpdateCheckDialog.vue';
@@ -261,81 +262,64 @@ async function submitPassword(): Promise<void> {
void router.push({ name: 'login' });
}
/* ------------------------------------------------------------ 首次登录引导 */
/**
* 引导版本:内容改版后 +1,看过旧版的老用户会再收到一次新版引导。
* 「已看过」存 localStorage(STORAGE_KEYS.onboarding,值为版本号)。
*/
const ONBOARDING_VERSION = 1;
const tourOpen = ref(false);
/** 「看过」落盘:走完、跳过(右上角 × / Esc)都算看过,之后不再自动弹出 */
function markOnboardingSeen(): void {
try {
localStorage.setItem(STORAGE_KEYS.onboarding, String(ONBOARDING_VERSION));
} catch {
// localStorage 不可用(隐私模式等)时仅本次会话内生效
/* 隐私模式仅在当前会话显示。 */
}
}
let onboardingTimer: ReturnType<typeof setTimeout>;
onMounted(() => {
try {
if (localStorage.getItem(STORAGE_KEYS.onboarding) === String(ONBOARDING_VERSION)) return;
} catch {
return;
}
// 等布局与首屏数据渲染稳定后再弹,避免和首屏加载抢注意力
window.setTimeout(() => {
onboardingTimer = setTimeout(() => {
tourOpen.value = true;
}, 600);
});
/**
* 引导锚点:按 data-tour 属性惰性查询 DOM(弹出某一步时才找元素)。
* 找不到(例如手机小屏没有侧边栏)就返回 null,el-tour 会把卡片放到屏幕居中,不会报错。
*/
function tourTarget(name: string): () => HTMLElement | null {
return () => document.querySelector<HTMLElement>(`[data-tour="${name}"]`);
}
onUnmounted(() => clearTimeout(onboardingTimer));
const tourSteps = computed(() => [
{
target: null,
title: '欢迎使用 ClassHelper',
description:
'教师与管理员在这里发布课表、作业、通知与成绩,学生通过桌面客户端实时接收。花一分钟认识一下界面。',
},
isMobile.value
? {
target: tourTarget('nav-toggle'),
title: '打开功能菜单',
description: '小屏幕下侧边栏收进抽屉,点左上角按钮即可唤出全部功能页面。',
placement: 'bottom-start',
}
: {
target: tourTarget('side-nav'),
title: '左侧功能菜单',
description:
'菜单按角色显示:管理员可管理班级、学生与教师;班主任与科任老师可维护课表、发布作业与通知、录入成绩。',
// 侧栏是全高元素,默认 bottom 会把卡片推到视口外,必须放右侧
placement: 'right',
},
{
target: tourTarget('conn-tag'),
title: '实时通道',
description: '绿色表示与后端保持实时连接,发布的内容会立刻推送到对应班级的 ClassHelper 班级端与灵动岛。',
id: 'navigation',
title: '从工作台开始',
text: '左侧菜单只显示你可以使用的功能。',
example: ['工作台', '教学管理', '班级与人员'],
},
{
target: tourTarget('user-chip'),
title: '账号菜单',
description: '在这里修改密码、退出登录,也可以随时重看本引导。',
id: 'dates',
title: '用日历查找记录',
text: '选择日期筛选内容,圆点表示当天有记录。',
example: ['选择日期', '有记录的日期 ·', '查看当天内容'],
},
...(auth.can('homework:write') || auth.can('courseware:write') || auth.can('notification:publish')
? [
{
id: 'publish',
title: '发布与导入',
text: '在对应页面发布内容,导入文件时先核对预览。',
example: ['选择班级', '填写内容或选择文件', '核对后发布'],
},
]
: []),
...(auth.can('ai:use')
? [
{
id: 'ai',
title: '让 AI 帮你处理',
text: '描述任务或添加文件,核对操作计划后再确认执行。',
example: ['把这份课件推送给任教班级', '核对文件和班级', '确认执行'],
},
]
: []),
{
target: null,
title: '开始使用',
description: '发布第一条内容试试吧。以后随时可以点右上角头像 →「使用引导」重看。',
id: 'account',
title: '随时调整与重看',
text: '账号菜单可以修改密码、退出登录和重看引导。',
example: ['主题与关怀模式', '账号菜单', '使用引导'],
},
]);
</script>
@@ -667,20 +651,12 @@ const tourSteps = computed(() => [
<!-- 检查更新:问服务端最新 Release(浏览器受 CSP 限制不能直连 GitHub),见组件内说明 -->
<UpdateCheckDialog v-model="updateVisible" />
<!--
新手引导:首次登录自动弹出(见 script 的 onMounted),头像菜单「使用引导」可重看。
target 为 null 的步骤(首尾两步)由 el-tour 放到屏幕居中;其余步骤锚定真实 UI。
-->
<el-tour v-model="tourOpen" @close="markOnboardingSeen" @finish="markOnboardingSeen">
<el-tour-step
v-for="(step, index) in tourSteps"
:key="index"
:target="step.target"
:title="step.title"
:description="step.description"
:placement="step.placement"
/>
</el-tour>
<FullScreenGuide
v-model="tourOpen"
:steps="tourSteps"
brand-logo="/logo.png"
@finish="markOnboardingSeen"
/>
</el-container>
</template>
@@ -710,9 +686,9 @@ const tourSteps = computed(() => [
.brand {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
height: 56px;
padding: 0 16px;
padding: 0 var(--ch-space-4);
color: #fff;
font-weight: 600;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
@@ -760,7 +736,7 @@ const tourSteps = computed(() => [
.layout-menu::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.18);
border-radius: 999px;
border-radius: var(--ch-radius-pill);
}
.layout-menu::-webkit-scrollbar-track {
@@ -775,7 +751,7 @@ const tourSteps = computed(() => [
* 现在激活项不再单独改外边距,切换时整列菜单纹丝不动。
*/
.layout-menu :deep(.el-menu-item) {
margin: 2px 8px;
margin: var(--ch-space-1) var(--ch-space-2);
border-radius: var(--ch-radius-sm);
/* 压在指示器之上,文字才不会被盖住 */
position: relative;
@@ -834,8 +810,8 @@ const tourSteps = computed(() => [
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 0 16px;
gap: var(--ch-space-3);
padding: 0 var(--ch-space-4);
}
.nav-toggle {
@@ -844,7 +820,7 @@ const tourSteps = computed(() => [
justify-content: center;
width: 32px;
height: 32px;
margin-right: 2px;
margin-right: var(--ch-space-1);
border: none;
border-radius: var(--ch-radius-sm);
background: var(--ch-surface-sunken);
@@ -860,7 +836,7 @@ const tourSteps = computed(() => [
.header-left {
display: flex;
align-items: center;
gap: 10px;
gap: var(--ch-space-3);
min-width: 0;
}
@@ -872,14 +848,14 @@ const tourSteps = computed(() => [
}
.header-conn {
margin-left: 4px;
margin-left: var(--ch-space-1);
}
.header-right {
display: flex;
align-items: center;
/* 主题按钮与用户名牌之间留一点气口(两者原本紧贴) */
gap: 4px;
gap: var(--ch-space-1);
flex: 0 0 auto;
}
@@ -925,7 +901,7 @@ const tourSteps = computed(() => [
.user-chip {
display: flex;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
cursor: pointer;
outline: none;
}
@@ -940,8 +916,8 @@ const tourSteps = computed(() => [
@media (max-width: 768px) {
.layout-header {
height: var(--ch-header-height);
padding: 0 10px;
gap: 8px;
padding: 0 var(--ch-space-3);
gap: var(--ch-space-2);
}
.header-title {
@@ -994,14 +970,14 @@ const tourSteps = computed(() => [
.care-panel {
display: flex;
flex-direction: column;
gap: 6px;
gap: var(--ch-space-2);
}
.care-panel-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
gap: var(--ch-space-2);
}
.care-panel-title {
+3
View File
@@ -11,6 +11,8 @@ import { registerAppIcons } from './icons';
import { applyMotionTokens } from './composables/motion';
import { useUiStore } from './stores/ui';
import '@/styles/index.css';
import { registerSharedUi } from '@classhelper/ui';
import '@classhelper/ui/theme.css';
const app = createApp(App);
const pinia = createPinia();
@@ -21,6 +23,7 @@ registerAppIcons(app);
app.use(pinia);
app.use(router);
registerElementPlus(app);
registerSharedUi(app);
/**
* 全局错误处理。
+4
View File
@@ -12,6 +12,7 @@ import {
} from '@classhelper/shared';
import { authApi, permissionApi } from '@/api';
import type { MenuAction } from '@/config/navigation';
import { clearCalendarCache } from '@/composables/calendarCache';
/**
* 会话主体。
@@ -184,6 +185,7 @@ export const useAuthStore = defineStore('auth', () => {
}
function clear(): void {
clearCalendarCache();
token.value = null;
user.value = null;
resetPermissions();
@@ -195,6 +197,8 @@ export const useAuthStore = defineStore('auth', () => {
user,
loading,
permissions,
classScopes,
allScopeKeys,
permissionsFromGroups,
permissionsLoaded,
isAuthenticated,
@@ -133,6 +133,10 @@ export const useRealtimeStore = defineStore('realtime', () => {
dispatch(SOCKET_EVENTS.scheduleUpdated, payload);
});
instance.on(SOCKET_EVENTS.coursewareChanged, (payload) => {
markEvent(SOCKET_EVENTS.coursewareChanged);
dispatch(SOCKET_EVENTS.coursewareChanged, payload);
});
instance.on(SOCKET_EVENTS.connected, (payload: { rooms: string[] }) => {
markEvent(SOCKET_EVENTS.connected);
console.info('[realtime] 已加入房间', payload.rooms);
+57 -48
View File
@@ -1,11 +1,20 @@
:root {
--ch-bg: #f2f4f8;
/* 圆角设计令牌:卡片 > 面板 > 控件 > 小元素,统一走这四个档位 */
/* 圆角设计令牌:弹窗 > 卡片 > 面板 > 控件 > 小元素。 */
--ch-radius-xl: 22px;
--ch-radius-lg: 18px;
--ch-radius-md: 14px;
--ch-radius-sm: 10px;
--ch-radius-xs: 6px;
--ch-radius-pill: 999px;
/* 间距统一使用 4px 网格,深浅主题与关怀模式共用同一套几何。 */
--ch-space-1: 4px;
--ch-space-2: 8px;
--ch-space-3: 12px;
--ch-space-4: 16px;
--ch-space-5: 20px;
--ch-space-6: 24px;
--ch-space-7: 28px;
--ch-card-radius: var(--ch-radius-lg);
--ch-border: #e6e8ef;
--ch-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
@@ -58,7 +67,7 @@
/* Element Plus 圆角令牌对齐(组件库内部都引用这些变量,改这里即可全局生效) */
--el-border-radius-base: var(--ch-radius-sm);
--el-border-radius-small: 8px;
--el-border-radius-small: var(--ch-radius-xs);
--el-border-radius-round: var(--ch-radius-pill);
--el-box-shadow-light: var(--ch-shadow-sm);
}
@@ -229,17 +238,17 @@ html.care-mode .care-emphasis {
.ch-nav.is-collapsed .el-menu--vertical:not(.el-menu--collapse) .el-sub-menu__title {
height: 36px;
line-height: 36px;
margin: 1px 8px;
padding-left: 12px;
padding-right: 12px;
margin: var(--ch-space-1) var(--ch-space-2);
padding-left: var(--ch-space-3);
padding-right: var(--ch-space-3);
}
.ch-nav.is-collapsed .el-menu--vertical:not(.el-menu--collapse) .el-sub-menu .el-menu-item {
height: 36px;
line-height: 36px;
margin: 1px 8px;
padding-left: 12px;
padding-right: 12px;
margin: var(--ch-space-1) var(--ch-space-2);
padding-left: var(--ch-space-3);
padding-right: var(--ch-space-3);
}
/*
@@ -270,8 +279,8 @@ html.care-mode .care-emphasis {
/* 品牌区在折叠态收成图标一枚:收内边距 + 收掉 gap + 文字淡出(**不是** v-if 删节点) */
.ch-nav.is-collapsed .brand {
gap: 0;
padding-left: 20px;
padding-right: 20px;
padding-left: var(--ch-space-5);
padding-right: var(--ch-space-5);
}
.ch-nav.is-collapsed .brand-text {
@@ -296,12 +305,12 @@ html.care-mode .care-emphasis {
.el-card__header {
border-bottom: 1px solid var(--ch-border);
padding: 14px 18px;
padding: var(--ch-space-4) var(--ch-space-5);
font-weight: 600;
}
.el-card__body {
padding: 18px;
padding: var(--ch-space-5);
}
.el-button {
@@ -344,16 +353,16 @@ html.care-mode .care-emphasis {
.el-dialog__header {
margin-right: 0;
padding: 18px 22px 8px;
padding: var(--ch-space-5) var(--ch-space-6) var(--ch-space-2);
font-weight: 600;
}
.el-dialog__body {
padding: 10px 22px 6px;
padding: var(--ch-space-3) var(--ch-space-6) var(--ch-space-2);
}
.el-dialog__footer {
padding: 8px 22px 18px;
padding: var(--ch-space-2) var(--ch-space-6) var(--ch-space-5);
}
.el-drawer {
@@ -385,7 +394,7 @@ html.care-mode .care-emphasis {
.el-message-box {
border-radius: var(--ch-radius-lg);
padding: 20px 22px;
padding: var(--ch-space-5) var(--ch-space-6);
}
.el-popper.is-light {
@@ -396,12 +405,12 @@ html.care-mode .care-emphasis {
.el-dropdown-menu__item,
.el-select-dropdown__item {
border-radius: var(--ch-radius-sm);
margin: 2px 6px;
margin: var(--ch-space-1) var(--ch-space-2);
}
.el-tag {
border-radius: var(--ch-radius-pill);
padding: 0 10px;
padding: 0 var(--ch-space-3);
}
.el-alert {
@@ -514,15 +523,15 @@ body {
}
.page {
padding: 18px 22px 28px;
padding: var(--ch-space-5) var(--ch-space-6) var(--ch-space-7);
}
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
gap: 12px;
margin-bottom: var(--ch-space-4);
gap: var(--ch-space-3);
flex-wrap: wrap;
}
@@ -535,12 +544,12 @@ body {
.page-subtitle {
color: var(--ch-text-muted);
font-size: 13px;
margin: 4px 0 0;
margin: var(--ch-space-1) 0 0;
}
.toolbar {
display: flex;
gap: 10px;
gap: var(--ch-space-3);
flex-wrap: wrap;
align-items: center;
}
@@ -548,13 +557,13 @@ body {
.stat-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 12px;
gap: var(--ch-space-3);
}
.stat-card {
background: var(--ch-surface);
border-radius: var(--ch-radius-lg);
padding: 18px;
padding: var(--ch-space-5);
border: none;
box-shadow: var(--ch-shadow-sm);
transition:
@@ -581,13 +590,13 @@ body {
.stat-value {
font-size: 26px;
font-weight: 700;
margin-top: 6px;
margin-top: var(--ch-space-2);
}
.stat-hint {
color: var(--ch-text-placeholder);
font-size: 12px;
margin-top: 4px;
margin-top: var(--ch-space-1);
}
.text-muted {
@@ -595,11 +604,11 @@ body {
}
.mt-12 {
margin-top: 12px;
margin-top: var(--ch-space-3);
}
.mt-16 {
margin-top: 16px;
margin-top: var(--ch-space-4);
}
.timetable-cell {
@@ -621,7 +630,7 @@ body {
height: 8px;
border-radius: 50%;
background: #f56c6c;
margin-right: 6px;
margin-right: var(--ch-space-2);
}
/* ---------------------------------------------------------------- 小屏适配 */
@@ -634,22 +643,22 @@ body {
/* 平板:内容区收紧一点,避免横向滚动 */
@media (max-width: 992px) {
.page {
padding: 14px 14px 20px;
padding: var(--ch-space-4) var(--ch-space-4) var(--ch-space-5);
}
.page-header {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
}
}
@media (max-width: 768px) {
.page {
padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
padding: var(--ch-space-3) var(--ch-space-3) calc(var(--ch-space-4) + env(safe-area-inset-bottom, 0px));
}
.page-header {
margin-bottom: 10px;
gap: 8px;
margin-bottom: var(--ch-space-3);
gap: var(--ch-space-2);
}
.page-title {
@@ -663,7 +672,7 @@ body {
/* 工具栏:控件纵向铺满,方便拇指点击 */
.toolbar {
width: 100%;
gap: 8px;
gap: var(--ch-space-2);
}
.toolbar > .el-select,
@@ -691,11 +700,11 @@ body {
/* 统计卡片:小屏两列 */
.stat-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
gap: var(--ch-space-3);
}
.stat-card {
padding: 12px;
padding: var(--ch-space-3);
}
.stat-value {
@@ -704,7 +713,7 @@ body {
/* 表格:放进卡片内横向滚动,避免整页左右晃动 */
.table-card > .el-card__body {
padding: 8px;
padding: var(--ch-space-2);
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
@@ -721,15 +730,15 @@ body {
.el-dialog {
width: calc(100vw - 24px) !important;
max-width: 560px;
margin: 10px auto !important;
margin: var(--ch-space-3) auto !important;
}
.el-dialog__body {
padding: 12px 14px !important;
padding: var(--ch-space-3) var(--ch-space-4) !important;
}
.el-dialog__header {
padding: 14px 14px 6px !important;
padding: var(--ch-space-4) var(--ch-space-4) var(--ch-space-2) !important;
}
.el-message-box {
@@ -749,7 +758,7 @@ body {
/* 表单标签顶部对齐,输入框占满整行 */
.el-form-item {
margin-bottom: 14px;
margin-bottom: var(--ch-space-4);
}
.page .el-descriptions__label {
@@ -759,7 +768,7 @@ body {
.el-pagination {
justify-content: center;
flex-wrap: wrap;
gap: 4px;
gap: var(--ch-space-1);
}
/* 标签页在窄屏下可横向滚动,避免换行挤压 */
@@ -915,17 +924,17 @@ input[type='file']:not([hidden]) {
color: var(--el-text-color-regular);
}
input[type='file']::file-selector-button {
padding: 8px 16px;
margin-right: 12px;
padding: var(--ch-space-2) var(--ch-space-4);
margin-right: var(--ch-space-3);
border: 1px solid var(--el-border-color);
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: var(--el-color-primary-light-9);
color: var(--el-color-primary);
font: inherit;
cursor: pointer;
}
.toolbar {
row-gap: 12px;
row-gap: var(--ch-space-3);
}
.toolbar > .el-button + .el-button {
margin-left: 0;
@@ -30,8 +30,8 @@ html.dark {
.layout .brand,
.ch-sidebar-drawer .brand {
height: 64px;
padding: 0 24px;
gap: 12px;
padding: 0 var(--ch-space-6);
gap: var(--ch-space-3);
border-bottom: 0;
color: var(--ch-text);
letter-spacing: 0.3px;
@@ -45,7 +45,7 @@ html.dark {
border-radius: 0;
box-shadow: none;
border-bottom: 1px solid var(--ch-border);
padding: 0 24px;
padding: 0 var(--ch-space-6);
}
.layout .layout-body {
display: flex;
@@ -64,14 +64,14 @@ html.dark {
display: none;
}
.layout .header-right {
gap: 12px;
gap: var(--ch-space-3);
}
.layout .nav-toggle {
background: transparent;
}
.layout .user-chip {
padding: 6px 10px;
border-radius: 10px;
padding: var(--ch-space-2) var(--ch-space-3);
border-radius: var(--ch-radius-sm);
background: var(--ch-surface-alt);
}
.sidebar-foot {
@@ -79,7 +79,7 @@ html.dark {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
gap: var(--ch-space-2);
height: 48px;
color: var(--ch-text-muted);
border-top: 1px solid var(--ch-border);
@@ -95,12 +95,12 @@ html.dark {
.nav-search {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
background: var(--ch-surface-alt);
border: 1px solid var(--ch-border);
color: var(--ch-text-muted);
border-radius: 8px;
padding: 7px 10px;
border-radius: var(--ch-radius-sm);
padding: var(--ch-space-2) var(--ch-space-3);
cursor: pointer;
font: inherit;
font-size: 12px;
@@ -110,16 +110,16 @@ html.dark {
font: inherit;
font-size: 10px;
border: 1px solid var(--ch-border);
border-radius: 4px;
padding: 1px 4px;
border-radius: var(--ch-radius-xs);
padding: var(--ch-space-1) var(--ch-space-1);
background: var(--ch-surface);
}
.workspace-tabs {
display: flex;
flex-shrink: 0;
height: 46px;
padding: 0 20px;
gap: 12px;
padding: 0 var(--ch-space-5);
gap: var(--ch-space-3);
background: var(--ch-surface);
border-bottom: 1px solid var(--ch-border);
min-width: 0;
@@ -131,16 +131,16 @@ html.dark {
overflow-x: auto;
scrollbar-width: none;
min-width: 0;
gap: 4px;
gap: var(--ch-space-1);
}
.workspace-tab {
display: flex;
align-items: center;
flex-shrink: 0;
border-bottom: 2px solid transparent;
gap: 2px;
gap: var(--ch-space-1);
color: var(--ch-text-muted);
padding: 0 4px;
padding: 0 var(--ch-space-1);
}
.workspace-tab.active {
border-bottom-color: var(--el-color-primary);
@@ -151,20 +151,20 @@ html.dark {
.tabs-action {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
border: 0;
color: inherit;
background: transparent;
cursor: pointer;
font: inherit;
font-size: 13px;
padding: 8px;
padding: var(--ch-space-2);
white-space: nowrap;
}
.workspace-tab button.close-tab {
font-size: 18px;
padding: 2px 5px;
border-radius: 4px;
padding: var(--ch-space-1) var(--ch-space-1);
border-radius: var(--ch-radius-xs);
}
.workspace-tab button:hover,
.tabs-action:hover {
@@ -179,7 +179,7 @@ html.dark {
.layout-main .page {
max-width: 1800px;
margin: 0 auto;
padding: 24px;
padding: var(--ch-space-6);
}
.layout-main .page-title {
font-size: 22px;
@@ -187,16 +187,16 @@ html.dark {
font-weight: 600;
}
.layout-main .page-subtitle {
margin-top: 8px;
margin-top: var(--ch-space-2);
color: var(--ch-text-muted);
}
.layout-main .el-card {
border-radius: 12px;
border-radius: var(--ch-radius-md);
border: 1px solid var(--ch-border);
box-shadow: none;
}
.layout-main .el-card__header {
padding: 18px 22px;
padding: var(--ch-space-5) var(--ch-space-6);
background: transparent;
font-weight: 600;
border-color: var(--ch-border);
@@ -213,19 +213,19 @@ html.dark {
.navigation-results {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 16px;
gap: var(--ch-space-2);
margin-top: var(--ch-space-4);
max-height: 50vh;
overflow: auto;
}
.navigation-results > button {
border: 0;
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: var(--ch-surface-alt);
padding: 12px;
padding: var(--ch-space-3);
display: flex;
align-items: center;
gap: 12px;
gap: var(--ch-space-3);
color: var(--ch-text);
cursor: pointer;
text-align: left;
@@ -251,7 +251,7 @@ html.dark {
display: none;
}
.layout .header-right {
gap: 6px;
gap: var(--ch-space-2);
}
.management-breadcrumb .el-breadcrumb__item:nth-child(2) {
display: none;
@@ -260,17 +260,17 @@ html.dark {
@media (max-width: 768px) {
.layout .layout-header {
height: 56px;
padding: 0 12px;
padding: 0 var(--ch-space-3);
}
.workspace-tabs {
height: 42px;
padding: 0 10px;
padding: 0 var(--ch-space-3);
}
.layout-main .page {
padding: 16px 12px;
padding: var(--ch-space-4) var(--ch-space-3);
}
.layout .user-chip {
padding: 6px;
padding: var(--ch-space-2);
background: transparent;
}
}
+25 -26
View File
@@ -12,20 +12,7 @@ import { aiApi, systemApi } from '@/api';
import { useAuthStore } from '@/stores/auth';
import { useResponsive } from '@/composables/useResponsive';
/**
* 大模型设置(`ai:manage`)。
*
* 三个 Tab 的理由:
* 1. 「模型配置」—— 开关与接入参数。**密钥单向**:`GET /ai/settings` 永不回传密钥,
* 只回 `hasApiKey` + `keyHint`(尾号),所以输入框永远是空的,"留空 = 不修改"是刻意的语义
* (见 `api/index.ts` 的 `aiApi.updateSettings` 与 `modules/ai/ai.service.ts` 的 put 分支)。
* 2. 「使用记录」—— 解析审计(谁、什么原话、判断成什么动作)。
* 本页只读,不做"发布回执":审计行是解析那一刻写的(`status: 'pending'`),
* 真正发布走的是既有发布端点,那不是助手链路的事。
* 3. 「系统」(仅 `system:manage`)—— 开发者模式 + 只读诊断。
* 放在这里而不是单独开一个路由,是因为它权限更高、平时不需要看,
* Tabs 天然按权限隐藏(没有 system:manage 的人连标签都看不到),比多一个菜单项更省事。
*/
/** 模型配置只回传 Key 状态;使用记录同时包含计划和业务执行结果。 */
const auth = useAuthStore();
const { isMobile } = useResponsive();
@@ -146,13 +133,24 @@ const STATUS_LABELS: Record<string, string> = {
interpreted: '已解析,待人工确认',
unrecognized: '未识别出可用动作',
pending: '已解析',
confirmed: '已发布',
confirmed: '已确认,待执行',
succeeded: '已完成',
partial: '部分完成',
queried: '已查询',
rejected: '已拒绝或取消',
blocked: '已停止,待核对',
cancelled: '已放弃',
failed: '发布失败',
failed: '执行失败',
};
function intentLabel(intent: string): string {
return INTENT_LABELS[intent] ?? intent;
const parts = intent
.split(',')
.filter(Boolean)
.map((key) => INTENT_LABELS[key] ?? key);
return parts.length > 2
? `${parts.slice(0, 2).join('、')} 等 ${parts.length} 项`
: parts.join('、') || '未识别';
}
function statusLabel(status: string): string {
@@ -162,7 +160,9 @@ function statusLabel(status: string): string {
async function loadAudit(): Promise<void> {
auditLoading.value = true;
try {
audit.value = await aiApi.audit(50);
const [rows, tools] = await Promise.all([aiApi.audit(50), aiApi.capabilities().catch(() => [])]);
for (const tool of tools) INTENT_LABELS[tool.action] = tool.label;
audit.value = rows;
} catch {
// 拦截器已提示
} finally {
@@ -241,7 +241,6 @@ onMounted(async () => {
<div class="page-header">
<div>
<h2 class="page-title">大模型设置</h2>
<p class="page-subtitle">配置「AI 助手」用哪种解析方式;助手只解析、不写库,发布始终由老师确认</p>
</div>
</div>
@@ -420,7 +419,7 @@ onMounted(async () => {
}
.field-hint {
margin: 4px 0 0;
margin: var(--ch-space-1) 0 0;
color: var(--ch-text-muted);
font-size: var(--el-font-size-extra-small);
line-height: 1.6;
@@ -429,7 +428,7 @@ onMounted(async () => {
.key-row {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
width: 100%;
}
@@ -437,8 +436,8 @@ onMounted(async () => {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
gap: var(--ch-space-3);
margin-bottom: var(--ch-space-3);
}
.cell-muted {
@@ -446,7 +445,7 @@ onMounted(async () => {
}
.cell-text {
margin-left: 8px;
margin-left: var(--ch-space-2);
color: var(--ch-text-secondary);
}
@@ -457,14 +456,14 @@ onMounted(async () => {
}
.system-card + .system-card {
margin-top: 16px;
margin-top: var(--ch-space-4);
}
.switch-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
gap: var(--ch-space-4);
}
.switch-title {
File diff suppressed because it is too large. Load diff
+6 -7
View File
@@ -502,7 +502,6 @@ async function saveSettings() {
<div class="page-header">
<div>
<h2 class="page-title">班级管理</h2>
<p class="page-subtitle">按授权范围查看班级,管理操作需要相应权限。</p>
</div>
<div class="toolbar">
<el-input
@@ -595,7 +594,7 @@ async function saveSettings() {
<el-input-number v-model="settings.termWeeks" :min="1" :max="maxTermWeeks" />
</el-form-item>
<el-form-item label="开学日期">
<el-date-picker v-model="settings.termStartDate" type="date" value-format="YYYY-MM-DD" clearable />
<ch-date-picker v-model="settings.termStartDate" type="date" value-format="YYYY-MM-DD" clearable />
</el-form-item>
</el-form>
<template #footer>
@@ -928,24 +927,24 @@ async function saveSettings() {
<style scoped>
.account-tag {
margin-left: 6px;
margin-left: var(--ch-space-2);
}
.mb-12 {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
}
.ml-8 {
margin-left: 8px;
margin-left: var(--ch-space-2);
}
.setting-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
gap: var(--ch-space-6);
}
.setting-title {
font-weight: 600;
margin-bottom: 4px;
margin-bottom: var(--ch-space-1);
}
</style>
+16 -20
View File
@@ -637,10 +637,6 @@ const deviceEmptyText = computed(() =>
<div class="page-header">
<div>
<h2 class="page-title">客户端设备</h2>
<p class="page-subtitle">
教室里每台 ClassHelper 班级端都会上报自己的版本与状态;这里可以看版本、统一推送更新,也可以下发关机
/ 重启等远控指令。
</p>
</div>
</div>
@@ -1146,7 +1142,7 @@ const deviceEmptyText = computed(() =>
<style scoped>
/* 顶部横幅 / 弹窗内提示:圆角与底都走设计令牌,不写死数值(AGENTS.md 的现行工程约定) */
.client-banner {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
border-radius: var(--ch-radius-sm);
}
@@ -1163,29 +1159,29 @@ const deviceEmptyText = computed(() =>
/* 主操作按钮组:桌面端推到右侧,小屏铺满一行 */
.client-actions {
display: flex;
gap: 8px;
gap: var(--ch-space-2);
margin-left: auto;
}
.client-selection-bar {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
flex-wrap: wrap;
padding: 6px 2px 10px;
padding: var(--ch-space-2) var(--ch-space-1) var(--ch-space-3);
font-size: 13px;
}
/* 表格里的次级说明(状态备注 / IP / 等待确认) */
.client-sub {
margin-top: 2px;
margin-top: var(--ch-space-1);
font-size: 12px;
line-height: 1.4;
word-break: break-all;
}
.client-tag {
margin: 0 6px 2px 0;
margin: 0 var(--ch-space-2) var(--ch-space-1) 0;
}
.client-full {
@@ -1193,13 +1189,13 @@ const deviceEmptyText = computed(() =>
}
.client-switch-hint {
margin-left: 10px;
margin-left: var(--ch-space-3);
font-size: 12px;
line-height: 1.5;
}
.client-note {
margin: 8px 0 0;
margin: var(--ch-space-2) 0 0;
font-size: 12px;
line-height: 1.6;
}
@@ -1207,29 +1203,29 @@ const deviceEmptyText = computed(() =>
.client-release-forms {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
margin-bottom: 12px;
gap: var(--ch-space-3);
margin-bottom: var(--ch-space-3);
}
.client-release-form {
padding: 12px;
padding: var(--ch-space-3);
border: 1px solid var(--ch-border);
border-radius: var(--ch-radius-md);
background: var(--ch-surface-alt);
}
.client-release-form-title {
margin-bottom: 8px;
margin-bottom: var(--ch-space-2);
font-size: 13px;
font-weight: 600;
}
.client-release-file {
margin-top: 8px;
margin-top: var(--ch-space-2);
}
.client-release-submit {
margin-top: 8px;
margin-top: var(--ch-space-2);
width: 100%;
}
@@ -1241,10 +1237,10 @@ const deviceEmptyText = computed(() =>
.client-target-list {
display: flex;
flex-wrap: wrap;
gap: 4px;
gap: var(--ch-space-1);
max-height: 120px;
overflow-y: auto;
padding: 4px 10px;
padding: var(--ch-space-1) var(--ch-space-3);
border: 1px solid var(--ch-border);
border-radius: var(--ch-radius-md);
background: var(--ch-surface-alt);
+58 -34
View File
@@ -1,5 +1,8 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { countDates } from '@classhelper/ui';
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { SOCKET_EVENTS } from '@classhelper/shared';
import { useRealtimeStore } from '@/stores/realtime';
import { ElMessage, ElMessageBox } from 'element-plus';
import {
COURSEWARE_CATEGORIES,
@@ -13,6 +16,28 @@ import {
import { api } from '@/api/http';
import { useAuthStore } from '@/stores/auth';
import { useResponsive } from '@/composables/useResponsive';
const realtime = useRealtimeStore();
const onCoursewareChange = () => {
void refresh();
};
onMounted(() => {
realtime.on(SOCKET_EVENTS.coursewareChanged, onCoursewareChange);
});
onUnmounted(() => {
realtime.off(SOCKET_EVENTS.coursewareChanged, onCoursewareChange);
});
watch(
() => realtime.connected,
(connected) => {
if (connected) void refresh();
},
);
let coursewareRequest = 0,
disposed = false;
onUnmounted(() => {
disposed = true;
++coursewareRequest;
});
const auth = useAuthStore();
const { isMobile } = useResponsive();
const items = ref<CoursewareDto[]>([]),
@@ -36,16 +61,8 @@ const folders = ref<CoursewareFolderDto[]>([]),
folderPath = ref(''),
folderFilter = ref('');
const grouping = ref<'date' | 'folder'>('date');
const dateFolder = ref('');
const dateFolders = computed(() =>
[
...new Set(
items.value.map((item) => item.archivePath?.split('/').slice(0, -1).join('/') || item.archiveDate),
),
]
.sort()
.reverse(),
);
const teacher = ref('');
const teachers = computed(() => [...new Set(items.value.map((item) => item.teacher.name))]);
async function newFolder() {
try {
const { value } = await ElMessageBox.prompt(
@@ -65,7 +82,7 @@ async function move(item: CoursewareDto, target: string) {
await api.patch(`/courseware/${item.id}/folder`, { folderPath: target });
await refresh();
}
const filtered = computed(() =>
const dateSource = computed(() =>
items.value.filter(
(item) =>
(!query.value || `${item.name} ${item.teacher.name}`.includes(query.value)) &&
@@ -74,12 +91,13 @@ const filtered = computed(() =>
!folderFilter.value ||
item.folderPath === folderFilter.value ||
item.folderPath?.startsWith(folderFilter.value + '/')) &&
(grouping.value !== 'date' ||
!dateFolder.value ||
(item.archivePath?.startsWith(dateFolder.value + '/') ?? item.archiveDate === dateFolder.value)) &&
(!date.value || item.archiveDate === date.value),
(!teacher.value || item.teacher.name === teacher.value),
),
);
const dateMarks = computed(() => countDates(dateSource.value, (item) => item.archiveDate));
const filtered = computed(() =>
dateSource.value.filter((item) => !date.value || item.archiveDate === date.value),
);
function size(bytes: number) {
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
}
@@ -95,16 +113,22 @@ function pickFile() {
fileInput.value.click();
}
async function refresh() {
const request = ++coursewareRequest;
loading.value = true;
try {
items.value = await api.get<CoursewareDto[]>('/courseware');
if (canWrite.value)
[classes.value, folders.value] = await Promise.all([
api.get<CoursewareClassDto[]>('/courseware/classes'),
api.get<CoursewareFolderDto[]>('/courseware/folders'),
]);
const list = await api.get<CoursewareDto[]>('/courseware');
const scope = canWrite.value
? await Promise.all([
api.get<CoursewareClassDto[]>('/courseware/classes'),
api.get<CoursewareFolderDto[]>('/courseware/folders'),
])
: null;
if (disposed || request !== coursewareRequest) return;
items.value = list;
classes.value = scope?.[0] ?? [];
folders.value = scope?.[1] ?? [];
} finally {
loading.value = false;
if (!disposed && request === coursewareRequest) loading.value = false;
}
}
async function upload() {
@@ -265,14 +289,14 @@ onMounted(() => void refresh());
<el-select v-if="grouping === 'folder'" v-model="folderFilter" clearable placeholder="全部文件夹">
<el-option v-for="folder in folders" :key="folder.id" :value="folder.path" :label="folder.path" />
</el-select>
<el-select v-else v-model="dateFolder" filterable clearable placeholder="教师 / 年 / 月 / 日 / 时间">
<el-option v-for="folder in dateFolders" :key="folder" :value="folder" :label="folder" />
<el-select v-model="teacher" clearable placeholder="全部教师">
<el-option v-for="name in teachers" :key="name" :value="name" :label="name" />
</el-select>
<el-input v-model="query" clearable placeholder="搜索文件名、教师" />
<el-select v-model="category" clearable placeholder="全部类型">
<el-option v-for="(label, key) in COURSEWARE_CATEGORIES" :key="key" :label="label" :value="key" />
</el-select>
<el-date-picker v-model="date" value-format="YYYY-MM-DD" placeholder="归档日期" />
<ch-date-picker v-model="date" :marks="dateMarks" value-format="YYYY-MM-DD" placeholder="归档日期" />
</div>
<el-table :data="filtered" empty-text="暂无课件">
<el-table-column prop="name" label="文件名称" min-width="220" show-overflow-tooltip />
@@ -359,13 +383,13 @@ onMounted(() => void refresh());
<style scoped>
.courseware-page {
display: grid;
gap: 20px;
gap: var(--ch-space-5);
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
gap: var(--ch-space-3);
}
h2,
h3 {
@@ -378,21 +402,21 @@ p,
}
.filters {
display: flex;
gap: 12px;
gap: var(--ch-space-3);
flex-wrap: wrap;
margin-bottom: 18px;
margin-bottom: var(--ch-space-5);
}
.filters > * {
flex: 1;
min-width: 160px;
}
.el-progress {
margin-top: 16px;
margin-top: var(--ch-space-4);
}
.folder-picker {
display: flex;
flex-wrap: wrap;
gap: 12px;
gap: var(--ch-space-3);
width: 100%;
}
.folder-picker .el-select {
@@ -402,12 +426,12 @@ p,
display: block;
overflow-wrap: anywhere;
color: var(--el-text-color-secondary);
margin-top: 6px;
margin-top: var(--ch-space-2);
}
.file-picker {
display: flex;
align-items: center;
gap: 12px;
gap: var(--ch-space-3);
flex-wrap: wrap;
min-width: 0;
}
+16 -16
View File
@@ -232,10 +232,10 @@ function openNotification(item: NotificationDto): void {
display: flex;
align-items: center;
justify-content: space-between;
padding: 26px 30px;
padding: var(--ch-space-7) var(--ch-space-8);
border: 1px solid var(--el-color-primary-light-8);
border-radius: 14px;
margin-bottom: 16px;
border-radius: var(--ch-radius-md);
margin-bottom: var(--ch-space-4);
background: linear-gradient(110deg, var(--el-color-primary-light-9), var(--ch-surface));
}
.welcome-eyebrow {
@@ -243,7 +243,7 @@ function openNotification(item: NotificationDto): void {
font-size: 12px;
}
.dashboard-welcome h3 {
margin: 10px 0;
margin: var(--ch-space-3) 0;
color: var(--ch-text);
font-size: 24px;
font-weight: 600;
@@ -257,7 +257,7 @@ function openNotification(item: NotificationDto): void {
place-items: center;
width: 84px;
height: 84px;
border-radius: 24px;
border-radius: var(--ch-radius-xl);
background: var(--el-color-primary-light-8);
color: var(--el-color-primary);
font-size: 44px;
@@ -266,17 +266,17 @@ function openNotification(item: NotificationDto): void {
.dashboard-shortcuts {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 14px;
margin-bottom: 20px;
gap: var(--ch-space-4);
margin-bottom: var(--ch-space-5);
}
.dashboard-shortcuts button {
display: flex;
align-items: center;
gap: 12px;
padding: 18px;
gap: var(--ch-space-3);
padding: var(--ch-space-5);
min-width: 0;
border: 1px solid var(--ch-border);
border-radius: 12px;
border-radius: var(--ch-radius-md);
background: var(--ch-surface);
color: var(--el-color-primary);
cursor: pointer;
@@ -291,7 +291,7 @@ function openNotification(item: NotificationDto): void {
flex-shrink: 0;
width: 38px;
height: 38px;
border-radius: 10px;
border-radius: var(--ch-radius-sm);
background: var(--el-color-primary-light-9);
font-size: 22px;
}
@@ -311,7 +311,7 @@ function openNotification(item: NotificationDto): void {
display: block;
font-size: 11px;
color: var(--ch-text-muted);
margin-top: 6px;
margin-top: var(--ch-space-2);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -323,7 +323,7 @@ function openNotification(item: NotificationDto): void {
}
@media (max-width: 600px) {
.dashboard-welcome {
padding: 20px;
padding: var(--ch-space-5);
}
.dashboard-welcome h3 {
font-size: 20px;
@@ -332,7 +332,7 @@ function openNotification(item: NotificationDto): void {
display: none;
}
.dashboard-shortcuts button {
padding: 12px;
padding: var(--ch-space-3);
}
}
.card-header {
@@ -350,8 +350,8 @@ function openNotification(item: NotificationDto): void {
.list-item {
display: flex;
align-items: center;
gap: 10px;
padding: 9px 4px;
gap: var(--ch-space-3);
padding: var(--ch-space-2) var(--ch-space-1);
border-bottom: 1px dashed var(--ch-border);
cursor: pointer;
}
+12 -10
View File
@@ -58,7 +58,10 @@ async function runTest(): Promise<void> {
testing.value = true;
testResult.value = null;
try {
const result = await databaseApi.testConnection({ provider: testForm.provider, url: testForm.url.trim() });
const result = await databaseApi.testConnection({
provider: testForm.provider,
url: testForm.url.trim(),
});
testResult.value = {
ok: result.ok,
text: result.ok
@@ -276,7 +279,6 @@ onMounted(async () => {
<div class="page-header">
<div>
<h2 class="page-title">数据库管理</h2>
<p class="page-subtitle">连接状态、备份恢复、导入导出与一键切换(仅管理员可见)</p>
</div>
<div class="toolbar">
<el-button icon="Refresh" :loading="loading" @click="reload">刷新</el-button>
@@ -420,8 +422,8 @@ onMounted(async () => {
<el-card shadow="never">
<template #header><span>导入 / 导出</span></template>
<p class="card-hint">
快照为 JSON 格式(含全部 14 张表数据),可在 SQLite 与 MySQL 之间互相恢复;
「数据库文件」仅 SQLite 提供整文件下载。
快照为 JSON 格式(含全部 14 张表数据),可在 SQLite 与 MySQL 之间互相恢复; 「数据库文件」仅
SQLite 提供整文件下载。
</p>
<div class="toolbar-row">
<el-button @click="exportSnapshot">下载快照 JSON</el-button>
@@ -543,7 +545,7 @@ onMounted(async () => {
<style scoped>
.section-card {
margin-bottom: 2px;
margin-bottom: var(--ch-space-1);
}
.card-header-row {
@@ -553,17 +555,17 @@ onMounted(async () => {
}
.schedule-form {
margin-top: 4px;
margin-top: var(--ch-space-1);
}
.form-hint {
margin-left: 8px;
margin-left: var(--ch-space-2);
font-size: 12px;
color: var(--el-text-color-secondary);
}
.card-hint {
margin: 0 0 10px;
margin: 0 0 var(--ch-space-3);
font-size: 12px;
line-height: 1.7;
color: var(--el-text-color-secondary);
@@ -572,11 +574,11 @@ onMounted(async () => {
.toolbar-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
gap: var(--ch-space-2);
align-items: center;
}
.switch-form {
margin-top: 2px;
margin-top: var(--ch-space-1);
}
</style>
+2 -3
View File
@@ -500,7 +500,6 @@ function canEditContent(row: GradeDto): boolean {
<div class="page-header">
<div>
<h2 class="page-title">成绩录入</h2>
<p class="page-subtitle">同一学生 + 课程 + 考试重复录入会覆盖旧分数,避免产生重复记录</p>
</div>
<div class="toolbar">
<el-select
@@ -899,13 +898,13 @@ function canEditContent(row: GradeDto): boolean {
.level-cell {
display: flex;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
}
.detail-toolbar {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
}
.dialog-hint {
+52 -40
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import type { CalendarRange } from '@classhelper/ui';
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue';
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
import {
@@ -6,7 +7,6 @@ import {
SUBJECT_CATALOG,
dayKeyLocal,
formatDate,
shiftDayKey,
truncate,
type ClassDto,
type CourseDto,
@@ -17,6 +17,7 @@ import { classApi, courseApi, courseIdFromExistsError, homeworkApi } from '@/api
import { useAuthStore } from '@/stores/auth';
import { useRealtimeStore } from '@/stores/realtime';
import { useResponsive } from '@/composables/useResponsive';
import { cachedCalendarMarks, calendarCacheScope } from '@/composables/calendarCache';
const auth = useAuthStore();
const realtime = useRealtimeStore();
@@ -31,7 +32,7 @@ const courses = ref<CourseDto[]>([]);
const homeworks = ref<HomeworkDto[]>([]);
const filter = reactive({ classId: '', courseId: '', keyword: '', date: '' });
/** 有作业的日期(日期选择器高亮),来自 GET /homeworks/days */
const dayMarks = ref<Map<string, number>>(new Map());
const calendarRevision = ref(0);
const detailVisible = ref(false);
const current = ref<HomeworkDto | null>(null);
@@ -153,6 +154,7 @@ async function loadCourses(): Promise<void> {
let homeworkRequest = 0;
async function loadHomeworks(): Promise<void> {
const request = ++homeworkRequest;
calendarRevision.value++;
loading.value = true;
try {
const params: { classId?: string; courseId?: string; keyword?: string; date?: string } = {};
@@ -171,29 +173,39 @@ async function loadHomeworks(): Promise<void> {
async function onClassChange(): Promise<void> {
homeworkRequest += 1;
filter.courseId = '';
await Promise.all([loadCourses(), loadDayMarks(), loadHomeworks()]);
await Promise.all([loadCourses(), loadHomeworks()]);
}
/** 拉取"哪些天有作业"(日期选择器高亮);范围取今天前后各 45 天 */
async function loadDayMarks(): Promise<void> {
try {
const today = dayKeyLocal(new Date());
const result = await homeworkApi.days({
classId: filter.classId || undefined,
from: shiftDayKey(today, -45),
to: shiftDayKey(today, 45),
});
dayMarks.value = new Map(result.days.map((item) => [item.date, item.count]));
} catch {
dayMarks.value = new Map();
}
async function formCalendarDays(range: CalendarRange) {
return (
await homeworkApi.days({
...range,
classId: form.classId || undefined,
courseId: form.courseId || undefined,
})
).days;
}
/** 日期选择器:有作业的日期加高亮类 */
function dayCellClass(date: Date): string {
return dayMarks.value.has(dayKeyLocal(date)) ? 'day-has-homework' : '';
async function bulkCalendarDays(range: CalendarRange) {
const lists = await Promise.all(
bulkForm.classIds.map(async (classId) => (await homeworkApi.days({ ...range, classId })).days),
);
const counts = new Map<string, number>();
for (const item of lists.flat()) counts.set(item.date, (counts.get(item.date) ?? 0) + item.count);
return [...counts].map(([date, count]) => ({ date, count }));
}
async function calendarDays(range: CalendarRange) {
const params = {
...range,
classId: filter.classId || undefined,
courseId: filter.courseId || undefined,
keyword: filter.keyword || undefined,
};
return cachedCalendarMarks(
calendarCacheScope(auth),
{ domain: 'homeworks', ...params },
async () => (await homeworkApi.days(params)).days,
);
}
/* ------------------------------------------------------------ 发布 / 编辑 */
const formVisible = ref(false);
@@ -486,8 +498,6 @@ function onHomeworkEvent(): void {
onMounted(async () => {
await loadClasses();
// 首屏也要拉一次"哪些天有作业",否则日期选择器上没有任何高亮,直到手动切一次班级才出现
await loadDayMarks();
await loadHomeworks();
realtime.on(SOCKET_EVENTS.homeworkNew, onHomeworkEvent);
realtime.on(SOCKET_EVENTS.homeworkUpdated, onHomeworkEvent);
@@ -512,7 +522,6 @@ function canEditContent(row: HomeworkDto): boolean {
<div class="page-header">
<div>
<h2 class="page-title">作业发布</h2>
<p class="page-subtitle">按班级和课程发布作业,实时送达教室并查看完成情况</p>
</div>
<div class="toolbar">
<el-select
@@ -532,14 +541,15 @@ function canEditContent(row: HomeworkDto): boolean {
>
<el-option v-for="item in courses" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-date-picker
<ch-date-picker
v-model="filter.date"
type="date"
value-format="YYYY-MM-DD"
placeholder="按天查看"
clearable
class="day-picker"
:cell-class-name="dayCellClass"
:load-marks="calendarDays"
:scope-key="JSON.stringify([filter, calendarRevision])"
@change="loadHomeworks"
/>
<el-input
@@ -628,11 +638,12 @@ function canEditContent(row: HomeworkDto): boolean {
</div>
</el-form-item>
<el-form-item label="所属日期">
<el-date-picker
<ch-date-picker
v-model="form.assignDate"
type="date"
value-format="YYYY-MM-DD"
:cell-class-name="dayCellClass"
:load-marks="formCalendarDays"
:scope-key="JSON.stringify([form.classId, form.courseId, calendarRevision])"
style="width: 200px"
/>
<span class="form-hint">作业会出现在这一天(按天查看与 ClassHelper 班级端都按它归类)</span>
@@ -686,11 +697,12 @@ function canEditContent(row: HomeworkDto): boolean {
</div>
</el-form-item>
<el-form-item label="所属日期">
<el-date-picker
<ch-date-picker
v-model="bulkForm.assignDate"
type="date"
value-format="YYYY-MM-DD"
:cell-class-name="dayCellClass"
:load-marks="bulkCalendarDays"
:scope-key="JSON.stringify([bulkForm.classIds, calendarRevision])"
style="width: 200px"
/>
</el-form-item>
@@ -820,7 +832,7 @@ function canEditContent(row: HomeworkDto): boolean {
}
.form-hint {
margin-left: 10px;
margin-left: var(--ch-space-3);
opacity: 0.65;
font-size: 12px;
}
@@ -830,15 +842,15 @@ function canEditContent(row: HomeworkDto): boolean {
font-size: 12px;
line-height: 1.5;
color: var(--ch-text-muted);
margin-top: 4px;
margin-top: var(--ch-space-1);
}
.content-block {
white-space: pre-wrap;
line-height: 1.7;
background: var(--ch-surface-sunken);
border-radius: 12px;
padding: 12px;
border-radius: var(--ch-radius-md);
padding: var(--ch-space-3);
margin: 0;
}
@@ -848,7 +860,7 @@ function canEditContent(row: HomeworkDto): boolean {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px;
gap: var(--ch-space-2);
}
.submission-tag {
@@ -858,21 +870,21 @@ function canEditContent(row: HomeworkDto): boolean {
.submission-toolbar {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
gap: var(--ch-space-3);
margin-bottom: var(--ch-space-3);
}
.submission-list {
max-height: 46vh;
overflow-y: auto;
border: 1px solid var(--ch-border);
border-radius: 12px;
padding: 12px;
border-radius: var(--ch-radius-md);
padding: var(--ch-space-3);
}
.submission-list :deep(.el-checkbox-group) {
display: flex;
flex-direction: column;
gap: 4px;
gap: var(--ch-space-1);
}
</style>
@@ -1,9 +1,9 @@
<script setup lang="ts">
import type { CalendarRange } from '@classhelper/ui';
import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
import { useRoute } from 'vue-router';
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
import {
dayKeyLocal,
CALL_QUICK_PHRASES,
NOTIFICATION_PRIORITIES,
PRIORITY_LABELS,
@@ -15,7 +15,6 @@ import {
type ClassDto,
type ClassPeriod,
type NotificationCreatorSummary,
type NotificationDaySummary,
type NotificationDto,
type NotificationPriority,
type StudentDto,
@@ -24,8 +23,11 @@ import { callApi, classApi, notificationApi } from '@/api';
import { useRealtimeStore } from '@/stores/realtime';
import { findClassInSession } from '@/composables/useClassInSession';
import UrgentClassWarning from '@/components/UrgentClassWarning.vue';
import { useAuthStore } from '@/stores/auth';
import { cachedCalendarMarks, calendarCacheScope } from '@/composables/calendarCache';
const realtime = useRealtimeStore();
const auth = useAuthStore();
const route = useRoute();
const loading = ref(false);
@@ -33,33 +35,36 @@ const classes = ref<ClassDto[]>([]);
const notifications = ref<NotificationDto[]>([]);
const filter = reactive({ classId: '', priority: '', keyword: '', date: '', createdBy: '' });
/**
* 按天归档 / 按发布人归档的候选列表(需求:通知按天归档,也可按发布人、类型看)。
*
* 两者跟着"班级 + 优先级"走:班级一换,日期栏与发布人栏就应该只剩那个班里真实存在的
* 日期与人 —— 否则选项里全是别的班级的数据,选中后得到空列表,看着像坏了。
* 发布人栏还额外跟着当前选中的日期收敛("这一天都有谁发过通知")。
*/
const days = ref<NotificationDaySummary[]>([]);
const calendarRevision = ref(0);
const creators = ref<NotificationCreatorSummary[]>([]);
let archiveRequest = 0;
let refreshRequest = 0;
let notificationRequest = 0;
async function calendarDays(range: CalendarRange) {
const params = {
...range,
classId: filter.classId || undefined,
priority: filter.priority || undefined,
createdBy: filter.createdBy || undefined,
keyword: filter.keyword || undefined,
};
return cachedCalendarMarks(
calendarCacheScope(auth),
{ domain: 'notifications', ...params },
async () => (await notificationApi.days(params)).days,
);
}
async function loadArchive(): Promise<void> {
const request = ++archiveRequest;
const base = {
...(filter.classId ? { classId: filter.classId } : {}),
...(filter.priority ? { priority: filter.priority } : {}),
};
const [dayList, creatorList] = await Promise.all([
notificationApi.days(base).catch(() => ({ days: [] as NotificationDaySummary[] })),
notificationApi
.creators({ ...base, ...(filter.date ? { date: filter.date } : {}) })
.catch(() => ({ creators: [] as NotificationCreatorSummary[] })),
]);
const creatorList = await notificationApi
.creators({ ...base, ...(filter.date ? { date: filter.date } : {}) })
.catch(() => ({ creators: [] as NotificationCreatorSummary[] }));
if (request !== archiveRequest) return;
days.value = dayList.days;
creators.value = creatorList.creators;
if (filter.createdBy && !creatorList.creators.some((item) => item.id === filter.createdBy))
filter.createdBy = '';
@@ -109,6 +114,7 @@ async function loadClassStudentCounts(): Promise<void> {
async function loadNotifications(): Promise<void> {
const request = ++notificationRequest;
calendarRevision.value++;
loading.value = true;
try {
const params: {
@@ -428,7 +434,6 @@ onUnmounted(() => {
<div class="page-header">
<div>
<h2 class="page-title">通知发布</h2>
<p class="page-subtitle">发布后按班级房间广播(notification:new),ClassHelper 班级端 5 秒内到达</p>
</div>
<div class="toolbar">
<el-select
@@ -455,27 +460,16 @@ onUnmounted(() => {
/>
</el-select>
<!-- 按天归档:只列当前班级/优先级下真实存在的日期与条数 -->
<el-date-picker
<ch-date-picker
v-model="filter.date"
type="date"
value-format="YYYY-MM-DD"
placeholder="按天归档"
clearable
:load-marks="calendarDays"
:scope-key="JSON.stringify([filter, calendarRevision])"
@change="refreshList"
>
<template #default="cell">
<span
:title="
days.some((d) => d.date === dayKeyLocal(cell.date))
? `${days.find((d) => d.date === dayKeyLocal(cell.date))?.count} 条通知`
: ''
"
>
{{ cell.text }}
<b v-if="days.some((d) => d.date === dayKeyLocal(cell.date))">·</b>
</span>
</template>
</el-date-picker>
/>
<!-- 按发布人归档:跟着班级/优先级/日期收敛 -->
<el-select
v-model="filter.createdBy"
@@ -306,7 +306,6 @@ const actions: Record<string, string> = {
<div class="page-header">
<div>
<h2 class="page-title">权限与范围</h2>
<p class="page-subtitle">模板授予能力,分配限定范围,业务关系由系统独立校验。</p>
</div>
<el-button @click="load">刷新</el-button>
</div>
@@ -531,8 +530,8 @@ const actions: Record<string, string> = {
<style scoped>
.assignment {
display: flex;
gap: 12px;
margin: 16px 0;
gap: var(--ch-space-3);
margin: var(--ch-space-4) 0;
flex-wrap: wrap;
}
.assignment .el-select {
@@ -541,7 +540,7 @@ const actions: Record<string, string> = {
.capability {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
flex-wrap: wrap;
}
.risk {
@@ -555,6 +554,6 @@ pre {
font-size: 12px;
}
.toolbar {
margin: 16px 0;
margin: var(--ch-space-4) 0;
}
</style>
+112 -106
View File
@@ -948,7 +948,6 @@ function selectPlanItem(id: string) {
<header class="page-header">
<div>
<h2 class="page-title">课表档案</h2>
<p class="page-subtitle">维护日课表、时间表与科目,按周查看和调整课程安排。</p>
</div>
<div class="toolbar archive-commands">
<el-select
@@ -983,7 +982,7 @@ function selectPlanItem(id: string) {
:disabled="!canWrite || !auth.can('import:schedule') || !classId"
@click="openImport"
>
导入 ClassIsland 档案
导入课表(JSON / YAML)
</el-button>
<el-button
text
@@ -1049,10 +1048,15 @@ function selectPlanItem(id: string) {
<p>暂无可管理的班级</p>
</div>
<div v-else-if="tab === 'plans'" class="schedule-workspace" :inert="saving">
<!--
只在保存过程中置为 inert。不能写成 :inert="saving":旧内核没有 inert DOM property,
Vue 会把 false 落成 inert="false" 属性,而 inert 属性只要存在就整块不可交互(表现为点击没反应)。
undefined 会让 Vue 直接移除属性,现代浏览器与旧内核行为一致。
-->
<div v-else-if="tab === 'plans'" class="schedule-workspace" :inert="saving ? true : undefined">
<main class="schedule-main" :aria-busy="loading">
<div class="week-navigation">
<el-date-picker
<ch-date-picker
:model-value="selectedDate"
type="date"
value-format="YYYY-MM-DD"
@@ -1432,9 +1436,10 @@ function selectPlanItem(id: string) {
</aside>
</div>
<!-- 同上:仅保存时 inert,避免旧内核落成 inert="false" 属性 -->
<TimeLayoutEditor
v-else-if="tab === 'layouts'"
:inert="saving"
:inert="saving ? true : undefined"
v-model:layout="layout"
:layouts="layouts"
:courses="courses"
@@ -1451,7 +1456,8 @@ function selectPlanItem(id: string) {
@import-points="importLayout"
@apply-default="applyDefault"
/>
<div v-else class="detail-workspace" :inert="saving">
<!-- 同上:仅保存时 inert,避免旧内核落成 inert="false" 属性 -->
<div v-else class="detail-workspace" :inert="saving ? true : undefined">
<main class="detail-content">
<template v-if="tab === 'subjects'">
<h3>科目管理</h3>
@@ -1529,7 +1535,7 @@ function selectPlanItem(id: string) {
<el-select v-model="temporaryGroup" class="setting-control">
<el-option v-for="g in groups" :key="g.id" :label="g.name" :value="g.id" />
</el-select>
<el-date-picker
<ch-date-picker
v-model="expireTime"
type="datetime"
value-format="YYYY-MM-DDTHH:mm:ss"
@@ -1662,7 +1668,7 @@ function selectPlanItem(id: string) {
.archive-commands .archive-icon {
width: 17px;
height: 17px;
margin-right: 6px;
margin-right: var(--ch-space-2);
}
.class-picker {
width: 180px;
@@ -1674,7 +1680,7 @@ function selectPlanItem(id: string) {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ch-border);
border-radius: 12px;
border-radius: var(--ch-radius-md);
background: var(--ch-surface);
color: var(--ch-text);
font-size: var(--el-font-size-base);
@@ -1701,17 +1707,17 @@ function selectPlanItem(id: string) {
}
.archive-header {
flex-shrink: 0;
padding: 0 20px;
padding: 0 var(--ch-space-5);
border-bottom: 1px solid var(--ch-border);
}
.archive-tabs {
display: flex;
gap: 28px;
gap: var(--ch-space-7);
}
.archive-tabs button {
position: relative;
min-height: 50px;
padding: 12px 0;
padding: var(--ch-space-3) 0;
border: 0;
background: transparent;
color: var(--ch-text-secondary);
@@ -1737,9 +1743,9 @@ function selectPlanItem(id: string) {
justify-content: center;
gap: 7px;
min-height: 32px;
padding: 6px 10px;
padding: var(--ch-space-2) var(--ch-space-3);
border: 0;
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: transparent;
color: var(--ch-text-secondary);
white-space: nowrap;
@@ -1757,27 +1763,27 @@ function selectPlanItem(id: string) {
}
.icon-command {
width: 34px;
padding: 6px;
padding: var(--ch-space-2);
}
.command-separator {
flex: 0 0 1px;
height: 22px;
margin: 0 3px;
margin: 0 var(--ch-space-1);
background: var(--ch-border);
}
.archive-toolbar {
display: flex;
flex-shrink: 0;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
min-height: 48px;
padding: 6px 12px;
padding: var(--ch-space-2) var(--ch-space-3);
border-bottom: 1px solid var(--ch-border);
}
.selection-label {
overflow: hidden;
min-width: 0;
padding: 0 6px;
padding: 0 var(--ch-space-2);
color: var(--ch-text-secondary);
text-overflow: ellipsis;
white-space: nowrap;
@@ -1793,8 +1799,8 @@ function selectPlanItem(id: string) {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
padding: 5px 12px;
gap: var(--ch-space-2);
padding: var(--ch-space-1) var(--ch-space-3);
color: var(--el-color-danger);
background: var(--el-color-danger-light-9);
}
@@ -1814,9 +1820,9 @@ function selectPlanItem(id: string) {
display: flex;
flex-shrink: 0;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
min-height: 56px;
padding: 10px 12px;
padding: var(--ch-space-3) var(--ch-space-3);
}
.week-navigation :deep(.el-date-editor) {
flex-shrink: 0;
@@ -1825,7 +1831,7 @@ function selectPlanItem(id: string) {
.week-picker select {
max-width: 110px;
min-height: 32px;
padding: 3px 8px;
padding: var(--ch-space-1) var(--ch-space-2);
border: 1px solid var(--ch-border);
border-radius: var(--el-border-radius-base);
background: var(--ch-surface);
@@ -1879,10 +1885,10 @@ function selectPlanItem(id: string) {
}
.schedule-grid thead th {
height: 78px;
padding: 8px;
padding: var(--ch-space-2);
}
.schedule-grid thead .time-heading {
padding-left: 16px;
padding-left: var(--ch-space-4);
text-align: left;
color: var(--ch-text-secondary);
}
@@ -1890,7 +1896,7 @@ function selectPlanItem(id: string) {
display: flex;
align-items: center;
justify-content: space-between;
gap: 4px;
gap: var(--ch-space-1);
color: var(--ch-text-secondary);
font-size: var(--el-font-size-small);
font-variant-numeric: tabular-nums;
@@ -1901,14 +1907,14 @@ function selectPlanItem(id: string) {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
gap: var(--ch-space-1);
overflow: hidden;
width: 100%;
min-height: 30px;
margin-top: 7px;
padding: 4px 6px;
padding: var(--ch-space-1) var(--ch-space-2);
border: 1px solid var(--ch-border);
border-radius: 6px;
border-radius: var(--ch-radius-xs);
background: var(--ch-surface);
color: var(--ch-text-secondary);
text-overflow: ellipsis;
@@ -1940,7 +1946,7 @@ function selectPlanItem(id: string) {
color: var(--el-color-primary);
}
.time-cell {
padding: 8px 16px;
padding: var(--ch-space-2) var(--ch-space-4);
background: var(--ch-surface-alt);
font-size: var(--el-font-size-small);
font-variant-numeric: tabular-nums;
@@ -1951,7 +1957,7 @@ function selectPlanItem(id: string) {
display: block;
}
.time-cell small {
margin-top: 3px;
margin-top: var(--ch-space-1);
color: var(--ch-text-muted);
font-size: var(--el-font-size-extra-small);
}
@@ -1962,7 +1968,7 @@ function selectPlanItem(id: string) {
justify-content: center;
width: 100%;
min-height: 64px;
padding: 8px 5px;
padding: var(--ch-space-2) var(--ch-space-1);
border: 0;
background: transparent;
color: var(--ch-text);
@@ -1993,11 +1999,11 @@ function selectPlanItem(id: string) {
height: 29px;
}
.non-lesson-row .time-cell {
padding: 4px 16px;
padding: var(--ch-space-1) var(--ch-space-4);
}
.break-label {
display: block;
padding: 4px;
padding: var(--ch-space-1);
color: var(--ch-text-secondary);
font-size: var(--el-font-size-extra-small);
}
@@ -2008,14 +2014,14 @@ function selectPlanItem(id: string) {
justify-content: center;
align-items: center;
min-height: 240px;
padding: 24px;
padding: var(--ch-space-6);
color: var(--ch-text-muted);
text-align: center;
}
.grid-empty svg {
width: 48px;
height: 48px;
margin-bottom: 14px;
margin-bottom: var(--ch-space-4);
color: var(--ch-text-placeholder);
}
.grid-empty p {
@@ -2023,31 +2029,31 @@ function selectPlanItem(id: string) {
font-size: var(--el-font-size-base);
}
.grid-empty .command {
margin-top: 12px;
margin-top: var(--ch-space-3);
}
.subject-panel {
display: flex;
flex-direction: column;
overflow: auto;
min-width: 0;
padding: 16px;
padding: var(--ch-space-4);
border-left: 1px solid var(--ch-border);
background: var(--ch-surface-alt);
}
.subject-panel h3 {
margin: 0 0 16px;
margin: 0 0 var(--ch-space-4);
font-size: var(--el-font-size-base);
font-weight: 600;
}
.inspector-tabs {
display: flex;
gap: 2px;
margin-bottom: 14px;
margin-bottom: var(--ch-space-4);
border-bottom: 1px solid var(--ch-border);
}
.inspector-tabs button {
flex: 1;
padding: 8px 6px;
padding: var(--ch-space-2) var(--ch-space-2);
border: 0;
border-bottom: 2px solid transparent;
background: transparent;
@@ -2069,13 +2075,13 @@ function selectPlanItem(id: string) {
.subject-palette {
display: grid;
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 6px;
gap: var(--ch-space-2);
}
.subject-palette button {
min-width: 0;
height: 40px;
border: 1px solid var(--ch-border);
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: var(--ch-surface);
color: var(--ch-text);
font-size: var(--el-font-size-medium);
@@ -2094,15 +2100,15 @@ function selectPlanItem(id: string) {
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 6px;
margin-top: 16px;
gap: var(--ch-space-2);
margin-top: var(--ch-space-4);
color: var(--ch-text-secondary);
font-size: var(--el-font-size-extra-small);
}
.auto-advance {
height: auto;
margin-top: auto;
padding-top: 20px;
padding-top: var(--ch-space-5);
}
.auto-advance :deep(.el-checkbox__label) {
white-space: normal;
@@ -2113,9 +2119,9 @@ function selectPlanItem(id: string) {
align-items: center;
justify-content: space-between;
flex: 0 0 48px;
gap: 12px;
gap: var(--ch-space-3);
min-height: 48px;
padding: 6px 14px;
padding: var(--ch-space-2) var(--ch-space-4);
border-top: 1px solid var(--ch-border);
color: var(--ch-text-muted);
font-size: var(--el-font-size-extra-small);
@@ -2123,15 +2129,15 @@ function selectPlanItem(id: string) {
.archive-footer nav {
display: flex;
align-items: center;
gap: 4px;
padding: 3px;
border-radius: 8px;
gap: var(--ch-space-1);
padding: var(--ch-space-1);
border-radius: var(--ch-radius-sm);
background: var(--ch-surface-alt);
}
.archive-footer .icon-command {
width: auto;
min-height: 28px;
padding: 4px 9px;
padding: var(--ch-space-1) var(--ch-space-2);
font-size: var(--el-font-size-extra-small);
}
.archive-footer .active {
@@ -2154,7 +2160,7 @@ function selectPlanItem(id: string) {
.plan-explorer {
flex: 0 0 210px;
width: 210px;
padding: 12px;
padding: var(--ch-space-3);
overflow: auto;
border-right: 1px solid var(--ch-border);
}
@@ -2162,12 +2168,12 @@ function selectPlanItem(id: string) {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
gap: var(--ch-space-1);
width: 100%;
margin-top: 6px;
padding: 10px;
margin-top: var(--ch-space-2);
padding: var(--ch-space-3);
border: 0;
border-radius: 8px;
border-radius: var(--ch-radius-sm);
background: transparent;
color: var(--ch-text);
text-align: left;
@@ -2187,15 +2193,15 @@ function selectPlanItem(id: string) {
.daily-editor {
flex: 1;
min-width: 0;
padding: 20px;
padding: var(--ch-space-5);
overflow: auto;
}
.section-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 16px;
gap: var(--ch-space-3);
margin-bottom: var(--ch-space-4);
}
.section-header h3,
.detail-content h3 {
@@ -2210,21 +2216,21 @@ function selectPlanItem(id: string) {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
padding: 16px 0;
gap: var(--ch-space-3);
padding: var(--ch-space-4) 0;
border-bottom: 1px solid var(--ch-border);
}
.left-section {
display: flex;
flex: 1;
flex-direction: column;
gap: 4px;
gap: var(--ch-space-1);
min-width: 180px;
}
.left-section strong {
display: flex;
align-items: center;
gap: 8px;
gap: var(--ch-space-2);
font-weight: 500;
}
.left-section small {
@@ -2237,13 +2243,13 @@ function selectPlanItem(id: string) {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
gap: var(--ch-space-3);
}
.control-row :deep(.el-input-number) {
width: 110px;
}
.toolbar {
margin-top: 16px;
margin-top: var(--ch-space-4);
}
.toolbar :deep(.el-button + .el-button) {
margin-left: 0;
@@ -2260,16 +2266,16 @@ function selectPlanItem(id: string) {
display: grid;
grid-template-columns: 34px minmax(150px, 1fr) minmax(130px, 1.1fr) 100px 54px;
align-items: center;
gap: 10px;
gap: var(--ch-space-3);
}
.course-table-head {
padding: 8px 6px;
padding: var(--ch-space-2) var(--ch-space-2);
border-bottom: 1px solid var(--ch-border);
color: var(--ch-text-muted);
font-size: var(--el-font-size-extra-small);
}
.course-row {
padding: 9px 6px;
padding: var(--ch-space-2) var(--ch-space-2);
border-bottom: 1px solid var(--ch-border);
}
.course-row.selected {
@@ -2278,7 +2284,7 @@ function selectPlanItem(id: string) {
.course-time {
display: flex;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
min-width: 0;
}
.course-time-text {
@@ -2299,7 +2305,7 @@ function selectPlanItem(id: string) {
.course-course {
display: flex;
align-items: center;
gap: 6px;
gap: var(--ch-space-2);
min-width: 0;
}
.course-course :deep(.el-select) {
@@ -2308,9 +2314,9 @@ function selectPlanItem(id: string) {
}
.default-badge {
flex-shrink: 0;
padding: 1px 5px;
padding: 1px var(--ch-space-1);
border: 1px solid var(--el-color-primary-light-5);
border-radius: 999px;
border-radius: var(--ch-radius-pill);
color: var(--el-color-primary);
font-size: var(--el-font-size-extra-small);
}
@@ -2318,7 +2324,7 @@ function selectPlanItem(id: string) {
width: 100%;
}
.drag {
padding: 7px 3px;
padding: 7px var(--ch-space-1);
border: 0;
background: transparent;
color: var(--ch-text-muted);
@@ -2341,7 +2347,7 @@ function selectPlanItem(id: string) {
.plan-explorer {
display: flex;
flex-direction: column;
gap: 8px;
gap: var(--ch-space-2);
}
.plan-group {
display: flex;
@@ -2351,16 +2357,16 @@ function selectPlanItem(id: string) {
.plan-group-title {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 8px 2px;
gap: var(--ch-space-2);
padding: var(--ch-space-2) var(--ch-space-2) 2px;
color: var(--ch-text-muted);
font-size: var(--el-font-size-extra-small);
font-weight: 500;
}
.plan-group-title small {
padding: 0 5px;
padding: 0 var(--ch-space-1);
border: 1px solid var(--ch-border);
border-radius: 999px;
border-radius: var(--ch-radius-pill);
font-size: 10px;
font-weight: 400;
}
@@ -2384,10 +2390,10 @@ function selectPlanItem(id: string) {
.month-view {
flex: 1;
overflow: auto;
padding: 16px 20px;
padding: var(--ch-space-4) var(--ch-space-5);
}
.month-view h3 {
margin: 0 0 16px;
margin: 0 0 var(--ch-space-4);
font-size: var(--el-font-size-medium);
font-weight: 600;
}
@@ -2396,7 +2402,7 @@ function selectPlanItem(id: string) {
grid-template-columns: repeat(7, minmax(0, 1fr));
}
.calendar-heading {
padding: 8px;
padding: var(--ch-space-2);
color: var(--ch-text-secondary);
text-align: center;
}
@@ -2404,9 +2410,9 @@ function selectPlanItem(id: string) {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 5px;
gap: var(--ch-space-1);
min-height: 70px;
padding: 9px;
padding: var(--ch-space-2);
border: 1px solid var(--ch-border);
background: transparent;
color: var(--ch-text);
@@ -2433,17 +2439,17 @@ function selectPlanItem(id: string) {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 10px;
gap: var(--ch-space-3);
}
.editor-help p {
margin-bottom: 18px;
margin-bottom: var(--ch-space-5);
line-height: 1.8;
}
.transfer-menu {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 3px;
gap: var(--ch-space-1);
}
.transfer-menu .el-button {
margin-left: 0;
@@ -2462,14 +2468,14 @@ function selectPlanItem(id: string) {
grid-template-columns: minmax(0, 1fr) 260px;
}
.subject-panel {
padding: 12px;
padding: var(--ch-space-3);
}
.subject-palette {
grid-template-columns: repeat(5, minmax(0, 1fr));
}
.week-navigation {
flex-wrap: wrap;
gap: 6px;
gap: var(--ch-space-2);
}
.course-table-head,
.course-row {
@@ -2487,16 +2493,16 @@ function selectPlanItem(id: string) {
}
@media (max-width: 768px) {
.archive-commands {
gap: 8px;
gap: var(--ch-space-2);
}
.class-picker {
width: 160px;
}
.archive-header {
padding: 0 12px;
padding: 0 var(--ch-space-3);
}
.archive-tabs {
gap: 24px;
gap: var(--ch-space-6);
}
.archive-tabs button {
min-height: 44px;
@@ -2506,10 +2512,10 @@ function selectPlanItem(id: string) {
}
.archive-toolbar {
flex-wrap: wrap;
padding: 8px;
padding: var(--ch-space-2);
}
.archive-toolbar .command {
padding: 5px 7px;
padding: var(--ch-space-1) 7px;
}
.selection-label {
max-width: 145px;
@@ -2529,7 +2535,7 @@ function selectPlanItem(id: string) {
min-height: 300px;
}
.week-navigation {
padding: 10px 8px;
padding: var(--ch-space-3) var(--ch-space-2);
}
.week-navigation :deep(.el-date-editor) {
width: 140px;
@@ -2539,11 +2545,11 @@ function selectPlanItem(id: string) {
}
.week-picker select {
max-width: 90px;
padding: 3px;
padding: var(--ch-space-1);
}
.grid-empty {
min-height: 220px;
padding: 20px;
padding: var(--ch-space-5);
}
.grid-empty p {
max-width: 280px;
@@ -2555,7 +2561,7 @@ function selectPlanItem(id: string) {
border-left: 0;
}
.subject-panel h3 {
margin-bottom: 10px;
margin-bottom: var(--ch-space-3);
}
.subject-palette {
grid-template-columns: repeat(6, minmax(0, 1fr));
@@ -2564,19 +2570,19 @@ function selectPlanItem(id: string) {
height: 36px;
}
.auto-advance {
padding-top: 12px;
padding-top: var(--ch-space-3);
}
.selection-details {
display: none;
}
.archive-footer {
flex-wrap: wrap;
gap: 6px;
padding: 8px;
gap: var(--ch-space-2);
padding: var(--ch-space-2);
}
.archive-footer .icon-command {
gap: 5px;
padding: 4px 6px;
gap: var(--ch-space-1);
padding: var(--ch-space-1) var(--ch-space-2);
}
.detail-workspace {
flex-direction: column;
@@ -2589,7 +2595,7 @@ function selectPlanItem(id: string) {
}
.detail-content,
.daily-editor {
padding: 12px;
padding: var(--ch-space-3);
}
.course-table-head {
display: none;
@@ -2597,7 +2603,7 @@ function selectPlanItem(id: string) {
.course-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
gap: var(--ch-space-2);
}
.course-time {
flex: 1 1 140px;
@@ -7,7 +7,6 @@ import PromotionSettings from '@/components/PromotionSettings.vue';
<div class="page-header">
<div>
<h2 class="page-title">学年升级</h2>
<p class="page-subtitle">维护年度升级计划与学段轨道,执行前先预览影响并确认备份。</p>
</div>
</div>
<PromotionSettings />
@@ -316,7 +316,6 @@ onUnmounted(() => {
<div class="page-header">
<div>
<h2 class="page-title">课表管理</h2>
<p class="page-subtitle">按周次维护课程安排,支持单双周范围(起始周 - 结束周)</p>
</div>
<div class="toolbar">
<el-select
@@ -784,28 +784,28 @@ async function submitCall(): Promise<void> {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
gap: var(--ch-space-3);
flex-wrap: wrap;
}
.call-alert {
margin-bottom: 12px;
margin-bottom: var(--ch-space-3);
}
.call-section {
margin-bottom: 14px;
margin-bottom: var(--ch-space-4);
}
.call-label {
font-size: 13px;
color: var(--ch-text-secondary);
margin-bottom: 8px;
margin-bottom: var(--ch-space-2);
}
.call-phrases {
display: flex;
flex-wrap: wrap;
gap: 8px;
gap: var(--ch-space-2);
}
.call-phrase {
@@ -242,7 +242,7 @@ onMounted(async () => {
<el-card shadow="never" style="margin-bottom: 12px">
<div class="toolbar">
<span class="label">学期开始日期</span>
<el-date-picker
<ch-date-picker
v-model="termStartDate"
:disabled="!canEdit"
type="date"
@@ -298,7 +298,7 @@ onMounted(async () => {
<template #default="{ row }">
<!-- 用 :model-value + @update 而不是 v-model:数据模型里是 startDate/endDate 两个字段,
el-date-picker 的 daterange 给的是一个数组,直接 v-model 会写到一个不存在的 range 上 -->
<el-date-picker
<ch-date-picker
:model-value="row.startDate && row.endDate ? [row.startDate, row.endDate] : null"
:disabled="!canEdit"
type="daterange"
@@ -343,7 +343,7 @@ onMounted(async () => {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
gap: var(--ch-space-3);
}
.label {
@@ -358,6 +358,6 @@ onMounted(async () => {
}
.holiday-tag {
margin: 0 6px 6px 0;
margin: 0 var(--ch-space-2) var(--ch-space-2) 0;
}
</style>