feat: 交付任务005-021全量改动(自动化/AI/联系人中心、消息中心改造、运维与容器化)

- 自动化中心:规则引擎、流程画布与触发器(V7/V10/V12/V18/V21)、测试全流程、安全边界、执行记录
- AI 中心:服务商/模型/调用与工具授权/治理(V8/V17)及配套前端页面
- 联系人中心:联系人目录、分组/标签、同步幂等(V19)与实装页面
- 消息中心:三栏布局重做、头像昵称服务端抓取与缓存(V16 conversation_profile)、出站归属修复
- 接入管理:NapCat 反向 WS/HTTP 回调多通道发送传输、连接状态统一口径
- 运维中心:备份保留与恢复确认(V13/V22/V24)、监控告警(V23)、日志与审计
- 全局:账号上下文切换(V20 account_profile)、统一 UI 基础组件、分页样式、Flyway 增量迁移护栏
- 部署:Dockerfile/docker-compose/Nginx 容器化编排与 CI 校验脚本
- 文档:任务 005-021 交付记录、设计画板导出、接口/数据库/架构文档同步
This commit is contained in:
2026-11-17 17:29:06 +08:00
parent d804696fd0
commit 27182fc7d2
518 changed files with 80433 additions and 1905 deletions
+43
View File
@@ -0,0 +1,43 @@
<script setup>
import { computed, ref } from 'vue'
/**
* 复选框:原生 input 仅作为无障碍与表单语义载体,视觉完全自绘。
*/
const props = defineProps({
modelValue: { type: Boolean, default: false },
value: { type: [String, Number, Boolean], default: true },
disabled: Boolean,
indeterminate: Boolean,
label: { type: String, default: '' }
})
const emit = defineEmits(['update:modelValue', 'change'])
const inputRef = ref(null)
const checked = computed(() => Boolean(props.modelValue))
function onChange(event) {
const next = event.target.checked
emit('update:modelValue', next)
emit('change', next)
}
</script>
<template>
<label class="qk-checkbox" :class="{ 'is-disabled': disabled }" @click.stop>
<input
ref="inputRef"
class="qk-checkbox__input"
type="checkbox"
:checked="checked"
:disabled="disabled"
:indeterminate="indeterminate"
@change="onChange"
/>
<span class="qk-checkbox__box" aria-hidden="true" />
<span v-if="label || $slots.default" class="qk-checkbox__text">
<slot>{{ label }}</slot>
</span>
</label>
</template>
+103
View File
@@ -0,0 +1,103 @@
<script setup>
import { computed, ref, useAttrs } from 'vue'
defineOptions({ inheritAttrs: false })
/**
* 文本输入:默认根节点就是 input(可直接放在既有 .field / .fld 容器里,不改变布局语义),
* 仅在需要标签或字数计数时才多包一层容器。
*/
const props = defineProps({
modelValue: { type: [String, Number], default: '' },
type: { type: String, default: 'text' },
label: { type: String, default: '' },
placeholder: { type: String, default: '' },
hint: { type: String, default: '' },
error: { type: String, default: '' },
disabled: Boolean,
readonly: Boolean,
invalid: Boolean,
size: { type: String, default: 'md' },
maxlength: { type: [String, Number], default: undefined },
showCount: Boolean,
numeric: Boolean
})
const emit = defineEmits(['update:modelValue', 'change', 'blur', 'focus', 'enter'])
const attrs = useAttrs()
const inputRef = ref(null)
const length = computed(() => String(props.modelValue ?? '').length)
const limit = computed(() => (props.maxlength === undefined ? null : Number(props.maxlength)))
const hasWrap = computed(() => Boolean(props.label || props.hint || props.error || props.showCount))
function onInput(event) {
const raw = event.target.value
emit('update:modelValue', props.numeric && raw !== '' ? Number(raw) : raw)
}
function onChange(event) {
emit('change', event)
}
function onBlur(event) {
emit('blur', event)
}
function onFocus(event) {
emit('focus', event)
}
function onKeydown(event) {
if (event.key === 'Enter') emit('enter', event)
}
defineExpose({ focus: () => inputRef.value?.focus() })
</script>
<template>
<div v-if="hasWrap" class="qk-field-wrap">
<span v-if="label" class="qk-field-label">{{ label }}</span>
<input
ref="inputRef"
v-bind="attrs"
class="qk-field"
:class="[`qk-field-${size}`, { 'is-invalid': invalid || error }]"
:type="type"
:value="modelValue"
:placeholder="placeholder"
:disabled="disabled"
:readonly="readonly"
:maxlength="maxlength"
:aria-invalid="Boolean(invalid || error) || undefined"
@input="onInput"
@change="onChange"
@blur="onBlur"
@focus="onFocus"
@keydown="onKeydown"
/>
<div v-if="hint || error || showCount" class="qk-field-meta">
<span :class="{ 'qk-field-error': Boolean(error) }">{{ error || hint }}</span>
<span v-if="showCount" class="qk-field-count">{{ length }}{{ limit ? `/${limit}` : '' }}</span>
</div>
</div>
<input
v-else
ref="inputRef"
v-bind="attrs"
class="qk-field"
:class="[`qk-field-${size}`, { 'is-invalid': invalid }]"
:type="type"
:value="modelValue"
:placeholder="placeholder"
:disabled="disabled"
:readonly="readonly"
:maxlength="maxlength"
:aria-invalid="invalid || undefined"
@input="onInput"
@change="onChange"
@blur="onBlur"
@focus="onFocus"
@keydown="onKeydown"
/>
</template>
+102
View File
@@ -0,0 +1,102 @@
<script setup>
import { computed } from 'vue'
/**
* 通用弹窗外壳:Element Plus `el-dialog` 的薄封装。
* 保留原有 props/插槽契约(open/title/subtitle/size/busy/head/body/foot),
* ESC、遮罩关闭策略、焦点捕获与锁滚动由 el-dialog 承载;关闭后焦点回到触发元素。
*/
const props = defineProps({
open: { type: Boolean, default: false },
title: { type: String, default: '' },
subtitle: { type: String, default: '' },
ariaLabel: { type: String, default: '' },
size: { type: String, default: 'md' },
closable: { type: Boolean, default: true },
closeOnMask: { type: Boolean, default: true },
closeOnEsc: { type: Boolean, default: true },
busy: Boolean
})
const emit = defineEmits(['close', 'opened', 'closed'])
const WIDTH = { sm: '420px', md: '576px', lg: '720px' }
const dialogWidth = computed(() => WIDTH[props.size] || WIDTH.md)
let lastFocused = null
function onOpen() {
lastFocused = document.activeElement
emit('opened')
}
function onClosed() {
const target = lastFocused
lastFocused = null
if (target && typeof target.focus === 'function') {
requestAnimationFrame(() => {
try { target.focus() } catch { /* 元素可能已被移除 */ }
})
}
emit('closed')
}
// 关闭动作统一走 before-close,保证父组件先拿到 close 事件再决定是否收起(busy 时直接拒绝)。
function onBeforeClose() {
if (props.busy) return
emit('close')
}
</script>
<template>
<el-dialog
class="qk-dialog"
:model-value="open"
:width="dialogWidth"
:show-close="closable && !busy"
:close-on-click-modal="closeOnMask && !busy"
:close-on-press-escape="closeOnEsc && !busy"
:before-close="onBeforeClose"
:aria-label="ariaLabel || title || '对话框'"
append-to-body
align-center
:style="{ maxWidth: 'calc(100vw - 32px)' }"
@open="onOpen"
@closed="onClosed"
>
<template #header>
<div class="qk-dialog__head">
<h3>{{ title }}</h3>
<p v-if="subtitle">{{ subtitle }}</p>
<slot name="head" />
</div>
</template>
<slot />
<template #footer>
<div class="qk-dialog__foot">
<slot name="foot" />
</div>
</template>
</el-dialog>
</template>
<style scoped>
.qk-dialog__head h3 {
margin: 0;
font-size: 14px;
font-weight: 600;
line-height: 20px;
color: var(--qk-text);
}
.qk-dialog__head p {
margin: 4px 0 0;
font-size: 10px;
line-height: 1.55;
color: var(--qk-text-4);
}
.qk-dialog__foot {
display: flex;
justify-content: flex-end;
gap: 8px;
}
</style>
+32
View File
@@ -0,0 +1,32 @@
<script setup>
import { ref } from 'vue'
/**
* 静态提示条:替代页面里零散拼接的 .notice 结构,统一 4 种语义色。
*/
const props = defineProps({
tone: { type: String, default: 'info' },
title: { type: String, default: '' },
closable: Boolean
})
const emit = defineEmits(['close'])
const closed = ref(false)
const TONE_CLASS = { success: 'is-success', warning: 'is-warning', danger: 'is-danger', error: 'is-danger' }
</script>
<template>
<div
v-if="!closed"
class="qk-notice"
:class="TONE_CLASS[tone] || ''"
:role="tone === 'danger' || tone === 'error' ? 'alert' : 'status'"
>
<div class="qk-notice__body">
<strong v-if="title">{{ title }}</strong>
<slot />
</div>
<button v-if="closable" class="btn sm ghost" type="button" aria-label="关闭提示" @click="closed = true; emit('close')">×</button>
</div>
</template>
+145
View File
@@ -0,0 +1,145 @@
<script setup>
import { computed } from 'vue'
/**
* 下拉选择器:Element Plus `el-select` 的薄封装。
* 保留原有 options API(value/label/hint/group/disabled),因此 53 处调用点无需改写;
* 交互(键盘导航、过滤、浮层定位、可清空)与视觉由 el-select + styles/element-theme.css 统一承载。
* readonly 场景按不可交互展示处理(映射为 disabled),与旧行为的视觉/语义一致。
*/
const props = defineProps({
modelValue: { type: [String, Number, Boolean, Object, Array], default: '' },
options: { type: Array, default: () => [] },
placeholder: { type: String, default: '请选择' },
searchable: { type: Boolean, default: false },
clearable: { type: Boolean, default: false },
disabled: Boolean,
readonly: Boolean,
block: Boolean,
size: { type: String, default: 'md' },
id: { type: String, default: '' },
// 校验失败态:与 .field.is-invalid 同款红描边,保持表单前后端校验的视觉一致。
invalid: Boolean,
ariaLabel: { type: String, default: '' },
emptyText: { type: String, default: '没有匹配的选项' },
// 多选:值类型为数组;配合 searchable 支持过滤,标签过多时折叠为 +N。
multiple: Boolean,
collapseTags: Boolean,
maxCollapseTags: { type: Number, default: 1 }
})
const emit = defineEmits(['update:modelValue', 'change', 'visible-change'])
const elSize = computed(() => ({ sm: 'small', lg: 'large' })[props.size] || 'default')
// 按出现顺序聚合分组,与旧自绘下拉的分组表现一致;无 group 的选项走平铺列表。
const groupedOptions = computed(() => {
const buckets = []
props.options.forEach((option, index) => {
const group = option?.group || ''
const last = buckets[buckets.length - 1]
const entry = { key: `o${index}`, option }
if (last && last.group === group) last.items.push(entry)
else buckets.push({ group, items: [entry] })
})
return buckets
})
const hasGroups = computed(() => groupedOptions.value.some((bucket) => bucket.group))
function onUpdate(value) {
emit('update:modelValue', value)
}
function onChange(value) {
emit('change', value)
}
/** 打开/收起浮层;调用方可借此在展开前刷新选项数据(如连接状态)。 */
function onVisibleChange(visible) {
emit('visible-change', visible)
}
</script>
<template>
<el-select
:id="id || undefined"
class="qk-select"
:class="[`is-${size}`, { 'is-block': block, 'is-invalid': invalid }]"
:model-value="modelValue"
:placeholder="placeholder"
:size="elSize"
:disabled="disabled || readonly"
:filterable="searchable"
:clearable="clearable"
:multiple="multiple"
:collapse-tags="multiple && collapseTags"
:max-collapse-tags="maxCollapseTags"
:collapse-tags-tooltip="multiple && collapseTags"
:fit-input-width="false"
:no-data-text="emptyText"
:aria-label="ariaLabel || placeholder"
:aria-invalid="invalid || undefined"
:teleported="true"
@update:model-value="onUpdate"
@change="onChange"
@visible-change="onVisibleChange"
>
<template v-if="hasGroups">
<template v-for="bucket in groupedOptions" :key="bucket.group || 'flat'">
<el-option-group v-if="bucket.group" :label="bucket.group">
<el-option
v-for="entry in bucket.items"
:key="entry.key"
:label="entry.option?.label ?? String(entry.option?.value ?? '')"
:value="entry.option?.value"
:disabled="Boolean(entry.option?.disabled)"
>
<span class="qk-opt-label">{{ entry.option?.label }}</span>
<span v-if="entry.option?.hint" class="qk-opt-hint">{{ entry.option.hint }}</span>
</el-option>
</el-option-group>
<template v-else>
<el-option
v-for="entry in bucket.items"
:key="entry.key"
:label="entry.option?.label ?? String(entry.option?.value ?? '')"
:value="entry.option?.value"
:disabled="Boolean(entry.option?.disabled)"
>
<span class="qk-opt-label">{{ entry.option?.label }}</span>
<span v-if="entry.option?.hint" class="qk-opt-hint">{{ entry.option.hint }}</span>
</el-option>
</template>
</template>
</template>
<template v-else>
<el-option
v-for="(option, index) in options"
:key="`o${index}`"
:label="option?.label ?? String(option?.value ?? '')"
:value="option?.value"
:disabled="Boolean(option?.disabled)"
>
<span class="qk-opt-label">{{ option?.label }}</span>
<span v-if="option?.hint" class="qk-opt-hint">{{ option.hint }}</span>
</el-option>
</template>
</el-select>
</template>
<style scoped>
.qk-opt-label {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.qk-opt-hint {
flex: none;
margin-left: 8px;
font-size: 10px;
color: var(--qk-text-4);
}
</style>
+30
View File
@@ -0,0 +1,30 @@
<script setup>
/**
* 开关:真实 button[role=switch],支持键盘 Space/Enter,禁用态不响应。
*/
const props = defineProps({
modelValue: { type: Boolean, default: false },
disabled: Boolean,
ariaLabel: { type: String, default: '' }
})
const emit = defineEmits(['update:modelValue', 'change'])
function toggle() {
if (props.disabled) return
emit('update:modelValue', !props.modelValue)
emit('change', !props.modelValue)
}
</script>
<template>
<button
type="button"
class="qk-switch"
role="switch"
:aria-checked="modelValue"
:aria-label="ariaLabel || '开关'"
:disabled="disabled"
@click="toggle"
/>
</template>
+74
View File
@@ -0,0 +1,74 @@
<script setup>
import { computed } from 'vue'
/**
* 多行文本:默认根节点是 textarea,保留既有 .field 布局;仅在需要标签/计数时包裹容器。
*/
const props = defineProps({
modelValue: { type: String, default: '' },
label: { type: String, default: '' },
placeholder: { type: String, default: '' },
hint: { type: String, default: '' },
error: { type: String, default: '' },
rows: { type: [String, Number], default: 4 },
disabled: Boolean,
readonly: Boolean,
invalid: Boolean,
maxlength: { type: [String, Number], default: undefined },
showCount: Boolean,
autoResize: Boolean
})
const emit = defineEmits(['update:modelValue', 'change', 'blur'])
const length = computed(() => String(props.modelValue ?? '').length)
const limit = computed(() => (props.maxlength === undefined ? null : Number(props.maxlength)))
const hasWrap = computed(() => Boolean(props.label || props.hint || props.error || props.showCount))
function onInput(event) {
emit('update:modelValue', event.target.value)
if (props.autoResize) {
event.target.style.height = 'auto'
event.target.style.height = `${event.target.scrollHeight}px`
}
}
</script>
<template>
<div v-if="hasWrap" class="qk-field-wrap">
<span v-if="label" class="qk-field-label">{{ label }}</span>
<textarea
class="qk-field"
:class="{ 'is-invalid': invalid || error }"
:value="modelValue"
:rows="rows"
:placeholder="placeholder"
:disabled="disabled"
:readonly="readonly"
:maxlength="maxlength"
:aria-invalid="Boolean(invalid || error) || undefined"
@input="onInput"
@change="emit('change', $event)"
@blur="emit('blur', $event)"
/>
<div v-if="hint || error || showCount" class="qk-field-meta">
<span :class="{ 'qk-field-error': Boolean(error) }">{{ error || hint }}</span>
<span v-if="showCount" class="qk-field-count">{{ length }}{{ limit ? `/${limit}` : '' }}</span>
</div>
</div>
<textarea
v-else
class="qk-field"
:class="{ 'is-invalid': invalid }"
:value="modelValue"
:rows="rows"
:placeholder="placeholder"
:disabled="disabled"
:readonly="readonly"
:maxlength="maxlength"
:aria-invalid="invalid || undefined"
@input="onInput"
@change="emit('change', $event)"
@blur="emit('blur', $event)"
/>
</template>
+59
View File
@@ -0,0 +1,59 @@
<script setup>
import { nextTick, onBeforeUnmount, ref } from 'vue'
/**
* 轻量 Tooltip:替代原生 title 属性。鼠标悬停、键盘聚焦都会显示,位置自动翻转。
*/
const props = defineProps({
content: { type: String, default: '' },
placement: { type: String, default: 'top' },
delay: { type: Number, default: 120 },
disabled: Boolean
})
const rootRef = ref(null)
const visible = ref(false)
const style = ref({})
let timer = 0
const TEXT_WIDTH = 240
function measure() {
const anchor = rootRef.value
if (!anchor) return
const rect = anchor.getBoundingClientRect()
const place = props.placement === 'bottom' ? 'bottom' : 'top'
style.value = {
left: `${Math.max(8, Math.min(rect.left + rect.width / 2 - TEXT_WIDTH / 2, window.innerWidth - TEXT_WIDTH - 8))}px`,
minWidth: `${Math.min(rect.width, TEXT_WIDTH)}px`,
...(place === 'bottom'
? { top: `${rect.bottom + 6}px` }
: { bottom: `${window.innerHeight - rect.top + 6}px` })
}
}
function show() {
if (props.disabled || !props.content) return
window.clearTimeout(timer)
timer = window.setTimeout(() => {
visible.value = true
nextTick(measure)
}, props.delay)
}
function hide() {
window.clearTimeout(timer)
visible.value = false
}
onBeforeUnmount(() => window.clearTimeout(timer))
</script>
<template>
<span ref="rootRef" class="qk-tooltip" @mouseenter="show" @mouseleave="hide" @focusin="show" @focusout="hide">
<slot />
<Teleport to="body">
<span v-if="visible" class="qk-tooltip-pop" :style="style" role="tooltip">{{ content }}</span>
</Teleport>
</span>
</template>
+43
View File
@@ -0,0 +1,43 @@
import { h } from 'vue'
/**
* 命令式确认:基于 Element Plus `ElMessageBox`,返回 Promise<boolean>。
* - 取消、关闭(X / ESC)都解析为 false,不产生任何变更;
* - tone === 'danger' 时确认按钮渲染为红色实心(危险操作),其余为常规主色;
* - 文案(title/message/hint)沿用调用方传入的中文,不在封装层改写。
*/
export function askConfirm(options = {}) {
// 同一时间只处理一个确认请求:新请求先关闭上一条,避免弹窗叠层与 Promise 悬挂。
ElMessageBox.close()
const {
title = '确认操作',
message = '',
hint = '',
confirmText = '确认',
cancelText = '取消',
tone = 'primary'
} = options
return ElMessageBox.confirm(
() =>
h('div', { class: 'qk-confirm-body' }, [
message ? h('div', { class: 'qk-confirm-text' }, message) : null,
hint ? h('div', { class: 'qk-confirm-hint' }, hint) : null
]),
title,
{
confirmButtonText: confirmText,
cancelButtonText: cancelText,
showCancelButton: true,
showClose: true,
closeOnClickModal: false,
closeOnPressEscape: true,
confirmButtonClass: tone === 'danger' ? 'qk-btn-danger' : '',
customClass: 'qk-confirm'
}
).then(
() => true,
() => false
)
}
+9
View File
@@ -0,0 +1,9 @@
export { default as Select } from './Select.vue'
export { default as Modal } from './Modal.vue'
export { default as Input } from './Input.vue'
export { default as Textarea } from './Textarea.vue'
export { default as Switch } from './Switch.vue'
export { default as Checkbox } from './Checkbox.vue'
export { default as Tooltip } from './Tooltip.vue'
export { default as Notice } from './Notice.vue'
export { askConfirm } from './feedback'
+90
View File
@@ -0,0 +1,90 @@
/**
* v-tooltip 指令:批量替代原生 title 属性,不改变既有 DOM 结构与布局。
* 用法:v-tooltip="'说明文字'" 或 v-tooltip="{ content: '说明', placement: 'bottom' }"
* 与 <Tooltip> 组件共用 .qk-tooltip-pop 样式。
*/
const state = new WeakMap()
const DELAY = 120
function clearTimer(record) {
if (record?.timer) window.clearTimeout(record.timer)
}
function removeTip(record) {
if (record?.tip?.parentNode) record.tip.parentNode.removeChild(record.tip)
if (record) record.tip = null
}
function hide(el) {
const record = state.get(el)
if (!record) return
clearTimer(record)
removeTip(record)
}
function place(el, text, placement) {
const tip = document.createElement('div')
tip.className = 'qk-tooltip-pop'
tip.setAttribute('role', 'tooltip')
tip.textContent = text
document.body.appendChild(tip)
const rect = el.getBoundingClientRect()
const width = Math.min(tip.offsetWidth || 0, 240)
const left = Math.max(8, Math.min(rect.left + rect.width / 2 - width / 2, window.innerWidth - width - 8))
tip.style.left = `${left}px`
if (placement === 'bottom') tip.style.top = `${rect.bottom + 6}px`
else tip.style.bottom = `${window.innerHeight - rect.top + 6}px`
return tip
}
function show(el, binding) {
const raw = binding.value
const text = typeof raw === 'string' ? raw : raw?.content
const placement = typeof raw === 'object' && raw?.placement ? raw.placement : 'top'
if (!text) return
hide(el)
const record = state.get(el) || {}
record.timer = window.setTimeout(() => {
removeTip(record)
record.tip = place(el, text, placement)
state.set(el, record)
}, DELAY)
state.set(el, record)
}
function normalize(el, binding) {
// 原生 title 会与自绘提示重复,移除它,但保留 aria-label 语义。
if (el.hasAttribute('title')) el.removeAttribute('title')
show(el, binding)
}
export const vTooltip = {
mounted(el, binding) {
el.__qkTooltipShow = () => normalize(el, binding)
el.__qkTooltipHide = () => hide(el)
el.addEventListener('mouseenter', el.__qkTooltipShow)
el.addEventListener('focusin', el.__qkTooltipShow)
el.addEventListener('mouseleave', el.__qkTooltipHide)
el.addEventListener('focusout', el.__qkTooltipHide)
el.addEventListener('click', el.__qkTooltipHide)
},
updated(el, binding) {
if (el.hasAttribute('title')) el.removeAttribute('title')
if (binding.value !== binding.oldValue) {
hide(el)
el.__qkTooltipShow = () => normalize(el, binding)
}
},
unmounted(el) {
hide(el)
el.removeEventListener('mouseenter', el.__qkTooltipShow)
el.removeEventListener('focusin', el.__qkTooltipShow)
el.removeEventListener('mouseleave', el.__qkTooltipHide)
el.removeEventListener('focusout', el.__qkTooltipHide)
el.removeEventListener('click', el.__qkTooltipHide)
}
}
export function installTooltip(app) {
app.directive('tooltip', vTooltip)
}