mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-04-07 05:47:38 +00:00
fix ai assistant bugs
This commit is contained in:
@@ -94,7 +94,7 @@ import type { DepartmentUpsertModel } from "@/types/department";
|
|||||||
import DOMPurify from "dompurify";
|
import DOMPurify from "dompurify";
|
||||||
import { Modal, type ModalInterface, initFlowbite } from "flowbite";
|
import { Modal, type ModalInterface, initFlowbite } from "flowbite";
|
||||||
import { marked } from "marked";
|
import { marked } from "marked";
|
||||||
import { onMounted, onUnmounted, ref, watch } from "vue";
|
import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import Button from "../components/Button.vue";
|
import Button from "../components/Button.vue";
|
||||||
import DepartmentUpsertModal from "../components/DepartmentUpsertModal.vue";
|
import DepartmentUpsertModal from "../components/DepartmentUpsertModal.vue";
|
||||||
@@ -256,6 +256,9 @@ const chatByMode = async (
|
|||||||
isUser: true,
|
isUser: true,
|
||||||
username: user.username!,
|
username: user.username!,
|
||||||
});
|
});
|
||||||
|
await nextTick(() => {
|
||||||
|
scrollToBottom();
|
||||||
|
});
|
||||||
if (mode === "search") {
|
if (mode === "search") {
|
||||||
await searchAction(message);
|
await searchAction(message);
|
||||||
} else if (mode === "execute") {
|
} else if (mode === "execute") {
|
||||||
@@ -269,7 +272,6 @@ const handleSendClick = async (
|
|||||||
message: string,
|
message: string,
|
||||||
mode: "chat" | "search" | "execute",
|
mode: "chat" | "search" | "execute",
|
||||||
) => {
|
) => {
|
||||||
scrollToBottom();
|
|
||||||
if (isLoading.value) {
|
if (isLoading.value) {
|
||||||
abortChat();
|
abortChat();
|
||||||
return;
|
return;
|
||||||
@@ -289,10 +291,7 @@ onMounted(async () => {
|
|||||||
initFlowbite();
|
initFlowbite();
|
||||||
const $upsertModalElement: HTMLElement | null =
|
const $upsertModalElement: HTMLElement | null =
|
||||||
document.querySelector("#user-upsert-modal");
|
document.querySelector("#user-upsert-modal");
|
||||||
userUpsertModal.value = new Modal(
|
userUpsertModal.value = new Modal($upsertModalElement, {});
|
||||||
$upsertModalElement,
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
const $userDeleteModalElement: HTMLElement | null =
|
const $userDeleteModalElement: HTMLElement | null =
|
||||||
document.querySelector("#user-delete-modal");
|
document.querySelector("#user-delete-modal");
|
||||||
userDeleteModal.value = new Modal(
|
userDeleteModal.value = new Modal(
|
||||||
@@ -304,16 +303,10 @@ onMounted(async () => {
|
|||||||
);
|
);
|
||||||
const $departmentDeleteModalElement: HTMLElement | null =
|
const $departmentDeleteModalElement: HTMLElement | null =
|
||||||
document.querySelector("#department-delete-modal");
|
document.querySelector("#department-delete-modal");
|
||||||
departmentDeleteModal.value = new Modal(
|
departmentDeleteModal.value = new Modal($departmentDeleteModalElement, {});
|
||||||
$departmentDeleteModalElement,
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
const $departmentUpsertModalElement: HTMLElement | null =
|
const $departmentUpsertModalElement: HTMLElement | null =
|
||||||
document.querySelector("#department-upsert-modal");
|
document.querySelector("#department-upsert-modal");
|
||||||
departmentUpsertModal.value = new Modal(
|
departmentUpsertModal.value = new Modal($departmentUpsertModalElement, {});
|
||||||
$departmentUpsertModalElement,
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -101,12 +101,12 @@ import { RouteName, RoutePath } from "../router/constants";
|
|||||||
import AiChatIcon from "./icons/AiChatIcon.vue";
|
import AiChatIcon from "./icons/AiChatIcon.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
changeAssistantVisible: () => void;
|
changeAssistantVisible: () => void;
|
||||||
onSidebarToggle: () => void;
|
onSidebarToggle: () => void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const handleSidebarToggle = () => {
|
const handleSidebarToggle = () => {
|
||||||
props.onSidebarToggle();
|
props.onSidebarToggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
const userDropDownMenu = ref<DropdownInterface>();
|
const userDropDownMenu = ref<DropdownInterface>();
|
||||||
@@ -115,19 +115,19 @@ const { user } = useUserStore();
|
|||||||
const { signOut } = useUserAuth();
|
const { signOut } = useUserAuth();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const handleLogoutClick = () => {
|
const handleLogoutClick = () => {
|
||||||
signOut();
|
signOut();
|
||||||
router.push(RoutePath.LOGIN);
|
router.push(RoutePath.LOGIN);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initFlowbite();
|
initFlowbite();
|
||||||
const $dropdownUser = document.getElementById("dropdown-user");
|
const $dropdownUser = document.getElementById("dropdown-user");
|
||||||
const $dropdownButton = document.getElementById("dropdown-button");
|
const $dropdownButton = document.getElementById("dropdown-button");
|
||||||
userDropDownMenu.value = new Dropdown(
|
userDropDownMenu.value = new Dropdown(
|
||||||
$dropdownUser,
|
$dropdownUser,
|
||||||
$dropdownButton,
|
$dropdownButton,
|
||||||
{},
|
{},
|
||||||
{ id: "dropdownMenu", override: true },
|
{ id: "dropdownMenu", override: true },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ import SettingsIcon from "./icons/SettingsIcon.vue";
|
|||||||
import UsersIcon from "./icons/UsersIcon.vue";
|
import UsersIcon from "./icons/UsersIcon.vue";
|
||||||
|
|
||||||
const isDrawerVisible = ref(false);
|
const isDrawerVisible = ref(false);
|
||||||
const emit = defineEmits(['menu-click']);
|
const emit = defineEmits(["menu-click"]);
|
||||||
|
|
||||||
// 菜单点击处理
|
// 菜单点击处理
|
||||||
const handleMenuClick = () => {
|
const handleMenuClick = () => {
|
||||||
emit('menu-click');
|
emit("menu-click");
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
@@ -66,7 +66,7 @@ defineExpose({
|
|||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
openSidebar,
|
openSidebar,
|
||||||
closeSidebar,
|
closeSidebar,
|
||||||
isDrawerVisible
|
isDrawerVisible,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 菜单配置
|
// 菜单配置
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export const useAiChat = () => {
|
|||||||
console.log("onclose");
|
console.log("onclose");
|
||||||
},
|
},
|
||||||
onerror(err) {
|
onerror(err) {
|
||||||
|
console.error(err);
|
||||||
throw err;
|
throw err;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user