Merge branch 'dev' into test
This commit is contained in:
commit
4cb0c5839c
15 files changed
+2100
-571
No files matched your search
@@ -80,7 +80,16 @@ def export_schedule_result_excel(
|
||||
if not headers:
|
||||
return None, None, 0
|
||||
|
||||
rows: list[dict[str, Any]] = []
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "result"
|
||||
ws.append([header_labels.get(k, k) for k in headers])
|
||||
|
||||
detail_key_set = set(all_detail_headers)
|
||||
merge_keys = [k for k in headers if k not in detail_key_set]
|
||||
col_index_map = {k: idx + 1 for idx, k in enumerate(headers)}
|
||||
|
||||
current_excel_row = 2 # header is row 1
|
||||
for row in details:
|
||||
if not isinstance(row, dict):
|
||||
continue
|
||||
@@ -98,23 +107,30 @@ def export_schedule_result_excel(
|
||||
base_row[key] = _flatten_value(v)
|
||||
|
||||
detail_rows = row.get("_detail_rows")
|
||||
group_rows: list[dict[str, Any]] = []
|
||||
if all_detail_headers and isinstance(detail_rows, list) and detail_rows:
|
||||
for dr in detail_rows:
|
||||
flat = dict(base_row)
|
||||
if isinstance(dr, dict):
|
||||
for dk in all_detail_headers:
|
||||
flat[dk] = dr.get(dk, "")
|
||||
rows.append(flat)
|
||||
group_rows.append(flat)
|
||||
else:
|
||||
rows.append(base_row)
|
||||
group_rows.append(base_row)
|
||||
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "result"
|
||||
ws.append([header_labels.get(k, k) for k in headers])
|
||||
for out_row in group_rows:
|
||||
ws.append([out_row.get(k, "") for k in headers])
|
||||
|
||||
for row in rows:
|
||||
ws.append([row.get(k, "") for k in headers])
|
||||
group_size = len(group_rows)
|
||||
if group_size > 1:
|
||||
start_row = current_excel_row
|
||||
end_row = current_excel_row + group_size - 1
|
||||
for key in merge_keys:
|
||||
col = col_index_map.get(key)
|
||||
if not col:
|
||||
continue
|
||||
ws.merge_cells(start_row=start_row, start_column=col, end_row=end_row, end_column=col)
|
||||
current_excel_row += group_size
|
||||
|
||||
buf = io.BytesIO()
|
||||
wb.save(buf)
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
from __future__ import annotations
|
||||
|
||||
"""
|
||||
WeCom mobile -> userid diagnostic script.
|
||||
|
||||
Usage:
|
||||
cd backend
|
||||
WECOM_DIAGNOSTIC_MOBILE=13800138000 .\\venv\\Scripts\\python.exe tests\\test_wecom_get_userid_by_mobile.py
|
||||
|
||||
Optional:
|
||||
WECOM_DIAGNOSTIC_VERIFY_USER_GET=1 After getuserid, call user/get for the returned userid.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import requests
|
||||
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(BACKEND_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(BACKEND_ROOT))
|
||||
|
||||
from app import create_app # noqa: E402
|
||||
from app.services.wecom_notify import _get_access_token # noqa: E402
|
||||
|
||||
|
||||
def _get_userid_by_mobile(mobile: str) -> dict[str, Any]:
|
||||
token = _get_access_token()
|
||||
resp = requests.post(
|
||||
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserid",
|
||||
params={"access_token": token},
|
||||
json={"mobile": mobile},
|
||||
timeout=8,
|
||||
)
|
||||
return {"http_status": resp.status_code, "response": resp.json()}
|
||||
|
||||
|
||||
def _user_get(userid: str) -> dict[str, Any]:
|
||||
token = _get_access_token()
|
||||
resp = requests.get(
|
||||
"https://qyapi.weixin.qq.com/cgi-bin/user/get",
|
||||
params={"access_token": token, "userid": userid},
|
||||
timeout=8,
|
||||
)
|
||||
return {"http_status": resp.status_code, "response": resp.json()}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
mobile = os.getenv("WECOM_DIAGNOSTIC_MOBILE", "").strip()
|
||||
if not mobile:
|
||||
print("Missing WECOM_DIAGNOSTIC_MOBILE", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
app = create_app("development")
|
||||
with app.app_context():
|
||||
if not app.config.get("WECOM_CORP_ID") or not app.config.get("WECOM_SECRET"):
|
||||
print("WECOM_CORP_ID / WECOM_SECRET is not configured", file=sys.stderr)
|
||||
return 2
|
||||
if not app.config.get("WECOM_AGENT_ID"):
|
||||
print("WECOM_AGENT_ID is not configured", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
data = _get_userid_by_mobile(mobile)
|
||||
print(json.dumps({"mobile": mobile, "getuserid": data}, ensure_ascii=False, indent=2))
|
||||
|
||||
resp = data["response"] or {}
|
||||
if resp.get("errcode") != 0:
|
||||
print(
|
||||
f"user/getuserid failed for mobile={mobile}: {resp}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
userid = str(resp.get("userid") or "").strip()
|
||||
if not userid:
|
||||
print(
|
||||
f"user/getuserid succeeded but userid is empty for mobile={mobile}: {resp}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
if os.getenv("WECOM_DIAGNOSTIC_VERIFY_USER_GET", "1") == "1":
|
||||
user_get = _user_get(userid)
|
||||
print(json.dumps({"user_get": user_get}, ensure_ascii=False, indent=2))
|
||||
ug = user_get["response"] or {}
|
||||
if ug.get("errcode") != 0:
|
||||
print(
|
||||
f"user/get failed for userid={userid}: {ug}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
print("OK")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
from __future__ import annotations
|
||||
|
||||
"""
|
||||
WeCom userid diagnostic script.
|
||||
|
||||
Usage:
|
||||
cd backend
|
||||
WECOM_DIAGNOSTIC_TARGET=sophie .\\venv\\Scripts\\python.exe tests\\test_wecom_userid_diagnostic.py
|
||||
|
||||
Optional:
|
||||
WECOM_DIAGNOSTIC_SEND=1 Also try sending a minimal textcard message
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import or_
|
||||
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(BACKEND_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(BACKEND_ROOT))
|
||||
|
||||
from app import create_app, db # noqa: E402
|
||||
from app.models import User # noqa: E402
|
||||
from app.services.wecom_notify import _get_access_token, send_wecom_textcard_message # noqa: E402
|
||||
|
||||
|
||||
def _resolve_target_userid(app, target: str) -> tuple[str, dict[str, Any] | None]:
|
||||
target = (target or "").strip()
|
||||
if not target:
|
||||
raise ValueError("WECOM_DIAGNOSTIC_TARGET is empty")
|
||||
|
||||
with app.app_context():
|
||||
query = db.session.query(User).filter(
|
||||
or_(
|
||||
User.username == target,
|
||||
User.real_name == target,
|
||||
User.employee_id == target,
|
||||
User.employee_id == target if target.isdigit() else False,
|
||||
)
|
||||
)
|
||||
user = query.first()
|
||||
if not user:
|
||||
# Allow direct WeCom userid input
|
||||
return target, None
|
||||
|
||||
snapshot = {
|
||||
"id": user.id,
|
||||
"username": user.username,
|
||||
"real_name": user.real_name,
|
||||
"employee_id": user.employee_id,
|
||||
"wecom_userid": user.wecom_userid,
|
||||
"wecom_unionid": user.wecom_unionid,
|
||||
"department": user.department,
|
||||
"status": user.status,
|
||||
}
|
||||
if not user.wecom_userid:
|
||||
raise RuntimeError(f"Matched DB user {user.username} but wecom_userid is empty")
|
||||
return str(user.wecom_userid).strip(), snapshot
|
||||
|
||||
|
||||
def _wecom_user_get(userid: str) -> dict[str, Any]:
|
||||
token = _get_access_token()
|
||||
import requests
|
||||
|
||||
resp = requests.get(
|
||||
"https://qyapi.weixin.qq.com/cgi-bin/user/get",
|
||||
params={"access_token": token, "userid": userid},
|
||||
timeout=8,
|
||||
)
|
||||
return {"http_status": resp.status_code, "response": resp.json()}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
target = os.getenv("WECOM_DIAGNOSTIC_TARGET", "").strip()
|
||||
if not target:
|
||||
print("Missing WECOM_DIAGNOSTIC_TARGET", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
app = create_app("development")
|
||||
with app.app_context():
|
||||
if not app.config.get("WECOM_CORP_ID") or not app.config.get("WECOM_SECRET"):
|
||||
print("WECOM_CORP_ID / WECOM_SECRET is not configured", file=sys.stderr)
|
||||
return 2
|
||||
if not app.config.get("WECOM_AGENT_ID"):
|
||||
print("WECOM_AGENT_ID is not configured", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
userid, matched_user = _resolve_target_userid(app, target)
|
||||
print(json.dumps({
|
||||
"target": target,
|
||||
"resolved_userid": userid,
|
||||
"matched_user": matched_user,
|
||||
}, ensure_ascii=False, indent=2))
|
||||
|
||||
user_get = _wecom_user_get(userid)
|
||||
print(json.dumps({"user_get": user_get}, ensure_ascii=False, indent=2))
|
||||
|
||||
user_get_resp = user_get["response"] or {}
|
||||
if user_get_resp.get("errcode") != 0:
|
||||
print(
|
||||
f"user/get failed for userid={userid}: {user_get_resp}. "
|
||||
f"This usually means the userid is invalid or the app has no access to that user.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
if os.getenv("WECOM_DIAGNOSTIC_SEND", "0") == "1":
|
||||
send_resp = send_wecom_textcard_message(
|
||||
userid,
|
||||
title="WeCom userid diagnostic",
|
||||
description=f"userid={userid}",
|
||||
jump_url="",
|
||||
)
|
||||
print(json.dumps({"send_response": send_resp}, ensure_ascii=False, indent=2))
|
||||
if send_resp.get("errcode") != 0:
|
||||
print(
|
||||
f"message/send failed for userid={userid}: {send_resp}. "
|
||||
f"If user/get passed, the userid is valid and the issue is likely app scope or agent permissions.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
print("OK")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
* - 对 Office 文档在可公网 HTTPS 访问时走 Office 在线预览,否则降级为打开/下载
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { marked } from 'marked';
|
||||
import * as XLSX from 'xlsx';
|
||||
import { useMessage } from '../composables/useMessage';
|
||||
import VueOfficeDocx from '@vue-office/docx';
|
||||
import VueOfficeExcel from '@vue-office/excel';
|
||||
import '@vue-office/docx/lib/index.css';
|
||||
@@ -42,6 +44,8 @@ const props = defineProps<{
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void;
|
||||
}>();
|
||||
const msg = useMessage();
|
||||
const { t } = useI18n();
|
||||
|
||||
const isLoading = ref(false);
|
||||
const error = ref('');
|
||||
@@ -144,7 +148,7 @@ const downloadFile = async () => {
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (err: any) {
|
||||
console.error('Download failed:', err);
|
||||
alert('下载失败: ' + (err.message || '未知错误'));
|
||||
msg.error(t('filePreview.msg.downloadFailed', { reason: err.message || t('filePreview.msg.unknownError') }));
|
||||
} finally {
|
||||
isDownloading.value = false;
|
||||
}
|
||||
@@ -417,7 +421,7 @@ watch(
|
||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-xl w-full max-w-5xl h-[85vh] flex flex-col overflow-hidden border border-slate-200 dark:border-slate-700">
|
||||
<div class="px-6 py-4 border-b border-slate-200 dark:border-slate-700 flex items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-medium text-slate-500 dark:text-slate-400 tracking-wide">文件预览</div>
|
||||
<div class="text-sm font-medium text-slate-500 dark:text-slate-400 tracking-wide">{{ t('filePreview.title') }}</div>
|
||||
<div class="mt-1 font-semibold text-slate-900 dark:text-slate-100 break-words">{{ file.name }}</div>
|
||||
<button type="button" @click="downloadFile" :disabled="isDownloading" class="mt-2 inline-flex items-center justify-center px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-50 text-brand-700 hover:bg-brand-100 border border-brand-200 dark:bg-brand-900/30 dark:text-brand-300 dark:border-brand-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
<svg v-if="!isDownloading" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
@@ -427,20 +431,20 @@ watch(
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
{{ isDownloading ? '下载中...' : '下载文件' }}
|
||||
{{ isDownloading ? t('filePreview.downloading') : t('filePreview.download') }}
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" @click="close" class="shrink-0 whitespace-nowrap inline-flex items-center justify-center px-4 py-2 rounded-xl border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 bg-white/80 dark:bg-slate-900/80 hover:bg-slate-100 dark:hover:bg-slate-800">关闭</button>
|
||||
<button type="button" @click="close" class="shrink-0 whitespace-nowrap inline-flex items-center justify-center px-4 py-2 rounded-xl border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 bg-white/80 dark:bg-slate-900/80 hover:bg-slate-100 dark:hover:bg-slate-800">{{ t('common.close') }}</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-auto p-4 bg-slate-50 dark:bg-slate-950">
|
||||
<div v-if="isLoading" class="text-sm text-slate-500 dark:text-slate-400">加载中...</div>
|
||||
<div v-if="isLoading" class="text-sm text-slate-500 dark:text-slate-400">{{ t('common.loading') }}</div>
|
||||
<div v-else-if="error" class="text-sm text-red-600 bg-red-50 border border-red-200 rounded-lg p-3">
|
||||
<template v-if="previewTooLarge">
|
||||
文件较大,暂不支持在线预览,请直接点击上方“下载文件”获取原文件。
|
||||
{{ t('filePreview.tooLarge') }}
|
||||
</template>
|
||||
<template v-else>
|
||||
预览失败:{{ error }}
|
||||
{{ t('filePreview.previewFailed') }}{{ error }}
|
||||
</template>
|
||||
</div>
|
||||
<div
|
||||
@@ -530,7 +534,7 @@ watch(
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
{{ isDownloading ? '下载中...' : '下载文件' }}
|
||||
{{ isDownloading ? t('filePreview.downloading') : t('filePreview.download') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { MessageSquareText, X } from 'lucide-vue-next';
|
||||
|
||||
interface Props {
|
||||
@@ -20,11 +21,23 @@ const emit = defineEmits<{
|
||||
(e: 'submitted'): void;
|
||||
}>();
|
||||
|
||||
const typeOptions = ['功能建议', '问题反馈', '体验优化'];
|
||||
const moduleOptions = ['知识库', '通用', '工作流', '账号权限'];
|
||||
const { t, locale } = useI18n({ useScope: 'global' });
|
||||
|
||||
const selectedType = ref<string>('功能建议');
|
||||
const selectedModule = ref<string>('知识库');
|
||||
const typeOptions = computed(() => [
|
||||
t('feedback.type.featureSuggestion'),
|
||||
t('feedback.type.issueReport'),
|
||||
t('feedback.type.experienceOptimization'),
|
||||
]);
|
||||
|
||||
const moduleOptions = computed(() => [
|
||||
t('feedback.module.knowledgeBase'),
|
||||
t('feedback.module.general'),
|
||||
t('feedback.module.workflow'),
|
||||
t('feedback.module.accountPermission'),
|
||||
]);
|
||||
|
||||
const selectedType = ref<string>(t('feedback.type.featureSuggestion'));
|
||||
const selectedModule = ref<string>(t('feedback.module.knowledgeBase'));
|
||||
const content = ref('');
|
||||
const submitting = ref(false);
|
||||
const error = ref('');
|
||||
@@ -36,8 +49,8 @@ const closeDialog = () => {
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
selectedType.value = '功能建议';
|
||||
selectedModule.value = '知识库';
|
||||
selectedType.value = t('feedback.type.featureSuggestion');
|
||||
selectedModule.value = t('feedback.module.knowledgeBase');
|
||||
content.value = '';
|
||||
error.value = '';
|
||||
submitting.value = false;
|
||||
@@ -46,20 +59,25 @@ const resetForm = () => {
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
resetForm();
|
||||
}
|
||||
if (visible) resetForm();
|
||||
},
|
||||
);
|
||||
|
||||
watch(locale, () => {
|
||||
if (props.modelValue) {
|
||||
resetForm();
|
||||
}
|
||||
});
|
||||
|
||||
const submitFeedback = async () => {
|
||||
if (!canSubmit.value) {
|
||||
error.value = '请填写反馈内容';
|
||||
error.value = t('feedback.msg.fillContent');
|
||||
return;
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
error.value = '';
|
||||
|
||||
try {
|
||||
const payload: Record<string, unknown> = {
|
||||
feedback_type: selectedType.value,
|
||||
@@ -67,6 +85,7 @@ const submitFeedback = async () => {
|
||||
content: content.value.trim(),
|
||||
source_page: props.sourcePage,
|
||||
};
|
||||
|
||||
if (props.chatLogId !== null && props.chatLogId !== undefined) {
|
||||
payload.chat_log_id = props.chatLogId;
|
||||
}
|
||||
@@ -82,14 +101,14 @@ const submitFeedback = async () => {
|
||||
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
error.value = data?.error || '提交失败,请稍后重试';
|
||||
error.value = data?.error || t('feedback.msg.submitFailed');
|
||||
return;
|
||||
}
|
||||
|
||||
emit('submitted');
|
||||
closeDialog();
|
||||
} catch {
|
||||
error.value = '提交失败,请稍后重试';
|
||||
error.value = t('feedback.msg.submitFailed');
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
@@ -103,7 +122,7 @@ const submitFeedback = async () => {
|
||||
>
|
||||
<div class="flex max-h-[92vh] w-full max-w-2xl flex-col rounded-2xl bg-white shadow-2xl">
|
||||
<div class="flex items-center justify-between border-b border-gray-100 px-5 pb-4 pt-5 sm:px-8 sm:pb-4 sm:pt-7">
|
||||
<h3 class="text-2xl font-bold text-gray-900">意见反馈</h3>
|
||||
<h3 class="text-2xl font-bold text-gray-900">{{ t('feedback.title') }}</h3>
|
||||
<button
|
||||
@click="closeDialog"
|
||||
class="rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600"
|
||||
@@ -115,7 +134,7 @@ const submitFeedback = async () => {
|
||||
|
||||
<div class="space-y-5 overflow-y-auto px-5 py-5 sm:px-8">
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-sm font-semibold text-gray-600">反馈类型</label>
|
||||
<label class="block text-sm font-semibold text-gray-600">{{ t('feedback.labels.type') }}</label>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<button
|
||||
v-for="item in typeOptions"
|
||||
@@ -134,7 +153,7 @@ const submitFeedback = async () => {
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-sm font-semibold text-gray-600">反馈模块</label>
|
||||
<label class="block text-sm font-semibold text-gray-600">{{ t('feedback.labels.module') }}</label>
|
||||
<select
|
||||
v-model="selectedModule"
|
||||
class="w-full rounded-xl border-gray-200 bg-gray-50 px-4 py-3 text-base shadow-sm outline-none transition-all focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20"
|
||||
@@ -144,13 +163,13 @@ const submitFeedback = async () => {
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-sm font-semibold text-gray-600">反馈内容<span class="ml-0.5 text-red-500">*</span></label>
|
||||
<label class="block text-sm font-semibold text-gray-600">{{ t('feedback.labels.content') }}<span class="ml-0.5 text-red-500">*</span></label>
|
||||
<textarea
|
||||
v-model="content"
|
||||
rows="5"
|
||||
maxlength="2000"
|
||||
class="w-full resize-none rounded-xl border-gray-200 bg-gray-50 px-4 py-3 text-base shadow-sm outline-none transition-all focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20"
|
||||
placeholder="请描述你的问题或建议,帮助我们持续优化。"
|
||||
:placeholder="t('feedback.placeholder.content')"
|
||||
/>
|
||||
<div class="mt-2 flex items-center justify-between">
|
||||
<div v-if="error" class="text-base text-red-600">{{ error }}</div>
|
||||
@@ -166,7 +185,7 @@ const submitFeedback = async () => {
|
||||
class="rounded-xl px-5 py-2.5 text-base font-medium text-gray-600 transition-colors hover:bg-gray-100"
|
||||
:disabled="submitting"
|
||||
>
|
||||
取消
|
||||
{{ t('feedback.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
@click="submitFeedback"
|
||||
@@ -174,7 +193,7 @@ const submitFeedback = async () => {
|
||||
:disabled="!canSubmit"
|
||||
>
|
||||
<MessageSquareText class="h-5 w-5" />
|
||||
{{ submitting ? '提交中' : '提交' }}
|
||||
{{ submitting ? t('feedback.submitting') : t('feedback.submit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { listWorkspaceScheduleRuns, workspaceRunExcelUrl, type ScheduleRun } from '../api/schedule';
|
||||
|
||||
const { t } = useI18n();
|
||||
const isLoading = ref(false);
|
||||
const error = ref('');
|
||||
const runs = ref<ScheduleRun[]>([]);
|
||||
@@ -12,7 +14,7 @@ const loadRuns = async () => {
|
||||
try {
|
||||
runs.value = await listWorkspaceScheduleRuns();
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '加载排程记录失败';
|
||||
error.value = e?.message || t('scheduleRuns.msg.loadFailed');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
@@ -26,27 +28,27 @@ onMounted(() => {
|
||||
<template>
|
||||
<div class="mt-6 rounded-2xl border border-slate-200 bg-white p-5">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h3 class="text-lg font-semibold text-slate-900">排程记录</h3>
|
||||
<h3 class="text-lg font-semibold text-slate-900">{{ t('scheduleRuns.title') }}</h3>
|
||||
<button class="rounded-lg border border-slate-300 px-3 py-1.5 text-sm text-slate-700 hover:bg-slate-50" @click="loadRuns">
|
||||
刷新
|
||||
{{ t('scheduleRuns.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="mb-3 text-xs text-slate-500">仅展示你是 owner 或在通知名单中的记录</p>
|
||||
<div v-if="isLoading" class="py-6 text-sm text-slate-500">加载中...</div>
|
||||
<p class="mb-3 text-xs text-slate-500">{{ t('scheduleRuns.tip') }}</p>
|
||||
<div v-if="isLoading" class="py-6 text-sm text-slate-500">{{ t('scheduleRuns.loading') }}</div>
|
||||
<div v-else-if="error" class="py-6 text-sm text-rose-500">{{ error }}</div>
|
||||
<div v-else-if="runs.length === 0" class="py-6 text-sm text-slate-400">暂无可见记录</div>
|
||||
<div v-else-if="runs.length === 0" class="py-6 text-sm text-slate-400">{{ t('scheduleRuns.empty') }}</div>
|
||||
<div v-else class="overflow-x-auto">
|
||||
<table class="w-full min-w-[920px] text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-200 text-left text-slate-500">
|
||||
<th class="px-2 py-2">执行单号</th>
|
||||
<th class="px-2 py-2">排程</th>
|
||||
<th class="px-2 py-2">开始</th>
|
||||
<th class="px-2 py-2">结束</th>
|
||||
<th class="px-2 py-2">状态</th>
|
||||
<th class="px-2 py-2">处理</th>
|
||||
<th class="px-2 py-2">成功</th>
|
||||
<th class="px-2 py-2">失败</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.runNo') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.schedule') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.start') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.end') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.status') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.total') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.success') }}</th>
|
||||
<th class="px-2 py-2">{{ t('scheduleRuns.columns.failed') }}</th>
|
||||
<th class="px-2 py-2">Excel</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -61,7 +63,7 @@ onMounted(() => {
|
||||
<td class="px-2 py-2">{{ run.success_count }}</td>
|
||||
<td class="px-2 py-2">{{ run.failed_count }}</td>
|
||||
<td class="px-2 py-2">
|
||||
<a class="text-brand-600 hover:underline" :href="workspaceRunExcelUrl(run.id)" target="_blank">查看Excel</a>
|
||||
<a class="text-brand-600 hover:underline" :href="workspaceRunExcelUrl(run.id)" target="_blank">{{ t('scheduleRuns.viewExcel') }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getKbDifyHealth, type KbDifyHealth } from '../../api/kb';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
error: [message: string];
|
||||
}>();
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ close: []; error: [message: string] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const loading = ref(false);
|
||||
const payload = ref<KbDifyHealth | null>(null);
|
||||
@@ -20,94 +16,61 @@ const loadHealth = async () => {
|
||||
loading.value = true;
|
||||
payload.value = await getKbDifyHealth();
|
||||
loading.value = false;
|
||||
if (!payload.value) {
|
||||
emit('error', '加载 Dify 健康状态失败');
|
||||
}
|
||||
if (!payload.value) emit('error', t('kbDifyHealth.msg.loadFailed'));
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (open) {
|
||||
void loadHealth();
|
||||
}
|
||||
}
|
||||
);
|
||||
watch(() => props.open, (open) => {
|
||||
if (open) void loadHealth();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm"
|
||||
@click="close"
|
||||
>
|
||||
<div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm" @click="close">
|
||||
<div class="w-full max-w-4xl rounded-3xl border border-slate-200 bg-white p-6 shadow-xl dark:border-slate-700 dark:bg-slate-900" @click.stop>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">Dify 健康检查</h3>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">
|
||||
查看知识库模块当前的 Dify 连接情况和本地同步概况。
|
||||
</p>
|
||||
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ t('kbDifyHealth.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="loadHealth">
|
||||
刷新
|
||||
{{ t('common.refresh') }}
|
||||
</button>
|
||||
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="close">
|
||||
关闭
|
||||
{{ t('common.close') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-slate-400">正在检测...</div>
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-slate-400">{{ t('kbDifyHealth.loading') }}</div>
|
||||
<div v-else-if="payload" class="mt-6 grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">Dify API</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ payload.api.reachable ? '可访问' : '不可访问' }}
|
||||
</div>
|
||||
<div class="mt-2 break-all text-xs text-slate-500 dark:text-slate-400">
|
||||
{{ payload.dify_base_url || '未配置' }}
|
||||
</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}</div>
|
||||
<div class="mt-2 break-all text-xs text-slate-500 dark:text-slate-400">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">Dataset 数量</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ payload.api.dataset_count ?? '--' }}
|
||||
</div>
|
||||
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">
|
||||
配置完成:{{ payload.dify_api_configured ? '是' : '否' }}
|
||||
</div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.datasetCount') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.api.dataset_count ?? '--' }}</div>
|
||||
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.configured') }}{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">已绑定分组</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ payload.local_sync_health.dataset_bound_groups }}
|
||||
</div>
|
||||
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">
|
||||
本地同步记录:{{ payload.local_sync_health.sync_records }}
|
||||
</div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.boundGroups') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.dataset_bound_groups }}</div>
|
||||
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.localSyncRecords') }}{{ payload.local_sync_health.sync_records }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">同步中版本</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ payload.local_sync_health.syncing_versions }}
|
||||
</div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.syncingVersions') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.syncing_versions }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">已同步版本</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ payload.local_sync_health.synced_versions }}
|
||||
</div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.syncedVersions') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.synced_versions }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">待同步任务</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ payload.local_sync_health.pending_sync_jobs }}
|
||||
</div>
|
||||
<div class="mt-2 text-xs text-rose-500" v-if="payload.api.error">
|
||||
{{ payload.api.error }}
|
||||
</div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.pendingSyncJobs') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.pending_sync_jobs }}</div>
|
||||
<div class="mt-2 text-xs text-rose-500" v-if="payload.api.error">{{ payload.api.error }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getKbDifySettings, updateKbDifySettings } from '../../api/kb';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
saved: [message: string];
|
||||
error: [message: string];
|
||||
}>();
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ close: []; saved: [message: string]; error: [message: string] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
@@ -30,7 +25,7 @@ const loadSettings = async () => {
|
||||
const settings = await getKbDifySettings();
|
||||
loading.value = false;
|
||||
if (!settings) {
|
||||
emit('error', '加载 Dify 设置失败');
|
||||
emit('error', t('kbDifySettings.msg.loadFailed'));
|
||||
return;
|
||||
}
|
||||
Object.assign(form, settings);
|
||||
@@ -41,43 +36,32 @@ const save = async () => {
|
||||
const result = await updateKbDifySettings(form);
|
||||
saving.value = false;
|
||||
if (!result.ok) {
|
||||
emit('error', result.error || '保存 Dify 设置失败');
|
||||
emit('error', result.error || t('kbDifySettings.msg.saveFailed'));
|
||||
return;
|
||||
}
|
||||
emit('saved', 'Dify 设置已保存');
|
||||
emit('saved', t('kbDifySettings.msg.saved'));
|
||||
emit('close');
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (open) {
|
||||
void loadSettings();
|
||||
}
|
||||
}
|
||||
);
|
||||
watch(() => props.open, (open) => {
|
||||
if (open) void loadSettings();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm"
|
||||
@click="close"
|
||||
>
|
||||
<div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm" @click="close">
|
||||
<div class="w-full max-w-3xl rounded-3xl border border-slate-200 bg-white p-6 shadow-xl dark:border-slate-700 dark:bg-slate-900" @click.stop>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">Dify 设置</h3>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">
|
||||
管理知识库模块使用的 Dify 连接和默认同步参数。
|
||||
</p>
|
||||
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ t('kbDifySettings.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ t('kbDifySettings.subtitle') }}</p>
|
||||
</div>
|
||||
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="close">
|
||||
关闭
|
||||
{{ t('common.close') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-slate-400">正在加载设置...</div>
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-slate-400">{{ t('kbDifySettings.loading') }}</div>
|
||||
<div v-else class="mt-6 grid gap-4 md:grid-cols-2">
|
||||
<label class="space-y-2 md:col-span-2">
|
||||
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Dify Base URL</span>
|
||||
@@ -119,14 +103,10 @@ watch(
|
||||
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button class="rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800" @click="close">
|
||||
取消
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
class="rounded-2xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="saving"
|
||||
@click="save"
|
||||
>
|
||||
{{ saving ? '保存中...' : '保存设置' }}
|
||||
<button class="rounded-2xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60" :disabled="saving" @click="save">
|
||||
{{ saving ? t('kbDifySettings.saving') : t('kbDifySettings.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Activity, FolderPlus, Pencil, Play, Settings, Trash2, Wrench, X } from 'lucide-vue-next';
|
||||
import DifyHealthDialog from './DifyHealthDialog.vue';
|
||||
import DifySettingsDialog from './DifySettingsDialog.vue';
|
||||
import DeleteConfirmDialog from '../DeleteConfirmDialog.vue';
|
||||
import {
|
||||
createKbGroup,
|
||||
deleteKbGroup,
|
||||
@@ -16,6 +18,7 @@ import {
|
||||
} from '../../api/kb';
|
||||
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
const groups = ref<KbGroup[]>([]);
|
||||
const jobs = ref<KbJob[]>([]);
|
||||
@@ -31,14 +34,16 @@ const feedbackType = ref<'success' | 'error' | ''>('');
|
||||
const runningJobId = ref<number | string | null>(null);
|
||||
const settingsDialogOpen = ref(false);
|
||||
const healthDialogOpen = ref(false);
|
||||
const deleteDialogOpen = ref(false);
|
||||
const deletingGroup = ref<KbGroup | null>(null);
|
||||
|
||||
const formTitle = computed(() => editingGroupId.value ? '编辑知识库分组' : '新建知识库分组');
|
||||
const formTitle = computed(() => editingGroupId.value ? t('kbAdmin.form.editTitle') : t('kbAdmin.form.createTitle'));
|
||||
const formDescription = computed(() => editingGroupId.value
|
||||
? '修改知识库分组名称和描述,保存后会立即刷新列表。'
|
||||
: '用于验证主平台里的知识库管理入口和基础接口壳。');
|
||||
? t('kbAdmin.form.editDesc')
|
||||
: t('kbAdmin.form.createDesc'));
|
||||
const submitText = computed(() => {
|
||||
if (isSubmitting.value) return editingGroupId.value ? '保存中...' : '提交中...';
|
||||
return editingGroupId.value ? '保存修改' : '创建分组';
|
||||
if (isSubmitting.value) return editingGroupId.value ? t('kbAdmin.form.saving') : t('kbAdmin.form.submitting');
|
||||
return editingGroupId.value ? t('kbAdmin.form.saveChanges') : t('kbAdmin.form.create');
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
@@ -47,13 +52,13 @@ const loadData = async () => {
|
||||
if (groupsResult.ok) {
|
||||
groups.value = groupsResult.data;
|
||||
} else {
|
||||
feedback.value = groupsResult.error || '加载知识库分组失败';
|
||||
feedback.value = groupsResult.error || t('kbAdmin.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
if (jobsResult.ok) {
|
||||
jobs.value = jobsResult.data;
|
||||
} else {
|
||||
feedback.value = jobsResult.error || '加载任务列表失败';
|
||||
feedback.value = jobsResult.error || t('kbAdmin.msg.loadJobsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
isRefreshing.value = false;
|
||||
@@ -66,7 +71,7 @@ const resetForm = () => {
|
||||
|
||||
const handleCreateGroup = async () => {
|
||||
if (!form.value.name.trim()) {
|
||||
feedback.value = '请输入知识库分组名称';
|
||||
feedback.value = t('kbAdmin.msg.nameRequired');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -81,12 +86,12 @@ const handleCreateGroup = async () => {
|
||||
isSubmitting.value = false;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '创建失败';
|
||||
feedback.value = result.error || t('kbAdmin.msg.createFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = editingGroupId.value ? '知识库分组已更新' : '知识库分组创建成功';
|
||||
feedback.value = editingGroupId.value ? t('kbAdmin.msg.updated') : t('kbAdmin.msg.created');
|
||||
feedbackType.value = 'success';
|
||||
resetForm();
|
||||
await loadData();
|
||||
@@ -103,21 +108,26 @@ const handleEditGroup = (group: KbGroup) => {
|
||||
};
|
||||
|
||||
const handleDeleteGroup = async (group: KbGroup) => {
|
||||
const confirmed = window.confirm(`确认删除知识库分组「${group.name}」吗?`);
|
||||
if (!confirmed) return;
|
||||
deletingGroup.value = group;
|
||||
deleteDialogOpen.value = true;
|
||||
};
|
||||
|
||||
const result = await deleteKbGroup(group.id);
|
||||
const handleDeleteGroupConfirm = async () => {
|
||||
if (!deletingGroup.value) return;
|
||||
const result = await deleteKbGroup(deletingGroup.value.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除失败';
|
||||
feedback.value = result.error || t('kbAdmin.msg.deleteFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingGroupId.value === group.id) {
|
||||
if (editingGroupId.value === deletingGroup.value.id) {
|
||||
resetForm();
|
||||
}
|
||||
feedback.value = '知识库分组已删除';
|
||||
feedback.value = t('kbAdmin.msg.deleted');
|
||||
feedbackType.value = 'success';
|
||||
deleteDialogOpen.value = false;
|
||||
deletingGroup.value = null;
|
||||
await loadData();
|
||||
};
|
||||
|
||||
@@ -127,12 +137,12 @@ const handleRunJob = async (job: KbJob) => {
|
||||
runningJobId.value = null;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '任务执行失败';
|
||||
feedback.value = result.error || t('kbAdmin.msg.runFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = result.run_result || '任务已执行';
|
||||
feedback.value = result.run_result || t('kbAdmin.msg.runDone');
|
||||
feedbackType.value = 'success';
|
||||
await loadData();
|
||||
};
|
||||
@@ -148,34 +158,34 @@ defineExpose({ loadData });
|
||||
<div class="animate-fade-in-up">
|
||||
<div class="flex flex-col gap-4 border-b border-gray-100 bg-white px-8 py-6 dark:border-slate-700 dark:bg-slate-900 lg:flex-row lg:items-start lg:justify-between">
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="text-xl font-bold text-gray-900 dark:text-slate-100">知识库管理</h2>
|
||||
<h2 class="text-xl font-bold text-gray-900 dark:text-slate-100">{{ t('kbAdmin.title') }}</h2>
|
||||
<p class="mt-1 text-sm text-gray-500 dark:text-slate-400">
|
||||
第一阶段先承接分组、任务和 Dify 管理入口,后续再接入清洗链路。
|
||||
{{ t('kbAdmin.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:justify-end">
|
||||
<div
|
||||
class="inline-flex w-full items-stretch divide-x divide-slate-200 overflow-hidden rounded-xl border border-slate-200 bg-slate-50 dark:divide-slate-600 dark:border-slate-600 dark:bg-slate-800/80 sm:w-auto"
|
||||
role="toolbar"
|
||||
aria-label="知识库工具操作"
|
||||
:aria-label="t('kbAdmin.toolbar')"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
@click="settingsDialogOpen = true"
|
||||
class="inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-white dark:text-slate-200 dark:hover:bg-slate-700 sm:flex-none sm:px-4"
|
||||
title="Dify 设置"
|
||||
:title="t('kbAdmin.difySettings')"
|
||||
>
|
||||
<Settings class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">Dify 设置</span>
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.difySettings') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="healthDialogOpen = true"
|
||||
class="inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-white dark:text-slate-200 dark:hover:bg-slate-700 sm:flex-none sm:px-4"
|
||||
title="健康检查"
|
||||
:title="t('kbAdmin.healthCheck')"
|
||||
>
|
||||
<Activity class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">健康检查</span>
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.healthCheck') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
@@ -184,7 +194,7 @@ defineExpose({ loadData });
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-blue-600 px-5 py-2.5 text-sm font-medium text-white shadow-lg shadow-blue-200 transition-colors hover:bg-blue-700 sm:w-auto"
|
||||
>
|
||||
<Wrench class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">前往工作台</span>
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.goWorkspace') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -203,16 +213,16 @@ defineExpose({ loadData });
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">分组名称</label>
|
||||
<input v-model="form.name" class="input-field" placeholder="例如:财务制度库" />
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">{{ t('kbAdmin.form.groupName') }}</label>
|
||||
<input v-model="form.name" class="input-field" :placeholder="t('kbAdmin.form.groupNamePlaceholder')" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">分组描述</label>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">{{ t('kbAdmin.form.groupDesc') }}</label>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
rows="4"
|
||||
class="input-field"
|
||||
placeholder="描述该知识库分组的业务范围或清洗目标"
|
||||
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-end gap-2 border-t border-slate-100 pt-4 dark:border-slate-700">
|
||||
@@ -232,7 +242,7 @@ defineExpose({ loadData });
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
<X class="h-4 w-4 shrink-0" />
|
||||
取消编辑
|
||||
{{ t('kbAdmin.form.cancelEdit') }}
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
@@ -248,11 +258,11 @@ defineExpose({ loadData });
|
||||
<div class="space-y-6">
|
||||
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">知识库分组概览</h3>
|
||||
<span class="text-xs text-slate-400">{{ isRefreshing ? '加载中...' : '/api/kb/groups' }}</span>
|
||||
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbAdmin.groupsTitle') }}</h3>
|
||||
<span class="text-xs text-slate-400">{{ isRefreshing ? t('common.loading') : '/api/kb/groups' }}</span>
|
||||
</div>
|
||||
<div v-if="groups.length === 0" class="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
|
||||
当前暂无分组,或知识库接口尚未联调完成。
|
||||
{{ t('kbAdmin.groupsEmpty') }}
|
||||
</div>
|
||||
<div v-else class="grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<div
|
||||
@@ -263,15 +273,15 @@ defineExpose({ loadData });
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ group.name }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ group.description || '暂无描述' }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ group.description || t('kbAdmin.noDescription') }}</div>
|
||||
</div>
|
||||
<div class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300">
|
||||
{{ group.document_count ?? 0 }} 文档
|
||||
{{ t('kbAdmin.documentCount', { count: group.document_count ?? 0 }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="text-xs text-slate-400">
|
||||
更新时间:{{ group.updated_at || '--' }}
|
||||
{{ t('kbAdmin.updatedAt') }}{{ group.updated_at || '--' }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@@ -279,14 +289,14 @@ defineExpose({ loadData });
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-slate-200 px-3 py-2 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<Pencil class="h-3.5 w-3.5" />
|
||||
编辑
|
||||
{{ t('common.edit') }}
|
||||
</button>
|
||||
<button
|
||||
@click="handleDeleteGroup(group)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 dark:border-rose-500/30 dark:text-rose-400 dark:hover:bg-rose-500/10"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
删除
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -296,11 +306,11 @@ defineExpose({ loadData });
|
||||
|
||||
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">任务队列占位</h3>
|
||||
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbAdmin.jobsTitle') }}</h3>
|
||||
<span class="text-xs text-slate-400">/api/kb/jobs</span>
|
||||
</div>
|
||||
<div v-if="jobs.length === 0" class="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
|
||||
暂无任务。第二阶段会在这里接入清洗、同步和重试任务。
|
||||
{{ t('kbAdmin.jobsEmpty') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
@@ -313,10 +323,10 @@ defineExpose({ loadData });
|
||||
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ job.job_type }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ job.created_at || '--' }}</div>
|
||||
<div class="mt-2 text-sm text-slate-500 dark:text-slate-400">
|
||||
{{ job.message || '暂无任务说明' }}
|
||||
{{ job.message || t('kbAdmin.noJobMessage') }}
|
||||
</div>
|
||||
<div class="mt-2 text-xs text-slate-400">
|
||||
文档:{{ job.document_id ?? '--' }} · 版本:{{ job.document_version_id ?? '--' }} · 进度:{{ job.progress ?? 0 }}%
|
||||
{{ t('kbAdmin.jobMeta', { docId: job.document_id ?? '--', versionId: job.document_version_id ?? '--', progress: job.progress ?? 0 }) }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300">
|
||||
@@ -330,7 +340,7 @@ defineExpose({ loadData });
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-brand-500/30 dark:text-brand-300 dark:hover:bg-brand-500/10"
|
||||
>
|
||||
<Play class="h-3.5 w-3.5" />
|
||||
{{ runningJobId === job.id ? '执行中...' : '执行任务' }}
|
||||
{{ runningJobId === job.id ? t('kbAdmin.running') : t('kbAdmin.runJob') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -351,4 +361,11 @@ defineExpose({ loadData });
|
||||
@close="healthDialogOpen = false"
|
||||
@error="(message) => { feedback = message; feedbackType = 'error'; }"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-model="deleteDialogOpen"
|
||||
:title="t('kbAdmin.deleteDialog.title')"
|
||||
:message="t('kbAdmin.deleteDialog.message', { name: deletingGroup?.name || '' })"
|
||||
@confirm="handleDeleteGroupConfirm"
|
||||
@cancel="() => { deleteDialogOpen = false; deletingGroup = null; }"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
import { useGlobalMessageDialog } from './useGlobalMessageDialog';
|
||||
|
||||
type MessageTitle = string | undefined;
|
||||
|
||||
/**
|
||||
* 业务层消息助手:
|
||||
* - 统一复用全局 LevelMessageDialog
|
||||
* - 提供更短的方法名,减少重复传 level 字符串
|
||||
*/
|
||||
export const useMessage = () => {
|
||||
const { showMessageDialog } = useGlobalMessageDialog();
|
||||
|
||||
const info = (message: string, title?: MessageTitle) =>
|
||||
showMessageDialog('info', message, title);
|
||||
|
||||
const success = (message: string, title?: MessageTitle) =>
|
||||
showMessageDialog('success', message, title);
|
||||
|
||||
const warning = (message: string, title?: MessageTitle) =>
|
||||
showMessageDialog('warning', message, title);
|
||||
|
||||
// 兼容常见缩写调用:msg.warn(...)
|
||||
const warn = warning;
|
||||
|
||||
const error = (message: string, title?: MessageTitle) =>
|
||||
showMessageDialog('error', message, title);
|
||||
|
||||
return {
|
||||
info,
|
||||
success,
|
||||
warning,
|
||||
warn,
|
||||
error,
|
||||
};
|
||||
};
|
||||
+1130
-7
File diff suppressed because it is too large.
Load diff
+189
-125
@@ -18,7 +18,7 @@ import { config } from '../config';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
|
||||
import { loadReportLayoutPref, saveReportLayoutPref } from '../composables/useReportLayoutStorage';
|
||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
import { useMessage } from '../composables/useMessage';
|
||||
import { buildWecomAuditMeta, formatWecomAuditReason } from '../utils/wecom';
|
||||
import { getAuthHeaders } from '../utils/auth';
|
||||
import { listAdminSchedules, createAdminSchedule, updateAdminSchedule, deleteAdminSchedule, toggleAdminSchedule, runAdminSchedule, listAdminScheduleRuns, getAdminScheduleTaskConfig, testAdminScheduleSql, testAdminScheduleRun, type ScheduleTask, type ScheduleRun, type TestScheduleRunResult } from '../api/schedule';
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
import * as XLSX from 'xlsx';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { showMessageDialog } = useGlobalMessageDialog();
|
||||
const msg = useMessage();
|
||||
const EMAIL_PATTERN = /^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;
|
||||
|
||||
const sidebarItems = computed(() => {
|
||||
@@ -321,18 +321,18 @@ const openEditUserModal = (user: UserRow) => {
|
||||
|
||||
const saveUser = async () => {
|
||||
if (!editingUser.value.username) {
|
||||
showMessageDialog('warning', t('admin.user.msgs.usernameRequired'));
|
||||
msg.warning(t('admin.user.msgs.usernameRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
const email = (editingUser.value.email || '').trim();
|
||||
if (email && !EMAIL_PATTERN.test(email)) {
|
||||
showMessageDialog('warning', t('admin.user.msgs.invalidEmail'));
|
||||
msg.warning(t('admin.user.msgs.invalidEmail'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!editingUser.value.id && !editingUser.value.password) {
|
||||
showMessageDialog('warning', t('admin.user.msgs.passwordRequired'));
|
||||
msg.warning(t('admin.user.msgs.passwordRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ const saveUser = async () => {
|
||||
showUserModal.value = false;
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', e.message || t('admin.msg.failed'));
|
||||
msg.error(e.message || t('admin.msg.failed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -396,7 +396,25 @@ const wecomBindForm = ref({
|
||||
wecom_userid: '',
|
||||
wecom_unionid: '',
|
||||
});
|
||||
const wecomBindUserQuery = ref('');
|
||||
const wecomBindUserDropdownOpen = ref(false);
|
||||
const wecomBindUserOptions = computed(() => {
|
||||
const keyword = wecomBindUserQuery.value.trim().toLowerCase();
|
||||
return users.value
|
||||
.filter((u) => {
|
||||
if (!keyword) return true;
|
||||
return [u.real_name, u.employee_id, String(u.id)]
|
||||
.filter(Boolean)
|
||||
.some((val) => String(val).toLowerCase().includes(keyword));
|
||||
})
|
||||
.map((u) => ({
|
||||
id: u.id,
|
||||
label: `${u.real_name || u.username} ${u.employee_id ? `(${u.employee_id})` : ''}`.trim(),
|
||||
employeeId: u.employee_id || '',
|
||||
}));
|
||||
});
|
||||
const wecomBoundOnly = ref(false);
|
||||
let wecomBindUserCloseTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
const wecomAuditSourceFilter = ref<'all' | 'wecom' | 'password'>('all');
|
||||
const wecomAuditStatusFilter = ref<'all' | 'success' | 'failed'>('all');
|
||||
const filteredWecomLoginAudits = computed(() => wecomLoginAudits.value);
|
||||
@@ -505,13 +523,13 @@ const scheduleCronDesigner = ref({
|
||||
weekly_minute: 0,
|
||||
});
|
||||
const weeklyDayOptions = [
|
||||
{ value: 1, label: '周一' },
|
||||
{ value: 2, label: '周二' },
|
||||
{ value: 3, label: '周三' },
|
||||
{ value: 4, label: '周四' },
|
||||
{ value: 5, label: '周五' },
|
||||
{ value: 6, label: '周六' },
|
||||
{ value: 0, label: '周日' },
|
||||
{ value: 1, label: t('admin.schedule.weekday.mon') },
|
||||
{ value: 2, label: t('admin.schedule.weekday.tue') },
|
||||
{ value: 3, label: t('admin.schedule.weekday.wed') },
|
||||
{ value: 4, label: t('admin.schedule.weekday.thu') },
|
||||
{ value: 5, label: t('admin.schedule.weekday.fri') },
|
||||
{ value: 6, label: t('admin.schedule.weekday.sat') },
|
||||
{ value: 0, label: t('admin.schedule.weekday.sun') },
|
||||
];
|
||||
|
||||
const buildCronExprFromDesigner = () => {
|
||||
@@ -790,20 +808,20 @@ const selectedSchedule = computed(() =>
|
||||
);
|
||||
|
||||
const scheduleRunStatusOptions = [
|
||||
{ value: 'all', label: '全部状态' },
|
||||
{ value: 'success', label: '成功' },
|
||||
{ value: 'partial_failed', label: '部分成功' },
|
||||
{ value: 'failed', label: '失败' },
|
||||
{ value: 'running', label: '执行中' },
|
||||
{ value: 'all', label: t('admin.schedule.status.all') },
|
||||
{ value: 'success', label: t('admin.schedule.status.success') },
|
||||
{ value: 'partial_failed', label: t('admin.schedule.status.partialFailed') },
|
||||
{ value: 'failed', label: t('admin.schedule.status.failed') },
|
||||
{ value: 'running', label: t('admin.schedule.status.running') },
|
||||
];
|
||||
|
||||
const getScheduleRunStatusBadge = (status: string) => {
|
||||
const map: Record<string, { cls: string; label: string }> = {
|
||||
success: { cls: 'bg-emerald-100 text-emerald-700', label: '成功' },
|
||||
partial_failed: { cls: 'bg-blue-100 text-blue-700', label: '部分成功' },
|
||||
failed: { cls: 'bg-rose-100 text-rose-700', label: '失败' },
|
||||
running: { cls: 'bg-amber-100 text-amber-700', label: '执行中' },
|
||||
queued: { cls: 'bg-slate-100 text-slate-600', label: '排队中' },
|
||||
success: { cls: 'bg-emerald-100 text-emerald-700', label: t('admin.schedule.status.success') },
|
||||
partial_failed: { cls: 'bg-blue-100 text-blue-700', label: t('admin.schedule.status.partialFailed') },
|
||||
failed: { cls: 'bg-rose-100 text-rose-700', label: t('admin.schedule.status.failed') },
|
||||
running: { cls: 'bg-amber-100 text-amber-700', label: t('admin.schedule.status.running') },
|
||||
queued: { cls: 'bg-slate-100 text-slate-600', label: t('admin.schedule.status.queued') },
|
||||
};
|
||||
return map[status] || { cls: 'bg-slate-100 text-slate-600', label: status };
|
||||
};
|
||||
@@ -819,15 +837,15 @@ const formatDateTime = (iso?: string | null) => {
|
||||
const expandedScheduleRunId = ref<number | null>(null);
|
||||
|
||||
const stepLabelMap: Record<string, string> = {
|
||||
fetch_srm: '抓取外部系统数据',
|
||||
call_dify: '调用Dify服务',
|
||||
writeback_srm: '回写外部系统数据',
|
||||
call_internal_api: '调用内部API',
|
||||
pre_dify: 'Dify前处理',
|
||||
fetch_srm: t('admin.schedule.step.fetchSrm'),
|
||||
call_dify: t('admin.schedule.step.callDify'),
|
||||
writeback_srm: t('admin.schedule.step.writebackSrm'),
|
||||
call_internal_api: t('admin.schedule.step.callInternalApi'),
|
||||
pre_dify: t('admin.schedule.step.preDify'),
|
||||
};
|
||||
const stepStatusMap: Record<string, { cls: string; label: string }> = {
|
||||
success: { cls: 'bg-emerald-100 text-emerald-700', label: '成功' },
|
||||
failed: { cls: 'bg-rose-100 text-rose-700', label: '失败' },
|
||||
success: { cls: 'bg-emerald-100 text-emerald-700', label: t('admin.schedule.status.success') },
|
||||
failed: { cls: 'bg-rose-100 text-rose-700', label: t('admin.schedule.status.failed') },
|
||||
};
|
||||
|
||||
const showTestRunDialog = ref(false);
|
||||
@@ -875,7 +893,7 @@ const handleTestRun = async () => {
|
||||
await viewScheduleRuns(s.id);
|
||||
}
|
||||
} catch (e: any) {
|
||||
showMessageDialog('error', `测试执行失败: ${e?.message || e}`);
|
||||
msg.error(`${t('admin.schedule.msg.testRunFailed')}: ${e?.message || e}`);
|
||||
} finally {
|
||||
testRunLoading.value = false;
|
||||
}
|
||||
@@ -973,7 +991,7 @@ const handleTestScheduleSql = async () => {
|
||||
});
|
||||
scheduleTestResult.value = result;
|
||||
} catch (e: any) {
|
||||
showMessageDialog('error', `测试查询失败: ${e?.message || e}`);
|
||||
msg.error(`测试查询失败: ${e?.message || e}`);
|
||||
} finally {
|
||||
scheduleTestLoading.value = false;
|
||||
}
|
||||
@@ -1007,7 +1025,7 @@ const createSchedule = async () => {
|
||||
const hasSql = dst === 'database' && !!scheduleSqlEditForm.value.base_fetch_sql.trim();
|
||||
const hasApi = dst === 'external_api' && !!scheduleSqlEditForm.value.api_url.trim();
|
||||
if (!hasAgent && !hasSql && !hasApi) {
|
||||
showMessageDialog('error', 'Dify Agent、SQL 配置或外部 API 至少填写一项,否则排程执行无任何效果');
|
||||
msg.error(t('admin.schedule.msg.configRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1015,7 +1033,7 @@ const createSchedule = async () => {
|
||||
try {
|
||||
headerLabels = JSON.parse(scheduleSqlEditForm.value.header_labels_str || '{}');
|
||||
} catch {
|
||||
showMessageDialog('error', 'header_labels JSON 格式错误,请检查');
|
||||
msg.error(t('admin.schedule.msg.headerLabelsJsonInvalid'));
|
||||
return;
|
||||
}
|
||||
let apiHeaders: Record<string, string> = {};
|
||||
@@ -1023,7 +1041,7 @@ const createSchedule = async () => {
|
||||
try {
|
||||
apiHeaders = JSON.parse(scheduleSqlEditForm.value.api_headers_str || '{}');
|
||||
} catch {
|
||||
showMessageDialog('error', 'API Headers JSON 格式错误,请检查');
|
||||
msg.error(t('admin.schedule.msg.apiHeadersJsonInvalid'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1165,7 @@ const runScheduleNow = async (taskId: number) => {
|
||||
const res = await runAdminSchedule(taskId);
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
showMessageDialog('error', data?.error || '手动执行失败');
|
||||
msg.error(data?.error || t('admin.schedule.msg.runNowFailed'));
|
||||
return;
|
||||
}
|
||||
await viewScheduleRuns(taskId);
|
||||
@@ -1171,7 +1189,7 @@ const setScheduleEnabled = async (taskId: number, enabled: boolean) => {
|
||||
const downloadScheduleExcel = async (runId: number) => {
|
||||
const res = await fetch(`/api/admin/schedule-runs/${runId}/excel`, { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
showMessageDialog('error', '下载 Excel 失败');
|
||||
msg.error(t('admin.schedule.msg.downloadExcelFailed'));
|
||||
return;
|
||||
}
|
||||
const blob = await res.blob();
|
||||
@@ -1188,11 +1206,11 @@ const downloadScheduleExcel = async (runId: number) => {
|
||||
|
||||
const deleteSchedule = (task: ScheduleTask) => {
|
||||
openDeleteConfirmDialog(
|
||||
`确认删除排程「${task.name}」?`,
|
||||
t('admin.schedule.deleteConfirmMessage', { name: task.name }),
|
||||
async () => {
|
||||
const res = await deleteAdminSchedule(task.id);
|
||||
if (!res.ok) {
|
||||
showMessageDialog('error', '删除排程失败');
|
||||
msg.error(t('admin.schedule.msg.deleteFailed'));
|
||||
return;
|
||||
}
|
||||
if (selectedScheduleId.value === task.id) {
|
||||
@@ -1201,7 +1219,7 @@ const deleteSchedule = (task: ScheduleTask) => {
|
||||
}
|
||||
await loadSchedules();
|
||||
},
|
||||
'删除排程'
|
||||
t('admin.schedule.deleteDialogTitle')
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1278,7 +1296,7 @@ const loadDepartments = async () => {
|
||||
};
|
||||
|
||||
const saveDepartment = async () => {
|
||||
if (!editingDept.value.name) return showMessageDialog('warning', t('admin.dept.msg.nameRequired'));
|
||||
if (!editingDept.value.name) return msg.warning(t('admin.dept.msg.nameRequired'));
|
||||
try {
|
||||
if (editingDept.value.id) {
|
||||
const res = await fetch(`/api/admin/departments/${editingDept.value.id}`, {
|
||||
@@ -1304,7 +1322,7 @@ const saveDepartment = async () => {
|
||||
await loadDepartments();
|
||||
editingDept.value = {};
|
||||
} catch (e: any) {
|
||||
showMessageDialog('error', e.message);
|
||||
msg.error(e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1412,14 +1430,14 @@ const cleanRejectedUsers = async () => {
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
showMessageDialog('success', t('admin.msg.batchDeleteResult', { count: data.deleted_count }));
|
||||
msg.success(t('admin.msg.batchDeleteResult', { count: data.deleted_count }));
|
||||
loadUsers();
|
||||
} else {
|
||||
showMessageDialog('error', data.error);
|
||||
msg.error(data.error);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.requestFailed'));
|
||||
msg.error(t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1438,15 +1456,15 @@ const batchDeleteUsers = async () => {
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
showMessageDialog('success', t('admin.msg.batchDeleteResult', { count: data.deleted_count }));
|
||||
msg.success(t('admin.msg.batchDeleteResult', { count: data.deleted_count }));
|
||||
selectedUserIds.value = [];
|
||||
loadUsers();
|
||||
} else {
|
||||
showMessageDialog('error', data.error);
|
||||
msg.error(data.error);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.requestFailed'));
|
||||
msg.error(t('admin.msg.requestFailed'));
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1490,7 +1508,7 @@ const submitBatchEdit = async () => {
|
||||
if (batchEditForm.value.status) data.status = batchEditForm.value.status;
|
||||
|
||||
if (Object.keys(data).length === 0) {
|
||||
showMessageDialog('warning', t('admin.msg.enterOneField'));
|
||||
msg.warning(t('admin.msg.enterOneField'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1510,7 +1528,7 @@ const submitBatchEdit = async () => {
|
||||
selectedUserIds.value = [];
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.batchUpdateFailed'));
|
||||
msg.error(t('admin.msg.batchUpdateFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -1518,7 +1536,7 @@ const submitBatchEdit = async () => {
|
||||
|
||||
const submitBatchPermission = async () => {
|
||||
if (batchPermissionForm.value.agent_ids.length === 0) {
|
||||
showMessageDialog('warning', t('admin.perm.msg.selectAgent'));
|
||||
msg.warning(t('admin.perm.msg.selectAgent'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1541,7 +1559,7 @@ const submitBatchPermission = async () => {
|
||||
selectedUserIds.value = [];
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.batchPermissionUpdateFailed'));
|
||||
msg.error(t('admin.msg.batchPermissionUpdateFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -1640,6 +1658,19 @@ const loadWecomBindings = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const selectWecomBindUser = (id: number, label: string) => {
|
||||
wecomBindForm.value.user_id = id;
|
||||
wecomBindUserQuery.value = label;
|
||||
wecomBindUserDropdownOpen.value = false;
|
||||
};
|
||||
|
||||
const scheduleCloseWecomBindUserDropdown = () => {
|
||||
if (wecomBindUserCloseTimer) clearTimeout(wecomBindUserCloseTimer);
|
||||
wecomBindUserCloseTimer = setTimeout(() => {
|
||||
wecomBindUserDropdownOpen.value = false;
|
||||
}, 150);
|
||||
};
|
||||
|
||||
const loadWecomAudits = async () => {
|
||||
try {
|
||||
const params = new URLSearchParams({ limit: '200' });
|
||||
@@ -1684,10 +1715,10 @@ const copyText = async (text: string) => {
|
||||
if (!text) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
alert(t('admin.wecom.msg.copySuccess'));
|
||||
msg.success(t('admin.wecom.msg.copySuccess'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(t('admin.wecom.msg.copyFailed'));
|
||||
msg.error(t('admin.wecom.msg.copyFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1752,7 +1783,7 @@ function patchWecomIntegrationManifestFromSettings() {
|
||||
function generateWecomAddressesFromPublicBase() {
|
||||
const base = normalizeWecomPublicBase(wecomSystemSettings.value.public_base_url);
|
||||
if (!base) {
|
||||
alert(t('admin.wecom.msg.publicBaseRequired'));
|
||||
msg.warning(t('admin.wecom.msg.publicBaseRequired'));
|
||||
return;
|
||||
}
|
||||
const host = new URL(base).hostname;
|
||||
@@ -1800,7 +1831,7 @@ const saveWecomSystemSettings = async () => {
|
||||
await loadWecomIntegrationManifest();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
alert(e.message || t('admin.msg.requestFailed'));
|
||||
msg.error(e.message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -1836,7 +1867,7 @@ const saveWecomNotifySettings = async () => {
|
||||
await loadWecomNotifyMetrics();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
alert(e.message || t('admin.msg.requestFailed'));
|
||||
msg.error(e.message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -1866,7 +1897,7 @@ const refreshWecomData = async () => {
|
||||
|
||||
const bindWecomUser = async () => {
|
||||
if (!wecomBindForm.value.user_id || !wecomBindForm.value.wecom_userid.trim()) {
|
||||
showMessageDialog('warning', t('admin.wecom.msg.bindInputRequired'));
|
||||
msg.warning(t('admin.wecom.msg.bindInputRequired'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
@@ -1882,17 +1913,19 @@ const bindWecomUser = async () => {
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || t('admin.wecom.msg.bindFailed'));
|
||||
wecomBindUserQuery.value = '';
|
||||
wecomBindUserDropdownOpen.value = false;
|
||||
wecomBindForm.value.wecom_userid = '';
|
||||
wecomBindForm.value.wecom_unionid = '';
|
||||
await refreshWecomData();
|
||||
showMessageDialog('success', t('admin.wecom.msg.bindSuccess'));
|
||||
msg.success(t('admin.wecom.msg.bindSuccess'));
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
const errorMessage = e?.message || t('admin.wecom.msg.bindFailed');
|
||||
if (String(errorMessage).includes('already bound to user')) {
|
||||
showMessageDialog('error', t('admin.wecom.msg.boundConflict', { detail: errorMessage }));
|
||||
msg.error(t('admin.wecom.msg.boundConflict', { detail: errorMessage }));
|
||||
} else {
|
||||
showMessageDialog('error', errorMessage);
|
||||
msg.error(errorMessage);
|
||||
}
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
@@ -1900,28 +1933,29 @@ const bindWecomUser = async () => {
|
||||
};
|
||||
|
||||
const unbindWecomUserByAdmin = async (userId: number) => {
|
||||
if (!confirm(t('admin.wecom.confirmUnbind'))) return;
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const res = await fetch('/api/admin/wecom/unbind', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({ user_id: userId }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || t('admin.wecom.msg.unbindFailed'));
|
||||
await refreshWecomData();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', e.message || t('admin.wecom.msg.unbindFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
openDeleteConfirmDialog(t('admin.wecom.confirmUnbind'), async () => {
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const res = await fetch('/api/admin/wecom/unbind', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({ user_id: userId }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || t('admin.wecom.msg.unbindFailed'));
|
||||
await refreshWecomData();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
msg.error(e.message || t('admin.wecom.msg.unbindFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const exportWecomAudits = () => {
|
||||
if (filteredWecomLoginAudits.value.length === 0) {
|
||||
showMessageDialog('warning', t('admin.wecom.noAuditData'));
|
||||
msg.warning(t('admin.wecom.noAuditData'));
|
||||
return;
|
||||
}
|
||||
const rows = filteredWecomLoginAudits.value.map((row) => ({
|
||||
@@ -1988,7 +2022,7 @@ const loadAnnouncementsAdmin = async () => {
|
||||
|
||||
const createAnnouncementAdmin = async () => {
|
||||
if (!newAnnouncement.value.title.trim() || !newAnnouncement.value.content.trim()) {
|
||||
showMessageDialog('warning', t('admin.announcement.msg.fillAll'));
|
||||
msg.warning(t('admin.announcement.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
@@ -2009,7 +2043,7 @@ const createAnnouncementAdmin = async () => {
|
||||
await loadAnnouncementsAdmin();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', e.message || t('admin.msg.requestFailed'));
|
||||
msg.error(e.message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -2029,7 +2063,7 @@ const deleteAnnouncementAdmin = async (id: number) => {
|
||||
await loadAnnouncementsAdmin();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', e.message || t('admin.msg.requestFailed'));
|
||||
msg.error(e.message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -2045,7 +2079,7 @@ const loadQuickQuestions = async () => {
|
||||
|
||||
const saveQuestion = async () => {
|
||||
if (!newQuestion.value.title || !newQuestion.value.question || !newQuestion.value.agent_id) {
|
||||
showMessageDialog('warning', t('admin.question.msg.fillAll'));
|
||||
msg.warning(t('admin.question.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2066,11 +2100,11 @@ const saveQuestion = async () => {
|
||||
await loadQuickQuestions();
|
||||
resetQuestionForm();
|
||||
} else {
|
||||
showMessageDialog('error', t('admin.msg.failed'));
|
||||
msg.error(t('admin.msg.failed'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.requestFailed'));
|
||||
msg.error(t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -2162,7 +2196,7 @@ watch(activeModule, async (value) => {
|
||||
* 用途:目前仅作为“保存成功”提示,核心配置变更在具体操作时已写入后台
|
||||
*/
|
||||
// const saveConfig = () => {
|
||||
// showMessageDialog('success', t('admin.msg.allSaved'));
|
||||
// msg.success(t('admin.msg.allSaved'));
|
||||
// };
|
||||
|
||||
const pendingUsers = computed(() => users.value.filter(u => u.status === 'pending'));
|
||||
@@ -2283,7 +2317,7 @@ const runAgentTest = async (agent?: AgentRow) => {
|
||||
*/
|
||||
const createAgent = async () => {
|
||||
if (!newAgent.value.name) {
|
||||
showMessageDialog('warning', t('admin.dept.msg.nameRequired'));
|
||||
msg.warning(t('admin.dept.msg.nameRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2352,54 +2386,56 @@ const createAgent = async () => {
|
||||
const text = await res.text();
|
||||
try {
|
||||
const err = JSON.parse(text);
|
||||
showMessageDialog('error', err.error || t('admin.msg.failed'));
|
||||
msg.error(err.error || t('admin.msg.failed'));
|
||||
} catch {
|
||||
showMessageDialog('error', `${t('admin.msg.failed')}: ${res.status} ${res.statusText}`);
|
||||
msg.error(`${t('admin.msg.failed')}: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.requestFailed'));
|
||||
msg.error(t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const approveUser = async (userId: number) => {
|
||||
if (!confirm(t('admin.approval.confirmApprove'))) return;
|
||||
const res = await fetch(`/api/admin/users/${userId}/approve`, {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
await loadUsers();
|
||||
} else {
|
||||
showMessageDialog('error', t('admin.msg.failed'));
|
||||
}
|
||||
};
|
||||
|
||||
const rejectUser = async (userId: number) => {
|
||||
if (!confirm(t('admin.approval.confirmReject'))) return;
|
||||
try {
|
||||
const res = await fetch(`/api/admin/users/${userId}/reject`, {
|
||||
openDeleteConfirmDialog(t('admin.approval.confirmApprove'), async () => {
|
||||
const res = await fetch(`/api/admin/users/${userId}/approve`, {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
await loadUsers();
|
||||
} else {
|
||||
const text = await res.text();
|
||||
try {
|
||||
const err = JSON.parse(text);
|
||||
showMessageDialog('error', err.error || t('admin.msg.failed'));
|
||||
} catch {
|
||||
showMessageDialog('error', `${t('admin.msg.failed')}: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
msg.error(t('admin.msg.failed'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const rejectUser = async (userId: number) => {
|
||||
openDeleteConfirmDialog(t('admin.approval.confirmReject'), async () => {
|
||||
try {
|
||||
const res = await fetch(`/api/admin/users/${userId}/reject`, {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
await loadUsers();
|
||||
} else {
|
||||
const text = await res.text();
|
||||
try {
|
||||
const err = JSON.parse(text);
|
||||
msg.error(err.error || t('admin.msg.failed'));
|
||||
} catch {
|
||||
msg.error(`${t('admin.msg.failed')}: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error(t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 报表相关状态
|
||||
@@ -3081,13 +3117,13 @@ const batchDeleteChatLogs = async () => {
|
||||
if (!res.ok) {
|
||||
throw new Error(data.error || t('admin.msg.failed'));
|
||||
}
|
||||
showMessageDialog('success', `Deleted ${data.deleted_count ?? 0} chat logs.`);
|
||||
msg.success(`Deleted ${data.deleted_count ?? 0} chat logs.`);
|
||||
selectedReportRowIds.value = [];
|
||||
await loadTableData();
|
||||
chatLogsTotal.value = await loadTableCount('chat_logs');
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', e.message || t('admin.msg.failed'));
|
||||
msg.error(e.message || t('admin.msg.failed'));
|
||||
} finally {
|
||||
isDeletingChatLogs.value = false;
|
||||
}
|
||||
@@ -3189,14 +3225,14 @@ const deleteAgent = async (id: number) => {
|
||||
const text = await res.text();
|
||||
try {
|
||||
const err = JSON.parse(text);
|
||||
showMessageDialog('error', err.error || t('admin.msg.failed'));
|
||||
msg.error(err.error || t('admin.msg.failed'));
|
||||
} catch {
|
||||
showMessageDialog('error', `${t('admin.msg.failed')}: ${res.status} ${res.statusText}`);
|
||||
msg.error(`${t('admin.msg.failed')}: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('admin.msg.requestFailed'));
|
||||
msg.error(t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -3235,7 +3271,7 @@ const saveAgentPermissions = async () => {
|
||||
showAgentPermissionModal.value = false;
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', e.message || t('admin.msg.failed'));
|
||||
msg.error(e.message || t('admin.msg.failed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -3272,7 +3308,7 @@ const toggleUserAgentPermission = async (user: UserRow, agentId: number) => {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
user.agent_ids = originalIds; // Revert on error
|
||||
showMessageDialog('error', t('admin.msg.failed'));
|
||||
msg.error(t('admin.msg.failed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4667,7 +4703,35 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div class="bg-white rounded-2xl border border-gray-100 shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-gray-900">{{ t('admin.wecom.quickBind') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
|
||||
<input v-model="wecomBindForm.user_id" type="number" :placeholder="t('admin.wecom.fields.userId')" class="input-field" />
|
||||
<div class="relative md:col-span-1">
|
||||
<input
|
||||
v-model="wecomBindUserQuery"
|
||||
type="text"
|
||||
class="input-field"
|
||||
:placeholder="t('admin.wecom.fields.userSelect')"
|
||||
@focus="wecomBindUserDropdownOpen = true"
|
||||
@input="wecomBindUserDropdownOpen = true"
|
||||
@blur="scheduleCloseWecomBindUserDropdown"
|
||||
/>
|
||||
<div
|
||||
v-if="wecomBindUserDropdownOpen"
|
||||
class="absolute z-20 mt-2 max-h-64 w-72 overflow-auto rounded-xl border border-gray-200 bg-white shadow-lg"
|
||||
>
|
||||
<button
|
||||
v-for="u in wecomBindUserOptions"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-blue-50"
|
||||
@mousedown.prevent="selectWecomBindUser(u.id, u.label)"
|
||||
>
|
||||
<span class="text-sm text-gray-900">{{ u.label }}</span>
|
||||
<span class="text-xs text-gray-500">{{ u.employeeId || '' }}</span>
|
||||
</button>
|
||||
<div v-if="wecomBindUserOptions.length === 0" class="px-3 py-2 text-sm text-gray-400">
|
||||
{{ t('admin.wecom.noData') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" class="input-field md:col-span-2" />
|
||||
<input v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" class="input-field" />
|
||||
</div>
|
||||
|
||||
@@ -18,15 +18,16 @@ import { marked } from 'marked';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
import FilePreviewModal from '../components/FilePreviewModal.vue';
|
||||
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
|
||||
import GeneralFeedbackDialog from '../components/GeneralFeedbackDialog.vue';
|
||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
import { useMessage } from '../composables/useMessage';
|
||||
import { useIsMobile } from '../composables/useIsMobile';
|
||||
import { useTheme } from '../composables/useTheme';
|
||||
import { getAuthHeaders, getStoredAuthUser, clearAuthUser } from '../utils/auth';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { appliedTheme, toggleLightDark } = useTheme();
|
||||
const { showMessageDialog } = useGlobalMessageDialog();
|
||||
const msg = useMessage();
|
||||
const { isMobile } = useIsMobile();
|
||||
const showMobileAgentPopover = ref(false);
|
||||
const mobileAgentPopoverRef = ref<HTMLElement | null>(null);
|
||||
@@ -51,6 +52,11 @@ const selectedKb = ref('企业知识库');
|
||||
const showKbDropdown = ref(false);
|
||||
const kbMenuRef = ref<HTMLElement | null>(null);
|
||||
const kbOptions = ['企业知识库', 'ERP知识库'];
|
||||
const getKbLabel = (kb: string) => {
|
||||
if (kb === '企业知识库') return t('chat.kb.enterprise');
|
||||
if (kb === 'ERP知识库') return t('chat.kb.erp');
|
||||
return kb;
|
||||
};
|
||||
const chatScrollContainer = ref<HTMLElement | null>(null);
|
||||
let scrollToBottomFrame: number | null = null;
|
||||
let wasThinking = false;
|
||||
@@ -98,7 +104,7 @@ watch(locale, (newLang) => {
|
||||
});
|
||||
|
||||
const handleVoiceFeatureClick = () => {
|
||||
showMessageDialog('info', t('chat.devComingSoon'));
|
||||
msg.info(t('chat.devComingSoon'));
|
||||
};
|
||||
|
||||
const stripReasoningPrelude = (text: string) => {
|
||||
@@ -569,7 +575,7 @@ const openPreview = async (file: SourceFileLink) => {
|
||||
previewFile.value = resolvedFile;
|
||||
filePreviewVisible.value = true;
|
||||
} catch (error: any) {
|
||||
showMessageDialog('warning', error?.message || t('chat.previewUnavailable'));
|
||||
msg.warning(error?.message || t('chat.previewUnavailable'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -597,8 +603,32 @@ const input = ref('');
|
||||
const currentAgent = ref<any>(null);
|
||||
const userAgents = ref<Array<{ id: number; name: string; description: string; icon_url?: string; dify_app_type?: 'chatflow' | 'workflow' }>>([]);
|
||||
const showGeneralFeedbackDialog = ref(false);
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let pendingDeleteAction: (() => Promise<void> | void) | null = null;
|
||||
const showAgentPanel = ref(true);
|
||||
|
||||
const openDeleteConfirmDialog = (
|
||||
message: string,
|
||||
onConfirm: () => Promise<void> | void
|
||||
) => {
|
||||
deleteConfirmMessage.value = message;
|
||||
pendingDeleteAction = onConfirm;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDeleteConfirmDialog = () => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmMessage.value = '';
|
||||
pendingDeleteAction = null;
|
||||
};
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!pendingDeleteAction) return;
|
||||
await pendingDeleteAction();
|
||||
closeDeleteConfirmDialog();
|
||||
};
|
||||
|
||||
const OA_BASE_URL = 'http://192.168.100.221:8888';
|
||||
const OA_VERIFY_LOGIN_URL = `${OA_BASE_URL}/login/VerifyLogin.jsp`;
|
||||
const OA_LEAVE_APPLY_PATH = '/workflow/request/AddRequest.jsp?workflowid=652&isagent=0&beagenter=0&f_weaver_belongto_userid=';
|
||||
@@ -617,7 +647,7 @@ const openOAAutoLoginPage = (gopage: string, username: string, password: string,
|
||||
// 直接在弹出窗口内写入自动提交表单,避免跨窗口时序问题
|
||||
const popup = window.open('about:blank', target);
|
||||
if (!popup) {
|
||||
showMessageDialog('warning', t('chat.oaPopupBlocked'));
|
||||
msg.warning(t('chat.oaPopupBlocked'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -646,7 +676,7 @@ const openOAAutoLoginPage = (gopage: string, username: string, password: string,
|
||||
const openOALeaveRequestDirectly = () => {
|
||||
const employeeId = currentUserEmployeeId.value;
|
||||
if (!employeeId || employeeId === '-') {
|
||||
showMessageDialog('warning', t('chat.noEmployeeId'));
|
||||
msg.warning(t('chat.noEmployeeId'));
|
||||
return;
|
||||
}
|
||||
oaLoginEmployeeId.value = employeeId;
|
||||
@@ -658,7 +688,7 @@ const openOALeaveRequestDirectly = () => {
|
||||
|
||||
const confirmOALogin = () => {
|
||||
if (!oaLoginPassword.value.trim()) {
|
||||
showMessageDialog('warning', t('chat.oaPasswordRequired'));
|
||||
msg.warning(t('chat.oaPasswordRequired'));
|
||||
return;
|
||||
}
|
||||
// 记住密码到 localStorage
|
||||
@@ -674,12 +704,12 @@ const cancelOALogin = () => {
|
||||
const openOARequestDirectly = (requestId: string) => {
|
||||
const normalizedRequestId = String(requestId || '').trim();
|
||||
if (!normalizedRequestId || normalizedRequestId === '-') {
|
||||
showMessageDialog('warning', t('chat.oaRequestMissing'));
|
||||
msg.warning(t('chat.oaRequestMissing'));
|
||||
return;
|
||||
}
|
||||
const employeeId = currentUserEmployeeId.value;
|
||||
if (!employeeId || employeeId === '-') {
|
||||
showMessageDialog('warning', t('chat.noEmployeeId'));
|
||||
msg.warning(t('chat.noEmployeeId'));
|
||||
return;
|
||||
}
|
||||
oaLoginEmployeeId.value = employeeId;
|
||||
@@ -1310,7 +1340,7 @@ const toggleBrowserPanel = () => {
|
||||
const loadBrowserPage = () => {
|
||||
const normalized = normalizeBrowserInput(browserDraftUrl.value);
|
||||
if (!normalized) {
|
||||
showMessageDialog('warning', t('chat.invalidBrowserUrl'));
|
||||
msg.warning(t('chat.invalidBrowserUrl'));
|
||||
return;
|
||||
}
|
||||
browserCurrentUrl.value = normalized;
|
||||
@@ -1330,7 +1360,7 @@ const refreshBrowserPage = () => {
|
||||
const openBrowserInNewTab = () => {
|
||||
const normalized = browserCurrentUrl.value || normalizeBrowserInput(browserDraftUrl.value);
|
||||
if (!normalized) {
|
||||
showMessageDialog('warning', t('chat.enterBrowserUrl'));
|
||||
msg.warning(t('chat.enterBrowserUrl'));
|
||||
return;
|
||||
}
|
||||
window.open(normalized, '_blank', 'noopener,noreferrer');
|
||||
@@ -1457,7 +1487,7 @@ const submitLeaveForm = (msg: any) => {
|
||||
syncLeaveDuration(payload.form);
|
||||
const error = validateLeaveForm(payload.form);
|
||||
if (error) {
|
||||
showMessageDialog('warning', error);
|
||||
msg.warning(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1555,7 +1585,7 @@ const confirmLeaveSubmission = async (msg: any) => {
|
||||
saveLocalMessageToBackend(resultMsg);
|
||||
} catch (error: any) {
|
||||
const errorMessage = error?.message || t('chat.oaLeaveSubmitFailed');
|
||||
showMessageDialog('error', errorMessage);
|
||||
msg.error(errorMessage);
|
||||
const resultMsg = {
|
||||
role: 'assistant' as const,
|
||||
type: 'leave-result' as const,
|
||||
@@ -1615,40 +1645,42 @@ const loadHistory = async () => {
|
||||
};
|
||||
|
||||
const clearAllHistory = async () => {
|
||||
if (!confirm(t('chat.confirmClearHistory'))) return;
|
||||
try {
|
||||
const res = await fetch(`/api/chat/sessions?agent_id=${agentId}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
history.value = [];
|
||||
if (conversationId.value) {
|
||||
startNewChat();
|
||||
openDeleteConfirmDialog(t('chat.confirmClearHistory'), async () => {
|
||||
try {
|
||||
const res = await fetch(`/api/chat/sessions?agent_id=${agentId}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
history.value = [];
|
||||
if (conversationId.value) {
|
||||
startNewChat();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to clear history', e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to clear history', e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const deleteHistoryItem = async (id: string, event: Event) => {
|
||||
event.stopPropagation();
|
||||
if (!confirm(t('chat.confirmDeleteHistoryItem'))) return;
|
||||
try {
|
||||
const res = await fetch(`/api/chat/sessions/${id}?agent_id=${agentId}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
history.value = history.value.filter(h => h.conversation_id !== id);
|
||||
if (conversationId.value === id) {
|
||||
startNewChat();
|
||||
openDeleteConfirmDialog(t('chat.confirmDeleteHistoryItem'), async () => {
|
||||
try {
|
||||
const res = await fetch(`/api/chat/sessions/${id}?agent_id=${agentId}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
history.value = history.value.filter(h => h.conversation_id !== id);
|
||||
if (conversationId.value === id) {
|
||||
startNewChat();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to delete history item', e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to delete history item', e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const loadConversation = async (id: string) => {
|
||||
@@ -1679,7 +1711,7 @@ const loadAgent = async () => {
|
||||
currentAgent.value = await res.json();
|
||||
} else {
|
||||
if (res.status === 403) {
|
||||
showMessageDialog('error', t('workspace.permission.denied') || 'Access denied');
|
||||
msg.error(t('workspace.permission.denied') || 'Access denied');
|
||||
router.push('/workspace?no_redirect=1');
|
||||
return;
|
||||
}
|
||||
@@ -2427,7 +2459,7 @@ const showChatRating = ref(false);
|
||||
class="flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<Database class="h-3.5 w-3.5 text-brand-500" />
|
||||
{{ selectedKb }} <ChevronDown class="h-3 w-3" />
|
||||
{{ getKbLabel(selectedKb) }} <ChevronDown class="h-3 w-3" />
|
||||
</button>
|
||||
<div
|
||||
v-if="showKbDropdown"
|
||||
@@ -2440,7 +2472,7 @@ const showChatRating = ref(false);
|
||||
class="flex w-full items-center justify-between px-3 py-2 text-xs text-slate-700 transition-colors hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
:class="{ 'font-bold text-brand-700 dark:text-brand-300': selectedKb === option }"
|
||||
>
|
||||
{{ option }}
|
||||
{{ getKbLabel(option) }}
|
||||
<Check v-if="selectedKb === option" class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
@@ -2576,7 +2608,7 @@ const showChatRating = ref(false);
|
||||
if (activeFeedbackMessageIndex !== null && messages[activeFeedbackMessageIndex]) {
|
||||
(messages[activeFeedbackMessageIndex] as any).rated = true;
|
||||
}
|
||||
showMessageDialog('success', t('chat.feedbackSubmitSuccess'));
|
||||
msg.success(t('chat.feedbackSubmitSuccess'));
|
||||
showGeneralFeedbackDialog = false;
|
||||
}"
|
||||
/>
|
||||
@@ -2701,6 +2733,12 @@ const showChatRating = ref(false);
|
||||
</div>
|
||||
</Teleport>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="handleDeleteConfirm"
|
||||
@cancel="closeDeleteConfirmDialog"
|
||||
/>
|
||||
|
||||
</template>
|
||||
<style scoped>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, FolderPlus, Info, Pencil, RefreshCw, Trash2, Upload, X } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
|
||||
import {
|
||||
createKbGroup,
|
||||
createKbDocument,
|
||||
@@ -36,6 +38,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
const { t } = useI18n({ useScope: 'global' });
|
||||
|
||||
const isLoading = ref(true);
|
||||
const isDocumentsLoading = ref(false);
|
||||
@@ -61,6 +64,9 @@ const showSourceInfoModal = ref(false);
|
||||
const showFailureModal = ref(false);
|
||||
const showPathUploadModal = ref(false);
|
||||
const showPathUploadHistoryModal = ref(false);
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let pendingDeleteAction: (() => Promise<void> | void) | null = null;
|
||||
const showPathUploadDetails = ref(false);
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null);
|
||||
const pathUploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
@@ -91,6 +97,27 @@ const groupForm = ref({
|
||||
name: '',
|
||||
description: '',
|
||||
});
|
||||
|
||||
const openDeleteConfirmDialog = (
|
||||
message: string,
|
||||
onConfirm: () => Promise<void> | void
|
||||
) => {
|
||||
deleteConfirmMessage.value = message;
|
||||
pendingDeleteAction = onConfirm;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDeleteConfirmDialog = () => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmMessage.value = '';
|
||||
pendingDeleteAction = null;
|
||||
};
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!pendingDeleteAction) return;
|
||||
await pendingDeleteAction();
|
||||
closeDeleteConfirmDialog();
|
||||
};
|
||||
const selectedDocument = computed(() => documents.value.find((item) => item.id === selectedDocumentId.value) || null);
|
||||
const sourceInfoDocument = computed(() => documents.value.find((item) => item.id === sourceInfoDocumentId.value) || null);
|
||||
const selectedGroup = computed(() => groups.value.find((item) => item.id === selectedGroupId.value) || null);
|
||||
@@ -666,23 +693,22 @@ const handleSubmitGroup = async () => {
|
||||
};
|
||||
|
||||
const handleDeleteGroup = async (group: KbGroup) => {
|
||||
const confirmed = window.confirm(`确认删除分组「${group.name}」吗?`);
|
||||
if (!confirmed) return;
|
||||
openDeleteConfirmDialog(`确认删除分组「${group.name}」吗?`, async () => {
|
||||
const result = await deleteKbGroup(group.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除分组失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await deleteKbGroup(group.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除分组失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingGroupId.value === group.id) {
|
||||
resetGroupForm();
|
||||
}
|
||||
feedback.value = '分组已删除';
|
||||
feedbackType.value = 'success';
|
||||
await loadGroups();
|
||||
await loadJobs();
|
||||
if (editingGroupId.value === group.id) {
|
||||
resetGroupForm();
|
||||
}
|
||||
feedback.value = '分组已删除';
|
||||
feedbackType.value = 'success';
|
||||
await loadGroups();
|
||||
await loadJobs();
|
||||
});
|
||||
};
|
||||
|
||||
const loadDocuments = async (groupId: number | null) => {
|
||||
@@ -1084,25 +1110,24 @@ const toggleSelectAllFiltered = () => {
|
||||
};
|
||||
|
||||
const handleDeleteDocument = async (doc: KbDocumentItem) => {
|
||||
const confirmed = window.confirm(`确认删除文档「${getDocumentDisplayTitle(doc)}」吗?`);
|
||||
if (!confirmed) return;
|
||||
openDeleteConfirmDialog(`确认删除文档「${getDocumentDisplayTitle(doc)}」吗?`, async () => {
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除文档失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除文档失败';
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedDocumentId.value === doc.id) {
|
||||
selectedDocumentId.value = null;
|
||||
showRecordModal.value = false;
|
||||
}
|
||||
feedback.value = '文档已删除';
|
||||
feedbackType.value = 'success';
|
||||
await Promise.all([loadGroups(), loadDocuments(selectedGroupId.value), loadJobs()]);
|
||||
selectedDocumentVersions.value = [];
|
||||
selectedDocumentSyncRecords.value = [];
|
||||
if (selectedDocumentId.value === doc.id) {
|
||||
selectedDocumentId.value = null;
|
||||
showRecordModal.value = false;
|
||||
}
|
||||
feedback.value = '文档已删除';
|
||||
feedbackType.value = 'success';
|
||||
await Promise.all([loadGroups(), loadDocuments(selectedGroupId.value), loadJobs()]);
|
||||
selectedDocumentVersions.value = [];
|
||||
selectedDocumentSyncRecords.value = [];
|
||||
});
|
||||
};
|
||||
|
||||
const handleBatchSync = async () => {
|
||||
@@ -1141,31 +1166,34 @@ const handleBatchDelete = async () => {
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
const confirmed = window.confirm(`确认批量删除已选中的 ${selectedDocuments.value.length} 条文档吗?会同步删除 Dify 对应文档。`);
|
||||
if (!confirmed) return;
|
||||
batchSubmitting.value = true;
|
||||
let successCount = 0;
|
||||
let failCount = 0;
|
||||
const errors: string[] = [];
|
||||
try {
|
||||
for (const doc of selectedDocuments.value) {
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (result.ok) {
|
||||
successCount += 1;
|
||||
} else {
|
||||
failCount += 1;
|
||||
errors.push(`${getDocumentDisplayTitle(doc)}: ${result.error || '删除失败'}`);
|
||||
openDeleteConfirmDialog(
|
||||
`确认批量删除已选中的 ${selectedDocuments.value.length} 条文档吗?会同步删除 Dify 对应文档。`,
|
||||
async () => {
|
||||
batchSubmitting.value = true;
|
||||
let successCount = 0;
|
||||
let failCount = 0;
|
||||
const errors: string[] = [];
|
||||
try {
|
||||
for (const doc of selectedDocuments.value) {
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (result.ok) {
|
||||
successCount += 1;
|
||||
} else {
|
||||
failCount += 1;
|
||||
errors.push(`${getDocumentDisplayTitle(doc)}: ${result.error || '删除失败'}`);
|
||||
}
|
||||
}
|
||||
feedback.value = failCount
|
||||
? `批量删除完成:成功 ${successCount} 条,失败 ${failCount} 条。${errors[0] || ''}`
|
||||
: `批量删除完成:共成功 ${successCount} 条`;
|
||||
feedbackType.value = failCount ? 'error' : 'success';
|
||||
selectedDocumentIds.value = [];
|
||||
await Promise.all([loadGroups(), loadDocuments(selectedGroupId.value), loadJobs()]);
|
||||
} finally {
|
||||
batchSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
feedback.value = failCount
|
||||
? `批量删除完成:成功 ${successCount} 条,失败 ${failCount} 条。${errors[0] || ''}`
|
||||
: `批量删除完成:共成功 ${successCount} 条`;
|
||||
feedbackType.value = failCount ? 'error' : 'success';
|
||||
selectedDocumentIds.value = [];
|
||||
await Promise.all([loadGroups(), loadDocuments(selectedGroupId.value), loadJobs()]);
|
||||
} finally {
|
||||
batchSubmitting.value = false;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleRetryFailedItem = async (
|
||||
@@ -1426,7 +1454,7 @@ onUnmounted(() => {
|
||||
v-if="!embedded || (embedded && viewMode === 'group_detail')"
|
||||
@click="embedded ? backToGroupOverview() : router.push('/workspace')"
|
||||
class="rounded-2xl border border-slate-200 p-3 text-slate-500 transition-colors hover:bg-slate-50 hover:text-slate-900 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white"
|
||||
:title="embedded ? '返回分组概览' : '返回工作台'"
|
||||
:title="embedded ? t('kbWorkspace.actions.backToOverview') : t('kbWorkspace.actions.backToWorkspace')"
|
||||
>
|
||||
<ArrowLeft class="h-5 w-5" />
|
||||
</button>
|
||||
@@ -1437,10 +1465,10 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-slate-900 dark:text-slate-100">
|
||||
{{ viewMode === 'group_overview' ? '知识库分组概览' : '知识库工作台' }}
|
||||
{{ viewMode === 'group_overview' ? t('kbWorkspace.header.groupOverviewTitle') : t('kbWorkspace.header.workspaceTitle') }}
|
||||
</h1>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">
|
||||
{{ viewMode === 'group_overview' ? '点击分组卡片进入该分组工作台。' : '数据清洗与知识库管理模块已接入主平台,当前为第一阶段页面壳。' }}
|
||||
{{ viewMode === 'group_overview' ? t('kbWorkspace.header.groupOverviewSubtitle') : t('kbWorkspace.header.workspaceSubtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1452,7 +1480,7 @@ onUnmounted(() => {
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
{{ viewMode === 'group_overview' ? '刷新分组' : '刷新文档' }}
|
||||
{{ viewMode === 'group_overview' ? t('kbWorkspace.actions.refreshGroups') : t('kbWorkspace.actions.refreshDocuments') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1460,28 +1488,26 @@ onUnmounted(() => {
|
||||
<template v-if="viewMode === 'group_overview'">
|
||||
<section class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold text-slate-900 dark:text-slate-100">知识库分组概览</h2>
|
||||
<h2 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbWorkspace.overview.title') }}</h2>
|
||||
<span class="text-xs text-slate-400">`/api/kb/groups`</span>
|
||||
</div>
|
||||
<div v-if="isLoading" class="py-10 text-center text-sm text-slate-400">正在加载分组...</div>
|
||||
<div v-if="isLoading" class="py-10 text-center text-sm text-slate-400">{{ t('kbWorkspace.overview.loadingGroups') }}</div>
|
||||
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr">
|
||||
<div class="rounded-2xl border border-slate-200 p-4 transition-colors hover:border-brand-300 dark:border-slate-700 h-full min-h-[260px] flex flex-col">
|
||||
<div class="mb-3 flex items-center gap-2">
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-xl bg-brand-50 text-brand-600 dark:bg-brand-500/10">
|
||||
<FolderPlus class="h-4 w-4" />
|
||||
</div>
|
||||
<div class="font-semibold text-slate-900 dark:text-slate-100">新增知识库分组</div>
|
||||
</div>
|
||||
<div class="text-sm text-slate-500 dark:text-slate-400">
|
||||
参考知识库入口,点击按钮弹窗输入后创建新分组。
|
||||
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ t('kbWorkspace.overview.createGroupTitle') }}</div>
|
||||
</div>
|
||||
<div class="text-sm text-slate-500 dark:text-slate-400">{{ t('kbWorkspace.overview.createGroupDesc') }}</div>
|
||||
<div class="mt-auto pt-3">
|
||||
<button
|
||||
@click="openCreateGroupModal"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-brand-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
<FolderPlus class="h-4 w-4" />
|
||||
新增知识库
|
||||
{{ t('kbWorkspace.overview.createGroupButton') }}
|
||||
</button>
|
||||
<p
|
||||
v-if="feedback"
|
||||
@@ -2554,5 +2580,12 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="handleDeleteConfirm"
|
||||
@cancel="closeDeleteConfirmDialog"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -13,7 +13,7 @@ import type { ThemePreference } from '../composables/useTheme';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
|
||||
import GeneralFeedbackDialog from '../components/GeneralFeedbackDialog.vue';
|
||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
import { useMessage } from '../composables/useMessage';
|
||||
import { useIsMobile } from '../composables/useIsMobile';
|
||||
import loginBg from '../assets/login-bg.png';
|
||||
|
||||
@@ -56,7 +56,7 @@ import { listWorkspaceScheduleRuns, workspaceRunExcelUrl, type ScheduleRun } fro
|
||||
import { Clock, Download, Search, RefreshCw } from 'lucide-vue-next';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { showMessageDialog } = useGlobalMessageDialog();
|
||||
const msg = useMessage();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { setThemePreference, appliedTheme } = useTheme();
|
||||
@@ -193,7 +193,7 @@ const clearWecomCallbackQuery = () => {
|
||||
|
||||
const handleForgotPassword = async () => {
|
||||
if (!forgotPasswordForm.value.email) {
|
||||
showMessageDialog('warning', t('register.emailRequired'));
|
||||
msg.warning(t('register.emailRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,21 +206,21 @@ const handleForgotPassword = async () => {
|
||||
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
showMessageDialog('success', t('login.passwordResetEmailSent'));
|
||||
msg.success(t('login.passwordResetEmailSent'));
|
||||
showForgotPasswordModal.value = false;
|
||||
forgotPasswordForm.value = { email: '' };
|
||||
} else {
|
||||
showMessageDialog('error', data.error || t('login.passwordResetRequestFailed'));
|
||||
msg.error(data.error || t('login.passwordResetRequestFailed'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Password reset error', e);
|
||||
showMessageDialog('error', t('common.errorOccurred'));
|
||||
msg.error(t('common.errorOccurred'));
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
const showLoginTip = () => {
|
||||
showMessageDialog('warning', t('login.pleaseLoginFirst'));
|
||||
msg.warning(t('login.pleaseLoginFirst'));
|
||||
};
|
||||
*/
|
||||
const userReport = ref<any>(null);
|
||||
@@ -277,7 +277,7 @@ const fetchHome = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/user/home', { headers: getAuthHeaders() });
|
||||
if (res.status === 401) {
|
||||
showMessageDialog('error', t('login.loginRequired'));
|
||||
msg.error(t('login.loginRequired'));
|
||||
handleLogout();
|
||||
return;
|
||||
}
|
||||
@@ -431,7 +431,7 @@ const handleLogin = async (event?: Event) => {
|
||||
event?.stopPropagation();
|
||||
|
||||
if (!loginUsername.value.trim()) {
|
||||
showMessageDialog('warning', t('login.usernameRequired'));
|
||||
msg.warning(t('login.usernameRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ const handleLogin = async (event?: Event) => {
|
||||
let msg = err.error || t('login.failed');
|
||||
if (isCasdoorMode) {
|
||||
if (err.error_code === 'CASDOOR_USER_NOT_FOUND') {
|
||||
msg = 'Casdoor 登录成功,但未匹配到本地账号,请联系管理员。';
|
||||
msg = t('workspace.msg.casdoorNotMatchedContactAdmin');
|
||||
} else if (err.error_code === 'ACCOUNT_DISABLED') {
|
||||
msg = t('login.accountDisabled');
|
||||
} else if (String(err.error || '').includes('invalid_grant')) {
|
||||
@@ -469,7 +469,7 @@ const handleLogin = async (event?: Event) => {
|
||||
if (err.error === 'Database connection failed') msg = t('login.dbConnectionFailed');
|
||||
if (err.error === 'Internal server error') msg = t('login.internalError');
|
||||
|
||||
showMessageDialog('error', msg);
|
||||
msg.error(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ const handleLogin = async (event?: Event) => {
|
||||
await router.replace(`/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('login.requestFailed'));
|
||||
msg.error(t('login.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -506,7 +506,7 @@ const tryCasdoorCallbackLogin = async () => {
|
||||
const shouldStrictCheck = !!expectedState && !!state && !String(state).startsWith('hxops_casdoor_v1.');
|
||||
if (shouldStrictCheck && state !== expectedState) {
|
||||
// Prevent CSRF/state mismatch replay.
|
||||
showMessageDialog('error', 'Invalid or expired Casdoor state');
|
||||
msg.error('Invalid or expired Casdoor state');
|
||||
clearWecomCallbackQuery();
|
||||
return true;
|
||||
}
|
||||
@@ -522,11 +522,11 @@ const tryCasdoorCallbackLogin = async () => {
|
||||
const code = String(data.error_code || '');
|
||||
let msg = data.error || 'Casdoor login failed';
|
||||
if (code === 'CASDOOR_USER_NOT_FOUND') {
|
||||
msg = 'Casdoor 登录成功,但未匹配到本地账号。请让管理员在本地用户表创建同名 username 或相同 email 的账号。';
|
||||
msg = t('workspace.msg.casdoorNotMatchedNeedLocalUser');
|
||||
} else if (code === 'ACCOUNT_DISABLED') {
|
||||
msg = '该本地账号已被禁用,请联系管理员启用后再登录。';
|
||||
msg = t('workspace.msg.localAccountDisabled');
|
||||
}
|
||||
showMessageDialog('error', msg);
|
||||
msg.error(msg);
|
||||
clearWecomCallbackQuery();
|
||||
return true;
|
||||
}
|
||||
@@ -538,7 +538,7 @@ const tryCasdoorCallbackLogin = async () => {
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', 'Casdoor login failed');
|
||||
msg.error('Casdoor login failed');
|
||||
clearWecomCallbackQuery();
|
||||
return true;
|
||||
}
|
||||
@@ -551,7 +551,7 @@ const handleWecomLogin = async () => {
|
||||
try {
|
||||
if (viaCasdoor) {
|
||||
if (!config.auth?.casdoor?.enabled) {
|
||||
showMessageDialog('error', t('login.wecomStartFailed'));
|
||||
msg.error(t('login.wecomStartFailed'));
|
||||
return;
|
||||
}
|
||||
const callbackPath = config.auth.casdoor.callbackPath || '/casdoor-callback';
|
||||
@@ -568,7 +568,7 @@ const handleWecomLogin = async () => {
|
||||
const res = await fetch(`${api}?${qs.toString()}`);
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data.url) {
|
||||
showMessageDialog('error', data.error || t('login.wecomStartFailed'));
|
||||
msg.error(data.error || t('login.wecomStartFailed'));
|
||||
return;
|
||||
}
|
||||
if (data.state) {
|
||||
@@ -583,7 +583,7 @@ const handleWecomLogin = async () => {
|
||||
const res = await fetch(`${api}?redirect_uri=${encodeURIComponent(redirectUri)}`);
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data.url) {
|
||||
showMessageDialog('error', data.error || t('login.wecomStartFailed'));
|
||||
msg.error(data.error || t('login.wecomStartFailed'));
|
||||
return;
|
||||
}
|
||||
if (data.state) {
|
||||
@@ -592,7 +592,7 @@ const handleWecomLogin = async () => {
|
||||
window.location.href = data.url;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('login.wecomStartFailed'));
|
||||
msg.error(t('login.wecomStartFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -690,7 +690,7 @@ const tryWecomCallbackLogin = async () => {
|
||||
|
||||
const expectedState = sessionStorage.getItem('hxops_wecom_state');
|
||||
if (expectedState && state && state !== expectedState) {
|
||||
showMessageDialog('error', t('login.wecomInvalidState'));
|
||||
msg.error(t('login.wecomInvalidState'));
|
||||
openWecomLoginDialog({ error: 'Invalid or expired WeCom state' });
|
||||
clearWecomCallbackQuery();
|
||||
return true;
|
||||
@@ -715,7 +715,7 @@ const tryWecomCallbackLogin = async () => {
|
||||
} else if (rawError.includes('Account is disabled')) {
|
||||
friendly = t('login.wecomAccountDisabled');
|
||||
}
|
||||
showMessageDialog('error', friendly);
|
||||
msg.error(friendly);
|
||||
sessionStorage.removeItem('hxops_wecom_state');
|
||||
if (String(data.error_code || '') === 'WECOM_BIND_INPUT_REQUIRED') {
|
||||
openWecomBindPrompt(data);
|
||||
@@ -735,7 +735,7 @@ const tryWecomCallbackLogin = async () => {
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', t('login.wecomLoginFailed'));
|
||||
msg.error(t('login.wecomLoginFailed'));
|
||||
sessionStorage.removeItem('hxops_wecom_state');
|
||||
openWecomLoginDialog({ error: t('login.wecomLoginFailed') });
|
||||
clearWecomCallbackQuery();
|
||||
@@ -747,7 +747,7 @@ const tryWecomCallbackLogin = async () => {
|
||||
|
||||
const handleRegister = async () => {
|
||||
if (!registerForm.value.username || !registerForm.value.password || !registerForm.value.real_name || !registerForm.value.employee_id || !registerForm.value.phone_number) {
|
||||
showMessageDialog('warning', t('register.inputError'));
|
||||
msg.warning(t('register.inputError'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -759,16 +759,16 @@ const handleRegister = async () => {
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
showMessageDialog('success', t('register.success'));
|
||||
msg.success(t('register.success'));
|
||||
showRegisterModal.value = false;
|
||||
registerForm.value = { username: '', password: '', email: '', real_name: '', employee_id: '', phone_number: '' };
|
||||
} else {
|
||||
const err = await res.json();
|
||||
showMessageDialog('error', err.error || t('register.failed'));
|
||||
msg.error(err.error || t('register.failed'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Register error:', e);
|
||||
showMessageDialog('error', t('register.requestFailed'));
|
||||
msg.error(t('register.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -835,9 +835,9 @@ const mobileTabActive = computed({
|
||||
});
|
||||
|
||||
const mobileTabTitle = computed(() => {
|
||||
if (mobileTabActive.value === 'profile') return '我的';
|
||||
if (mobileTabActive.value === 'history') return '历史会话';
|
||||
return '应用管理';
|
||||
if (mobileTabActive.value === 'profile') return t('workspace.mobileTabs.me');
|
||||
if (mobileTabActive.value === 'history') return t('workspace.mobileTabs.history');
|
||||
return t('workspace.mobileTabs.applications');
|
||||
});
|
||||
|
||||
const handleLogout = () => {
|
||||
@@ -876,7 +876,7 @@ const fetchProfile = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/user/profile', { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
showMessageDialog('error', '加载个人中心失败');
|
||||
msg.error(t('workspace.profile.msg.loadFailed'));
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
@@ -891,7 +891,7 @@ const fetchProfile = async () => {
|
||||
isProfileEditing.value = false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', '加载个人中心失败');
|
||||
msg.error(t('workspace.profile.msg.loadFailed'));
|
||||
} finally {
|
||||
isProfileLoading.value = false;
|
||||
}
|
||||
@@ -946,16 +946,16 @@ const saveProfile = async () => {
|
||||
|
||||
if (!res.ok) {
|
||||
const message = await parseErrorMessage(res);
|
||||
showMessageDialog('error', message || '保存个人资料失败');
|
||||
msg.error(message || t('workspace.profile.msg.saveFailed'));
|
||||
return;
|
||||
}
|
||||
|
||||
showMessageDialog('success', '个人资料已保存');
|
||||
msg.success(t('workspace.profile.msg.saved'));
|
||||
captureOriginalProfile();
|
||||
isProfileEditing.value = false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', '保存个人资料失败');
|
||||
msg.error(t('workspace.profile.msg.saveFailed'));
|
||||
} finally {
|
||||
isProfileSaving.value = false;
|
||||
}
|
||||
@@ -963,7 +963,7 @@ const saveProfile = async () => {
|
||||
|
||||
const handleChangePassword = async () => {
|
||||
if (passwordForm.value.new !== passwordForm.value.confirm) {
|
||||
showMessageDialog('warning', t('profile.passwordMismatch') || 'Passwords do not match');
|
||||
msg.warning(t('profile.passwordMismatch') || 'Passwords do not match');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -979,16 +979,16 @@ const handleChangePassword = async () => {
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
showMessageDialog('error', data.error || '修改密码失败');
|
||||
msg.error(data.error || t('workspace.profile.msg.changePasswordFailed'));
|
||||
return;
|
||||
}
|
||||
|
||||
showMessageDialog('success', t('profile.passwordChanged') || 'Password changed successfully');
|
||||
msg.success(t('profile.passwordChanged') || 'Password changed successfully');
|
||||
passwordForm.value = { current: '', new: '', confirm: '' };
|
||||
showPasswordModal.value = false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showMessageDialog('error', '修改密码失败');
|
||||
msg.error(t('workspace.profile.msg.changePasswordFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1051,20 +1051,20 @@ const wsScheduleStartedAfter = ref(todayStartLocal());
|
||||
const wsScheduleStartedBefore = ref(todayEndLocal());
|
||||
|
||||
const wsScheduleStatusOptions = [
|
||||
{ value: 'all', label: '全部状态' },
|
||||
{ value: 'success', label: '成功' },
|
||||
{ value: 'partial_failed', label: '部分成功' },
|
||||
{ value: 'failed', label: '失败' },
|
||||
{ value: 'running', label: '执行中' },
|
||||
{ value: 'all', label: t('workspace.schedule.status.all') },
|
||||
{ value: 'success', label: t('workspace.schedule.status.success') },
|
||||
{ value: 'partial_failed', label: t('workspace.schedule.status.partialFailed') },
|
||||
{ value: 'failed', label: t('workspace.schedule.status.failed') },
|
||||
{ value: 'running', label: t('workspace.schedule.status.running') },
|
||||
];
|
||||
|
||||
const getWsScheduleStatusBadge = (status: string) => {
|
||||
const map: Record<string, { cls: string; label: string }> = {
|
||||
success: { cls: 'bg-emerald-100 text-emerald-700', label: '成功' },
|
||||
partial_failed: { cls: 'bg-blue-100 text-blue-700', label: '部分成功' },
|
||||
failed: { cls: 'bg-rose-100 text-rose-700', label: '失败' },
|
||||
running: { cls: 'bg-amber-100 text-amber-700', label: '执行中' },
|
||||
queued: { cls: 'bg-slate-100 text-slate-600', label: '排队中' },
|
||||
success: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.schedule.status.success') },
|
||||
partial_failed: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.schedule.status.partialFailed') },
|
||||
failed: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.schedule.status.failed') },
|
||||
running: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.schedule.status.running') },
|
||||
queued: { cls: 'bg-slate-100 text-slate-600', label: t('workspace.schedule.status.queued') },
|
||||
};
|
||||
return map[status] || { cls: 'bg-slate-100 text-slate-600', label: status };
|
||||
};
|
||||
@@ -1104,7 +1104,7 @@ const resetWsScheduleFilters = () => {
|
||||
const downloadWsScheduleExcel = async (runId: number) => {
|
||||
const res = await fetch(workspaceRunExcelUrl(runId), { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
showMessageDialog('error', '下载 Excel 失败');
|
||||
msg.error(t('workspace.schedule.msg.downloadExcelFailed'));
|
||||
return;
|
||||
}
|
||||
const blob = await res.blob();
|
||||
@@ -1167,7 +1167,7 @@ const openAdminPanel = () => {
|
||||
const navigateToChat = (id: number) => {
|
||||
if (!isLoggedIn.value) {
|
||||
pendingAgentId.value = id;
|
||||
showMessageDialog('warning', t('login.loginRequired'));
|
||||
msg.warning(t('login.loginRequired'));
|
||||
return;
|
||||
}
|
||||
const url = router.resolve(`/chat/${id}`).href;
|
||||
@@ -1177,7 +1177,7 @@ const navigateToChat = (id: number) => {
|
||||
const navigateWithQuickQuestion = (agentId: number, question: string) => {
|
||||
if (!isLoggedIn.value) {
|
||||
pendingAgentId.value = agentId;
|
||||
showMessageDialog('warning', t('login.loginRequired'));
|
||||
msg.warning(t('login.loginRequired'));
|
||||
return;
|
||||
}
|
||||
const url = router.resolve({
|
||||
@@ -1269,7 +1269,7 @@ const cancelAddQuestion = () => {
|
||||
|
||||
const saveQuickQuestion = async () => {
|
||||
if (!newQuestion.value.title || !newQuestion.value.question || !newQuestion.value.agent_id) {
|
||||
showMessageDialog('warning', t('workspace.quickQuestions.msg.fillAll'));
|
||||
msg.warning(t('workspace.quickQuestions.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1290,7 +1290,7 @@ const saveQuickQuestion = async () => {
|
||||
isAddingQuestion.value = false;
|
||||
editingQuestionId.value = null;
|
||||
} else {
|
||||
showMessageDialog('error', t('workspace.quickQuestions.msg.saveFailed'));
|
||||
msg.error(t('workspace.quickQuestions.msg.saveFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1394,8 +1394,8 @@ onMounted(async () => {
|
||||
<ThemeToggleButton />
|
||||
<select v-model="locale" class="bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-xs font-medium text-slate-600 dark:text-slate-300 hover:text-slate-800 dark:hover:text-slate-100 cursor-pointer outline-none rounded-full px-3 py-1.5 transition-all hover:shadow-md">
|
||||
<option value="en">English</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="zh-CN">{{ $t('workspace.lang.zhCN') }}</option>
|
||||
<option value="zh-TW">{{ $t('workspace.lang.zhTW') }}</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -1547,7 +1547,7 @@ onMounted(async () => {
|
||||
<div v-else class="min-h-screen animate-fade-in">
|
||||
<header v-if="isMobile" class="sticky top-0 z-30 flex items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-slate-800 dark:bg-slate-950">
|
||||
<div class="flex items-center gap-2">
|
||||
<button @click="router.push('/chat/16')" class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20" title="返回聊天">AI</button>
|
||||
<button @click="router.push('/chat/16')" class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20" :title="$t('workspace.nav.backToChat')">AI</button>
|
||||
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ mobileTabTitle }}</span>
|
||||
</div>
|
||||
</header>
|
||||
@@ -1560,7 +1560,7 @@ onMounted(async () => {
|
||||
<Bot class="h-6 w-6" />
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<div class="text-2xl font-extrabold tracking-tight text-[#14213d]">和信AI</div>
|
||||
<div class="text-2xl font-extrabold tracking-tight text-[#14213d]">{{ $t('workspace.brandTitle') }}</div>
|
||||
<div class="truncate text-xs font-medium text-slate-400">
|
||||
{{ currentUser?.username }} / {{ currentUser?.role }}
|
||||
</div>
|
||||
@@ -1576,7 +1576,7 @@ onMounted(async () => {
|
||||
:class="activeSidebarItem === 'profile' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<User class="h-4 w-4" />
|
||||
<span>个人中心</span>
|
||||
<span>{{ $t('workspace.nav.profile') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="currentUser?.role === 'admin'"
|
||||
@@ -1584,7 +1584,7 @@ onMounted(async () => {
|
||||
class="flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium text-slate-600 transition-all hover:bg-slate-50 hover:text-slate-900"
|
||||
>
|
||||
<Settings class="h-4 w-4" />
|
||||
<span>管理后台</span>
|
||||
<span>{{ $t('workspace.nav.admin') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="navigateToApplications"
|
||||
@@ -1592,7 +1592,7 @@ onMounted(async () => {
|
||||
:class="activeSidebarItem === 'applications' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<LayoutGrid class="h-4 w-4" />
|
||||
<span>应用管理</span>
|
||||
<span>{{ $t('workspace.nav.applications') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="navigateToKnowledgeBase"
|
||||
@@ -1600,7 +1600,7 @@ onMounted(async () => {
|
||||
:class="activeSidebarItem === 'knowledge_base' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<FileText class="h-4 w-4" />
|
||||
<span>知识库管理</span>
|
||||
<span>{{ $t('workspace.nav.knowledgeBase') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="navigateToScheduleRuns"
|
||||
@@ -1608,7 +1608,7 @@ onMounted(async () => {
|
||||
:class="activeSidebarItem === 'schedule_runs' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<Clock class="h-4 w-4" />
|
||||
<span>排程记录</span>
|
||||
<span>{{ $t('workspace.nav.scheduleRuns') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="openGeneralFeedback"
|
||||
@@ -1616,7 +1616,7 @@ onMounted(async () => {
|
||||
:class="activeSidebarItem === 'feedback' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<Edit class="h-4 w-4" />
|
||||
<span>意见反馈</span>
|
||||
<span>{{ $t('workspace.nav.feedback') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="navigateToUpdates"
|
||||
@@ -1624,7 +1624,7 @@ onMounted(async () => {
|
||||
:class="activeSidebarItem === 'updates' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
>
|
||||
<Megaphone class="h-4 w-4" />
|
||||
<span>最近更新</span>
|
||||
<span>{{ $t('workspace.nav.updates') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1636,14 +1636,14 @@ onMounted(async () => {
|
||||
class="flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium text-slate-600 transition-all hover:bg-slate-50 hover:text-slate-900"
|
||||
>
|
||||
<Bot class="h-4 w-4" />
|
||||
<span>返回聊天</span>
|
||||
<span>{{ $t('workspace.nav.backToChat') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="handleLogout"
|
||||
class="flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium text-red-500 transition-all hover:bg-red-50 hover:text-red-600"
|
||||
>
|
||||
<LogOut class="h-4 w-4" />
|
||||
<span>退出登录</span>
|
||||
<span>{{ $t('workspace.nav.logout') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1658,7 +1658,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div v-else-if="chatHistories.length === 0" class="flex flex-col items-center justify-center py-20 text-slate-400">
|
||||
<Bot class="h-10 w-10 mb-2" />
|
||||
<p class="text-sm">暂无历史会话</p>
|
||||
<p class="text-sm">{{ $t('workspace.history.empty') }}</p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<button
|
||||
@@ -1674,7 +1674,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="truncate text-sm font-medium text-slate-800 dark:text-slate-100">{{ item.title || '未命名对话' }}</span>
|
||||
<span class="truncate text-sm font-medium text-slate-800 dark:text-slate-100">{{ item.title || $t('workspace.history.untitled') }}</span>
|
||||
</div>
|
||||
<div class="mt-0.5 flex items-center gap-2 text-xs text-slate-400">
|
||||
<span>{{ item.agent_name || '' }}</span>
|
||||
@@ -1701,39 +1701,39 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="grid flex-1 text-left" :class="isMobile ? 'grid-cols-2 gap-x-4 gap-y-1' : 'grid-cols-1 gap-x-12 gap-y-3 sm:grid-cols-2'">
|
||||
<div :class="isMobile ? '' : ''">
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? '姓名' : (profileUser.username || '-') }}</div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? $t('profile.realName') : (profileUser.username || '-') }}</div>
|
||||
<div v-if="isMobile" class="text-sm font-medium text-slate-900 truncate">{{ profileUser.real_name || profileUser.username || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? '工号' : (profileUser.employee_id || '-') }}</div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? $t('profile.employeeId') : (profileUser.employee_id || '-') }}</div>
|
||||
<div v-if="isMobile" class="text-sm font-medium text-slate-900 truncate">{{ profileUser.employee_id || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? '部门' : (profileUser.department || '-') }}</div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? $t('profile.department') : (profileUser.department || '-') }}</div>
|
||||
<div v-if="isMobile" class="text-sm font-medium text-slate-900 truncate">{{ profileUser.department || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? '角色' : (profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User')) }}</div>
|
||||
<div v-if="isMobile" class="text-sm font-medium text-slate-900 truncate">{{ profileUser.role === 'admin' ? ($t('profile.roleAdmin') || '管理员') : ($t('profile.roleUser') || '用户') }}</div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'text-lg font-semibold text-slate-900'">{{ isMobile ? $t('profile.role') : (profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User')) }}</div>
|
||||
<div v-if="isMobile" class="text-sm font-medium text-slate-900 truncate">{{ profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User') }}</div>
|
||||
</div>
|
||||
<div :class="isMobile ? 'col-span-2' : 'sm:col-span-2'">
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'break-all text-lg font-semibold text-slate-900'">{{ isMobile ? '邮箱' : (profileUser.email || '-') }}</div>
|
||||
<div :class="isMobile ? 'text-xs text-slate-400' : 'break-all text-lg font-semibold text-slate-900'">{{ isMobile ? $t('profile.email') : (profileUser.email || '-') }}</div>
|
||||
<div v-if="isMobile" class="text-sm font-medium text-slate-900 truncate">{{ profileUser.email || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!isMobile" class="flex shrink-0 items-center gap-2 self-start lg:ml-6">
|
||||
<button @click="showPasswordModal = true" class="btn-primary px-6 py-3 text-base">
|
||||
修改密码
|
||||
{{ $t('profile.changePassword') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isMobile" class="mt-4 flex items-center justify-center gap-4">
|
||||
<button @click="showPasswordModal = true" class="btn-primary flex-1 py-2.5 text-sm text-center">
|
||||
修改密码
|
||||
{{ $t('profile.changePassword') }}
|
||||
</button>
|
||||
<button @click="handleLogout" class="btn-secondary flex-1 py-2.5 text-sm text-center text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950">
|
||||
退出登录
|
||||
{{ $t('workspace.nav.logout') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1744,18 +1744,18 @@ onMounted(async () => {
|
||||
<div class="flex items-center" :class="isMobile ? 'w-full justify-center gap-2' : ''">
|
||||
<h3 class="flex items-center gap-3 text-3xl font-bold text-slate-900" :class="isMobile ? 'text-lg gap-2' : ''">
|
||||
<User class="h-6 w-6 text-brand-500" :class="isMobile ? 'h-4 w-4' : ''" />
|
||||
基本信息
|
||||
{{ $t('profile.basicInfo') }}
|
||||
</h3>
|
||||
<button v-if="isMobile && !isProfileEditing" @click="startProfileEditing" class="btn-secondary px-3 py-1 text-xs">
|
||||
编辑
|
||||
{{ $t('profile.edit') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="!isMobile" class="mt-2 text-sm text-slate-500">
|
||||
{{ isProfileEditing ? '可直接修改并保存个人资料' : '切换到编辑模式以更新个人资料' }}
|
||||
{{ isProfileEditing ? $t('profile.directEditHint') : $t('profile.switchEditHint') }}
|
||||
</p>
|
||||
<div v-if="!isMobile" class="flex items-center gap-2">
|
||||
<button v-if="!isProfileEditing" @click="startProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
|
||||
编辑
|
||||
{{ $t('profile.edit') }}
|
||||
</button>
|
||||
<template v-else>
|
||||
<button @click="cancelProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
|
||||
@@ -1767,7 +1767,7 @@ onMounted(async () => {
|
||||
class="btn-primary px-5 py-2.5 text-sm disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Save class="w-4 h-4" />
|
||||
<span>{{ isProfileSaving ? '保存中...' : '保存' }}</span>
|
||||
<span>{{ isProfileSaving ? $t('profile.saving') : $t('workspace.save') }}</span>
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
@@ -1775,7 +1775,7 @@ onMounted(async () => {
|
||||
<div class="grid grid-cols-1 gap-5 md:grid-cols-2" :class="isMobile ? 'gap-3' : ''">
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-slate-500" :class="isMobile ? 'text-xs mb-1' : ''">
|
||||
<User class="h-4 w-4" /> 用户名
|
||||
<User class="h-4 w-4" /> {{ $t('profile.username') }}
|
||||
</label>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg font-medium text-slate-700" :class="isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ profileUser.username || '-' }}
|
||||
@@ -1783,7 +1783,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-slate-500" :class="isMobile ? 'text-xs mb-1' : ''">
|
||||
<CreditCard class="h-4 w-4" /> 工号
|
||||
<CreditCard class="h-4 w-4" /> {{ $t('profile.employeeId') }}
|
||||
</label>
|
||||
<input v-if="isProfileEditing" v-model="profileUser.employee_id" type="text" class="input-field" :class="isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
|
||||
<div v-else class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg font-medium text-slate-700" :class="isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
@@ -1792,7 +1792,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-slate-500" :class="isMobile ? 'text-xs mb-1' : ''">
|
||||
<User class="h-4 w-4" /> 真实姓名
|
||||
<User class="h-4 w-4" /> {{ $t('profile.realName') }}
|
||||
</label>
|
||||
<input v-if="isProfileEditing" v-model="profileUser.real_name" type="text" class="input-field" :class="isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
|
||||
<div v-else class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg font-medium text-slate-700" :class="isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
@@ -1801,7 +1801,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-slate-500" :class="isMobile ? 'text-xs mb-1' : ''">
|
||||
<Building class="h-4 w-4" /> 部门
|
||||
<Building class="h-4 w-4" /> {{ $t('profile.department') }}
|
||||
</label>
|
||||
<input v-if="isProfileEditing" v-model="profileUser.department" type="text" class="input-field" :class="isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
|
||||
<div v-else class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg font-medium text-slate-700" :class="isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
@@ -1810,7 +1810,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-slate-500" :class="isMobile ? 'text-xs mb-1' : ''">
|
||||
<Mail class="h-4 w-4" /> 邮箱
|
||||
<Mail class="h-4 w-4" /> {{ $t('profile.email') }}
|
||||
</label>
|
||||
<input v-if="isProfileEditing" v-model="profileUser.email" type="email" class="input-field" :class="isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
|
||||
<div v-else class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg font-medium text-slate-700" :class="isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
@@ -1819,7 +1819,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-slate-500" :class="isMobile ? 'text-xs mb-1' : ''">
|
||||
<Globe class="h-4 w-4" /> 手机号
|
||||
<Globe class="h-4 w-4" /> {{ $t('profile.phoneNumber') }}
|
||||
</label>
|
||||
<input v-if="isProfileEditing" v-model="profileUser.phone_number" type="text" class="input-field" :class="isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
|
||||
<div v-else class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg font-medium text-slate-700" :class="isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
@@ -1832,20 +1832,20 @@ onMounted(async () => {
|
||||
<div class="rounded-3xl border border-slate-200 bg-white p-8 shadow-sm">
|
||||
<h3 class="mb-6 flex items-center gap-3 text-2xl font-bold text-slate-900">
|
||||
<Palette class="h-5 w-5 text-brand-500" />
|
||||
偏好设置
|
||||
{{ $t('profile.preferences') }}
|
||||
</h3>
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-500">语言</label>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-500">{{ $t('workspace.languageLabel') }}</label>
|
||||
<select v-model="profileUser.language" :disabled="!isProfileEditing" class="input-field h-[58px]">
|
||||
<option value="en">English</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="zh-CN">{{ $t('workspace.lang.zhCN') }}</option>
|
||||
<option value="zh-TW">{{ $t('workspace.lang.zhTW') }}</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-500">主题</label>
|
||||
<label class="mb-2 block text-sm font-medium text-slate-500">{{ $t('profile.theme') }}</label>
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<button
|
||||
v-for="item in themeOptions"
|
||||
@@ -1876,30 +1876,30 @@ onMounted(async () => {
|
||||
<template v-else-if="activeSidebarItem === 'schedule_runs'">
|
||||
<div class="space-y-5 animate-fade-in-up">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-2xl font-bold text-slate-900">排程记录</h2>
|
||||
<h2 class="text-2xl font-bold text-slate-900">{{ $t('workspace.schedule.title') }}</h2>
|
||||
<button
|
||||
@click="loadWorkspaceScheduleRuns"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
刷新
|
||||
{{ $t('workspace.schedule.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50/40 px-4 py-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">排程名称</label>
|
||||
<input type="text" v-model="wsScheduleNameFilter" placeholder="输入排程名称" class="!w-[150px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200 bg-white" />
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">{{ $t('workspace.schedule.filters.name') }}</label>
|
||||
<input type="text" v-model="wsScheduleNameFilter" :placeholder="$t('workspace.schedule.filters.namePlaceholder')" class="!w-[150px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200 bg-white" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">开始时间</label>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">{{ $t('workspace.schedule.filters.start') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="wsScheduleStartedAfter" class="!w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200 bg-white" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">结束时间</label>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">{{ $t('workspace.schedule.filters.end') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="wsScheduleStartedBefore" class="!w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200 bg-white" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">状态</label>
|
||||
<label class="mb-1 block text-xs font-medium text-slate-500">{{ $t('workspace.schedule.filters.status') }}</label>
|
||||
<select v-model="wsScheduleStatusFilter" class="!w-[120px] !py-1 !px-2 !text-xs rounded-lg border border-slate-200 bg-white">
|
||||
<option v-for="o in wsScheduleStatusOptions" :key="o.value" :value="o.value">{{ o.label }}</option>
|
||||
</select>
|
||||
@@ -1909,41 +1909,41 @@ onMounted(async () => {
|
||||
class="inline-flex items-center gap-1 rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-brand-700"
|
||||
>
|
||||
<Search class="h-3.5 w-3.5" />
|
||||
查询
|
||||
{{ $t('workspace.schedule.search') }}
|
||||
</button>
|
||||
<button
|
||||
@click="resetWsScheduleFilters"
|
||||
class="rounded-xl border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
>
|
||||
重置
|
||||
{{ $t('workspace.schedule.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="workspaceScheduleLoading" class="py-10 text-center text-sm text-slate-400">正在加载...</div>
|
||||
<div v-else-if="workspaceScheduleRuns.length === 0" class="py-10 text-center text-sm text-slate-400">暂无排程记录</div>
|
||||
<div v-if="workspaceScheduleLoading" class="py-10 text-center text-sm text-slate-400">{{ $t('workspace.schedule.loading') }}</div>
|
||||
<div v-else-if="workspaceScheduleRuns.length === 0" class="py-10 text-center text-sm text-slate-400">{{ $t('workspace.schedule.empty') }}</div>
|
||||
<div v-else class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-100 bg-slate-50/60">
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">排程名称</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">运行编号</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">触发方式</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">开始时间</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">结束时间</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">耗时</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">状态</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">处理笔数</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">成功笔数</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">失败笔数</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.name') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.runNo') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.triggerType') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.start') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.end') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.duration') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.status') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.total') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.success') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.failed') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">明细</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">{{ $t('workspace.schedule.columns.detail') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="r in workspaceScheduleRuns" :key="r.id" class="border-b border-slate-50 transition-colors hover:bg-slate-50/50">
|
||||
<td class="px-4 py-3 font-medium text-slate-900">{{ r.schedule_name || '-' }}</td>
|
||||
<td class="px-4 py-3 text-slate-500 font-mono text-xs">{{ r.run_no }}</td>
|
||||
<td class="px-4 py-3 text-slate-500">{{ r.trigger_type === 'manual' ? '手动' : r.trigger_type === 'test' ? '测试' : '定时' }}</td>
|
||||
<td class="px-4 py-3 text-slate-500">{{ r.trigger_type === 'manual' ? $t('workspace.schedule.trigger.manual') : r.trigger_type === 'test' ? $t('workspace.schedule.trigger.test') : $t('workspace.schedule.trigger.timed') }}</td>
|
||||
<td class="px-4 py-3 text-slate-500 whitespace-nowrap">{{ formatDateTime(r.started_at) }}</td>
|
||||
<td class="px-4 py-3 text-slate-500 whitespace-nowrap">{{ formatDateTime(r.finished_at) }}</td>
|
||||
<td class="px-4 py-3 text-slate-500 whitespace-nowrap">{{ r.duration_ms != null ? (r.duration_ms >= 1000 ? (r.duration_ms / 1000).toFixed(1) + 's' : r.duration_ms + 'ms') : '-' }}</td>
|
||||
@@ -1952,7 +1952,7 @@ onMounted(async () => {
|
||||
{{ getWsScheduleStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message && r.error_message !== '无待处理数据'" class="ml-1 text-xs text-slate-400" :title="r.error_message">...</span>
|
||||
<span v-else-if="r.error_message === '无待处理数据'" class="ml-1 text-xs text-slate-400">(无待处理数据)</span>
|
||||
<span v-else-if="r.error_message === '无待处理数据'" class="ml-1 text-xs text-slate-400">({{ $t('workspace.schedule.noPendingData') }})</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-slate-500">{{ r.total_count || 0 }}</td>
|
||||
<td class="px-4 py-3 text-emerald-600 font-medium">{{ r.success_count ?? 0 }}</td>
|
||||
@@ -1966,7 +1966,7 @@ onMounted(async () => {
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2 py-1 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
>
|
||||
<Download class="h-3 w-3" />
|
||||
下载
|
||||
{{ $t('workspace.schedule.download') }}
|
||||
</a>
|
||||
<span v-else class="text-xs text-slate-300">-</span>
|
||||
</td>
|
||||
@@ -2162,9 +2162,9 @@ onMounted(async () => {
|
||||
<div class="flex h-14 items-center justify-around">
|
||||
<button
|
||||
v-for="tab in ([
|
||||
{ key: 'applications', icon: LayoutGrid, label: '应用管理' },
|
||||
{ key: 'history', icon: Bot, label: '历史会话' },
|
||||
{ key: 'profile', icon: User, label: '我的' },
|
||||
{ key: 'applications', icon: LayoutGrid, label: $t('workspace.mobileTabs.applications') },
|
||||
{ key: 'history', icon: Bot, label: $t('workspace.mobileTabs.history') },
|
||||
{ key: 'profile', icon: User, label: $t('workspace.mobileTabs.me') },
|
||||
] as const)"
|
||||
:key="tab.key"
|
||||
@click="mobileTabActive = tab.key"
|
||||
@@ -2365,7 +2365,7 @@ onMounted(async () => {
|
||||
v-model="showGeneralFeedbackDialog"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
source-page="workspace"
|
||||
@submitted="showMessageDialog('success', '\u53cd\u9988\u63d0\u4ea4\u6210\u529f')"
|
||||
@submitted="msg.success('\u53cd\u9988\u63d0\u4ea4\u6210\u529f')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user