refactor(ui): 调整左右布局v1

- 将所有API接口中的String类型统一改为string类型
- 修改EchartsRander组件中option变量声明为const
- 调整FormItem组件中validator变量声明为const
- 更新侧边栏样式为固定宽度240px并重新设计布局结构
- 移除主布局中的头部组件和相关主题配置逻辑
- 调整布局容器最小宽度从240调整为260
v3.2
tanlianwang 2026-03-04 09:28:09 +08:00
parent bcb3afa17c
commit 8263ab2009
11 changed files with 76 additions and 93 deletions

View File

@ -43,7 +43,7 @@ const postChatLogAddKnowledge: (
} }
*/ */
const getChatLog: ( const getChatLog: (
application_id: String, application_id: string,
page: pageRequest, page: pageRequest,
param: any, param: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
@ -61,8 +61,8 @@ const getChatLog: (
* application_id, chart_id,order_asc * application_id, chart_id,order_asc
*/ */
const getChatRecordLog: ( const getChatRecordLog: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
page: pageRequest, page: pageRequest,
loading?: Ref<boolean>, loading?: Ref<boolean>,
order_asc?: boolean, order_asc?: boolean,
@ -108,11 +108,11 @@ const getMarkChatRecord: (
} }
*/ */
const putChatRecordLog: ( const putChatRecordLog: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
chart_record_id: String, chart_record_id: string,
knowledge_id: String, knowledge_id: string,
document_id: String, document_id: string,
data: any, data: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = ( ) => Promise<Result<any>> = (
@ -138,12 +138,12 @@ const putChatRecordLog: (
* application_id, chart_id, chart_record_id, knowledge_id, document_id,paragraph_id * application_id, chart_id, chart_record_id, knowledge_id, document_id,paragraph_id
*/ */
const delMarkChatRecord: ( const delMarkChatRecord: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
chart_record_id: String, chart_record_id: string,
knowledge_id: String, knowledge_id: string,
document_id: String, document_id: string,
paragraph_id: String, paragraph_id: string,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = ( ) => Promise<Result<any>> = (
application_id, application_id,

View File

@ -80,7 +80,7 @@ const putKnowledge: (
* *
* @param knowledge_id * @param knowledge_id
*/ */
const delKnowledge: (knowledge_id: String, loading?: Ref<boolean>) => Promise<Result<boolean>> = ( const delKnowledge: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
knowledge_id, knowledge_id,
loading, loading,
) => { ) => {

View File

@ -30,7 +30,7 @@ const postChatLogAddKnowledge: (
} }
*/ */
const getChatLog: ( const getChatLog: (
application_id: String, application_id: string,
page: pageRequest, page: pageRequest,
param: any, param: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
@ -48,8 +48,8 @@ const getChatLog: (
* application_id, chart_id,order_asc * application_id, chart_id,order_asc
*/ */
const getChatRecordLog: ( const getChatRecordLog: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
page: pageRequest, page: pageRequest,
loading?: Ref<boolean>, loading?: Ref<boolean>,
order_asc?: boolean, order_asc?: boolean,
@ -90,11 +90,11 @@ const getMarkChatRecord: (
} }
*/ */
const putChatRecordLog: ( const putChatRecordLog: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
chart_record_id: String, chart_record_id: string,
knowledge_id: String, knowledge_id: string,
document_id: String, document_id: string,
data: any, data: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = ( ) => Promise<Result<any>> = (
@ -120,12 +120,12 @@ const putChatRecordLog: (
* application_id, chart_id, chart_record_id, knowledge_id, document_id,paragraph_id * application_id, chart_id, chart_record_id, knowledge_id, document_id,paragraph_id
*/ */
const delMarkChatRecord: ( const delMarkChatRecord: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
chart_record_id: String, chart_record_id: string,
knowledge_id: String, knowledge_id: string,
document_id: String, document_id: string,
paragraph_id: String, paragraph_id: string,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = ( ) => Promise<Result<any>> = (
application_id, application_id,

View File

@ -72,7 +72,7 @@ const putKnowledge: (
* *
* @param knowledge_id * @param knowledge_id
*/ */
const delKnowledge: (knowledge_id: String, loading?: Ref<boolean>) => Promise<Result<boolean>> = ( const delKnowledge: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
knowledge_id, knowledge_id,
loading, loading,
) => { ) => {

View File

@ -73,7 +73,7 @@ const putKnowledge: (
* *
* @param knowledge_id * @param knowledge_id
*/ */
const delKnowledge: (knowledge_id: String, loading?: Ref<boolean>) => Promise<Result<boolean>> = ( const delKnowledge: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
knowledge_id, knowledge_id,
loading, loading,
) => { ) => {

View File

@ -96,7 +96,7 @@ const getToolById: (tool_id: string, loading?: Ref<boolean>) => Promise<Result<a
* *
* @param tool_id * @param tool_id
*/ */
const delTool: (tool_id: String, loading?: Ref<boolean>) => Promise<Result<boolean>> = ( const delTool: (tool_id: string, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
tool_id, tool_id,
loading, loading,
) => { ) => {

View File

@ -133,7 +133,7 @@ const errMsg = computed(() => {
*/ */
const to_rule = (rule: any) => { const to_rule = (rule: any) => {
if (rule.validator) { if (rule.validator) {
let validator = (rule: any, value: string, callback: any) => {} const validator = (rule: any, value: string, callback: any) => {}
eval(rule.validator) eval(rule.validator)
return { ...rule, validator } return { ...rule, validator }
} }

View File

@ -42,7 +42,7 @@ const props = defineProps({
resizable: Boolean, resizable: Boolean,
minLeftWidth: { minLeftWidth: {
type: Number, type: Number,
default: 240, default: 260,
}, },
maxLeftWidth: { maxLeftWidth: {
type: Number, type: Number,

View File

@ -44,7 +44,7 @@ function evalParseOption(option_json: any) {
if (option_json.style) { if (option_json.style) {
style.value = option_json.style style.value = option_json.style
} }
let option = {} const option = {}
tmp.value = echarts tmp.value = echarts
eval(option_json.option) eval(option_json.option)
return option return option

View File

@ -1,55 +1,55 @@
<template> <template>
<div class="sidebar p-8"> <div class="sidebar" style="display: flex; flex-direction: column; height: 100vh; background-color: #F9FAFB; width: 240px;">
<div v-if="showBreadcrumb"> <!-- 顶部 Logo -->
<AppBreadcrumb /> <div style="padding: 16px;">
<h1 style="font-size: 18px; font-weight: 600; margin: 0;">AI-RAG</h1>
</div>
<!-- 一级业务菜单 -->
<div style="padding: 0 16px;">
<div style="display: flex; flex-direction: column; gap: 8px;">
<router-link to="/application" style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;" :style="activeMainMenu === '/application' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}">
应用
</router-link>
<router-link to="/knowledge" style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;" :style="activeMainMenu === '/knowledge' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}">
知识库
</router-link>
<router-link to="/tool" style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;" :style="activeMainMenu === '/tool' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}">
工具
</router-link>
<router-link to="/model" style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;" :style="activeMainMenu === '/model' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}">
模型
</router-link>
</div>
</div>
<!-- 底部用户信息区 -->
<div style="margin-top: auto; padding: 16px; border-top: 1px solid #e5e7eb;">
<UserAvatar />
</div> </div>
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu :default-active="activeMenu" router>
<sidebar-item
v-hasPermission="menu.meta?.permission"
v-for="(menu, index) in subMenuList"
:key="index"
:menu="menu"
:activeMenu="activeMenu"
>
</sidebar-item>
</el-menu>
</el-scrollbar>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { getChildRouteListByPathAndName } from '@/router/index' import UserAvatar from '@/layout/layout-header/avatar/index.vue'
import SidebarItem from './SidebarItem.vue'
import AppBreadcrumb from './../breadcrumb/index.vue'
const route = useRoute() const route = useRoute()
const showBreadcrumb = computed(() => { const activeMainMenu = computed(() => {
const { meta } = route as any const path = route.path
return meta?.breadcrumb if (path.startsWith('/application')) return '/application'
if (path.startsWith('/knowledge')) return '/knowledge'
if (path.startsWith('/tool')) return '/tool'
if (path.startsWith('/model')) return '/model'
return '/application'
}) })
const subMenuList = computed(() => { const activeSubMenu = computed(() => {
const { meta } = route const path = route.path
return getChildRouteListByPathAndName(meta.parentPath, meta.parentName) return path
})
const activeMenu = computed(() => {
const { path, meta } = route
return meta.active || path
}) })
</script> </script>
<style lang="scss">
.sidebar {
.el-menu {
height: 100%;
border: none;
background: none;
max-height: calc(100vh - 100px);
}
}
</style>

View File

@ -1,17 +1,5 @@
<template> <template>
<div class="app-layout"> <div class="app-layout">
<div class="app-header" :class="!isDefaultTheme ? 'custom-header' : ''">
<el-alert
v-if="user.isExpire()"
:title="$t('layout.isExpire')"
type="warning"
class="border-b"
show-icon
:closable="false"
/>
<SystemHeader v-if="isShared"></SystemHeader>
<UserHeader v-else />
</div>
<div class="app-main" :class="user.isExpire() ? 'isExpire' : ''"> <div class="app-main" :class="user.isExpire() ? 'isExpire' : ''">
<layout-container> <layout-container>
<template #left> <template #left>
@ -24,8 +12,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import UserHeader from '@/layout/layout-header/UserHeader.vue'
import SystemHeader from '@/layout/layout-header/SystemHeader.vue'
import Sidebar from '@/layout/components/sidebar/index.vue' import Sidebar from '@/layout/components/sidebar/index.vue'
import AppMain from '@/layout/app-main/index.vue' import AppMain from '@/layout/app-main/index.vue'
import useStore from '@/stores' import useStore from '@/stores'
@ -43,10 +29,7 @@ const isShared = computed(() => {
route.path.includes('resource-management') route.path.includes('resource-management')
) )
}) })
const { theme, user } = useStore() const { user } = useStore()
const isDefaultTheme = computed(() => {
return theme.isDefaultTheme()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@use './index.scss'; @use './index.scss';