Repository navigation
fix: web icon #7842
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
fix: web icon #7842
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,12 +5,10 @@ import MkEditName from '@/components/mk-edit-name/index.vue' | |||||||||||||||
| import { MsgSuccess } from '@/utils/message' | ||||||||||||||||
| import { useKnowledgeDetailContext } from '@/views/knowledge-detail/context' | ||||||||||||||||
| import ParagraphDialog from '@/views/document-detail/paragraph-dialog/ParagraphDialog.vue' | ||||||||||||||||
| import fileImageIcon from '@/assets/file-type/file-image-icon.svg' | ||||||||||||||||
| import { getFileIconUrl } from '@/utils/icon' | ||||||||||||||||
| import { getFileUrl } from '@/utils/common' | ||||||||||||||||
| import { DOCUMENT_RESOURCE_TYPE } from '@/api/enums' | ||||||||||||||||
| import { KNOWLEDGE_TYPE_KEY, KNOWLEDGE_TYPE_MAP } from '@/constants/knowledge' | ||||||||||||||||
| import { isWorkspaceSharedResource,isSystemResource, isSystemSharedResource } from '@/utils/resource-context' | ||||||||||||||||
| import { isWorkspaceSharedResource, isSystemResource, isSystemSharedResource } from '@/utils/resource-context' | ||||||||||||||||
| import { perm } from '@/permission' | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
|
|
@@ -158,14 +156,13 @@ defineExpose({ refresh: handleLoadParagraphs }) | |||||||||||||||
| <div class="flex-align-center gap-2 text-sm text-N600"> | ||||||||||||||||
| <span class="shrink-0">{{ paragraph.content.length }} 字符</span> | ||||||||||||||||
| <el-divider direction="vertical" /> | ||||||||||||||||
| <img v-if="paragraph.document_resource_type === DOCUMENT_RESOURCE_TYPE.IMAGE" :src="fileImageIcon" class="size-4 shrink-0" /> | ||||||||||||||||
| <img | ||||||||||||||||
| v-else-if="paragraph.knowledge_type != null && KNOWLEDGE_TYPE_MAP[paragraph.knowledge_type] === KNOWLEDGE_TYPE_KEY.WEB" | ||||||||||||||||
| src="@/assets/file-type/web-link-icon.svg" | ||||||||||||||||
| :src=" | ||||||||||||||||
| getFileIconUrl(paragraph.document_name, paragraph.knowledge_type, paragraph.document_resource_type === DOCUMENT_RESOURCE_TYPE.IMAGE) | ||||||||||||||||
| " | ||||||||||||||||
| alt="" | ||||||||||||||||
| class="size-4 shrink-0" | ||||||||||||||||
| /> | ||||||||||||||||
| <img v-else :src="getFileIconUrl(paragraph.document_name)" class="size-4 shrink-0" alt="" /> | ||||||||||||||||
| <span class="truncate" :title="paragraph.document_name">{{ paragraph.document_name }}</span> | ||||||||||||||||
| </div> | ||||||||||||||||
| </el-card> | ||||||||||||||||
|
|
@@ -175,7 +172,7 @@ defineExpose({ refresh: handleLoadParagraphs }) | |||||||||||||||
| </div> | ||||||||||||||||
| <template #footer> | ||||||||||||||||
| <!-- 关联当前问题的分段 --> | ||||||||||||||||
| <el-button plain :disabled="loading" v-if="knowledgeProblemPermission('problemRelate')" @click="emit('associate')">关联分段</el-button> | ||||||||||||||||
| <el-button plain :disabled="loading" v-if="knowledgeProblemPermission('problemRelate')" @click="emit('associate')">关联分段</el-button> | ||||||||||||||||
| <!-- 查看上一个问题 --> | ||||||||||||||||
| <el-button plain :disabled="loading || !hasPrevious" @click="emit('previous')">上一个</el-button> | ||||||||||||||||
| <!-- 查看下一个问题 --> | ||||||||||||||||
|
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. Code Review1. Unused imports removed — good, but verify
2. Signature change of
|
||||||||||||||||
| Item | Verdict |
|---|---|
| Removed unused imports | ✅ Good (verify truly unused) |
| Consolidated icon logic | ✅ Good, but depends on getFileIconUrl supporting new args |
New getFileIconUrl args |
null handling, and behavioral parity |
| Positional boolean arg | 💡 Suggest options object |
Inline multi-line :src |
💡 Consider computed function |
| Whitespace-only edit | ℹ️ Separate from functional changes |
Key action: Confirm the updated getFileIconUrl implementation exists in @/utils/icon with matching params; otherwise the image/web-link icons will regress.
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.
Code Review
Potential Issues
getFileIconUrlsignature mismatch riskThe original call passes only
documentName. The new call passes three arguments including a boolean derived fromparagraph.documentResourceType === DOCUMENT_RESOURCE_TYPE.IMAGE. Ensure the utility actually accepts these new params (and their order/types match). If not, this will silently produce wrong icons.paragraph.knowledgeTypemay be undefined / not part of the typeVerify the paragraph model declares
knowledgeTypeanddocumentResourceType. IfDOCUMENT_RESOURCE_TYPEisn't exhaustive or these fields are optional, guard with a fallback to avoid runtime surprises.Order change of
MdPreviewvsel-imageMoving
MdPreviewbelow the image changes visual/output semantics: previously content rendered before the image, now after. Confirm this is intentional (e.g., captions/image-first layout). Also, ifparagraph.contentitself contains images, the manualel-imageplus markdown images could duplicate rendering — verify no double-render.fit="contain"+ removed width classDropping
w-full rounded-lgwhile switching tocontainmay collapse the image size for small/portrait images (no explicit width). Consider addingw-fullback or explicit max sizing to keep layout consistent.size-6vs priorwidth="24"size-6= 1.5rem (24px assuming default root 16px), so equivalent only if root font-size is default. If the app scales rem, icon size differs from the old fixed24px. Minor, but worth confirming intent.Optimization Suggestions
isImageResourceper item, keeping template cleaner.el-image'saltusesparagraph.title; ensure it's meaningful (empty alt is better for decorative images). Fine as-is if title is descriptive.:srchurts readability; extracting to a helper or computed improves maintainability.DOCUMENT_RESOURCE_TYPE.IMAGEexists at compile time (typo-safety); importing the enum is good practice.Summary
Main risks are the changed
getFileIconUrlcontract, possible undefined fields, and the intentional reorder/style changes. Verify the utility signature and paragraph typing, then this diff is otherwise clean.