Pr@main@fix bugs (#38)

* fix:  文件上传限制文件大小

* fix: 浮窗模式的LOGO更新

* fix: 上传文档大小扩大到100MB

* fix: 创建完知识库,点击设置页面没有保存按钮

* fix: 修复提示问题
This commit is contained in:
shaohuzhang1 2024-04-09 15:56:01 +08:00 committed by GitHub
parent 633c005905
commit e9d85b007c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 40 additions and 22 deletions

View File

@ -19,13 +19,16 @@ const guideHtml=`
</div>
`
const chatButtonHtml=
`<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">
`<div class="maxkb-chat-button" ><svg width="48" height="56" viewBox="0 0 48 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d_349_49711)">
<path d="M8 24C8 12.9543 16.9543 4 28 4H48V44H28C16.9543 44 8 35.0457 8 24Z" fill="url(#paint0_linear_349_49711)"/>
</g>
<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"/>
<path d="M21.6667 23.9998H20V28.1665H21.6667V23.9998Z" fill="white"/>
<path d="M38.3333 23.9998H40V28.1665H38.3333V23.9998Z" fill="white"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<defs>
<filter id="filter0_d_349_49711" x="0" y="0" width="56" height="56" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
@ -43,6 +46,7 @@ const chatButtonHtml=
</linearGradient>
</defs>
</svg>
</div>`

View File

@ -24,12 +24,12 @@ default_pattern_list = [re.compile('(?<=^)# .*|(?<=\\n)# .*'), re.compile('(?<!#
class DocSplitHandle(BaseSplitHandle):
@staticmethod
def paragraph_to_md(paragraph):
psn = paragraph.style.name
if psn.startswith('Heading'):
try:
try:
psn = paragraph.style.name
if psn.startswith('Heading'):
return "".join(["#" for i in range(int(psn.replace("Heading ", '')))]) + " " + paragraph.text
except Exception as e:
return paragraph.text
except Exception as e:
return paragraph.text
return paragraph.text
def to_md(self, doc):

View File

@ -470,8 +470,8 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
super().is_valid(raise_exception=True)
files = self.data.get('file')
for f in files:
if f.size > 1024 * 1024 * 10:
raise AppApiException(500, "上传文件最大不能超过10m")
if f.size > 1024 * 1024 * 100:
raise AppApiException(500, "上传文件最大不能超过100MB")
@staticmethod
def get_request_params_api():

View File

@ -75,11 +75,12 @@ const getAllDocument: (dataset_id: string, loading?: Ref<boolean>) => Promise<Re
]
}
*/
const postDocument: (dataset_id: string, data: any) => Promise<Result<any>> = (
dataset_id,
data
) => {
return post(`${prefix}/${dataset_id}/document/_bach`, data)
const postDocument: (
dataset_id: string,
data: any,
loading?: Ref<boolean>
) => Promise<Result<any>> = (dataset_id, data, loading) => {
return post(`${prefix}/${dataset_id}/document/_bach`, data, {}, loading)
}
/**

View File

@ -64,6 +64,7 @@ import useStore from '@/stores'
const { dataset, document } = useStore()
const baseInfo = computed(() => dataset.baseInfo)
const webInfo = computed(() => dataset.webInfo)
const documentsFiles = computed(() => dataset.documentsFiles)
const router = useRouter()
const route = useRoute()
@ -141,7 +142,7 @@ function submit() {
}
}
function back() {
if (baseInfo.value || webInfo.value || StepSecondRef.value?.paragraphList?.length > 0) {
if (baseInfo.value || webInfo.value || documentsFiles.value?.length > 0) {
MsgConfirm(`提示`, `当前的更改尚未保存,确认退出吗?`, {
confirmButtonText: '确认',
type: 'warning'

View File

@ -73,9 +73,7 @@
</el-row>
<div class="text-right">
<el-button @click="submit" v-hasPermission="`DATASET:MANAGE:${id}`" type="primary">
保存
</el-button>
<el-button @click="submit" type="primary"> 保存 </el-button>
</div>
</div>
</el-scrollbar>

View File

@ -19,6 +19,7 @@
accept=".txt, .md, .csv, .log, .doc, .docx, .pdf"
:limit="50"
:on-exceed="onExceed"
:on-change="filehandleChange"
>
<img src="@/assets/upload-icon.svg" alt="" />
<div class="el-upload__text">
@ -27,7 +28,9 @@
<em> 选择文件上传 </em>
</p>
<div class="upload__decoration">
<p>支持格式TXTMarkdownPDFDOCDOCX每次最多上传50个文件每个文件不超过 10MB</p>
<p>
支持格式TXTMarkdownPDFDOCDOCX每次最多上传50个文件每个文件不超过 10MB
</p>
<p>若使用高级分段建议上传前规范文件的分段标识</p>
</div>
</div>
@ -57,7 +60,7 @@
</template>
<script setup lang="ts">
import { ref, reactive, onUnmounted, onMounted, computed, watch } from 'vue'
import type { UploadProps } from 'element-plus'
import type { UploadFile, UploadFiles } from 'element-plus'
import { filesize, getImgUrl } from '@/utils/utils'
import { MsgError } from '@/utils/message'
import useStore from '@/stores'
@ -79,6 +82,17 @@ function deleteFlie(index: number) {
form.value.fileList.splice(index, 1)
}
// on-change
const filehandleChange = (file: any, fileList: UploadFiles) => {
//110M
const isLimit = file?.size / 1024 / 1024 < 100
if (!isLimit) {
MsgError('文件大小超过 100MB')
fileList.splice(-1, 1) //
return false
}
}
const onExceed = () => {
MsgError('每次最多上传50个文件')
}