1.添加移动端用户的检测工具类,移动端用户只能访问对话页面。

2.评查点列表添加文档属性类型字段。
3.优化dify的对话侧边栏的显示效果。
4.评查点规则添加使用文档属性类型的输入框。添加多实体开关的操作开关。
This commit is contained in:
2025-12-30 18:35:48 +08:00
parent d2aba899cc
commit 66d2f7cef4
18 changed files with 552 additions and 56 deletions
+9 -5
View File
@@ -5,6 +5,7 @@ import { createUserSession, sessionStorage } from "~/api/login/auth.server";
import { OAuthClient } from "~/api/login/oauth-client";
import { getServerOAuthConfigRuntime } from "~/config/oauth-secret.server";
import { loginWithOAuth, type LoginRequest } from "~/api/login/login-client";
import { isMobileDevice, MOBILE_CHAT_PATH } from "~/utils/mobile-detect.server";
/**
* 端口号到地区的映射关系
@@ -145,9 +146,12 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
console.log("✅ [Callback] 用户信息获取成功");
// 🔑 强制重定向到首页,确保用户选择入口模块并初始化 sessionStorage
// 忽略 redirect 参数,总是跳转到首页让用户选择模块
const redirectTo = "/";
// 🔑 检测移动端设备,决定重定向目标
const isMobile = isMobileDevice(request);
console.log(`📱 [Callback] 设备类型检测: ${isMobile ? '移动端' : '桌面端'}`);
// 移动端用户直接跳转到对话页面,桌面端用户跳转到首页选择模块
const redirectTo = isMobile ? MOBILE_CHAT_PATH : "/";
// 调用后端登录接口,传递 OAuth 用户信息,获取 JWT token
const loginRequest: LoginRequest = {
@@ -272,8 +276,8 @@ export default function Callback() {
// 从 URL 参数中获取 token(如果有)
const token = searchParams.get("token");
const userInfo = searchParams.get("userInfo");
// 🔑 强制重定向到首页,确保用户选择入口模块并初始化 sessionStorage
const redirectTo = "/";
// 从 URL 参数中获取重定向目标(服务端已根据设备类型设置)
const redirectTo = searchParams.get("redirectTo") || "/";
if (token && typeof window !== 'undefined') {
console.log('🔑 [Callback] 开始保存 token 到 localStorage');
+1 -1
View File
@@ -288,7 +288,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
typesPromise
]);
// console.log(`[loader 耗时] 并行API调用总耗时: ${Date.now() - apiStart}ms`);
console.log(`[loader 耗时] loader总耗时: ${(Date.now() - loaderStart)/1000}s`);
// console.log(`[loader 耗时] loader总耗时: ${(Date.now() - loaderStart)/1000}s`);
// console.log('loader: 文档加载结果:', documentsResponse);
// console.log('loader: 文档类型加载结果:', typesResponse);
+19 -9
View File
@@ -67,6 +67,7 @@ interface ApiRule {
description: string;
isActive: boolean;
area?: string; // 地区
documentAttributeType?: string; // 文档属性类型
createdAt: string;
updatedAt: string;
}
@@ -98,6 +99,7 @@ function mapApiRuleToModel(apiRule: ApiRule): Rule {
prompt: apiRule.description, // 使用描述作为默认prompt
isActive: apiRule.isActive,
area: apiRule.area || '', // 地区
documentAttributeType: apiRule.documentAttributeType || '', // 文档属性类型
createdAt: apiRule.createdAt,
updatedAt: apiRule.updatedAt
};
@@ -667,7 +669,7 @@ export default function RulesIndex() {
),
key: "selection",
align: "center" as const,
width: "50px",
width: "3%",
render: (_: unknown, record: Rule) => (
<input
type="checkbox"
@@ -682,7 +684,7 @@ export default function RulesIndex() {
dataIndex: "code" as keyof Rule,
key: "code",
align: "left" as const,
width: "15%",
width: "9%",
className: "whitespace-normal break-all",
render: (value: string) => (
<div className="whitespace-normal break-all overflow-visible">{value}</div>
@@ -693,13 +695,13 @@ export default function RulesIndex() {
dataIndex: "name" as keyof Rule,
key: "name",
align: "left" as const,
width: "15%"
width: "12%"
},
{
title: "评查点类型",
key: "ruleType",
align: "left" as const,
width: "10%",
width: "8%",
render: (_: unknown, record: Rule) => {
const typeColor = RULE_TYPE_COLORS[record.ruleType] as TagColor;
return (
@@ -714,13 +716,21 @@ export default function RulesIndex() {
dataIndex: "groupName" as keyof Rule,
key: "groupName",
align: "left" as const,
width: "10%"
width: "8%"
},
{
title: "地区",
dataIndex: "area" as keyof Rule,
key: "area",
align: "left" as const,
width: "5%",
render: (value: string) => value || '-'
},
{
title: "属性类型",
dataIndex: "documentAttributeType" as keyof Rule,
key: "documentAttributeType",
align: "left" as const,
width: "6%",
render: (value: string) => value || '-'
},
@@ -728,7 +738,7 @@ export default function RulesIndex() {
title: "优先级",
key: "priority",
align: "left" as const,
width: "6%",
width: "5%",
render: (_: unknown, record: Rule) => {
const priorityColor = RULE_PRIORITY_COLORS[record.priority] as TagColor;
return (
@@ -742,7 +752,7 @@ export default function RulesIndex() {
title: "状态",
key: "isActive",
align: "left" as const,
width: "6%",
width: "5%",
render: (_: unknown, record: Rule) => (
<StatusDot status={record.isActive} text={record.isActive ? "启用" : "禁用"} />
)
@@ -752,13 +762,13 @@ export default function RulesIndex() {
dataIndex: "createdAt" as keyof Rule,
key: "createdAt",
align: "left" as const,
width: "10%"
width: "9%"
},
{
title: "操作",
key: "operation",
align: "left" as const,
width: "150px",
width: "14%",
render: (_: unknown, record: Rule) => (
<div className="operations-cell">
{/* ✅ 查看/编辑和复制按钮 - 需要查看权限 */}
+12 -2
View File
@@ -238,7 +238,12 @@ export default function RuleNew() {
references_laws: { name: '', articles: [], content: '' },
evaluation_point_groups_pid: null,
evaluation_point_groups_id: null,
document_attribute_type: '通用',
extraction_config: {
multi_entity: {
enabled: false,
expand_mode: 'awareness'
},
llm: {
fields: [],
prompt_setting: {
@@ -633,7 +638,12 @@ export default function RuleNew() {
references_laws: formData.references_laws || null,
evaluation_point_groups_pid: formData.evaluation_point_groups_pid || null,
evaluation_point_groups_id: formData.evaluation_point_groups_id || null,
document_attribute_type: formData.document_attribute_type || '',
extraction_config: {
multi_entity: {
enabled: formData.extraction_config?.multi_entity?.enabled ?? false,
expand_mode: formData.extraction_config?.multi_entity?.expand_mode || 'awareness'
},
llm: {
fields: Array.isArray(formData.extraction_config?.llm?.fields) ?
[...formData.extraction_config.llm.fields] : [],
@@ -651,7 +661,7 @@ export default function RuleNew() {
}
},
regex: {
fields: Array.isArray(formData.extraction_config?.regex?.fields) ?
fields: Array.isArray(formData.extraction_config?.regex?.fields) ?
[...formData.extraction_config.regex.fields] : []
}
},
@@ -838,7 +848,7 @@ export default function RuleNew() {
if (isEditMode) {
// 使用新的 updateEvaluationPoint API
response = await updateEvaluationPoint(String(formData.id!), finalData, frontendJWT);
// console.log("最终提交的数据", finalData)
console.log("最终提交的数据", finalData)
} else {
// 使用新的 createEvaluationPoint API
response = await createEvaluationPoint(finalData as Omit<EvaluationPointData, 'id' | 'created_at' | 'updated_at'>, frontendJWT);