diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index a6f34fe..0000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -dist -out -.gitignore diff --git a/.eslintrc.cjs b/.eslintrc.cjs index b462405..b93ad7d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,17 +1,16 @@ /* eslint-env node */ -require('@rushstack/eslint-patch/modern-module-resolution') +require("@rushstack/eslint-patch/modern-module-resolution"); module.exports = { extends: [ - 'eslint:recommended', - 'plugin:vue/vue3-recommended', - '@electron-toolkit', - '@electron-toolkit/eslint-config-ts/eslint-recommended', - '@vue/eslint-config-typescript/recommended', - '@vue/eslint-config-prettier' + "eslint:recommended", + "plugin:vue/vue3-recommended", + "@vue/eslint-config-typescript/recommended", + "@vue/eslint-config-prettier", ], rules: { - 'vue/require-default-prop': 'off', - 'vue/multi-word-component-names': 'off' - } -} + "vue/require-default-prop": "off", + "vue/multi-word-component-names": "off", + }, + ignores: ["src/typed-router.d.ts", "node_modules", "dist", "out", ".gitignore"], +}; diff --git a/package.json b/package.json index 15f15a8..8df98fb 100644 --- a/package.json +++ b/package.json @@ -31,11 +31,17 @@ "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "autoprefixer": "^10.4.20", - "eslint": "^8.57.0", - "eslint-plugin-vue": "^9.26.0", + "eslint": "^9.10.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.30.0", + "eslint-plugin-n": "^17.10.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^7.1.0", + "eslint-plugin-vue": "^9.28.0", "naive-ui": "^2.39.0", "postcss": "^8.4.45", - "prettier": "^3.3.2", + "prettier": "^3.3.3", "tailwindcss": "^3.4.10", "typescript": "^5.5.2", "unplugin-auto-import": "^0.18.2", diff --git a/src/components.d.ts b/src/components.d.ts index d54317f..eda323f 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -12,6 +12,8 @@ declare module 'vue' { ChatMenu: typeof import('./components/ChatMenu.vue')['default'] Container: typeof import('./components/Container.vue')['default'] copy: typeof import('./components/AssistantMenu.vue')['default'] + LeftSetting: typeof import('./components/LeftSetting.vue')['default'] + LeftSettings: typeof import('./components/LeftSettings.vue')['default'] Menu: typeof import('./components/Menu.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/src/components/AssistantMenu.vue b/src/components/AssistantMenu.vue index 3ce01d5..b525c17 100644 --- a/src/components/AssistantMenu.vue +++ b/src/components/AssistantMenu.vue @@ -1,5 +1,6 @@ - - 对话 + + {{ c.name }} @@ -24,10 +24,20 @@ import { NMenu } from "naive-ui"; import { useRoute } from "vue-router"; import { leftMenuOptions } from "../plugins/menus/left"; import { ChatboxOutline } from "@vicons/ionicons5"; +import getApi from "../plugins/api"; +import { useChatStore } from "../stores/chat"; const route = useRoute(); const currentRoute: any = computed(() => route.name); const collapsed = ref(false); + +const chatStore = useChatStore(); + +async function getChats() { + chatStore.chats = (await getApi().Chat.apiV1ChatsGet()).data.data; +} + +getChats(); diff --git a/src/layouts/DefaultLayout.vue b/src/layouts/DefaultLayout.vue index ce6b12a..08a6d46 100644 --- a/src/layouts/DefaultLayout.vue +++ b/src/layouts/DefaultLayout.vue @@ -20,7 +20,7 @@ const menuCollapsed = ref({ - + --> + + + + + + + + +
正在更新数据
@@ -72,6 +90,16 @@ const userStore = useUserStore(); const isMobile = useIsMobile(); const isTablet = useIsTablet(); const appStore = useAppStore(); +const showDrawer = ref(false); +const width = ref(200); + +// 如果是手机,则 width 为全屏 +if (isMobile.value) { + // 获取屏幕宽度 + width.value = window.innerWidth - 100; +} else { + width.value = "40%"; +} const userPlacement = ref("bottom"); if (isMobile.value) { diff --git a/src/pages/chat/[id]/index copy.vue b/src/pages/chat/[id]/index copy.vue new file mode 100644 index 0000000..c1eca02 --- /dev/null +++ b/src/pages/chat/[id]/index copy.vue @@ -0,0 +1,322 @@ + + + diff --git a/src/pages/chat/[id]/index.vue b/src/pages/chat/[id]/index.vue new file mode 100644 index 0000000..7c04417 --- /dev/null +++ b/src/pages/chat/[id]/index.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/plugins/api.ts b/src/plugins/api.ts index 4fcdd05..3faee26 100644 --- a/src/plugins/api.ts +++ b/src/plugins/api.ts @@ -20,6 +20,7 @@ interface Api { Tool: ToolApi; ChatMessage: ChatMessageApi; ChatPublic: ChatPublicApi; + conf: Configuration } let api: Api | null = null; // 使用联合类型来表示初始状态可能是 null @@ -49,6 +50,7 @@ const getApi = () => { Tool: new ToolApi(conf, undefined, axios), ChatMessage: new ChatMessageApi(conf, undefined, axios), ChatPublic: new ChatPublicApi(conf, undefined, axios), + conf: conf }; return api; diff --git a/src/stores/chat.ts b/src/stores/chat.ts index bab59d0..d2f3817 100644 --- a/src/stores/chat.ts +++ b/src/stores/chat.ts @@ -4,6 +4,7 @@ import { EntityChat } from "../api"; export const useChatStore = defineStore("chats", { persist: false, state: () => ({ + currentChatId: 0, chats: [], }), }); diff --git a/src/typed-router.d.ts b/src/typed-router.d.ts index cf2fe80..ccf135b 100644 --- a/src/typed-router.d.ts +++ b/src/typed-router.d.ts @@ -23,6 +23,8 @@ declare module 'vue-router/auto-routes' { '/auth/continue': RouteRecordInfo<'/auth/continue', '/auth/continue', Record, Record>, '/auth/login': RouteRecordInfo<'/auth/login', '/auth/login', Record, Record>, '/auth/logout': RouteRecordInfo<'/auth/logout', '/auth/logout', Record, Record>, + '/chat/[id]/': RouteRecordInfo<'/chat/[id]/', '/chat/:id', { id: ParamValue }, { id: ParamValue }>, + '/chat/[id]/index copy': RouteRecordInfo<'/chat/[id]/index copy', '/chat/:id/index copy', { id: ParamValue }, { id: ParamValue }>, '/guest/': RouteRecordInfo<'/guest/', '/guest', Record, Record>, '/test': RouteRecordInfo<'/test', '/test', Record, Record>, '/test2': RouteRecordInfo<'/test2', '/test2', Record, Record>, diff --git a/tsconfig.json b/tsconfig.json index 811fab0..5daeec8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,16 @@ "skipLibCheck": true, "types": [ "unplugin-vue-router/client" - ] + ], + "paths": { + "@/*": [ + "./src/*" + ] + }, + "allowJs": true, + "strictNullChecks": true, + "noUnusedLocals": true, + "forceConsistentCasingInFileNames": true, }, "include": [ "src/**/*.ts", @@ -30,4 +39,4 @@ "path": "./tsconfig.node.json" } ] -} +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 0ef36d4..ba3f721 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,13 +1,13 @@ -import { defineConfig } from "vite" -import vue from "@vitejs/plugin-vue" -import VueRouter from "unplugin-vue-router/vite" -import Layouts from "vite-plugin-vue-layouts" -import Components from "unplugin-vue-components/vite" -import AutoImport from "unplugin-auto-import/vite" +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; +import VueRouter from "unplugin-vue-router/vite"; +import Layouts from "vite-plugin-vue-layouts"; +import Components from "unplugin-vue-components/vite"; +import AutoImport from "unplugin-auto-import/vite"; // import { resolve } from "path"; // const rootPath = new URL(".", import.meta.url).pathname; -import { fileURLToPath, URL } from "node:url" +import { fileURLToPath, URL } from "node:url"; // https://vitejs.dev/config/ export default defineConfig({ resolve: { @@ -54,4 +54,4 @@ export default defineConfig({ port: 5173, strictPort: true, }, -}) +});