-
Notifications
You must be signed in to change notification settings - Fork 2.8k
refactor: lark #2729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: lark #2729
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ export default { | |
| cancelGenerateQuestion: '取消生成問題', | ||
| cancelVectorization: '取消向量化', | ||
| cancelGenerate: '取消生成', | ||
| export: '匯出', | ||
| export: '匯出' | ||
| }, | ||
| tip: { | ||
| saveMessage: '當前的更改尚未保存,確認退出嗎?', | ||
|
|
@@ -149,7 +149,7 @@ export default { | |
| label: '相似度高于', | ||
| placeholder: '直接返回分段内容', | ||
| requiredMessage: '请输入相似度' | ||
| }, | ||
| } | ||
| }, | ||
| hitHandlingMethod: { | ||
| optimization: '模型優化', | ||
|
|
@@ -163,12 +163,13 @@ export default { | |
| tip3: '標籤中,系統會自動關聯標籤中的問題;', | ||
| tip4: '生成效果取決於所選模型和提示詞,用戶可自行調整至最佳效果。', | ||
| prompt1: `內容:{data}\n\n請總結上面的內容,並根據內容總結生成 5 個問題。\n回答要求:\n - 請只輸出問題;\n - 請將每個問題放置在`, | ||
| prompt2: `標籤中。`, | ||
| prompt2: `標籤中。` | ||
| }, | ||
| feishu: { | ||
| selectDocument: '選擇文檔', | ||
| tip1: '僅支持文檔和表格類型,文檔會根據標題分段,表格會轉為Markdown格式後再分段。', | ||
| tip1: '支持檔案和表格類型飛書檔案、支持TXT、Markdown、PDF、DOCX、HTML、XLS、XLSX、CSV、ZIP飛書檔案,檔案會根據標題分段,表格會轉為Markdown格式後再分段。', | ||
| tip2: '系統不存儲原始文檔,導入文檔前,建議規範文檔的分段標識。', | ||
| allCheck: '全選' | ||
| allCheck: '全選', | ||
| errorMessage1: '請選擇文檔' | ||
| } | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The given code is syntactically correct and does not appear to have any significant logical errors or issues. However, here are some minor suggestion for optimization:
Overall, the code adheres well to best practices without any immediate issues. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ | |
| @change="handleAllCheckChange" | ||
| /> | ||
| </div> | ||
| <div style="height:calc(100vh - 430px)"> | ||
| <div style="height: calc(100vh - 430px)"> | ||
| <el-scrollbar> | ||
| <el-tree | ||
| :props="props" | ||
|
|
@@ -63,13 +63,55 @@ | |
| src="@/assets/fileType/docx-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.type === 'docx'" | ||
| v-else-if="data.type === 'docx' || data.name.endsWith('.docx')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/xlsx-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.type === 'sheet'" | ||
| v-else-if="data.type === 'sheet' || data.name.endsWith('.xlsx')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/xls-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('xls')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/csv-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('csv')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/pdf-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('.pdf')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/html-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('.html')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/txt-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('.txt')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/zip-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('.zip')" | ||
| /> | ||
| <img | ||
| src="@/assets/fileType/md-icon.svg" | ||
| alt="" | ||
| height="22" | ||
| v-else-if="data.name.endsWith('.md')" | ||
| /> | ||
|
|
||
| <span class="ml-4">{{ node.label }}</span> | ||
|
|
@@ -94,7 +136,7 @@ | |
| <script setup lang="ts"> | ||
| import { ref, reactive, computed, onUnmounted } from 'vue' | ||
| import { useRouter, useRoute } from 'vue-router' | ||
| import { MsgConfirm, MsgSuccess } from '@/utils/message' | ||
| import { MsgConfirm, MsgSuccess, MsgWarning } from '@/utils/message' | ||
| import { getImgUrl } from '@/utils/utils' | ||
| import { t } from '@/locales' | ||
| import type Node from 'element-plus/es/components/tree/src/model/node' | ||
|
|
@@ -186,6 +228,12 @@ function submit() { | |
| type: node.type | ||
| } | ||
| }) | ||
| if (newList.length === 0) { | ||
| disabled.value = false | ||
| MsgWarning(t('views.document.feishu.errorMessage1')) | ||
| loading.value = false | ||
| return | ||
| } | ||
| dataset | ||
| .importLarkDocument(datasetId, newList, loading) | ||
| .then((res) => { | ||
|
|
@@ -230,6 +278,7 @@ function back() { | |
| margin-bottom: 20px; | ||
| } | ||
| } | ||
|
|
||
| .xlsx-icon { | ||
| svg { | ||
| width: 24px; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code appears to be well-written with no apparent structural errors. However, there are a few improvements and suggestions that could enhance its robustness and readability: Improvements:
Here's the revised part of the code highlighting these suggestions: <template>
<!-- ... (rest of the template remains unchanged) -->
</template>
<script setup lang="ts">
// ...
if (!node.name || !['.doc', '.xls'].includes(node.name)) {
const errorMsgMap: Record<string, string> = {
docx: t('views.document.feishu.errorMessage2'),
sheet: t('views.document.feishu.errorMessage3')
};
if (errorMsgMap[node.type] && !data.name.startsWith('.')) {
MsgWarning(errorMsgMap[data.type]);
disabled.value = false;
loading.value = false;
return;
}
// Alternatively, use a default message
MsgWarning(t('views.document.feishu.errorMessage4'));
} else {
// Continue processing the node
}
// ...Explanation of Changes:
These changes make the code cleaner, maintainable, and user-friendly. If additional handling is required based on file names instead of extensions, further customization can be done within the existing logic. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appear to be a few potential improvements and corrections in the provided code:
Typography Correction:
The
tip1text has been edited for better readability and consistency. The original sentence mentions "Feishu documents" while using it both capitalized and lowercase.Code Formatting:
Ensure consistent spacing between curly braces
{}and other punctuation marks around identifiers.Comments:
Consider adding comments explaining the purpose of each function or key within the object literal.
String Concatenation:
Use template literals (
\at the end) for multiple-line strings for improved clarity and conciseness.Here's a revised version of the code with these suggestions applied:
These changes make the code more readable and maintainable.