-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Add import document view #2578
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: '当前的更改尚未保存,确认退出吗?', | ||
|
@@ -108,7 +108,7 @@ export default { | |
GENERATE: '生成中', | ||
SYNC: '同步中', | ||
REVOKE: '取消中', | ||
finish:'完成' | ||
finish: '完成' | ||
}, | ||
enableStatus: { | ||
label: '启用状态', | ||
|
@@ -149,7 +149,7 @@ export default { | |
label: '相似度高于', | ||
placeholder: '直接返回分段内容', | ||
requiredMessage: '请输入相似度' | ||
}, | ||
} | ||
}, | ||
hitHandlingMethod: { | ||
optimization: '模型优化', | ||
|
@@ -163,6 +163,12 @@ export default { | |
tip3: '标签中,系统会自动关联标签中的问题;', | ||
tip4: '生成效果依赖于所选模型和提示词,用户可自行调整至最佳效果。', | ||
prompt1: `内容:{data}\n\n请总结上面的内容,并根据内容总结生成 5 个问题。\n回答要求:\n- 请只输出问题;\n- 请将每个问题放置`, | ||
prompt2: `标签中。`, | ||
prompt2: `标签中。` | ||
}, | ||
feishu: { | ||
selectDocument: '选择文档', | ||
tip1: '仅支持文档和表格类型,文档会根据标题分段,表格会转为Markdown格式后再分段。', | ||
tip2: '系统不存储原始文档,导入文档前,建议规范文档的分段标识。', | ||
allCheck: '全选' | ||
} | ||
} | ||
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 seems to be missing some closing braces and properly formatted syntax throughout. Specifically, there are issues with the JSON structure of the file:
"enableStatus": {
placeholder: '直接返回分段内容',
requiredMessage: '请输入相似度'
{
}
"label": "相似度高于",
After fixing these issues, here's how the corrected version should look like: export default {
common: {
cancelGenerateQuestion: '取消生成问题',
cancelVectorization: '取消向量化',
cancelGenerate: '取消生成',
export: '导出'
},
tip: {
saveMessage: '当前的更改尚未保存,确认退出吗? '
},
generateResult: {
GENERATE: '生成中',
SYNC: '同步中',
REVOKE: '取消中',
finish: '完成'
},
enableStatus: {
label: '启用状态'
},
hitHandlingMethod: {
optimization: '模型优化'
},
queryConfig: {},
feishu: {
selectDocument: '选择文档',
tip1: '仅支持文档和表格类型,文档会根据标题分段,表格会转为Markdown格式后再分段。',
tip2: '系统不存储原始文档,导入文档前,建议规范文档的分段标识。',
allCheck: '全选'
}
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -765,3 +765,9 @@ h5 { | |
width: 90% !important; | ||
} | ||
} | ||
|
||
// 蓝色提示框 | ||
.update-info { | ||
background: #d6e2ff; | ||
line-height: 25px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<template> | ||
<LayoutContainer :header="$t('views.document.importDocument')" class="create-dataset"> | ||
<template #backButton> | ||
<back-button @click="back"></back-button> | ||
</template> | ||
<div class="create-dataset__main flex" v-loading="loading"> | ||
<div class="create-dataset__component main-calc-height"> | ||
<el-scrollbar> | ||
<div class="upload-document p-24"> | ||
<h4 class="title-decoration-1 mb-8"> | ||
{{ $t('views.document.feishu.selectDocument') }} | ||
</h4> | ||
<el-form | ||
ref="FormRef" | ||
:model="form" | ||
:rules="rules" | ||
label-position="top" | ||
require-asterisk-position="right" | ||
> | ||
<div class="mt-16 mb-16"> | ||
<el-radio-group v-model="form.fileType" class="app-radio-button-group"> | ||
<el-radio-button value="txt">{{ | ||
$t('views.document.fileType.txt.label') | ||
}}</el-radio-button> | ||
</el-radio-group> | ||
</div> | ||
<div class="update-info flex p-8-12 border-r-4 mb-16"> | ||
<div class="mt-4"> | ||
<AppIcon iconName="app-warning-colorful" style="font-size: 16px"></AppIcon> | ||
</div> | ||
<div class="ml-16 lighter"> | ||
<p>{{ $t('views.document.feishu.tip1') }}</p> | ||
<p>{{ $t('views.document.feishu.tip2') }}</p> | ||
</div> | ||
</div> | ||
<div class="card-never border-r-4 mb-16"> | ||
<el-checkbox | ||
v-model="allCheck" | ||
:label="$t('views.document.feishu.allCheck')" | ||
size="large" | ||
class="ml-24" | ||
/> | ||
</div> | ||
|
||
<el-tree :props="props" :load="loadNode" lazy show-checkbox /> | ||
</el-form> | ||
</div> | ||
</el-scrollbar> | ||
</div> | ||
</div> | ||
<div class="create-dataset__footer text-right border-t"> | ||
<el-button @click="router.go(-1)">{{ $t('common.cancel') }}</el-button> | ||
|
||
<el-button @click="submit" type="primary"> | ||
{{ $t('views.document.buttons.import') }} | ||
</el-button> | ||
</div> | ||
</LayoutContainer> | ||
</template> | ||
<script setup lang="ts"> | ||
import { ref, reactive, computed, onUnmounted } from 'vue' | ||
import { useRouter, useRoute } from 'vue-router' | ||
|
||
import documentApi from '@/api/document' | ||
import { MsgConfirm, MsgSuccess } from '@/utils/message' | ||
import { t } from '@/locales' | ||
import type Node from 'element-plus/es/components/tree/src/model/node' | ||
|
||
interface Tree { | ||
name: string | ||
leaf?: boolean | ||
} | ||
const router = useRouter() | ||
const route = useRoute() | ||
const { | ||
query: { id } // id为datasetID,有id的是上传文档 | ||
} = route | ||
|
||
const loading = ref(false) | ||
const disabled = ref(false) | ||
const allCheck = ref(false) | ||
const form = ref({ | ||
fileType: 'txt', | ||
fileList: [] as any | ||
}) | ||
|
||
const rules = reactive({ | ||
fileList: [ | ||
{ required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' } | ||
] | ||
}) | ||
|
||
const props = { | ||
label: 'name', | ||
children: 'zones', | ||
isLeaf: 'leaf' | ||
} | ||
|
||
const loadNode = (node: Node, resolve: (data: Tree[]) => void) => { | ||
if (node.level === 0) { | ||
return resolve([{ name: 'region' }]) | ||
} | ||
if (node.level > 1) return resolve([]) | ||
|
||
setTimeout(() => { | ||
const data: Tree[] = [ | ||
{ | ||
name: 'leaf', | ||
leaf: true | ||
}, | ||
{ | ||
name: 'zone' | ||
} | ||
] | ||
|
||
resolve(data) | ||
}, 500) | ||
} | ||
|
||
function submit() { | ||
loading.value = true | ||
} | ||
function back() { | ||
router.go(-1) | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.create-dataset { | ||
&__component { | ||
width: 100%; | ||
margin: 0 auto; | ||
overflow: hidden; | ||
} | ||
&__footer { | ||
padding: 16px 24px; | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
background: #ffffff; | ||
width: 100%; | ||
box-sizing: border-box; | ||
} | ||
.upload-document { | ||
width: 70%; | ||
margin: 0 auto; | ||
margin-bottom: 20px; | ||
} | ||
} | ||
</style> | ||
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. In this Vue component template, there are several potential improvements and issues: Improvements
<script setup lang="ts">
// Use Vue 3 imports
import { ref, reactive, computed, onUnmounted } from 'vue';
// Import necessary modules/routes/...
const datasetId = computed(() => route.query.id);
// Usage:
if (datasetId.value) {
// Do something with datasetID.value
}
Optimizations
Here’s a refined version implementing some of these points: Script SectionUpdate to composition-api: <script setup lang="ts">
import { ref, reactive, computed, onUnmounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import documentApi from '@/api/document';
import { MsgConfirm, MsgSuccess } from '@/utils/message';
import { t } from '@/locales';
interface TreeNode {
name: string;
leaf?: boolean;
}
const router = useRouter();
const route = useRoute();
const datasetId = computed(() => Number(route.query.id)); // Convert to number for numeric comparisons
const loading = ref(false);
const allCheck = ref(false);
const form = ref({
fileType: 'txt',
fileList: []
});
const rules = reactive({
fileList: [{ required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' }]
});
const props = {
label: 'name',
children: () => ['zones'],
isLeaf: 'leaf'
};
async function fetchNodes(nodeId: number | null) {
try {
const nodesData = await documentApi.fetchNodesById(nodeId ?? undefined); // Adjust based on API call params
console.log(nodesData);
} catch (error) {
console.error(error);
}
}
onMounted(async () => {
await fetchNodes(datasetId.value || -1); // Initial fetch
});
// ...rest of the functions remain unchanged but now use new methods and variables properly
</script> Stylus/Css SectionsMove styles to global/styles or scoped styles appropriately: /* app.scss */
.create-dataset {
&__component {
@include no-scrollbar; // Example mixin
}
} By addressing these improvements and optimizations, you'll have a more robust and efficient Vue component that adheres closer to best practices while still being functional. |
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.
No significant irregularities, potential issues, or optimization suggestions were found in the provided code. The only minor change is that the closing comment tag
</style>
was moved to after the final style block definition, which follows standard SCSS syntax rules.