feat: 完善知识库、策略预览与OnlyOffice集成

## 配置与环境
- .env.example: 更新环境变量配置
- docker-compose.yml: 完善Docker编排配置
- docker/README.md: 更新Docker文档

## 后端知识库模块
- endpoints/knowledge.py: 增强知识库API端点
- schemas/knowledge.py: 扩展知识库数据模型
- services/knowledge.py: 完善知识库业务逻辑
- config.py: 优化配置管理
- storage/knowledge/.index.json: 更新知识库索引

## 前端功能
- api.js: 完善API服务层
- knowledge.js: 优化知识库服务
- onlyoffice.js: 新增OnlyOffice文档服务集成
- TopBar.vue: 优化顶部导航栏
- PoliciesView.vue: 完善策略视图
- AppShellRouteView.vue: 新增应用外壳路由视图
- views/scripts/PoliciesView.js: 优化策略脚本
- policiesPreviewFormatters.js: 新增策略预览格式化工具

## 样式
- policies-view.css: 完善策略页样式

## 测试
- api-request.test.mjs: API请求测试
- onlyoffice-service.test.mjs: OnlyOffice服务测试
- policies-preview-formatters.test.mjs: 策略预览格式化测试
This commit is contained in:
caoxiaozhu
2026-05-09 04:25:30 +00:00
parent 619281afc3
commit d9ffa9ce2c
21 changed files with 1469 additions and 508 deletions

View File

@@ -60,23 +60,36 @@
line-height: 1.5;
}
.preview-hint {
min-height: 28px;
.file-search {
width: min(320px, 100%);
min-height: 36px;
display: inline-flex;
align-items: center;
padding: 0 10px;
border-radius: 999px;
background: #f1f5f9;
gap: 8px;
padding: 0 12px;
border: 1px solid #d7e0ea;
border-radius: 10px;
background: #fff;
color: #64748b;
font-size: 12px;
font-weight: 800;
white-space: nowrap;
transition: background 220ms ease, color 220ms ease;
transition: border-color 180ms ease, box-shadow 180ms ease;
}
.preview-hint.active {
background: #dcfce7;
color: #059669;
.file-search:focus-within {
border-color: #60a5fa;
box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}
.file-search input {
width: 100%;
min-width: 0;
border: 0;
color: #0f172a;
font-size: 13px;
background: transparent;
}
.file-search input:focus {
outline: none;
}
.library-body {
@@ -90,41 +103,12 @@
.folder-rail {
min-height: 0;
display: grid;
grid-template-rows: auto minmax(0, 1fr) auto;
grid-template-rows: minmax(0, 1fr) auto;
gap: 12px;
border-right: 1px solid #edf2f7;
padding-right: 12px;
}
.folder-search {
height: 36px;
display: grid;
grid-template-columns: 18px minmax(0, 1fr) 24px;
align-items: center;
gap: 6px;
padding: 0 8px;
border: 1px solid #d7e0ea;
border-radius: 8px;
color: #64748b;
}
.folder-search input {
min-width: 0;
border: 0;
color: #0f172a;
font-size: 13px;
}
.folder-search input:focus {
outline: none;
}
.folder-search button {
border: 0;
background: transparent;
color: #64748b;
}
.folder-tree {
min-height: 0;
display: grid;
@@ -180,6 +164,12 @@
font-weight: 850;
}
.new-folder-btn.fixed {
border-color: rgba(148, 163, 184, 0.3);
background: #f8fafc;
color: #64748b;
}
.document-area {
min-width: 0;
min-height: 0;
@@ -188,6 +178,10 @@
gap: 12px;
}
.upload-input {
display: none;
}
.upload-zone {
min-height: 112px;
display: grid;
@@ -199,6 +193,23 @@
background: #f8fbff;
color: #334155;
text-align: center;
cursor: pointer;
transition: border-color 180ms ease, background 180ms ease, opacity 180ms ease;
}
.upload-zone:hover {
border-color: #60a5fa;
background: #f3f8ff;
}
.upload-zone.disabled {
cursor: default;
border-color: #cbd5e1;
background: #f8fafc;
}
.upload-zone.busy {
opacity: 0.72;
}
.upload-zone i {
@@ -308,11 +319,36 @@ th {
}
.more-btn {
width: 32px;
height: 32px;
display: grid;
place-items: center;
border: 0;
border-radius: 8px;
background: transparent;
color: #2563eb;
}
.more-btn.danger {
color: #dc2626;
}
.more-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.row-actions {
display: inline-flex;
align-items: center;
gap: 4px;
}
.empty-row {
color: #64748b;
text-align: center;
}
.list-foot {
display: grid;
grid-template-columns: 1fr auto 1fr;
@@ -444,8 +480,8 @@ th {
height: 100%;
min-height: 0;
display: grid;
grid-template-rows: auto auto minmax(0, 1fr);
padding: 18px;
grid-template-rows: auto minmax(0, 1fr);
padding: 20px 22px;
overflow: hidden;
}
@@ -453,19 +489,13 @@ th {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 14px;
gap: 18px;
padding-bottom: 16px;
border-bottom: 1px solid #edf2f7;
}
.preview-kicker {
display: inline-flex;
align-items: center;
min-height: 24px;
padding: 0 8px;
border-radius: 999px;
background: #ecfdf5;
color: #059669;
font-size: 11px;
font-weight: 800;
.preview-copy {
min-width: 0;
}
.preview-actions {
@@ -500,164 +530,281 @@ th {
place-items: center;
}
.preview-meta {
.preview-summary-line {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
margin-top: 14px;
padding-top: 14px;
border-top: 1px solid #edf2f7;
margin-top: 8px;
color: #64748b;
font-size: 13px;
line-height: 1.6;
}
.preview-meta span {
display: inline-flex;
.preview-secondary-line {
display: flex;
align-items: center;
gap: 6px;
min-height: 28px;
padding: 0 10px;
border-radius: 999px;
background: #f8fafc;
color: #475569;
gap: 10px;
flex-wrap: wrap;
margin-top: 12px;
padding: 10px 12px;
border-radius: 10px;
background: #1e293b;
color: #e2e8f0;
font-size: 12px;
font-weight: 700;
line-height: 1.5;
}
.preview-viewer {
min-height: 0;
display: grid;
grid-template-rows: auto minmax(0, 1fr);
gap: 12px;
margin-top: 14px;
margin-top: 18px;
}
.viewer-toolbar {
.preview-status {
display: grid;
place-items: center;
min-height: 180px;
padding: 24px;
border: 1px dashed #cbd5e1;
border-radius: 14px;
background: #f8fafc;
color: #64748b;
font-size: 13px;
font-weight: 700;
text-align: center;
}
.preview-status.error {
border-color: #fecaca;
background: #fef2f2;
color: #dc2626;
}
.preview-embed-wrap,
.preview-image-wrap {
min-height: 0;
overflow: hidden;
border: 1px solid #edf2f7;
border-radius: 12px;
background: #fff;
}
.preview-embed {
width: 100%;
height: 100%;
min-height: 560px;
border: 0;
}
.preview-image-wrap {
display: grid;
place-items: center;
padding: 20px;
}
.preview-image {
max-width: 100%;
max-height: 70vh;
object-fit: contain;
}
.onlyoffice-preview-wrap {
min-height: 0;
overflow: hidden;
border: 1px solid #dbe4ee;
border-radius: 12px;
background: #fff;
}
.onlyoffice-preview-host {
width: 100%;
min-height: 720px;
}
.excel-preview-wrap {
min-height: 0;
overflow: hidden;
border: 1px solid #dbe4ee;
border-radius: 12px;
background: #fff;
}
.excel-sheet-tabs {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 44px;
padding: 0 12px;
border: 1px solid #e2e8f0;
border-radius: 10px;
gap: 8px;
padding: 10px 12px;
border-bottom: 1px solid #e2e8f0;
background: #f8fafc;
overflow-x: auto;
}
.viewer-filetype {
display: inline-flex;
align-items: center;
gap: 8px;
.excel-sheet-tab {
min-height: 34px;
padding: 0 12px;
border: 1px solid #d7e0ea;
border-radius: 8px;
background: #fff;
color: #475569;
font-size: 12px;
font-weight: 700;
white-space: nowrap;
}
.excel-sheet-tab.active {
border-color: #93c5fd;
background: #dbeafe;
color: #1d4ed8;
}
.excel-preview-scroll {
min-height: 0;
overflow: auto;
}
.excel-preview-table {
width: 100%;
min-width: 640px;
border-collapse: separate;
border-spacing: 0;
}
.excel-preview-table th,
.excel-preview-table td {
padding: 10px 12px;
border-right: 1px solid #e2e8f0;
border-bottom: 1px solid #e2e8f0;
text-align: left;
vertical-align: top;
white-space: nowrap;
font-size: 13px;
line-height: 1.5;
}
.excel-preview-table th {
position: sticky;
top: 0;
z-index: 1;
background: #e8f0fe;
color: #0f172a;
font-weight: 800;
}
.viewer-toolbar-actions {
display: inline-flex;
gap: 8px;
.excel-preview-table td {
color: #334155;
background: #fff;
}
.viewer-toolbar-actions button {
width: 32px;
height: 32px;
display: grid;
place-items: center;
.excel-preview-table tbody tr:nth-child(even) td {
background: #f8fafc;
}
.excel-preview-table tr > *:last-child {
border-right: 0;
}
.excel-preview-table tbody tr:last-child td {
border-bottom: 0;
}
.page-stage {
min-height: 0;
overflow: auto;
display: grid;
gap: 16px;
padding-right: 4px;
gap: 20px;
padding-right: 6px;
}
.page-sheet {
display: grid;
gap: 16px;
padding: 18px;
border: 1px solid #e2e8f0;
border-radius: 14px;
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
gap: 18px;
padding: 0 0 20px;
border-bottom: 1px solid #edf2f7;
background: transparent;
box-shadow: none;
animation: previewSheetIn 360ms var(--ease) both;
animation-delay: var(--page-delay, 0ms);
}
.page-sheet:last-child {
border-bottom: 0;
padding-bottom: 0;
}
.page-title {
display: flex;
align-items: flex-start;
justify-content: space-between;
justify-content: flex-start;
gap: 12px;
}
.page-title strong {
color: #0f172a;
font-size: 15px;
font-size: 16px;
font-weight: 850;
}
.page-title span,
.page-title b {
.page-title span {
display: block;
margin-top: 4px;
margin-top: 6px;
color: #64748b;
font-size: 12px;
font-weight: 700;
font-size: 13px;
font-weight: 600;
}
.summary-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
gap: 12px;
}
.summary-item {
display: grid;
gap: 6px;
padding: 12px;
border-radius: 10px;
background: #f8fafc;
gap: 4px;
padding: 0 0 10px;
border-bottom: 1px solid #f1f5f9;
background: transparent;
}
.summary-item span {
color: #64748b;
font-size: 11px;
font-weight: 700;
font-size: 12px;
font-weight: 600;
}
.summary-item strong {
color: #0f172a;
font-size: 14px;
font-weight: 850;
font-weight: 800;
}
.page-content {
display: grid;
gap: 12px;
gap: 16px;
}
.content-block {
padding: 14px;
border-radius: 12px;
background: #ffffff;
border: 1px solid #edf2f7;
padding: 0;
border-radius: 0;
background: transparent;
border: 0;
}
.content-block h3 {
margin: 0 0 8px;
margin: 0 0 10px;
color: #0f172a;
font-size: 13px;
font-size: 14px;
font-weight: 850;
}
.content-block ul {
display: grid;
gap: 8px;
gap: 10px;
margin: 0;
padding-left: 18px;
padding-left: 20px;
color: #475569;
font-size: 12px;
line-height: 1.6;
font-size: 13px;
line-height: 1.75;
}
.preview-panel-enter-active,