refactor: change icon
This commit is contained in:
@@ -106,6 +106,10 @@ const formatFileSize = (bytes: number): string => {
|
|||||||
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getFileExt = (fileName: string): string => {
|
||||||
|
return fileName.split('.').pop()?.toUpperCase() || 'FILE';
|
||||||
|
};
|
||||||
|
|
||||||
const getFileIcon = (fileName: string): string => {
|
const getFileIcon = (fileName: string): string => {
|
||||||
const ext = fileName.split('.').pop()?.toLowerCase();
|
const ext = fileName.split('.').pop()?.toLowerCase();
|
||||||
if (['pdf'].includes(ext || '')) return 'file-pdf';
|
if (['pdf'].includes(ext || '')) return 'file-pdf';
|
||||||
@@ -147,9 +151,19 @@ defineExpose({
|
|||||||
class="attachment-preview-item"
|
class="attachment-preview-item"
|
||||||
>
|
>
|
||||||
<div class="attachment-preview-icon">
|
<div class="attachment-preview-icon">
|
||||||
<t-icon :name="getFileIcon(attachment.name)" />
|
<svg viewBox="0 0 40 48" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="38">
|
||||||
|
<rect width="40" height="48" rx="4" fill="#4A90D9"/>
|
||||||
|
<path d="M8 6h16l8 8v28a2 2 0 01-2 2H8a2 2 0 01-2-2V8a2 2 0 012-2z" fill="#5BA3E8"/>
|
||||||
|
<path d="M24 6l8 8h-6a2 2 0 01-2-2V6z" fill="#3A7BC8"/>
|
||||||
|
<rect x="10" y="20" width="20" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||||
|
<rect x="10" y="26" width="20" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||||
|
<rect x="10" y="32" width="14" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="attachment-preview-info">
|
||||||
|
<div class="attachment-preview-name">{{ attachment.name }}</div>
|
||||||
|
<div class="attachment-preview-meta">{{ getFileExt(attachment.name) }} · {{ formatFileSize(attachment.size) }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="attachment-preview-name">{{ attachment.name }}</div>
|
|
||||||
<span class="attachment-preview-remove" @click="removeAttachment(attachment.id)" :aria-label="$t('common.remove')">×</span>
|
<span class="attachment-preview-remove" @click="removeAttachment(attachment.id)" :aria-label="$t('common.remove')">×</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -173,55 +187,66 @@ defineExpose({
|
|||||||
|
|
||||||
.attachment-preview-item {
|
.attachment-preview-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 60px;
|
display: flex;
|
||||||
height: 60px;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 8px 32px 8px 10px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid var(--td-border-level-1-color, #e7e7e7);
|
border: 1px solid var(--td-border-level-1-color, #e7e7e7);
|
||||||
background: var(--td-bg-color-secondarycontainer, #f5f5f5);
|
background: var(--td-bg-color-container, #fff);
|
||||||
display: flex;
|
max-width: 240px;
|
||||||
flex-direction: column;
|
min-width: 140px;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
|
||||||
.attachment-preview-icon {
|
.attachment-preview-icon {
|
||||||
font-size: 22px;
|
flex-shrink: 0;
|
||||||
color: var(--td-brand-color, #07C05F);
|
display: flex;
|
||||||
line-height: 1;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-preview-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment-preview-name {
|
.attachment-preview-name {
|
||||||
font-size: 10px;
|
font-size: 13px;
|
||||||
color: var(--td-text-color-secondary, #666);
|
font-weight: 500;
|
||||||
text-align: center;
|
color: var(--td-text-color-primary, #333);
|
||||||
width: 100%;
|
|
||||||
padding: 0 4px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
box-sizing: border-box;
|
}
|
||||||
|
|
||||||
|
.attachment-preview-meta {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--td-text-color-secondary, #999);
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment-preview-remove {
|
.attachment-preview-remove {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 2px;
|
top: 4px;
|
||||||
right: 2px;
|
right: 6px;
|
||||||
width: 16px;
|
width: 18px;
|
||||||
height: 16px;
|
height: 18px;
|
||||||
background: rgba(0, 0, 0, 0.5);
|
background: rgba(0, 0, 0, 0.18);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: rgba(0, 0, 0, 0.7);
|
background: rgba(0, 0, 0, 0.4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,19 @@
|
|||||||
<div v-if="hasAttachments" class="user_attachments">
|
<div v-if="hasAttachments" class="user_attachments">
|
||||||
<div v-for="(att, idx) in props.attachments" :key="idx" class="user_attachment_card">
|
<div v-for="(att, idx) in props.attachments" :key="idx" class="user_attachment_card">
|
||||||
<div class="attachment_card_icon">
|
<div class="attachment_card_icon">
|
||||||
<t-icon :name="getAttachmentIcon(att.file_name || att.file_type)" />
|
<svg viewBox="0 0 40 48" fill="none" xmlns="http://www.w3.org/2000/svg" width="36" height="44">
|
||||||
|
<rect width="40" height="48" rx="4" fill="#4A90D9"/>
|
||||||
|
<path d="M8 6h16l8 8v28a2 2 0 01-2 2H8a2 2 0 01-2-2V8a2 2 0 012-2z" fill="#5BA3E8"/>
|
||||||
|
<path d="M24 6l8 8h-6a2 2 0 01-2-2V6z" fill="#3A7BC8"/>
|
||||||
|
<rect x="10" y="20" width="20" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||||
|
<rect x="10" y="26" width="20" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||||
|
<rect x="10" y="32" width="14" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="attachment_card_info">
|
||||||
|
<div class="attachment_card_name">{{ att.file_name }}</div>
|
||||||
|
<div class="attachment_card_meta">{{ getFileExt(att.file_name) }}<span v-if="att.file_size"> · {{ formatFileSize(att.file_size) }}</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="attachment_card_name">{{ att.file_name }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="user_msg">
|
<div class="user_msg">
|
||||||
@@ -106,6 +116,10 @@ const getAttachmentIcon = (fileNameOrType) => {
|
|||||||
return 'file';
|
return 'file';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getFileExt = (fileName) => {
|
||||||
|
return (fileName || '').split('.').pop()?.toUpperCase() || 'FILE';
|
||||||
|
};
|
||||||
|
|
||||||
const formatFileSize = (bytes) => {
|
const formatFileSize = (bytes) => {
|
||||||
if (!bytes) return '';
|
if (!bytes) return '';
|
||||||
if (bytes < 1024) return bytes + ' B';
|
if (bytes < 1024) return bytes + ' B';
|
||||||
@@ -240,34 +254,46 @@ const closePreImg = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.user_attachment_card {
|
.user_attachment_card {
|
||||||
width: 60px;
|
display: flex;
|
||||||
height: 60px;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 8px 12px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid var(--td-border-level-1-color, #e7e7e7);
|
border: 1px solid var(--td-border-level-1-color, #e7e7e7);
|
||||||
background: var(--td-bg-color-secondarycontainer, #f5f5f5);
|
background: var(--td-bg-color-container, #fff);
|
||||||
display: flex;
|
max-width: 260px;
|
||||||
flex-direction: column;
|
min-width: 160px;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
|
||||||
.attachment_card_icon {
|
.attachment_card_icon {
|
||||||
font-size: 22px;
|
flex-shrink: 0;
|
||||||
color: var(--td-brand-color, #07C05F);
|
display: flex;
|
||||||
line-height: 1;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment_card_info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment_card_name {
|
.attachment_card_name {
|
||||||
font-size: 10px;
|
font-size: 13px;
|
||||||
color: var(--td-text-color-secondary, #666);
|
font-weight: 500;
|
||||||
text-align: center;
|
color: var(--td-text-color-primary, #333);
|
||||||
width: 100%;
|
|
||||||
padding: 0 4px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment_card_meta {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--td-text-color-secondary, #999);
|
||||||
|
white-space: nowrap;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user