-
+
提问
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1f270f6..99d9562 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -8,12 +8,27 @@ importers:
.:
dependencies:
+ '@pinia/nuxt':
+ specifier: 0.10.1
+ version: 0.10.1(magicast@0.3.5)(pinia@3.0.1(typescript@5.8.2)(vue@3.5.13(typescript@5.8.2)))
+ '@tailwindcss/typography':
+ specifier: ^0.5.16
+ version: 0.5.16(tailwindcss@4.0.14)
'@tailwindcss/vite':
specifier: ^4.0.14
version: 4.0.14(vite@6.2.1(@types/node@22.13.10)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.0))
+ '@uniiem/uuid':
+ specifier: ^0.2.1
+ version: 0.2.1
+ dotenv:
+ specifier: ^16.4.7
+ version: 16.4.7
nuxt:
specifier: ^3.16.0
version: 3.16.0(@parcel/watcher@2.5.1)(@types/node@22.13.10)(db0@0.3.1)(ioredis@5.6.0)(lightningcss@1.29.2)(magicast@0.3.5)(rollup@4.35.0)(terser@5.39.0)(typescript@5.8.2)(vite@6.2.1(@types/node@22.13.10)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.0))(yaml@2.7.0)
+ pinia:
+ specifier: ^3.0.1
+ version: 3.0.1(typescript@5.8.2)(vue@3.5.13(typescript@5.8.2))
tailwindcss:
specifier: ^4.0.14
version: 4.0.14
@@ -638,6 +653,11 @@ packages:
resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==}
engines: {node: '>= 10.0.0'}
+ '@pinia/nuxt@0.10.1':
+ resolution: {integrity: sha512-xrpkKZHSmshPK6kQzboJ+TZiZ5zj73gBCI5SfiUaJkKKS9gx4B1hLEzJIjxZl0/HS5jRWrIvQ+u9ulvIRlNiow==}
+ peerDependencies:
+ pinia: ^3.0.1
+
'@pkgjs/parseargs@0.11.0':
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
engines: {node: '>=14'}
@@ -1003,6 +1023,11 @@ packages:
'@tailwindcss/postcss@4.0.13':
resolution: {integrity: sha512-zTmnPGDYb2HKClTBTBwB+lLQH+Rq4etnQXFXs2lisRyXryUnoJIBByFTljkaK9F1d7o14h6t4NJIlfbZuOHR+A==}
+ '@tailwindcss/typography@0.5.16':
+ resolution: {integrity: sha512-0wDLwCVF5V3x3b1SGXPCDcdsbDHMBe+lkFzBRaHeLvNi+nrrnZ1lA18u+OTWO8iSWU2GxUOCvlXtDuqftc1oiA==}
+ peerDependencies:
+ tailwindcss: '>=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1'
+
'@tailwindcss/vite@4.0.14':
resolution: {integrity: sha512-y69ztPTRFy+13EPS/7dEFVl7q2Goh1pQueVO8IfGeyqSpcx/joNJXFk0lLhMgUbF0VFJotwRSb9ZY7Xoq3r26Q==}
peerDependencies:
@@ -1059,6 +1084,9 @@ packages:
peerDependencies:
vue: '>=3.5.13'
+ '@uniiem/uuid@0.2.1':
+ resolution: {integrity: sha512-p8DOA3BTkZgvgtOCtK5x7Y2l+GRTFhYrOua70YPiEEUomQFirwxpWrQBst+7oB/iPTeY1zHuF6MKl+mxi0R00A==}
+
'@vercel/nft@0.29.2':
resolution: {integrity: sha512-A/Si4mrTkQqJ6EXJKv5EYCDQ3NL6nJXxG8VGXePsaiQigsomHYQC9xSpX8qGk7AEZk4b1ssbYIqJ0ISQQ7bfcA==}
engines: {node: '>=18'}
@@ -1118,6 +1146,9 @@ packages:
'@vue/devtools-api@6.6.4':
resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
+ '@vue/devtools-api@7.7.2':
+ resolution: {integrity: sha512-1syn558KhyN+chO5SjlZIwJ8bV/bQ1nOVTG66t2RbG66ZGekyiYNmRO7X9BJCXQqPsFHlnksqvPhce2qpzxFnA==}
+
'@vue/devtools-core@7.7.2':
resolution: {integrity: sha512-lexREWj1lKi91Tblr38ntSsy6CvI8ba7u+jmwh2yruib/ltLUcsIzEjCnrkh1yYGGIKXbAuYV2tOG10fGDB9OQ==}
peerDependencies:
@@ -2250,15 +2281,24 @@ packages:
resolution: {integrity: sha512-WunYko2W1NcdfAFpuLUoucsgULmgDBRkdxHxWQ7mK0cQqwPiy8E1enjuRBrhLtZkB5iScJ1XIPdhVEFK8aOLSg==}
engines: {node: '>=14'}
+ lodash.castarray@4.4.0:
+ resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==}
+
lodash.defaults@4.2.0:
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
lodash.isarguments@3.1.0:
resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==}
+ lodash.isplainobject@4.0.6:
+ resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
+
lodash.memoize@4.1.2:
resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==}
+ lodash.merge@4.6.2:
+ resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
+
lodash.uniq@4.5.0:
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
@@ -2567,6 +2607,15 @@ packages:
resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==}
engines: {node: '>=12'}
+ pinia@3.0.1:
+ resolution: {integrity: sha512-WXglsDzztOTH6IfcJ99ltYZin2mY8XZCXujkYWVIJlBjqsP6ST7zw+Aarh63E1cDVYeyUcPCxPHzJpEOmzB6Wg==}
+ peerDependencies:
+ typescript: '>=4.4.4'
+ vue: ^2.7.0 || ^3.5.11
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
pkg-types@1.3.1:
resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}
@@ -2727,6 +2776,10 @@ packages:
peerDependencies:
postcss: ^8.4.31
+ postcss-selector-parser@6.0.10:
+ resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==}
+ engines: {node: '>=4'}
+
postcss-selector-parser@6.1.2:
resolution: {integrity: sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==}
engines: {node: '>=4'}
@@ -4429,6 +4482,13 @@ snapshots:
'@parcel/watcher-win32-ia32': 2.5.1
'@parcel/watcher-win32-x64': 2.5.1
+ '@pinia/nuxt@0.10.1(magicast@0.3.5)(pinia@3.0.1(typescript@5.8.2)(vue@3.5.13(typescript@5.8.2)))':
+ dependencies:
+ '@nuxt/kit': 3.16.0(magicast@0.3.5)
+ pinia: 3.0.1(typescript@5.8.2)(vue@3.5.13(typescript@5.8.2))
+ transitivePeerDependencies:
+ - magicast
+
'@pkgjs/parseargs@0.11.0':
optional: true
@@ -4718,6 +4778,14 @@ snapshots:
postcss: 8.5.3
tailwindcss: 4.0.13
+ '@tailwindcss/typography@0.5.16(tailwindcss@4.0.14)':
+ dependencies:
+ lodash.castarray: 4.4.0
+ lodash.isplainobject: 4.0.6
+ lodash.merge: 4.6.2
+ postcss-selector-parser: 6.0.10
+ tailwindcss: 4.0.14
+
'@tailwindcss/vite@4.0.14(vite@6.2.1(@types/node@22.13.10)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.0))':
dependencies:
'@tailwindcss/node': 4.0.14
@@ -4771,6 +4839,8 @@ snapshots:
unhead: 2.0.0-rc.10
vue: 3.5.13(typescript@5.8.2)
+ '@uniiem/uuid@0.2.1': {}
+
'@vercel/nft@0.29.2(rollup@4.35.0)':
dependencies:
'@mapbox/node-pre-gyp': 2.0.0
@@ -4877,6 +4947,10 @@ snapshots:
'@vue/devtools-api@6.6.4': {}
+ '@vue/devtools-api@7.7.2':
+ dependencies:
+ '@vue/devtools-kit': 7.7.2
+
'@vue/devtools-core@7.7.2(vite@6.2.1(@types/node@22.13.10)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))':
dependencies:
'@vue/devtools-kit': 7.7.2
@@ -5986,12 +6060,18 @@ snapshots:
pkg-types: 2.1.0
quansync: 0.2.8
+ lodash.castarray@4.4.0: {}
+
lodash.defaults@4.2.0: {}
lodash.isarguments@3.1.0: {}
+ lodash.isplainobject@4.0.6: {}
+
lodash.memoize@4.1.2: {}
+ lodash.merge@4.6.2: {}
+
lodash.uniq@4.5.0: {}
lodash@4.17.21: {}
@@ -6474,6 +6554,13 @@ snapshots:
picomatch@4.0.2: {}
+ pinia@3.0.1(typescript@5.8.2)(vue@3.5.13(typescript@5.8.2)):
+ dependencies:
+ '@vue/devtools-api': 7.7.2
+ vue: 3.5.13(typescript@5.8.2)
+ optionalDependencies:
+ typescript: 5.8.2
+
pkg-types@1.3.1:
dependencies:
confbox: 0.1.8
@@ -6626,6 +6713,11 @@ snapshots:
postcss: 8.5.3
postcss-value-parser: 4.2.0
+ postcss-selector-parser@6.0.10:
+ dependencies:
+ cssesc: 3.0.0
+ util-deprecate: 1.0.2
+
postcss-selector-parser@6.1.2:
dependencies:
cssesc: 3.0.0
diff --git a/stores/state.ts b/stores/state.ts
new file mode 100644
index 0000000..0bd7769
--- /dev/null
+++ b/stores/state.ts
@@ -0,0 +1,51 @@
+import type { LocalMessage, VisitorRole } from "~/types";
+
+export const useGState = defineStore("global_state", () => {
+ const currentRole = ref
("stu");
+ const botName = computed(() => {
+ switch (currentRole.value) {
+ case "stu":
+ return "AI 辅导员";
+ case "tea":
+ return "AI 教研专家";
+ case "fans":
+ return "校园百事通";
+ default:
+ return "AI 智慧校园";
+ }
+ });
+
+ const setCurrentRole = (role: VisitorRole) => {
+ currentRole.value = role;
+ };
+
+ const messagesByRole = ref>({
+ stu: [],
+ tea: [],
+ fans: [],
+ });
+ const messages = computed({
+ get: () => messagesByRole.value[currentRole.value],
+ set: (value: LocalMessage[]) => {
+ messagesByRole.value[currentRole.value] = value;
+ },
+ });
+
+ const insertOrUpdateMessage = (message: LocalMessage) => {
+ const index = messages.value.findIndex((m) => m.id === message.id);
+ if (index >= 0) {
+ messages.value.splice(index, 1, message);
+ } else {
+ messages.value.push(message);
+ }
+ };
+
+ return {
+ currentRole,
+ botName,
+ setCurrentRole,
+ messagesByRole,
+ messages,
+ insertOrUpdateMessage,
+ };
+});
diff --git a/types/index.ts b/types/index.ts
index 3a91188..e1dad32 100644
--- a/types/index.ts
+++ b/types/index.ts
@@ -1 +1,30 @@
export type VisitorRole = "stu" | "tea" | "fans";
+
+export type LocalMessage = {
+ id: string;
+ role: "bot" | "user";
+ message?: string;
+};
+
+export interface IWorkflowResponse {
+ task_id: string;
+ workflow_run_id: string;
+ data: IWorkflowResponseData;
+}
+
+export interface IWorkflowResponseData {
+ id: string;
+ workflow_id: string;
+ status: string;
+ outputs: IWorkflowInquiryOutputs;
+ error: null;
+ elapsed_time: number;
+ total_tokens: number;
+ total_steps: number;
+ created_at: number;
+ finished_at: number;
+}
+
+export interface IWorkflowInquiryOutputs {
+ message: string;
+}