添加意见反馈
This commit is contained in:
1 parent
2bd27ed70d
commit
6b2ab65436
16 files changed
+853
-37
No files matched your search
@@ -5,7 +5,7 @@ backend/app/api/admin.py
|
||||
逻辑关系:提供 Agent 配置管理、用户与权限管理接口,供前端 Admin 控制台使用
|
||||
"""
|
||||
from flask import Blueprint, request, jsonify, current_app
|
||||
from app.models import Agent, User, PermissionRequest, ChatLog, Feedback, Department, UserFavoriteAgent, UserDefaultAgent, QuickQuestion, UserHomepageConfig, LoginAudit, WecomNotifyAudit
|
||||
from app.models import Agent, User, PermissionRequest, ChatLog, Feedback, GeneralFeedback, Department, UserFavoriteAgent, UserDefaultAgent, QuickQuestion, UserHomepageConfig, LoginAudit, WecomNotifyAudit
|
||||
from app.decorators import require_admin
|
||||
from app.config import Config
|
||||
from app import db
|
||||
@@ -829,6 +829,62 @@ def feedback_report():
|
||||
'distribution': [{'score': s, 'count': c} for s, c in dist]
|
||||
})
|
||||
|
||||
@admin_bp.route('/reports/general-feedbacks', methods=['GET'])
|
||||
@require_admin
|
||||
def list_general_feedbacks_report():
|
||||
"""
|
||||
List rows from general_feedbacks for report page display.
|
||||
Supports simple fuzzy filters by column name and optional limit.
|
||||
"""
|
||||
query = db.session.query(GeneralFeedback)
|
||||
|
||||
reserved = {'limit', 'offset', 'page', 'page_size'}
|
||||
for key, value in request.args.items():
|
||||
if key in reserved:
|
||||
continue
|
||||
if not value or not hasattr(GeneralFeedback, key):
|
||||
continue
|
||||
col = getattr(GeneralFeedback, key)
|
||||
query = query.filter(col.cast(db.String).ilike(f"%{value}%"))
|
||||
|
||||
query = query.order_by(desc(GeneralFeedback.created_at), desc(GeneralFeedback.id))
|
||||
|
||||
try:
|
||||
limit = int(request.args.get('limit', 200))
|
||||
except (TypeError, ValueError):
|
||||
limit = 200
|
||||
limit = max(1, min(limit, 1000))
|
||||
|
||||
items = query.limit(limit).all()
|
||||
rows = []
|
||||
for item in items:
|
||||
row = {}
|
||||
for col in item.__table__.columns:
|
||||
val = getattr(item, col.name)
|
||||
if isinstance(val, datetime):
|
||||
val = val.isoformat()
|
||||
row[col.name] = val
|
||||
rows.append(row)
|
||||
return jsonify(rows)
|
||||
|
||||
|
||||
@admin_bp.route('/reports/general-feedbacks/count', methods=['GET'])
|
||||
@require_admin
|
||||
def count_general_feedbacks_report():
|
||||
query = db.session.query(GeneralFeedback)
|
||||
|
||||
reserved = {'limit', 'offset', 'page', 'page_size'}
|
||||
for key, value in request.args.items():
|
||||
if key in reserved:
|
||||
continue
|
||||
if not value or not hasattr(GeneralFeedback, key):
|
||||
continue
|
||||
col = getattr(GeneralFeedback, key)
|
||||
query = query.filter(col.cast(db.String).ilike(f"%{value}%"))
|
||||
|
||||
total = query.count()
|
||||
return jsonify({'table': 'general_feedbacks', 'total': int(total)})
|
||||
|
||||
|
||||
# --- Database ---
|
||||
@admin_bp.route('/database/<table>', methods=['GET'])
|
||||
|
||||
@@ -155,6 +155,7 @@ def get_chat_messages():
|
||||
messages.append({
|
||||
'role': 'assistant',
|
||||
'content': log.answer,
|
||||
'chat_log_id': log.id,
|
||||
'retriever_resources': log.retriever_resources or [],
|
||||
'attribution_parts': log.attribution_parts or []
|
||||
})
|
||||
|
||||
+63
-1
@@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, request, jsonify, current_app
|
||||
from app import db
|
||||
from app.models import User, Agent, QuickQuestion, UserFavoriteAgent, UserDefaultAgent, UserHomepageConfig, Announcement, LoginAudit, WecomCallbackAudit
|
||||
from app.models import User, Agent, QuickQuestion, UserFavoriteAgent, UserDefaultAgent, UserHomepageConfig, Announcement, LoginAudit, WecomCallbackAudit, GeneralFeedback, ChatLog
|
||||
from app.services.wecom_notify import mark_wecom_message_opened, send_wecom_event_message
|
||||
from app.services.wecom_crypto import sha1_hex, decrypt_wecom_aes, extract_encrypt_field
|
||||
from sqlalchemy.exc import IntegrityError, OperationalError
|
||||
@@ -1147,6 +1147,68 @@ def unbind_wecom_self():
|
||||
db.session.commit()
|
||||
return jsonify({'status': 'ok', 'message': 'WeCom account unbound'})
|
||||
|
||||
@user_bp.route('/feedback', methods=['POST'])
|
||||
def submit_general_feedback():
|
||||
"""
|
||||
通用意见反馈接口(与 /api/chat/feedback 的对话评分接口不同
|
||||
"""
|
||||
user = _get_current_user()
|
||||
if not user:
|
||||
return jsonify({'error': 'Unauthorized'}), 401
|
||||
|
||||
data = request.get_json() or {}
|
||||
feedback_type = _clean_str(data.get('feedback_type'))
|
||||
feedback_module = _clean_str(data.get('feedback_module'))
|
||||
content = _clean_str(data.get('content'))
|
||||
source_page = _clean_str(data.get('source_page'))
|
||||
|
||||
raw_chat_log_id = data.get('chat_log_id')
|
||||
chat_log_id = None
|
||||
if raw_chat_log_id not in (None, ''):
|
||||
try:
|
||||
chat_log_id = int(raw_chat_log_id)
|
||||
except (TypeError, ValueError):
|
||||
return jsonify({'error': 'chat_log_id must be an integer'}), 400
|
||||
if chat_log_id <= 0:
|
||||
return jsonify({'error': 'chat_log_id must be a positive integer'}), 400
|
||||
|
||||
if not feedback_type:
|
||||
return jsonify({'error': 'feedback_type is required'}), 400
|
||||
if not feedback_module:
|
||||
return jsonify({'error': 'feedback_module is required'}), 400
|
||||
if len(feedback_type) > 32:
|
||||
return jsonify({'error': 'feedback_type is too long'}), 400
|
||||
if len(feedback_module) > 32:
|
||||
return jsonify({'error': 'feedback_module is too long'}), 400
|
||||
if not content:
|
||||
return jsonify({'error': 'content is required'}), 400
|
||||
if len(content) > 2000:
|
||||
return jsonify({'error': 'content is too long'}), 400
|
||||
|
||||
if source_page != 'chat':
|
||||
chat_log_id = None
|
||||
|
||||
if chat_log_id is not None:
|
||||
chat_log = db.session.get(ChatLog, chat_log_id)
|
||||
if not chat_log:
|
||||
return jsonify({'error': 'chat_log_id not found'}), 400
|
||||
if chat_log.user_id != user.id:
|
||||
return jsonify({'error': 'chat_log_id is not owned by current user'}), 403
|
||||
|
||||
row = GeneralFeedback(
|
||||
user_id=user.id,
|
||||
username=user.username,
|
||||
feedback_type=feedback_type,
|
||||
feedback_module=feedback_module,
|
||||
content=content,
|
||||
source_page=source_page,
|
||||
chat_log_id=chat_log_id,
|
||||
)
|
||||
db.session.add(row)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({'status': 'ok', 'id': row.id})
|
||||
|
||||
@user_bp.route('/home', methods=['GET'])
|
||||
def home():
|
||||
"""
|
||||
|
||||
@@ -72,8 +72,8 @@ class DevelopmentConfig(Config):
|
||||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = os.getenv(
|
||||
'DATABASE_URL',
|
||||
# 'postgresql://postgres:123456@8.152.207.171:5432/hxops_db',
|
||||
'postgresql://postgres:difyai123456@localhost:5432/hxops_db',
|
||||
'postgresql://postgres:123456@8.152.207.171:5432/hxops_db',
|
||||
#'postgresql://postgres:difyai123456@localhost:5432/hxops_db',
|
||||
)
|
||||
|
||||
|
||||
|
||||
+18
-1
@@ -1,4 +1,3 @@
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import String, Text, Integer, ForeignKey, JSON, DateTime, Index
|
||||
@@ -217,6 +216,23 @@ class Feedback(Base):
|
||||
|
||||
chat_log: Mapped["ChatLog"] = relationship(back_populates="feedback")
|
||||
|
||||
class GeneralFeedback(Base):
|
||||
"""
|
||||
通用意见反馈表
|
||||
用于存储 Workspace/Chat 页面提交的通用意见反馈
|
||||
"""
|
||||
__tablename__ = 'general_feedbacks'
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), index=True)
|
||||
chat_log_id: Mapped[Optional[int]] = mapped_column(ForeignKey('chat_logs.id'), nullable=True, index=True)
|
||||
username: Mapped[str] = mapped_column(String(50), nullable=False)
|
||||
feedback_type: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
feedback_module: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
content: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
source_page: Mapped[Optional[str]] = mapped_column(String(32))
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
|
||||
|
||||
class PermissionRequest(Base):
|
||||
"""
|
||||
权限申请表
|
||||
@@ -342,3 +358,4 @@ class WecomCallbackAudit(Base):
|
||||
msg_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True, index=True)
|
||||
error_message: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
|
||||
|
||||
@@ -24,7 +24,7 @@ chat.py (/api/chat/completions)
|
||||
"""
|
||||
import json
|
||||
import time
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Optional
|
||||
|
||||
import requests
|
||||
from flask import current_app
|
||||
@@ -153,7 +153,7 @@ class DifyService:
|
||||
usage = metadata.get('usage', {}) or {}
|
||||
|
||||
with current_app.app_context():
|
||||
DifyService._log_chat(
|
||||
chat_log_id = DifyService._log_chat(
|
||||
user_id=user_id,
|
||||
agent_id=agent.id,
|
||||
conversation_id=data.get('conversation_id') or conversation_id,
|
||||
@@ -164,6 +164,8 @@ class DifyService:
|
||||
retriever_resources=retriever_resources,
|
||||
attribution_parts=attribution_parts,
|
||||
)
|
||||
if chat_log_id:
|
||||
data['chat_log_id'] = chat_log_id
|
||||
if current_app:
|
||||
current_app.logger.info(
|
||||
"[chat-stream] message_end logged conversation_id=%s answer_len=%s resources=%s attribution=%s latency_ms=%s",
|
||||
@@ -195,7 +197,7 @@ class DifyService:
|
||||
latency,
|
||||
retriever_resources=None,
|
||||
attribution_parts=None,
|
||||
):
|
||||
) -> Optional[int]:
|
||||
"""
|
||||
把最终问答和元数据写入 ChatLog
|
||||
Persist one chat record into ChatLog table.
|
||||
@@ -223,10 +225,14 @@ class DifyService:
|
||||
)
|
||||
db.session.add(chat_log)
|
||||
db.session.commit()
|
||||
return chat_log.id
|
||||
except Exception as e:
|
||||
if current_app:
|
||||
current_app.logger.error(f'Failed to log chat: {e}')
|
||||
db.session.rollback()
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _normalize_resources(resources):
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
"""add chat_log_id to general_feedbacks
|
||||
|
||||
Revision ID: 1c2d3e4f5a6b
|
||||
Revises: f2b3c4d5e6f7
|
||||
Create Date: 2026-04-23 16:25:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1c2d3e4f5a6b'
|
||||
down_revision = 'f2b3c4d5e6f7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _normalize_chat_logs_id_postgresql(bind):
|
||||
"""
|
||||
Ensure chat_logs.id is unique before adding PK.
|
||||
Strategy:
|
||||
- Keep the first row for each duplicated id unchanged.
|
||||
- Reassign subsequent duplicated rows to fresh ids > current max(id).
|
||||
"""
|
||||
# fast path: already unique
|
||||
dup_cnt = bind.execute(sa.text(
|
||||
"SELECT COUNT(*) FROM (SELECT id FROM chat_logs GROUP BY id HAVING COUNT(*) > 1) t"
|
||||
)).scalar() or 0
|
||||
if int(dup_cnt) == 0:
|
||||
return
|
||||
|
||||
# Reassign duplicated rows (rn > 1) with new ids.
|
||||
bind.execute(sa.text("""
|
||||
WITH ordered AS (
|
||||
SELECT
|
||||
ctid,
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY id
|
||||
ORDER BY created_at NULLS LAST, ctid
|
||||
) AS rn
|
||||
FROM chat_logs
|
||||
),
|
||||
dups AS (
|
||||
SELECT
|
||||
ctid,
|
||||
id,
|
||||
ROW_NUMBER() OVER (ORDER BY id, ctid) AS dup_seq
|
||||
FROM ordered
|
||||
WHERE rn > 1
|
||||
),
|
||||
max_id AS (
|
||||
SELECT COALESCE(MAX(id), 0) AS m FROM chat_logs
|
||||
)
|
||||
UPDATE chat_logs t
|
||||
SET id = (SELECT m FROM max_id) + dups.dup_seq
|
||||
FROM dups
|
||||
WHERE t.ctid = dups.ctid
|
||||
"""))
|
||||
|
||||
|
||||
def _ensure_chat_logs_id_unique(bind):
|
||||
inspector = sa.inspect(bind)
|
||||
tables = inspector.get_table_names()
|
||||
if 'chat_logs' not in tables:
|
||||
return
|
||||
|
||||
# 1) If id is already the PK, we're good.
|
||||
pk = inspector.get_pk_constraint('chat_logs') or {}
|
||||
constrained = pk.get('constrained_columns') or []
|
||||
if 'id' in constrained:
|
||||
return
|
||||
|
||||
# 2) If id has a UNIQUE constraint, that's also enough for FK target.
|
||||
for uq in inspector.get_unique_constraints('chat_logs') or []:
|
||||
cols = uq.get('column_names') or []
|
||||
if cols == ['id'] or 'id' in cols:
|
||||
return
|
||||
|
||||
# 3) Fallback: add primary key on id.
|
||||
if bind.dialect.name == 'sqlite':
|
||||
# SQLite cannot easily add PK via ALTER TABLE.
|
||||
return
|
||||
|
||||
if bind.dialect.name == 'postgresql':
|
||||
_normalize_chat_logs_id_postgresql(bind)
|
||||
op.execute('ALTER TABLE chat_logs ADD PRIMARY KEY (id)')
|
||||
|
||||
# If chat_logs.id uses a sequence default, align sequence to MAX(id).
|
||||
op.execute("""
|
||||
DO $$
|
||||
DECLARE
|
||||
seq_name text;
|
||||
BEGIN
|
||||
SELECT pg_get_serial_sequence('chat_logs', 'id') INTO seq_name;
|
||||
IF seq_name IS NOT NULL THEN
|
||||
EXECUTE format(
|
||||
'SELECT setval(%L, COALESCE((SELECT MAX(id) FROM chat_logs), 0), true)',
|
||||
seq_name
|
||||
);
|
||||
END IF;
|
||||
END $$;
|
||||
""")
|
||||
return
|
||||
|
||||
op.create_primary_key('pk_chat_logs', 'chat_logs', ['id'])
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
_ensure_chat_logs_id_unique(bind)
|
||||
|
||||
op.add_column('general_feedbacks', sa.Column('chat_log_id', sa.Integer(), nullable=True))
|
||||
op.create_index('ix_general_feedbacks_chat_log_id', 'general_feedbacks', ['chat_log_id'])
|
||||
op.create_foreign_key(
|
||||
'fk_general_feedbacks_chat_log_id_chat_logs',
|
||||
'general_feedbacks',
|
||||
'chat_logs',
|
||||
['chat_log_id'],
|
||||
['id'],
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint('fk_general_feedbacks_chat_log_id_chat_logs', 'general_feedbacks', type_='foreignkey')
|
||||
op.drop_index('ix_general_feedbacks_chat_log_id', table_name='general_feedbacks')
|
||||
op.drop_column('general_feedbacks', 'chat_log_id')
|
||||
@@ -0,0 +1,66 @@
|
||||
"""add general feedbacks table
|
||||
|
||||
Revision ID: ab12cd34ef56
|
||||
Revises: 9a2d6b4e8c1f
|
||||
Create Date: 2026-04-22 15:30:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ab12cd34ef56'
|
||||
down_revision = '9a2d6b4e8c1f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _ensure_users_primary_key(bind):
|
||||
inspector = sa.inspect(bind)
|
||||
tables = inspector.get_table_names()
|
||||
if 'users' not in tables:
|
||||
return
|
||||
|
||||
pk = inspector.get_pk_constraint('users') or {}
|
||||
constrained = pk.get('constrained_columns') or []
|
||||
if 'id' in constrained:
|
||||
return
|
||||
|
||||
if bind.dialect.name == 'sqlite':
|
||||
# SQLite alter table limitations: assume existing schema already has users.id PK.
|
||||
return
|
||||
|
||||
if bind.dialect.name == 'postgresql':
|
||||
op.execute('ALTER TABLE users ADD PRIMARY KEY (id)')
|
||||
return
|
||||
|
||||
# Generic fallback for other dialects.
|
||||
op.create_primary_key('pk_users', 'users', ['id'])
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
_ensure_users_primary_key(bind)
|
||||
|
||||
op.create_table(
|
||||
'general_feedbacks',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('username', sa.String(length=50), nullable=False),
|
||||
sa.Column('feedback_type', sa.String(length=32), nullable=False),
|
||||
sa.Column('feedback_module', sa.String(length=32), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('source_page', sa.String(length=32), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id']),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('ix_general_feedbacks_user_id', 'general_feedbacks', ['user_id'])
|
||||
op.create_index('ix_general_feedbacks_created_at', 'general_feedbacks', ['created_at'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index('ix_general_feedbacks_created_at', table_name='general_feedbacks')
|
||||
op.drop_index('ix_general_feedbacks_user_id', table_name='general_feedbacks')
|
||||
op.drop_table('general_feedbacks')
|
||||
@@ -0,0 +1,23 @@
|
||||
"""legacy revision bridge
|
||||
|
||||
Revision ID: d4e5f6a7b8c9
|
||||
Revises: c7d2a4b9e1f0
|
||||
Create Date: 2026-04-22 23:30:00.000000
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd4e5f6a7b8c9'
|
||||
down_revision = 'c7d2a4b9e1f0'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Compatibility bridge for environments whose alembic_version
|
||||
# was stamped to a historical, now-missing revision id.
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -0,0 +1,22 @@
|
||||
"""merge heads after legacy bridge
|
||||
|
||||
Revision ID: f2b3c4d5e6f7
|
||||
Revises: ab12cd34ef56, d4e5f6a7b8c9
|
||||
Create Date: 2026-04-22 23:50:00.000000
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f2b3c4d5e6f7'
|
||||
down_revision = ('ab12cd34ef56', 'd4e5f6a7b8c9')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Merge-only revision to unify multiple heads.
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -0,0 +1,182 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { MessageSquareText, X } from 'lucide-vue-next';
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean;
|
||||
authHeaders?: Record<string, string>;
|
||||
sourcePage?: string;
|
||||
chatLogId?: number | null;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
authHeaders: () => ({}),
|
||||
sourcePage: 'unknown',
|
||||
chatLogId: null,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void;
|
||||
(e: 'submitted'): void;
|
||||
}>();
|
||||
|
||||
const typeOptions = ['功能建议', '问题反馈', '体验优化'];
|
||||
const moduleOptions = ['知识库', '通用', '工作流', '账号权限'];
|
||||
|
||||
const selectedType = ref<string>('功能建议');
|
||||
const selectedModule = ref<string>('知识库');
|
||||
const content = ref('');
|
||||
const submitting = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
const canSubmit = computed(() => content.value.trim().length > 0 && !submitting.value);
|
||||
|
||||
const closeDialog = () => {
|
||||
emit('update:modelValue', false);
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
selectedType.value = '功能建议';
|
||||
selectedModule.value = '知识库';
|
||||
content.value = '';
|
||||
error.value = '';
|
||||
submitting.value = false;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const submitFeedback = async () => {
|
||||
if (!canSubmit.value) {
|
||||
error.value = '请填写反馈内容';
|
||||
return;
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const payload: Record<string, unknown> = {
|
||||
feedback_type: selectedType.value,
|
||||
feedback_module: selectedModule.value,
|
||||
content: content.value.trim(),
|
||||
source_page: props.sourcePage,
|
||||
};
|
||||
if (props.chatLogId !== null && props.chatLogId !== undefined) {
|
||||
payload.chat_log_id = props.chatLogId;
|
||||
}
|
||||
|
||||
const res = await fetch('/api/user/feedback', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...props.authHeaders,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
error.value = data?.error || '提交失败,请稍后重试';
|
||||
return;
|
||||
}
|
||||
|
||||
emit('submitted');
|
||||
closeDialog();
|
||||
} catch {
|
||||
error.value = '提交失败,请稍后重试';
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="modelValue"
|
||||
class="fixed inset-0 z-[80] flex items-start justify-center overflow-y-auto bg-black/40 p-3 backdrop-blur-sm sm:items-center sm:p-4"
|
||||
>
|
||||
<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>
|
||||
<button
|
||||
@click="closeDialog"
|
||||
class="rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600"
|
||||
aria-label="Close"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<button
|
||||
v-for="item in typeOptions"
|
||||
:key="item"
|
||||
@click="selectedType = item"
|
||||
class="rounded-xl border px-4 py-2.5 text-base font-medium transition-colors"
|
||||
:class="
|
||||
selectedType === item
|
||||
? 'border-blue-500 bg-blue-50 text-blue-700'
|
||||
: 'border-gray-200 bg-gray-50 text-gray-700 hover:bg-gray-100'
|
||||
"
|
||||
>
|
||||
{{ item }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-sm font-semibold text-gray-600">反馈模块</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"
|
||||
>
|
||||
<option v-for="item in moduleOptions" :key="item" :value="item">{{ item }}</option>
|
||||
</select>
|
||||
</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>
|
||||
<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="请描述你的问题或建议,帮助我们持续优化。"
|
||||
/>
|
||||
<div class="mt-2 flex items-center justify-between">
|
||||
<div v-if="error" class="text-base text-red-600">{{ error }}</div>
|
||||
<div v-else class="text-base text-gray-400"> </div>
|
||||
<div class="text-base text-gray-400">{{ content.length }}/2000</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3 rounded-b-2xl border-t border-gray-100 bg-white px-5 py-4 sm:px-8">
|
||||
<button
|
||||
@click="closeDialog"
|
||||
class="rounded-xl px-5 py-2.5 text-base font-medium text-gray-600 transition-colors hover:bg-gray-100"
|
||||
:disabled="submitting"
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
@click="submitFeedback"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-blue-600 px-5 py-2.5 text-base font-medium text-white shadow-md shadow-blue-200 transition-all hover:bg-blue-700 active:scale-95 disabled:cursor-not-allowed disabled:opacity-70"
|
||||
:disabled="!canSubmit"
|
||||
>
|
||||
<MessageSquareText class="h-5 w-5" />
|
||||
{{ submitting ? '提交中' : '提交' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -23,6 +23,7 @@ interface ChatMessage {
|
||||
content: string;
|
||||
retriever_resources?: RetrieverResource[];
|
||||
attribution_parts?: string[];
|
||||
chat_log_id?: number;
|
||||
}
|
||||
|
||||
// 统一资源格式为数组,兼容 list 或 { data: list } 两种结构
|
||||
@@ -263,6 +264,12 @@ export function useChat() {
|
||||
}
|
||||
}
|
||||
} else if (data.event === 'message_end') {
|
||||
if (botMsgIndex !== null && Number.isInteger(data.chat_log_id)) {
|
||||
const currentBotMsg = messages.value[botMsgIndex];
|
||||
if (currentBotMsg) {
|
||||
currentBotMsg.chat_log_id = Number(data.chat_log_id);
|
||||
}
|
||||
}
|
||||
if (data.conversation_id) {
|
||||
conversationId.value = data.conversation_id;
|
||||
}
|
||||
|
||||
+23
-2
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
const messages = {
|
||||
@@ -757,7 +757,10 @@ const messages = {
|
||||
theme_preference: 'Theme Preference',
|
||||
password_hash: 'Password Hash',
|
||||
reset_token: 'Reset Token',
|
||||
reset_token_expiry: 'Reset Token Expiry'
|
||||
reset_token_expiry: 'Reset Token Expiry',
|
||||
feedback_module: 'Feedback Module',
|
||||
feedback_type: 'Feedback Type',
|
||||
source_page: 'Source Page'
|
||||
},
|
||||
tables: {
|
||||
users: 'Users',
|
||||
@@ -766,6 +769,24 @@ const messages = {
|
||||
departments: 'Departments',
|
||||
agents: 'Agents',
|
||||
permission_requests: 'Permission Requests'
|
||||
},
|
||||
feedbackValues: {
|
||||
types: {
|
||||
feature_suggestion: 'Feature Suggestion',
|
||||
issue_feedback: 'Issue Feedback',
|
||||
experience_optimization: 'Experience Optimization'
|
||||
},
|
||||
modules: {
|
||||
knowledge_base: 'Knowledge Base',
|
||||
general: 'General',
|
||||
workflow: 'Workflow',
|
||||
account_permission: 'Account & Permissions'
|
||||
},
|
||||
pages: {
|
||||
workspace: 'Workspace',
|
||||
chat: 'Chat',
|
||||
unknown: 'Unknown'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -133,12 +133,6 @@ interface UsageReport {
|
||||
by_day: { date: string; count: number }[];
|
||||
}
|
||||
|
||||
interface FeedbackReport {
|
||||
total: number;
|
||||
avg_score: number;
|
||||
distribution: { score: number; count: number }[];
|
||||
}
|
||||
|
||||
interface WecomBindingRow {
|
||||
id: number;
|
||||
username: string;
|
||||
@@ -364,7 +358,6 @@ const saveUser = async () => {
|
||||
|
||||
const permissionRequests = ref<PermissionRequestRow[]>([]);
|
||||
const usageReport = ref<UsageReport | null>(null);
|
||||
const feedbackReport = ref<FeedbackReport | null>(null);
|
||||
const wecomBindings = ref<WecomBindingRow[]>([]);
|
||||
const wecomLoginAudits = ref<LoginAuditRow[]>([]);
|
||||
const wecomBindForm = ref({
|
||||
@@ -840,10 +833,6 @@ const loadReports = async () => {
|
||||
if (usageRes.ok) {
|
||||
usageReport.value = await usageRes.json();
|
||||
}
|
||||
const feedbackRes = await fetch('/api/admin/reports/feedback', { headers: getAuthHeaders() });
|
||||
if (feedbackRes.ok) {
|
||||
feedbackReport.value = await feedbackRes.json();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error loading reports:', e);
|
||||
}
|
||||
@@ -1649,8 +1638,12 @@ const loadTableData = async () => {
|
||||
for (const [key, value] of Object.entries(columnFilters.value)) {
|
||||
if (value) params.append(key, value);
|
||||
}
|
||||
|
||||
const res = await fetch(`/api/admin/database/${currentTable.value}?${params.toString()}`, {
|
||||
|
||||
const url = currentTable.value === 'feedbacks'
|
||||
? `/api/admin/reports/general-feedbacks?${params.toString()}`
|
||||
: `/api/admin/database/${currentTable.value}?${params.toString()}`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
@@ -1796,7 +1789,11 @@ const startResizeColumn = (key: string, e: MouseEvent) => {
|
||||
|
||||
const loadTableCount = async (table: string) => {
|
||||
try {
|
||||
const res = await fetch(`/api/admin/database/${table}/count`, {
|
||||
const countUrl = table === 'feedbacks'
|
||||
? '/api/admin/reports/general-feedbacks/count'
|
||||
: `/api/admin/database/${table}/count`;
|
||||
|
||||
const res = await fetch(countUrl, {
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (!res.ok) return 0;
|
||||
@@ -1826,10 +1823,133 @@ const handleFilterChange = () => {
|
||||
|
||||
const isChatLogsTable = computed(() => currentTable.value === 'chat_logs');
|
||||
const visibleReportKeys = computed(() => {
|
||||
if (chatLogsColumns.value.length === 0) return Object.keys(tableData.value[0] || {});
|
||||
return chatLogsColumns.value.filter((c) => c.visible).map((c) => c.key);
|
||||
let keys: string[];
|
||||
if (chatLogsColumns.value.length === 0) {
|
||||
keys = Object.keys(tableData.value[0] || {});
|
||||
} else {
|
||||
keys = chatLogsColumns.value.filter((c) => c.visible).map((c) => c.key);
|
||||
}
|
||||
|
||||
if (currentTable.value === 'feedbacks') {
|
||||
return keys.filter((k) => k !== 'id' && k !== 'user_id');
|
||||
}
|
||||
|
||||
return keys;
|
||||
});
|
||||
|
||||
const resolveReportLang = () => {
|
||||
const l = String(locale.value || 'en').toLowerCase();
|
||||
if (l.startsWith('zh-cn')) return 'zh-CN';
|
||||
if (l.startsWith('zh-tw')) return 'zh-TW';
|
||||
if (l.startsWith('th')) return 'th';
|
||||
return 'en';
|
||||
};
|
||||
|
||||
const feedbackReportI18nMap: Record<string, {
|
||||
columns: Record<string, string>;
|
||||
types: Record<string, string>;
|
||||
modules: Record<string, string>;
|
||||
pages: Record<string, string>;
|
||||
}> = {
|
||||
en: {
|
||||
columns: {
|
||||
feedback_module: 'Feedback Module',
|
||||
feedback_type: 'Feedback Type',
|
||||
source_page: 'Source Page',
|
||||
},
|
||||
types: {
|
||||
feature_suggestion: 'Feature Suggestion',
|
||||
issue_feedback: 'Issue Feedback',
|
||||
experience_optimization: 'Experience Optimization',
|
||||
},
|
||||
modules: {
|
||||
knowledge_base: 'Knowledge Base',
|
||||
general: 'General',
|
||||
workflow: 'Workflow',
|
||||
account_permission: 'Account & Permissions',
|
||||
},
|
||||
pages: {
|
||||
workspace: 'Workspace',
|
||||
chat: 'Chat',
|
||||
unknown: 'Unknown',
|
||||
},
|
||||
},
|
||||
'zh-CN': {
|
||||
columns: {
|
||||
feedback_module: '\u53cd\u9988\u6a21\u5757',
|
||||
feedback_type: '\u53cd\u9988\u7c7b\u578b',
|
||||
source_page: '\u6765\u6e90\u9875\u9762',
|
||||
},
|
||||
types: {
|
||||
feature_suggestion: '\u529f\u80fd\u5efa\u8bae',
|
||||
issue_feedback: '\u95ee\u9898\u53cd\u9988',
|
||||
experience_optimization: '\u4f53\u9a8c\u4f18\u5316',
|
||||
},
|
||||
modules: {
|
||||
knowledge_base: '\u77e5\u8bc6\u5e93',
|
||||
general: '\u901a\u7528',
|
||||
workflow: '\u5de5\u4f5c\u6d41',
|
||||
account_permission: '\u8d26\u53f7\u6743\u9650',
|
||||
},
|
||||
pages: {
|
||||
workspace: '\u5de5\u4f5c\u53f0',
|
||||
chat: '\u5bf9\u8bdd',
|
||||
unknown: '\u672a\u77e5',
|
||||
},
|
||||
},
|
||||
'zh-TW': {
|
||||
columns: {
|
||||
feedback_module: '\u53cd\u994b\u6a21\u7d44',
|
||||
feedback_type: '\u53cd\u994b\u985e\u578b',
|
||||
source_page: '\u4f86\u6e90\u9801\u9762',
|
||||
},
|
||||
types: {
|
||||
feature_suggestion: '\u529f\u80fd\u5efa\u8b70',
|
||||
issue_feedback: '\u554f\u984c\u56de\u994b',
|
||||
experience_optimization: '\u9ad4\u9a57\u512a\u5316',
|
||||
},
|
||||
modules: {
|
||||
knowledge_base: '\u77e5\u8b58\u5eab',
|
||||
general: '\u901a\u7528',
|
||||
workflow: '\u5de5\u4f5c\u6d41',
|
||||
account_permission: '\u5e33\u865f\u6b0a\u9650',
|
||||
},
|
||||
pages: {
|
||||
workspace: '\u5de5\u4f5c\u53f0',
|
||||
chat: '\u5c0d\u8a71',
|
||||
unknown: '\u672a\u77e5',
|
||||
},
|
||||
},
|
||||
th: {
|
||||
columns: {
|
||||
feedback_module: '\u0e42\u0e21\u0e14\u0e39\u0e25\u0e02\u0e49\u0e2d\u0e40\u0e2a\u0e19\u0e2d\u0e41\u0e19\u0e30',
|
||||
feedback_type: '\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e02\u0e49\u0e2d\u0e40\u0e2a\u0e19\u0e2d\u0e41\u0e19\u0e30',
|
||||
source_page: '\u0e2b\u0e19\u0e49\u0e32\u0e15\u0e49\u0e19\u0e17\u0e32\u0e07',
|
||||
},
|
||||
types: {
|
||||
feature_suggestion: '\u0e02\u0e49\u0e2d\u0e40\u0e2a\u0e19\u0e2d\u0e41\u0e19\u0e30\u0e1f\u0e35\u0e40\u0e08\u0e2d\u0e23\u0e4c',
|
||||
issue_feedback: '\u0e41\u0e08\u0e49\u0e07\u0e1b\u0e31\u0e0d\u0e2b\u0e32',
|
||||
experience_optimization: '\u0e1b\u0e23\u0e31\u0e1a\u0e1b\u0e23\u0e38\u0e07\u0e1b\u0e23\u0e30\u0e2a\u0e1a\u0e01\u0e32\u0e23\u0e13\u0e4c',
|
||||
},
|
||||
modules: {
|
||||
knowledge_base: '\u0e04\u0e25\u0e31\u0e07\u0e04\u0e27\u0e32\u0e21\u0e23\u0e39\u0e49',
|
||||
general: '\u0e17\u0e31\u0e48\u0e27\u0e44\u0e1b',
|
||||
workflow: '\u0e40\u0e27\u0e34\u0e23\u0e4c\u0e01\u0e42\u0e1f\u0e25\u0e27\u0e4c',
|
||||
account_permission: '\u0e1a\u0e31\u0e0d\u0e0a\u0e35\u0e41\u0e25\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c',
|
||||
},
|
||||
pages: {
|
||||
workspace: '\u0e40\u0e27\u0e34\u0e23\u0e4c\u0e01\u0e2a\u0e40\u0e1b\u0e0b',
|
||||
chat: '\u0e41\u0e0a\u0e17',
|
||||
unknown: '\u0e44\u0e21\u0e48\u0e17\u0e23\u0e32\u0e1a',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const getReportColumnLabel = (key: string) => {
|
||||
const lang = resolveReportLang();
|
||||
const enPack = feedbackReportI18nMap['en'] || { columns: {}, types: {}, modules: {}, pages: {} };
|
||||
const direct = feedbackReportI18nMap[lang]?.columns?.[key] || enPack.columns[key];
|
||||
if (direct) return direct;
|
||||
const i18nKey = `admin.report.columns.${key}`;
|
||||
const translated = t(i18nKey);
|
||||
if (translated && translated !== i18nKey) return translated;
|
||||
@@ -1863,36 +1983,103 @@ const getTranslatedValue = (i18nKey: string, fallbackValue: any) => {
|
||||
return translated && translated !== i18nKey ? translated : fallbackValue;
|
||||
};
|
||||
|
||||
const normalizeFeedbackKey = (value: any) => {
|
||||
if (value === null || value === undefined) return '';
|
||||
const raw = String(value).trim();
|
||||
if (!raw) return '';
|
||||
const map: Record<string, string> = {
|
||||
'\u529f\u80fd\u5efa\u8bae': 'feature_suggestion',
|
||||
'\u95ee\u9898\u53cd\u9988': 'issue_feedback',
|
||||
'\u4f53\u9a8c\u4f18\u5316': 'experience_optimization',
|
||||
'\u77e5\u8bc6\u5e93': 'knowledge_base',
|
||||
'\u901a\u7528': 'general',
|
||||
'\u5de5\u4f5c\u6d41': 'workflow',
|
||||
'\u8d26\u53f7\u6743\u9650': 'account_permission',
|
||||
workspace: 'workspace',
|
||||
chat: 'chat',
|
||||
unknown: 'unknown',
|
||||
};
|
||||
const normalized = raw.toLowerCase().replace(/[\s\-]+/g, '_');
|
||||
return map[raw] || map[normalized] || normalized;
|
||||
};
|
||||
|
||||
const getTranslatedFeedbackValue = (group: 'types' | 'modules' | 'pages', value: any) => {
|
||||
const normalized = normalizeFeedbackKey(value);
|
||||
if (!normalized) return value;
|
||||
const lang = resolveReportLang();
|
||||
const enPack = feedbackReportI18nMap['en'] || { columns: {}, types: {}, modules: {}, pages: {} };
|
||||
const dict = feedbackReportI18nMap[lang]?.[group] || enPack[group];
|
||||
return dict?.[normalized] || value;
|
||||
};
|
||||
|
||||
const formatReportDateTime = (value: any) => {
|
||||
if (value === null || value === undefined || value === '') return value;
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return value;
|
||||
|
||||
const localeMap: Record<string, string> = {
|
||||
'zh-CN': 'zh-CN',
|
||||
'zh-TW': 'zh-TW',
|
||||
en: 'en-US',
|
||||
th: 'th-TH',
|
||||
};
|
||||
const lang = resolveReportLang();
|
||||
const localeName = localeMap[lang] || 'en-US';
|
||||
|
||||
return new Intl.DateTimeFormat(localeName, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false,
|
||||
}).format(d);
|
||||
};
|
||||
|
||||
const getReportCellValue = (row: any, key: string) => {
|
||||
const value = row?.[key];
|
||||
// 根据 is_active 这一列的值进行多语言翻译(布尔值兼容多种后端返回格式)
|
||||
|
||||
if (key === 'is_active') {
|
||||
const truthy = value === true || value === 1 || value === '1' || value === 'true' || value === 'True';
|
||||
return truthy ? t('admin.status.active') : t('admin.status.disabled');
|
||||
}
|
||||
|
||||
// 用户报表值翻译:角色(guest/user/admin) -> 中文角色名
|
||||
if (key === 'role' && typeof value === 'string') {
|
||||
return getTranslatedValue(`admin.role.${value}`, value);
|
||||
}
|
||||
|
||||
// 用户报表值翻译:状态(active/disabled/pending/rejected) -> 中文状态名
|
||||
if (key === 'status' && typeof value === 'string') {
|
||||
return getTranslatedValue(`admin.status.${value}`, value);
|
||||
}
|
||||
|
||||
// 用户报表值翻译:主题偏好(light/dark/system) -> 中文主题名
|
||||
if (key === 'theme_preference' && typeof value === 'string') {
|
||||
return getTranslatedValue(`theme.${value}`, value);
|
||||
}
|
||||
|
||||
// 用户报表值翻译:语言(zh-CN/zh-TW/en/th) -> 语言名称
|
||||
if (key === 'feedback_type') {
|
||||
return getTranslatedFeedbackValue('types', value);
|
||||
}
|
||||
|
||||
if (key === 'feedback_module') {
|
||||
return getTranslatedFeedbackValue('modules', value);
|
||||
}
|
||||
|
||||
if (key === 'source_page') {
|
||||
return getTranslatedFeedbackValue('pages', value);
|
||||
}
|
||||
|
||||
// format datetime fields in report table
|
||||
if (typeof value === 'string' && (key.endsWith('_at') || key === 'created_at' || key === 'updated_at')) {
|
||||
return formatReportDateTime(value);
|
||||
}
|
||||
|
||||
if (key === 'language' && typeof value === 'string') {
|
||||
const languageLabelMap: Record<string, string> = {
|
||||
'zh-CN': '简体中文',
|
||||
'zh-TW': '繁體中文',
|
||||
'zh-CN': '\u7b80\u4f53\u4e2d\u6587',
|
||||
'zh-TW': '\u7e41\u9ad4\u4e2d\u6587',
|
||||
en: 'English',
|
||||
th: 'ไทย',
|
||||
th: '\u0e44\u0e17\u0e22',
|
||||
};
|
||||
return languageLabelMap[value] || value;
|
||||
}
|
||||
@@ -2478,7 +2665,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<BarChart2 class="w-6 h-6 text-orange-600" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-slate-900 mb-1">{{ feedbackReport?.avg_score?.toFixed(1) ?? '0.0' }}</div>
|
||||
<div class="text-3xl font-bold text-slate-900 mb-1">{{ String(tableData.length || 0) }}</div>
|
||||
<div class="text-sm text-slate-500 font-medium">{{ t('admin.dash.avgRating') }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
@@ -19,6 +19,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
import FilePreviewModal from '../components/FilePreviewModal.vue';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
import GeneralFeedbackDialog from '../components/GeneralFeedbackDialog.vue';
|
||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
@@ -375,6 +376,17 @@ const copiedIndex = ref<number | null>(null);
|
||||
const { messages, isThinking, conversationId, sendMessage } = useChat();
|
||||
const input = ref('');
|
||||
const currentAgent = ref<any>(null);
|
||||
const showGeneralFeedbackDialog = ref(false);
|
||||
const currentGeneralFeedbackChatLogId = computed(() => {
|
||||
for (let i = messages.value.length - 1; i >= 0; i--) {
|
||||
const msg: any = messages.value[i];
|
||||
if (msg?.role === 'assistant') {
|
||||
const id = Number(msg?.chat_log_id);
|
||||
if (Number.isInteger(id) && id > 0) return id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
interface ChatHistoryItem {
|
||||
id: number;
|
||||
@@ -654,6 +666,12 @@ const submitFeedback = async () => {
|
||||
<Plus class="h-4 w-4" />
|
||||
{{ $t('chat.newChat') }}
|
||||
</button>
|
||||
<button
|
||||
@click="showGeneralFeedbackDialog = true"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-[#8cbce8] bg-[#eef6ff] px-2 py-1.5 text-[11px] font-semibold text-[#2f73b2] transition-colors hover:bg-[#e3f1ff] md:px-3 md:py-2 md:text-xs"
|
||||
>
|
||||
{{ '\u610f\u89c1\u53cd\u9988' }}
|
||||
</button>
|
||||
<ThemeToggleButton />
|
||||
</div>
|
||||
</header>
|
||||
@@ -918,4 +936,11 @@ const submitFeedback = async () => {
|
||||
:agent-id="agentId"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
/>
|
||||
<GeneralFeedbackDialog
|
||||
v-model="showGeneralFeedbackDialog"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
source-page="chat"
|
||||
:chat-log-id="currentGeneralFeedbackChatLogId"
|
||||
@submitted="showMessageDialog('success', '\u53cd\u9988\u63d0\u4ea4\u6210\u529f')"
|
||||
/>
|
||||
</template>
|
||||
@@ -10,6 +10,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { config } from '../config';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
|
||||
import GeneralFeedbackDialog from '../components/GeneralFeedbackDialog.vue';
|
||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
|
||||
import {
|
||||
@@ -141,6 +142,7 @@ const pendingAgentId = ref<number | null>(null);
|
||||
const isWecomLoggingIn = ref(false);
|
||||
const showDeleteQuickQuestionDialog = ref(false);
|
||||
const pendingDeleteQuickQuestionId = ref<number | null>(null);
|
||||
const showGeneralFeedbackDialog = ref(false);
|
||||
const wecomEntryHint = ref('');
|
||||
const wecomLoginDialog = ref<WecomLoginDialogContent | null>(null);
|
||||
const wecomBindPrompt = ref<WecomBindPromptState | null>(null);
|
||||
@@ -927,6 +929,12 @@ onBeforeUnmount(() => {
|
||||
<div class="flex items-center gap-2 md:gap-4 shrink-0">
|
||||
<!-- Keep header actions minimal on mobile; language switch is in the profile dropdown. -->
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="showGeneralFeedbackDialog = true"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-[#8cbce8] bg-[#eef6ff] px-2 py-1.5 text-[11px] font-semibold text-[#2f73b2] transition-colors hover:bg-[#e3f1ff] md:px-3 md:py-2 md:text-xs"
|
||||
>
|
||||
{{ '\u610f\u89c1\u53cd\u9988' }}
|
||||
</button>
|
||||
<ThemeToggleButton />
|
||||
</div>
|
||||
<!-- User Profile Dropdown -->
|
||||
@@ -1445,10 +1453,15 @@ onBeforeUnmount(() => {
|
||||
@confirm="confirmRemoveQuickQuestion"
|
||||
@cancel="cancelRemoveQuickQuestion"
|
||||
/>
|
||||
<GeneralFeedbackDialog
|
||||
v-model="showGeneralFeedbackDialog"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
source-page="workspace"
|
||||
@submitted="showMessageDialog('success', '\u53cd\u9988\u63d0\u4ea4\u6210\u529f')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Scoped styles removed in favor of global utilities in style.css */
|
||||
</style>
|
||||
|
||||
Reference in new issue
Block a user