refactor timi-web

This commit is contained in:
Timi
2026-08-27 16:04:06 +08:00
parent 13bd61326d
commit 7ef7653deb
33 changed files with 1193 additions and 1097 deletions
@@ -1,19 +1,30 @@
<template>
<t-button variant="outline" :theme="active ? 'primary' : 'default'" :loading="uploading" @click="openDialog">
<t-button :variant="active ? 'base' : 'text'" :theme="active ? 'light' : 'default'" :loading="uploading" @click="openDialog">
<t-icon :name="iconName" />
</t-button>
<t-popup
<bottom-popup
v-model="visible"
placement="bottom"
:title="`插入${typeLabel}`"
left-button-text="取消"
right-button-text="插入"
@left-button-click="visible = false"
@right-button-click="onConfirm"
destroy-on-close
>
<template #rightButton="{ onClick }">
<t-button
theme="primary"
variant="text"
size="small"
:loading="uploading"
:disabled="uploading"
@click="onClick"
>
插入
</t-button>
</template>
<div class="form-popup">
<div class="popup-head">
<span class="title" v-text="`插入${typeLabel}`" />
<t-button shape="square" size="small" variant="text" title="关闭" @click="visible = false">
<t-icon name="close" />
</t-button>
</div>
<t-form class="form-content" label-align="left" label-width="auto">
<t-form-item label="文件">
<t-button size="small" variant="outline" @click="pickFile">
@@ -31,18 +42,15 @@
<t-input v-model="mediaForm.height" placeholder="请输入高度,默认 auto" />
</t-form-item>
</t-form>
<div class="popup-actions">
<t-button variant="outline" block :disabled="uploading" @click="visible = false">取消</t-button>
<t-button theme="primary" block :loading="uploading" @click="onConfirm">插入</t-button>
</div>
</div>
</t-popup>
</bottom-popup>
<input ref="fileInputRef" class="file-input" type="file" :accept="accept" @change="onFileChange" />
</template>
<script lang="ts" setup>
import { showPlatformMessage } from "../message";
import type { TiptapEditorInstance, UploadResult } from "timi-web/editor";
import BottomPopup from "../bottom-popup/index.vue";
defineOptions({
name: "TiptapMediaButton"
@@ -180,34 +188,12 @@ async function onConfirm() {
overflow-y: auto;
background: var(--td-bg-color-container);
.popup-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
.title {
font-size: 1rem;
font-weight: 600;
color: var(--td-text-color-primary, #000);
}
}
.form-content {
:deep(.t-form__item) {
margin-bottom: .875rem;
}
}
.popup-actions {
gap: .75rem;
display: flex;
margin-top: 1rem;
:deep(.t-button) {
flex: 1;
}
}
}
.file-input {