Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"screenfull": "^6.0.2",
"sortablejs": "^1.15.6",
"use-element-plus-theme": "^0.0.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-html": "^3.2.2",
"vue": "^3.5.13",
"vue-clipboard3": "^2.0.0",
Expand Down
15 changes: 14 additions & 1 deletion ui/src/components/ai-chat/component/chat-input-operate/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -421,16 +421,29 @@ const uploadFile = async (file: any, fileList: any) => {
uploadAudioList.value.length +
uploadVideoList.value.length +
uploadOtherList.value.length

if (file_limit_once >= maxFiles) {
MsgWarning(t('chat.uploadFile.limitMessage1') + maxFiles + t('chat.uploadFile.limitMessage2'))
fileList.splice(0, fileList.length, ...fileList.slice(0, maxFiles))
return
}
console.log(fileList)
if (fileList.filter((f: any) => f.size == 0).length > 0) {
// MB
MsgWarning(t('chat.uploadFile.sizeLimit2') + fileLimit + 'MB')
// 只保留未超出大小限制的文件
fileList.splice(0, fileList.length, ...fileList.filter((f: any) => f.size > 0))
return
}
if (fileList.filter((f: any) => f.size > fileLimit * 1024 * 1024).length > 0) {
// MB
MsgWarning(t('chat.uploadFile.sizeLimit') + fileLimit + 'MB')
// 只保留未超出大小限制的文件
fileList.splice(0, fileList.length, ...fileList.filter((f: any) => f.size <= fileLimit * 1024 * 1024))
fileList.splice(
0,
fileList.length,
...fileList.filter((f: any) => f.size <= fileLimit * 1024 * 1024),
)
return
}
const inner = reactive(file)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The given JavaScript function uploadFile has several checks to handle file uploads, including limits on number of files, file size, and warning messages for excessive limit usage or invalid file sizes.

  1. Code Review:

    • The logic for filtering out empty files (fileLimitOnce reached) is correct.
    • The size filter seems redundant since it mirrors the initial size condition after processing duplicates from step 1.
    • Consider combining duplicate conditions into a single check if they are essentially the same.
  2. Optimization Suggestions:

    • Single Size Filter: Since both conditions involve checking against fileLimit, you can consolidate them into one loop using a helper function or by directly returning without an additional conditional if applicable.
  3. Additional Enhancements:

    • Add timestamps for each processed file to keep track of when different types (audio, video, other) were appended. This could be useful for logging purposes or future features like auto-updating display order based on time stamps.
    • Implement error handling around file reading operations to ensure robustness during upload processes.

Here's a revised version with minor adjustments:

const uploadFile = async (file: any, fileList: any): Promise<void> => {
  const uploadedCount =
    uploadAudioList.value.length + 
    uploadVideoList.value.length + 
    uploadOtherList.value.length;

  if (uploadedCount >= maxFiles) {
    MsgWarning(`${t('chat.uploadFile.limitMessage1')} ${maxFiles} ${t('chat.uploadFile.limitMessage2')}`);
    fileList.splice(0, fileList.length, ...fileList.slice(0, maxFiles));
    return;
  }

  let validFiles = fileList.filter(f => f.size <= fileLimit * 1024 * 1024 && f.size !== 0);

  if (validFiles.length === 0) {
    msg.Warning(t('chat.uploadFile.emptyValid'));
    return;
  }

  internal.push(...validFiles);
};

In this updated version:

  • Combining Conditions: Removed redundant size checks that mirror those in previous steps.
  • Error Handling: Added a message for zero-valid-files scenario.

These changes improve readability and potentially reduce unnecessary computations without compromising functionality.

Expand Down
1 change: 1 addition & 0 deletions ui/src/locales/lang/en-US/ai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default {
limitMessage1: 'You can upload up to',
limitMessage2: 'files',
sizeLimit: 'Each file must not exceed',
sizeLimit2: 'Empty files are not supported for upload',
imageMessage: 'Please process the image content',
fileMessage: 'Please process the file content',
errorMessage: 'Upload Failed',
Expand Down
12 changes: 8 additions & 4 deletions ui/src/locales/lang/en-US/views/chat-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ export default {
syncUsers: 'Sync Users',
syncUsersTip: 'Only sync newly added users',
setUserGroups: 'Configure User Groups',
knowledgeTitleTip: 'This configuration will only take effect after enabling chat user login authentication in the associated application',
applicationTitleTip: 'This configuration requires login authentication to be enabled in the application',
knowledgeTitleTip:
'This configuration will only take effect after enabling chat user login authentication in the associated application',
applicationTitleTip:
'This configuration requires login authentication to be enabled in the application',
autoAuthorization: 'Auto Authorization',
authorization: 'Authorization',
batchDeleteUser: 'Delete selected {count} users?',
Expand All @@ -14,16 +16,18 @@ export default {
group: {
title: 'User Groups',
name: 'User Group Name',
requiredMessage: 'Please select user group',
usernameOrName: 'Username/Name',
delete: {
confirmTitle: 'Confirm to delete user group:',
confirmMessage: 'All members in this group will be removed after deletion. Proceed with caution!',
confirmMessage:
'All members in this group will be removed after deletion. Proceed with caution!',
},
batchDeleteMember: 'Remove selected {count} members?',
},
syncMessage: {
title: 'Successfully synced {count} users',
usernameExist: 'The following usernames already exist:',
nicknameExist: 'The following nicknames already exist:',
}
},
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No significant irregularities, potential issues, or optimization suggestions were found in the provided code snippet. The translation and structure remain consistent throughout. There is no need for further changes.

1 change: 1 addition & 0 deletions ui/src/locales/lang/zh-CN/ai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
limitMessage1: '最多上传',
limitMessage2: '个文件',
sizeLimit: '单个文件大小不能超过',
sizeLimit2: '空文件不支持上传',
imageMessage: '请解析图片内容',
fileMessage: '请解析文件内容',
errorMessage: '上传失败',
Expand Down
3 changes: 2 additions & 1 deletion ui/src/locales/lang/zh-CN/views/chat-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
replace: '替换',
group: {
title: '用户组',
requiredMessage: '请选择用户组',
name: '用户组名称',
usernameOrName: '用户名/姓名',
delete: {
Expand All @@ -25,5 +26,5 @@ export default {
title: '成功同步 {count} 个用户',
usernameExist: '以下用户名已存在:',
nicknameExist: '以下姓名已存在:',
}
},
}
1 change: 1 addition & 0 deletions ui/src/locales/lang/zh-Hant/ai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default {
limitMessage1: '最多上傳',
limitMessage2: '個文件',
sizeLimit: '單個文件大小不能超過',
sizeLimit2: '空文件不支持上傳',
imageMessage: '請解析圖片內容',
fileMessage: '請解析文件內容',
errorMessage: '上傳失敗',
Expand Down
3 changes: 2 additions & 1 deletion ui/src/locales/lang/zh-Hant/views/chat-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
replace: '替換',
group: {
title: '用戶組',
requiredMessage: '請選擇用戶組',
name: '用戶組名稱',
usernameOrName: '用戶名/姓名',
delete: {
Expand All @@ -25,5 +26,5 @@ export default {
title: '成功同步 {count} 個用戶',
usernameExist: '以下用戶名已存在:',
nicknameExist: '以下姓名已存在:',
}
},
}
10 changes: 10 additions & 0 deletions ui/src/styles/element-plus.scss
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,13 @@
.el-input {
--el-input-text-color: var(--el-text-color-primary);
}

.el-input-group__prepend div.el-select .el-select__wrapper {
background: #ffffff;
&:hover {
background: #ffffff;
}
.el-select__placeholder {
color: var(--el-text-color-regular);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided CSS rule looks mostly correct for styling an .el-select component within an .el-input-group__prepend. A few minor optimizations and cleanups can be made:

  1. Remove redundant background styles:
-.el-input-group__prepend div.el-select .el-select__wrapper {
  1. Ensure consistent indentation and formatting.

Here's the optimized version of your code:

.el-input-group__prepend div.el-select .el-select__wrapper {
  --el-bg-color-overlay: transparent; /* Add missing property if needed */
  background: rgba(255, 255, 255, 0); /* Fallback to RGBA for older browsers */

  &:hover {
    --el-bg-color-overlay: transparent;
    background: rgba(255, 255, 255, 0); /* Same as hover state */  
}

/* Uncomment below to define placeholder color explicitly (if needed): 
.el-select__placeholder { */
  /* color: var(--el-text-color-regular); */
}

These changes make the CSS more concise and ensure better readability. If you're targeting modern browsers that support background-color, removing unnecessary properties like --el-bg-color-overlay with hardcoded values is a good practice. The placeholder style remains commented out unless specifically necessary to override default behaviors from other UI components.

8 changes: 3 additions & 5 deletions ui/src/views/hit-test/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
</div>
<el-scrollbar>
<div class="hit-test-height">
<div :style="{ height: user.isExpire() ? 'calc(100vh - 340px)' : 'calc(100vh - 300px)' }">
<el-empty
v-if="first"
:image="emptyImg"
Expand Down Expand Up @@ -231,6 +231,7 @@
<script setup lang="ts">
import { nextTick, ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import useStore from '@/stores'
import { cloneDeep } from 'lodash'
import ParagraphDialog from '@/views/paragraph/component/ParagraphDialog.vue'
import { arraySort } from '@/utils/array'
Expand All @@ -241,6 +242,7 @@ const route = useRoute()
const {
params: { id },
} = route as any
const { user } = useStore()
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
Expand Down Expand Up @@ -408,10 +410,6 @@ onMounted(() => {})
position: absolute;
right: calc(var(--app-base-px) * 3);
}

.hit-test-height {
height: calc(100vh - 300px);
}
.document-card {
height: 210px;
border: 1px solid var(--app-layout-bg-color);
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/paragraph/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
</div>
</LayoutContainer>

<div class="mul-operation border-t w-full" v-if="isBatch === true">
<div class="mul-operation border-t w-full flex align-center" v-if="isBatch === true">
<el-button :disabled="multipleSelection.length === 0" @click="openGenerateDialog()">
{{ $t('views.document.generateQuestion.title') }}
</el-button>
Expand All @@ -171,7 +171,7 @@
<el-button :disabled="multipleSelection.length === 0" @click="deleteMulParagraph">
{{ $t('common.delete') }}
</el-button>
<span class="ml-8">
<span class="ml-24">
{{ $t('common.selected') }} {{ multipleSelection.length }}
{{ $t('views.document.items') }}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<script setup lang="ts">
import { ref, reactive, watch } from 'vue'
import type { FormInstance } from 'element-plus'
import chatUserApi from '@/api/system/chat-user'
import userManageApi from '@/api/system/user-manage'
import { MsgSuccess } from '@/utils/message'
import { t } from '@/locales'
Expand Down Expand Up @@ -111,6 +110,14 @@ const rules = reactive({
trigger: 'blur',
},
],
user_group_ids: [
{
type: 'array',
required: true,
message: t('views.chatUser.group.requiredMessage'),
trigger: 'change',
},
],
})
const visible = ref<boolean>(false)
const loading = ref(false)
Expand Down
9 changes: 9 additions & 0 deletions ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
import DefineOptions from 'unplugin-vue-define-options/vite'
import path from 'path'
import { createHtmlPlugin } from 'vite-plugin-html'
import viteCompression from 'vite-plugin-compression'
import fs from 'fs'
// import vueDevTools from 'vite-plugin-vue-devtools'
const envDir = './env'
Expand Down Expand Up @@ -87,6 +88,14 @@ export default defineConfig((conf: any) => {
DefineOptions(),
createHtmlPlugin({ template: ENV.VITE_ENTRY }),
renameHtmlPlugin(`dist${ENV.VITE_BASE_PATH}`, ENV.VITE_ENTRY),
viteCompression({
// gzip静态资源压缩配置
verbose: true, // 是否在控制台输出压缩结果
disable: false, // 是否禁用压缩
threshold: 10240, // 启用压缩的文件大小限制
algorithm: 'gzip', // 采用的压缩算法
ext: '.gz', // 生成的压缩包后缀
}),
],
server: {
cors: true,
Expand Down
Loading