From c637d412e6884aadb2b68edf7dcb48708a1308f5 Mon Sep 17 00:00:00 2001 From: Gsh <15170702455@163.com> Date: Fri, 4 Jul 2025 00:12:26 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=AD=E5=BF=83=EF=BC=8C=E5=AE=8C=E6=88=90Apikey?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=A1=B5=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Ai.Vue3/.env.production | 2 +- Yi.Ai.Vue3/src/api/model/index.ts | 10 +- .../userPersonalCenter/NavDialog.vue | 132 ++++ .../components/APIKeyManagement.vue | 562 ++++++++++++++++++ .../components/UserManagement.vue | 24 + .../components/Header/components/Avatar.vue | 68 ++- Yi.Ai.Vue3/src/pages/products/index.vue | 4 + Yi.Ai.Vue3/src/utils/user.js | 10 + Yi.Ai.Vue3/types/components.d.ts | 11 + Yi.Ai.Vue3/types/import_meta.d.ts | 1 - 10 files changed, 814 insertions(+), 10 deletions(-) create mode 100644 Yi.Ai.Vue3/src/components/userPersonalCenter/NavDialog.vue create mode 100644 Yi.Ai.Vue3/src/components/userPersonalCenter/components/APIKeyManagement.vue create mode 100644 Yi.Ai.Vue3/src/components/userPersonalCenter/components/UserManagement.vue create mode 100644 Yi.Ai.Vue3/src/utils/user.js diff --git a/Yi.Ai.Vue3/.env.production b/Yi.Ai.Vue3/.env.production index 9a20ebcc..c5716d87 100644 --- a/Yi.Ai.Vue3/.env.production +++ b/Yi.Ai.Vue3/.env.production @@ -21,6 +21,6 @@ VITE_SSO_SEVER_URL='https://ccnetcore.com' # SSO单点登录项目标识 VITE_SSO_CLIENT_ID='YiXin-Ai'; # 版本号 -VITE_APP_VERSION='1.0.0'; +VITE_APP_VERSION='1.0.3'; diff --git a/Yi.Ai.Vue3/src/api/model/index.ts b/Yi.Ai.Vue3/src/api/model/index.ts index 0a08b5ba..7ef66abc 100644 --- a/Yi.Ai.Vue3/src/api/model/index.ts +++ b/Yi.Ai.Vue3/src/api/model/index.ts @@ -1,8 +1,16 @@ import type { GetSessionListVO } from './types'; -import { get } from '@/utils/request'; +import { get, post } from '@/utils/request'; // 获取当前用户的模型列表 export function getModelList() { // return get('/system/model/modelList'); return get('/ai-chat/model').json(); } +// 申请ApiKey +export function applyApiKey() { + return post('/token').json(); +} +// 获取ApiKey +export function getApiKey() { + return get('/token').json(); +} diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/NavDialog.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/NavDialog.vue new file mode 100644 index 00000000..f65a58e9 --- /dev/null +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/NavDialog.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/APIKeyManagement.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/APIKeyManagement.vue new file mode 100644 index 00000000..870a8970 --- /dev/null +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/APIKeyManagement.vue @@ -0,0 +1,562 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UserManagement.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UserManagement.vue new file mode 100644 index 00000000..01444dad --- /dev/null +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UserManagement.vue @@ -0,0 +1,24 @@ + + + diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue b/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue index 383e771e..0776701f 100644 --- a/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue +++ b/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue @@ -32,14 +32,19 @@ const popoverRef = ref(); // 弹出面板内容 const popoverList = ref([ + // { + // key: '1', + // title: '收藏夹', + // icon: 'book-mark-fill', + // }, + // { + // key: '2', + // title: '设置', + // icon: 'settings-4-fill', + // }, { - key: '1', - title: '收藏夹', - icon: 'book-mark-fill', - }, - { - key: '2', - title: '设置', + key: '5', + title: '用户中心', icon: 'settings-4-fill', }, { @@ -53,6 +58,25 @@ const popoverList = ref([ }, ]); +const dialogVisible = ref(false); +const navItems = [ + // { name: 'user', label: '用户管理', icon: 'User' }, + // { name: 'role', label: '角色管理', icon: 'Avatar' }, + // { name: 'permission', label: '权限管理', icon: 'Key' }, + { name: 'apiKey', label: 'API密钥', icon: 'Key' }, +]; +function openDialog() { + dialogVisible.value = true; +} +function handleConfirm(activeNav: string) { + console.log('确认操作,当前导航:', activeNav); + ElMessage.success('操作成功'); +} + +function handleNavChange(nav: string) { + console.log('导航切换:', nav); +} + // 点击 function handleClick(item: any) { switch (item.key) { @@ -64,6 +88,10 @@ function handleClick(item: any) { ElMessage.warning('暂未开放'); console.log('点击了设置'); break; + case '5': + console.log('点击了用户中心'); + openDialog(); + break; case '4': popoverRef.value?.hide?.(); ElMessageBox.confirm('退出登录不会丢失任何数据,你仍可以登录此账号。', '确认退出登录?', { @@ -226,6 +254,32 @@ function openVipGuide() { + + + + + + + + + + + + diff --git a/Yi.Ai.Vue3/src/pages/products/index.vue b/Yi.Ai.Vue3/src/pages/products/index.vue index 35d6cafe..0dcbe14f 100644 --- a/Yi.Ai.Vue3/src/pages/products/index.vue +++ b/Yi.Ai.Vue3/src/pages/products/index.vue @@ -16,6 +16,7 @@ const pricing = [ '无限制使用', '售后微信群支持', '可用优惠券,使用后29.9元', + '专属Api服务', ], }, { @@ -30,6 +31,7 @@ const pricing = [ 'AI超级加速', '无限制使用', '售后微信群支持', + '专属Api服务', ], }, { @@ -44,6 +46,8 @@ const pricing = [ '无限制使用', '售后微信群优先处理', '可用优惠券,使用后49.9元', + '专属Api服务', + ], }, ]; diff --git a/Yi.Ai.Vue3/src/utils/user.js b/Yi.Ai.Vue3/src/utils/user.js new file mode 100644 index 00000000..786e6483 --- /dev/null +++ b/Yi.Ai.Vue3/src/utils/user.js @@ -0,0 +1,10 @@ +import { useUserStore } from '@/stores/index.js'; + +const userStore = useUserStore(); + +// 获取用户角色信息 +const userRoles = userStore.userInfo?.roles ?? []; +const isUserVip = userRoles.some(role => role.roleCode === 'YiXinAi-Vip'); +export { + isUserVip, +}; diff --git a/Yi.Ai.Vue3/types/components.d.ts b/Yi.Ai.Vue3/types/components.d.ts index 2d516763..ed55d11b 100644 --- a/Yi.Ai.Vue3/types/components.d.ts +++ b/Yi.Ai.Vue3/types/components.d.ts @@ -9,14 +9,17 @@ export {} declare module 'vue' { export interface GlobalComponents { AccountPassword: typeof import('./../src/components/LoginDialog/components/FormLogin/AccountPassword.vue')['default'] + APIKeyManagement: typeof import('./../src/components/userPersonalCenter/components/APIKeyManagement.vue')['default'] DeepThinking: typeof import('./../src/components/DeepThinking/index.vue')['default'] ElAlert: typeof import('element-plus/es')['ElAlert'] ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElButton: typeof import('element-plus/es')['ElButton'] + ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] ElCard: typeof import('element-plus/es')['ElCard'] ElCollapse: typeof import('element-plus/es')['ElCollapse'] ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElContainer: typeof import('element-plus/es')['ElContainer'] + ElDialog: typeof import('element-plus/es')['ElDialog'] ElDivider: typeof import('element-plus/es')['ElDivider'] ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElForm: typeof import('element-plus/es')['ElForm'] @@ -26,6 +29,12 @@ declare module 'vue' { ElImage: typeof import('element-plus/es')['ElImage'] ElInput: typeof import('element-plus/es')['ElInput'] ElMain: typeof import('element-plus/es')['ElMain'] + ElMenu: typeof import('element-plus/es')['ElMenu'] + ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] + ElOption: typeof import('element-plus/es')['ElOption'] + ElSelect: typeof import('element-plus/es')['ElSelect'] + ElTable: typeof import('element-plus/es')['ElTable'] + ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] FilesSelect: typeof import('./../src/components/FilesSelect/index.vue')['default'] IconSelect: typeof import('./../src/components/IconSelect/index.vue')['default'] @@ -33,12 +42,14 @@ declare module 'vue' { LoginDialog: typeof import('./../src/components/LoginDialog/index.vue')['default'] ModeList: typeof import('./../src/components/modeList/index.vue')['default'] ModelSelect: typeof import('./../src/components/ModelSelect/index.vue')['default'] + NavDialog: typeof import('./../src/components/userPersonalCenter/NavDialog.vue')['default'] Popover: typeof import('./../src/components/Popover/index.vue')['default'] QrCodeLogin: typeof import('./../src/components/LoginDialog/components/QrCodeLogin/index.vue')['default'] RegistrationForm: typeof import('./../src/components/LoginDialog/components/FormLogin/RegistrationForm.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] SvgIcon: typeof import('./../src/components/SvgIcon/index.vue')['default'] + UserManagement: typeof import('./../src/components/userPersonalCenter/components/UserManagement.vue')['default'] VerificationCode: typeof import('./../src/components/LoginDialog/components/FormLogin/VerificationCode.vue')['default'] WelecomeText: typeof import('./../src/components/WelecomeText/index.vue')['default'] } diff --git a/Yi.Ai.Vue3/types/import_meta.d.ts b/Yi.Ai.Vue3/types/import_meta.d.ts index 9b14b379..09ae0d71 100644 --- a/Yi.Ai.Vue3/types/import_meta.d.ts +++ b/Yi.Ai.Vue3/types/import_meta.d.ts @@ -6,7 +6,6 @@ interface ImportMetaEnv { readonly VITE_WEB_ENV: string; readonly VITE_WEB_BASE_API: string; readonly VITE_API_URL: string; - readonly VITE_BUILD_COMPRESS: string; readonly VITE_SSO_SEVER_URL: string; readonly VITE_SSO_CLIENT_ID: string; readonly VITE_APP_VERSION: string;