From 99df028237a02ed9f1488449dccea0a788852b22 Mon Sep 17 00:00:00 2001 From: RockYang Date: Sun, 28 Apr 2024 19:09:26 +0800 Subject: [PATCH] feat: add index page for mobile --- CHANGELOG.md | 2 + api/handler/chatimpl/chat_item_handler.go | 10 +- api/store/vo/chat_item.go | 15 +- web/.env.development | 2 +- web/.env.production | 2 +- web/src/App.vue | 1 - web/src/assets/css/mobile/chat-list.styl | 3 + web/src/assets/css/mobile/chat-session.styl | 25 +- web/src/components/SendMsg.vue | 9 +- web/src/components/admin/AdminHeader.vue | 31 +- web/src/components/admin/AdminSidebar.vue | 12 +- web/src/components/admin/AdminTags.vue | 116 ++++---- web/src/components/mobile/ChatPrompt.vue | 1 + web/src/main.js | 6 +- web/src/router.js | 31 +- web/src/utils/libs.js | 14 + web/src/views/ChatPlus.vue | 9 - web/src/views/Index.vue | 6 +- web/src/views/mobile/ChatExport.vue | 59 ++-- web/src/views/mobile/ChatList.vue | 77 +++-- web/src/views/mobile/ChatSession.vue | 282 +++++++++++-------- web/src/views/mobile/Home.vue | 19 +- web/src/views/mobile/Image.vue | 4 +- web/src/views/mobile/Index.vue | 234 +++++++++++++++ web/src/views/mobile/Profile.vue | 5 +- web/src/views/mobile/{ => pages}/ImageMj.vue | 0 web/src/views/mobile/{ => pages}/ImageSd.vue | 0 web/src/views/mobile/{ => pages}/ImgWall.vue | 14 +- 28 files changed, 640 insertions(+), 349 deletions(-) create mode 100644 web/src/views/mobile/Index.vue rename web/src/views/mobile/{ => pages}/ImageMj.vue (100%) rename web/src/views/mobile/{ => pages}/ImageSd.vue (100%) rename web/src/views/mobile/{ => pages}/ImgWall.vue (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43553bf3..d0689b25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ * 功能优化:优化首页登录注册页面的 UI * BUG修复:修复License验证的逻辑漏洞 * Bug修复:后台添加用户的时候密码规则限制跟前台注册保持一致 +* 功能新增:管理后台支持切换主题,支持 light 和 dark 模式 +* 功能新增:移动端新增 DALL-E 绘画功能 ## v4.0.4 diff --git a/api/handler/chatimpl/chat_item_handler.go b/api/handler/chatimpl/chat_item_handler.go index b9337556..c04dab19 100644 --- a/api/handler/chatimpl/chat_item_handler.go +++ b/api/handler/chatimpl/chat_item_handler.go @@ -187,12 +187,20 @@ func (h *ChatHandler) Detail(c *gin.Context) { return } + // 填充角色名称 + var role model.ChatRole + res = h.DB.Where("id", chatItem.RoleId).First(&role) + if res.Error != nil { + resp.ERROR(c, "Role not found") + return + } + var chatItemVo vo.ChatItem err := utils.CopyObject(chatItem, &chatItemVo) if err != nil { resp.ERROR(c, err.Error()) return } - + chatItemVo.RoleName = role.Name resp.SUCCESS(c, chatItemVo) } diff --git a/api/store/vo/chat_item.go b/api/store/vo/chat_item.go index ec43c320..4ac66fcc 100644 --- a/api/store/vo/chat_item.go +++ b/api/store/vo/chat_item.go @@ -2,11 +2,12 @@ package vo type ChatItem struct { BaseVo - UserId uint `json:"user_id"` - Icon string `json:"icon"` - RoleId uint `json:"role_id"` - ChatId string `json:"chat_id"` - ModelId uint `json:"model_id"` - Model string `json:"model"` - Title string `json:"title"` + UserId uint `json:"user_id"` + Icon string `json:"icon"` + RoleId uint `json:"role_id"` + RoleName string `json:"role_name"` + ChatId string `json:"chat_id"` + ModelId uint `json:"model_id"` + Model string `json:"model"` + Title string `json:"title"` } diff --git a/web/.env.development b/web/.env.development index 86a41a45..5aa2e256 100644 --- a/web/.env.development +++ b/web/.env.development @@ -6,4 +6,4 @@ VUE_APP_ADMIN_USER=admin VUE_APP_ADMIN_PASS=admin123 VUE_APP_KEY_PREFIX=ChatPLUS_DEV_ VUE_APP_TITLE="Geek-AI 创作系统" -VUE_APP_VERSION=v4.0.4 +VUE_APP_VERSION=v4.0.5 diff --git a/web/.env.production b/web/.env.production index 06285be4..44521618 100644 --- a/web/.env.production +++ b/web/.env.production @@ -2,4 +2,4 @@ VUE_APP_API_HOST= VUE_APP_WS_HOST= VUE_APP_KEY_PREFIX=ChatPLUS_ VUE_APP_TITLE="Geek-AI 创作系统" -VUE_APP_VERSION=v4.0.4 +VUE_APP_VERSION=v4.0.5 diff --git a/web/src/App.vue b/web/src/App.vue index f743f393..ae0a0856 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -32,7 +32,6 @@ window.ResizeObserver = class ResizeObserver extends _ResizeObserver { diff --git a/web/src/components/admin/AdminTags.vue b/web/src/components/admin/AdminTags.vue index fcacc5d6..2fb757e4 100644 --- a/web/src/components/admin/AdminTags.vue +++ b/web/src/components/admin/AdminTags.vue @@ -118,71 +118,75 @@ const handleTags = (command) => { // }); - diff --git a/web/src/components/mobile/ChatPrompt.vue b/web/src/components/mobile/ChatPrompt.vue index c56b29be..8d9a464e 100644 --- a/web/src/components/mobile/ChatPrompt.vue +++ b/web/src/components/mobile/ChatPrompt.vue @@ -16,6 +16,7 @@ import {onMounted, ref} from "vue"; import Clipboard from "clipboard"; import {showNotify} from "vant"; +// eslint-disable-next-line no-unused-vars,no-undef const props = defineProps({ content: { type: String, diff --git a/web/src/main.js b/web/src/main.js index 64227b94..0e2bd740 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -14,7 +14,7 @@ import { Collapse, CollapseItem, ConfigProvider, - Dialog, + Dialog, Divider, DropdownItem, DropdownMenu, Empty, @@ -28,7 +28,7 @@ import { Lazyload, List, Loading, - NavBar, + NavBar, NoticeBar, Notify, Overlay, Picker, @@ -97,6 +97,8 @@ app.use(Lazyload); app.use(ImagePreview); app.use(Tab); app.use(Tabs); +app.use(Divider); +app.use(NoticeBar); app.use(router).use(ElementPlus).mount('#app') diff --git a/web/src/router.js b/web/src/router.js index 2454a974..538fc9eb 100644 --- a/web/src/router.js +++ b/web/src/router.js @@ -201,8 +201,13 @@ const routes = [ path: '/mobile', meta: {title: 'Geek-AI v4.0'}, component: () => import('@/views/mobile/Home.vue'), - redirect: '/mobile/chat', + redirect: '/mobile/index', children: [ + { + path: '/mobile/index', + name: 'mobile-index', + component: () => import('@/views/mobile/Index.vue'), + }, { path: '/mobile/chat', name: 'mobile-chat', @@ -219,22 +224,22 @@ const routes = [ component: () => import('@/views/mobile/Profile.vue'), }, { - path: '/mobile/img-wall', + path: '/mobile/imgWall', name: 'mobile-img-wall', - component: () => import('@/views/mobile/ImgWall.vue'), + component: () => import('@/views/mobile/pages/ImgWall.vue'), + }, + { + path: '/mobile/chat/session', + name: 'mobile-chat-session', + component: () => import('@/views/mobile/ChatSession.vue'), + }, + { + path: '/mobile/chat/export', + name: 'mobile-chat-export', + component: () => import('@/views/mobile/ChatExport.vue'), }, ] }, - { - path: '/mobile/chat/session', - name: 'mobile-chat-session', - component: () => import('@/views/mobile/ChatSession.vue'), - }, - { - path: '/mobile/chat/export', - name: 'mobile-chat-export', - component: () => import('@/views/mobile/ChatExport.vue'), - }, { name: 'test', diff --git a/web/src/utils/libs.js b/web/src/utils/libs.js index 646608e6..0a989f1a 100644 --- a/web/src/utils/libs.js +++ b/web/src/utils/libs.js @@ -1,6 +1,8 @@ /** * Util lib functions */ +import {showConfirmDialog} from "vant"; +import {useRouter} from "vue-router"; // generate a random string export function randString(length) { @@ -224,3 +226,15 @@ export function escapeHTML(html) { export function isIphone() { return /iPhone/i.test(navigator.userAgent) && !/iPad/i.test(navigator.userAgent); } + +export function showLoginDialog(router) { + showConfirmDialog({ + title: '登录', + message: + '当前操作需要登录才能进行,前往登录?', + }).then(() => { + router.push("/login") + }).catch(() => { + // on cancel + }); +} diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue index b5fb3c71..b0bcc7c7 100644 --- a/web/src/views/ChatPlus.vue +++ b/web/src/views/ChatPlus.vue @@ -355,7 +355,6 @@ const initData = () => { // 加载角色列表 httpGet(`/api/role/list`).then((res) => { roles.value = res.data; - console.log() if (router.currentRoute.value.params.role_id) { roleId.value = parseInt(router.currentRoute.value.params["role_id"]) } else { @@ -901,14 +900,6 @@ const exportChat = () => { window.open(url, '_blank'); } -const getChatById = (chatId) => { - for (let index in chatList.value) { - if (chatList.value[index].chat_id === chatId) { - return chatList.value[index] - } - } - return null -} const getModelValue = (model_id) => { for (let i = 0; i < models.value.length; i++) { diff --git a/web/src/views/Index.vue b/web/src/views/Index.vue index 559795c8..fb60766e 100644 --- a/web/src/views/Index.vue +++ b/web/src/views/Index.vue @@ -34,16 +34,16 @@

{{ slogan }}

- AI聊天 + AI 对话 - AI-MJ绘画 + MJ 绘画 - AI-SD绘画 + SD 绘画 diff --git a/web/src/views/mobile/ChatExport.vue b/web/src/views/mobile/ChatExport.vue index 507c476c..a3059d7c 100644 --- a/web/src/views/mobile/ChatExport.vue +++ b/web/src/views/mobile/ChatExport.vue @@ -1,18 +1,16 @@ - + @@ -260,6 +260,9 @@ const pay = (payWay, item) => {