Skip to content

Commit e9d85b0

Browse files
authored
Pr@main@fix bugs (#38)
* fix: 文件上传限制文件大小 * fix: 浮窗模式的LOGO更新 * fix: 上传文档大小扩大到100MB * fix: 创建完知识库,点击设置页面没有保存按钮 * fix: 修复提示问题
1 parent 633c005 commit e9d85b0

File tree

7 files changed

+40
-22
lines changed

7 files changed

+40
-22
lines changed

apps/application/template/embed.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ const guideHtml=`
1919
</div>
2020
`
2121
const chatButtonHtml=
22-
`<div class="maxkb-chat-button"><svg style="vertical-align: middle;overflow: hidden;" xmlns="http://www.w3.org/2000/svg" width="48" height="56" viewBox="0 0 48 56" fill="none">
22+
`<div class="maxkb-chat-button" ><svg width="48" height="56" viewBox="0 0 48 56" fill="none" xmlns="http://www.w3.org/2000/svg">
2323
<g filter="url(#filter0_d_349_49711)">
2424
<path d="M8 24C8 12.9543 16.9543 4 28 4H48V44H28C16.9543 44 8 35.0457 8 24Z" fill="url(#paint0_linear_349_49711)"/>
2525
</g>
26-
<path d="M31.6667 15.6665H28.3333V18.1665H29.1667V19.8332H24.5833C23.6629 19.8332 22.9167 20.5794 22.9167 21.4998V30.6665C22.9167 31.587 23.6629 32.3332 24.5833 32.3332H35.4167C36.3371 32.3332 37.0833 31.587 37.0833 30.6665V21.4998C37.0833 20.5794 36.3371 19.8332 35.4167 19.8332H30.8333V18.1665H31.6667V15.6665ZM25.8333 24.8332H28.3333V27.3332H25.8333V24.8332ZM34.1667 24.8332V27.3332H31.6667V24.8332H34.1667Z" fill="white"/>
27-
<path d="M21.6667 23.9998H20V28.1665H21.6667V23.9998Z" fill="white"/>
28-
<path d="M38.3333 23.9998H40V28.1665H38.3333V23.9998Z" fill="white"/>
26+
<path d="M31.2632 30.2754H28.1992L27.0636 31.411C26.9971 31.4775 26.9518 31.5623 26.9335 31.6546C26.9151 31.7468 26.9245 31.8425 26.9605 31.9294C26.9965 32.0163 27.0575 32.0906 27.1357 32.1429C27.2139 32.1951 27.3059 32.223 27.4 32.223H32.0625C32.1566 32.223 32.2486 32.1951 32.3268 32.1429C32.405 32.0906 32.466 32.0163 32.502 31.9294C32.538 31.8425 32.5474 31.7468 32.529 31.6546C32.5107 31.5623 32.4654 31.4775 32.3989 31.411L31.2632 30.2754Z" fill="white"/>
27+
<path d="M39.6831 21.3652H39.0791V25.6142H39.6831C39.8051 25.6142 39.9221 25.5657 40.0083 25.4795C40.0945 25.3932 40.143 25.2763 40.143 25.1543V21.8251C40.143 21.7031 40.0945 21.5862 40.0083 21.4999C39.9221 21.4137 39.8051 21.3652 39.6831 21.3652Z" fill="white"/>
28+
<path d="M20.9208 21.3652H20.3168C20.1948 21.3652 20.0779 21.4137 19.9916 21.4999C19.9054 21.5862 19.8569 21.7031 19.8569 21.8251V25.1543C19.8569 25.2763 19.9054 25.3932 19.9916 25.4795C20.0779 25.5657 20.1948 25.6142 20.3168 25.6142H20.9208V21.3652Z" fill="white"/>
29+
<path d="M32.3323 21.9277C32.1041 21.9277 31.8854 22.0184 31.7241 22.1796C31.5628 22.3409 31.4722 22.5597 31.4722 22.7878V23.4045C31.4722 23.6326 31.5628 23.8514 31.7241 24.0127C31.8854 24.174 32.1042 24.2646 32.3323 24.2646C32.5604 24.2646 32.7792 24.174 32.9405 24.0127C33.1018 23.8514 33.1924 23.6326 33.1924 23.4045V22.7878C33.1924 22.6749 33.1702 22.563 33.1269 22.4587C33.0837 22.3543 33.0204 22.2595 32.9405 22.1796C32.8606 22.0998 32.7658 22.0364 32.6614 21.9932C32.5571 21.95 32.4452 21.9277 32.3323 21.9277Z" fill="white"/>
30+
<path d="M27.8464 21.9277C27.6183 21.9277 27.3995 22.0184 27.2382 22.1796C27.0769 22.3409 26.9863 22.5597 26.9863 22.7878V23.4045C26.9863 23.6326 27.0769 23.8514 27.2383 24.0127C27.3996 24.174 27.6183 24.2646 27.8465 24.2646C28.0746 24.2646 28.2933 24.174 28.4547 24.0127C28.616 23.8514 28.7066 23.6326 28.7066 23.4045V22.7878C28.7066 22.6749 28.6843 22.563 28.6411 22.4587C28.5979 22.3543 28.5345 22.2595 28.4546 22.1796C28.3748 22.0998 28.2799 22.0364 28.1756 21.9932C28.0712 21.95 27.9594 21.9277 27.8464 21.9277Z" fill="white"/>
31+
<path d="M35.2258 17.0488H24.7738C23.8508 17.0499 22.9659 17.417 22.3133 18.0696C21.6606 18.7223 21.2935 19.6071 21.2925 20.5301V26.4227C21.2935 27.3457 21.6606 28.2306 22.3133 28.8832C22.9659 29.5359 23.8508 29.903 24.7738 29.904H35.2258C36.1488 29.903 37.0336 29.5359 37.6863 28.8832C38.3389 28.2306 38.7061 27.3457 38.7071 26.4227V20.5301C38.7061 19.6071 38.3389 18.7223 37.6863 18.0696C37.0336 17.417 36.1488 17.0499 35.2258 17.0488ZM35.5181 26.3875C35.5181 26.5538 35.452 26.7133 35.3344 26.8309C35.2168 26.9485 35.0573 27.0146 34.891 27.0146H29.7929C29.0215 27.0146 28.2631 27.2129 27.5904 27.5903L25.8801 28.55V27.0146H25.1086C24.9422 27.0146 24.7827 26.9486 24.6651 26.831C24.5475 26.7134 24.4815 26.5539 24.4815 26.3876V20.1408C24.4815 19.9745 24.5475 19.815 24.6651 19.6974C24.7827 19.5798 24.9422 19.5137 25.1086 19.5137H34.891C35.0573 19.5137 35.2168 19.5798 35.3344 19.6974C35.452 19.815 35.5181 19.9745 35.5181 20.1408V26.3875Z" fill="white"/>
2932
<defs>
3033
<filter id="filter0_d_349_49711" x="0" y="0" width="56" height="56" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3134
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
@@ -43,6 +46,7 @@ const chatButtonHtml=
4346
</linearGradient>
4447
</defs>
4548
</svg>
49+
4650
</div>`
4751

4852

apps/common/handle/impl/doc_split_handle.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
class DocSplitHandle(BaseSplitHandle):
2525
@staticmethod
2626
def paragraph_to_md(paragraph):
27-
psn = paragraph.style.name
28-
if psn.startswith('Heading'):
29-
try:
27+
try:
28+
psn = paragraph.style.name
29+
if psn.startswith('Heading'):
3030
return "".join(["#" for i in range(int(psn.replace("Heading ", '')))]) + " " + paragraph.text
31-
except Exception as e:
32-
return paragraph.text
31+
except Exception as e:
32+
return paragraph.text
3333
return paragraph.text
3434

3535
def to_md(self, doc):

apps/dataset/serializers/document_serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ def is_valid(self, *, raise_exception=True):
470470
super().is_valid(raise_exception=True)
471471
files = self.data.get('file')
472472
for f in files:
473-
if f.size > 1024 * 1024 * 10:
474-
raise AppApiException(500, "上传文件最大不能超过10m")
473+
if f.size > 1024 * 1024 * 100:
474+
raise AppApiException(500, "上传文件最大不能超过100MB")
475475

476476
@staticmethod
477477
def get_request_params_api():

ui/src/api/document.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ const getAllDocument: (dataset_id: string, loading?: Ref<boolean>) => Promise<Re
7575
]
7676
}
7777
*/
78-
const postDocument: (dataset_id: string, data: any) => Promise<Result<any>> = (
79-
dataset_id,
80-
data
81-
) => {
82-
return post(`${prefix}/${dataset_id}/document/_bach`, data)
78+
const postDocument: (
79+
dataset_id: string,
80+
data: any,
81+
loading?: Ref<boolean>
82+
) => Promise<Result<any>> = (dataset_id, data, loading) => {
83+
return post(`${prefix}/${dataset_id}/document/_bach`, data, {}, loading)
8384
}
8485

8586
/**

ui/src/views/dataset/CreateDataset.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import useStore from '@/stores'
6464
const { dataset, document } = useStore()
6565
const baseInfo = computed(() => dataset.baseInfo)
6666
const webInfo = computed(() => dataset.webInfo)
67+
const documentsFiles = computed(() => dataset.documentsFiles)
6768
6869
const router = useRouter()
6970
const route = useRoute()
@@ -141,7 +142,7 @@ function submit() {
141142
}
142143
}
143144
function back() {
144-
if (baseInfo.value || webInfo.value || StepSecondRef.value?.paragraphList?.length > 0) {
145+
if (baseInfo.value || webInfo.value || documentsFiles.value?.length > 0) {
145146
MsgConfirm(`提示`, `当前的更改尚未保存,确认退出吗?`, {
146147
confirmButtonText: '确认',
147148
type: 'warning'

ui/src/views/dataset/DatasetSetting.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@
7373
</el-row>
7474

7575
<div class="text-right">
76-
<el-button @click="submit" v-hasPermission="`DATASET:MANAGE:${id}`" type="primary">
77-
保存
78-
</el-button>
76+
<el-button @click="submit" type="primary"> 保存 </el-button>
7977
</div>
8078
</div>
8179
</el-scrollbar>

ui/src/views/dataset/component/UploadComponent.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
accept=".txt, .md, .csv, .log, .doc, .docx, .pdf"
2020
:limit="50"
2121
:on-exceed="onExceed"
22+
:on-change="filehandleChange"
2223
>
2324
<img src="@/assets/upload-icon.svg" alt="" />
2425
<div class="el-upload__text">
@@ -27,7 +28,9 @@
2728
<em> 选择文件上传 </em>
2829
</p>
2930
<div class="upload__decoration">
30-
<p>支持格式:TXT、Markdown、PDF、DOC、DOCX,每次最多上传50个文件,每个文件不超过 10MB</p>
31+
<p>
32+
支持格式:TXT、Markdown、PDF、DOC、DOCX,每次最多上传50个文件,每个文件不超过 10MB
33+
</p>
3134
<p>若使用【高级分段】建议上传前规范文件的分段标识</p>
3235
</div>
3336
</div>
@@ -57,7 +60,7 @@
5760
</template>
5861
<script setup lang="ts">
5962
import { ref, reactive, onUnmounted, onMounted, computed, watch } from 'vue'
60-
import type { UploadProps } from 'element-plus'
63+
import type { UploadFile, UploadFiles } from 'element-plus'
6164
import { filesize, getImgUrl } from '@/utils/utils'
6265
import { MsgError } from '@/utils/message'
6366
import useStore from '@/stores'
@@ -79,6 +82,17 @@ function deleteFlie(index: number) {
7982
form.value.fileList.splice(index, 1)
8083
}
8184
85+
// 上传on-change事件
86+
const filehandleChange = (file: any, fileList: UploadFiles) => {
87+
//1、判断文件大小是否合法,文件限制不能大于10M
88+
const isLimit = file?.size / 1024 / 1024 < 100
89+
if (!isLimit) {
90+
MsgError('文件大小超过 100MB')
91+
fileList.splice(-1, 1) //移除当前超出大小的文件
92+
return false
93+
}
94+
}
95+
8296
const onExceed = () => {
8397
MsgError('每次最多上传50个文件')
8498
}

0 commit comments

Comments
 (0)