mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-06 09:23:45 +08:00
stash code
This commit is contained in:
@@ -54,6 +54,7 @@ import {
|
||||
useAppConfig,
|
||||
DEFAULT_TOPIC,
|
||||
ModelType,
|
||||
usePluginStore,
|
||||
} from "../store";
|
||||
|
||||
import {
|
||||
@@ -440,6 +441,71 @@ export function ChatActions(props: {
|
||||
const config = useAppConfig();
|
||||
const navigate = useNavigate();
|
||||
const chatStore = useChatStore();
|
||||
const pluginStore = usePluginStore();
|
||||
console.log("pluginStore", pluginStore.getAll());
|
||||
// test
|
||||
if (pluginStore.getAll().length == 0) {
|
||||
pluginStore.create({
|
||||
title: "Pet API",
|
||||
version: "1.0.0",
|
||||
content: `{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"title": "Pet API",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"paths": {
|
||||
"/api/pets": {
|
||||
"get": {
|
||||
"operationId": "getPets",
|
||||
"description": "Returns all pets from the system that the user has access to",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "List of Pets",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"cat",
|
||||
"dog"
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"type"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
// switch themes
|
||||
const theme = config.theme;
|
||||
@@ -738,15 +804,22 @@ export function ChatActions(props: {
|
||||
title: Locale.Plugin.Artifacts,
|
||||
value: Plugin.Artifacts,
|
||||
},
|
||||
]}
|
||||
].concat(
|
||||
pluginStore
|
||||
.getAll()
|
||||
.map((item) => ({
|
||||
title: `${item.title}@${item.version}`,
|
||||
value: item.id,
|
||||
})),
|
||||
)}
|
||||
onClose={() => setShowPluginSelector(false)}
|
||||
onSelection={(s) => {
|
||||
const plugin = s[0];
|
||||
chatStore.updateCurrentSession((session) => {
|
||||
session.mask.plugin = s;
|
||||
});
|
||||
if (plugin) {
|
||||
showToast(plugin);
|
||||
if (s.includes(Plugin.Artifacts)) {
|
||||
showToast(Plugin.Artifacts);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user