perf: 对话日志修改内容改为markdown编辑器

This commit is contained in:
wangdan-fit2cloud 2024-09-23 18:36:56 +08:00
parent d6c369553f
commit ba1f0b557e
4 changed files with 92 additions and 18 deletions

View File

@ -6,7 +6,7 @@
:model="resetPasswordForm"
:rules="rules"
>
<p class="mb-8 lighter">{{ $t("layout.topbar.avatar.dialog.newPassword") }}</p>
<p class="mb-8 lighter">{{ $t('layout.topbar.avatar.dialog.newPassword') }}</p>
<el-form-item prop="password" style="margin-bottom: 8px">
<el-input
type="password"
@ -27,7 +27,7 @@
>
</el-input>
</el-form-item>
<p class="mb-8 lighter">{{ $t("layout.topbar.avatar.dialog.useEmail") }}</p>
<p class="mb-8 lighter">{{ $t('layout.topbar.avatar.dialog.useEmail') }}</p>
<el-form-item style="margin-bottom: 8px">
<el-input
class="input-item"
@ -39,7 +39,11 @@
</el-form-item>
<el-form-item prop="code">
<div class="flex-between w-full">
<el-input class="code-input" v-model="resetPasswordForm.code" :placeholder="$t('layout.topbar.avatar.dialog.enterVerificationCode')">
<el-input
class="code-input"
v-model="resetPasswordForm.code"
:placeholder="$t('layout.topbar.avatar.dialog.enterVerificationCode')"
>
</el-input>
<el-button
:disabled="isDisabled"
@ -47,15 +51,23 @@
@click="sendEmail"
:loading="loading"
>
{{ isDisabled ? $t('layout.topbar.avatar.dialog.resend', { time }) : $t('layout.topbar.avatar.dialog.getVerificationCode') }}
{{
isDisabled
? $t('layout.topbar.avatar.dialog.resend', { time })
: $t('layout.topbar.avatar.dialog.getVerificationCode')
}}
</el-button>
</div>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="resetPasswordDialog = false">{{ $t('layout.topbar.avatar.dialog.cancel') }}</el-button>
<el-button type="primary" @click="resetPassword"> {{ $t('layout.topbar.avatar.dialog.save') }} </el-button>
<el-button @click="resetPasswordDialog = false">{{
$t('layout.topbar.avatar.dialog.cancel')
}}</el-button>
<el-button type="primary" @click="resetPassword">
{{ $t('layout.topbar.avatar.dialog.save') }}
</el-button>
</div>
</template>
</el-dialog>
@ -88,7 +100,13 @@ const time = ref<number>(60)
const rules = ref<FormRules<ResetCurrentUserPasswordRequest>>({
// @ts-ignore
code: [{ required: true, message: t('layout.topbar.avatar.dialog.enterVerificationCode'), trigger: 'blur' }],
code: [
{
required: true,
message: t('layout.topbar.avatar.dialog.enterVerificationCode'),
trigger: 'blur'
}
],
password: [
{
required: true,
@ -131,7 +149,7 @@ const rules = ref<FormRules<ResetCurrentUserPasswordRequest>>({
*/
const sendEmail = () => {
UserApi.sendEmailToCurrent(loading).then(() => {
MsgSuccess(t('verificationCodeSentSuccess'))
MsgSuccess(t('layout.topbar.avatar.dialog.verificationCodeSentSuccess'))
isDisabled.value = true
handleTimeChange()
})
@ -176,7 +194,5 @@ const close = () => {
}
defineExpose({ open, close })
</script>
<style lang="scss" scope></style>

View File

@ -18,15 +18,20 @@
</el-input>
</el-form-item>
<el-form-item label="内容" prop="content">
<el-input
<MdEditor
v-model="form.content"
placeholder="请输入内容"
maxlength="100000"
show-word-limit
:rows="8"
type="textarea"
:maxLength="100000"
:preview="false"
:toolbars="toolbars"
style="height: 300px"
@onUploadImg="onUploadImg"
:footers="footers"
>
</el-input>
<template #defFooters>
<span style="margin-left: -6px">/ 100000</span>
</template>
</MdEditor>
</el-form-item>
<el-form-item label="标题">
<el-input
@ -99,6 +104,7 @@ import { ref, watch, reactive } from 'vue'
import { useRoute } from 'vue-router'
import type { FormInstance, FormRules } from 'element-plus'
import logApi from '@/api/log'
import imageApi from '@/api/image'
import useStore from '@/stores'
const { application, document } = useStore()
@ -111,6 +117,38 @@ const {
const emit = defineEmits(['refresh'])
const formRef = ref()
const toolbars = [
'bold',
'underline',
'italic',
'-',
'title',
'strikeThrough',
'sub',
'sup',
'quote',
'unorderedList',
'orderedList',
'task',
'-',
'codeRow',
'code',
'link',
'image',
'table',
'mermaid',
'katex',
'-',
'revoke',
'next',
'=',
'pageFullscreen',
'preview',
'htmlPreview'
] as any[]
const footers = ['markdownTotal', 0, '=', 1, 'scrollSwitch']
const dialogVisible = ref<boolean>(false)
const loading = ref(false)
@ -151,6 +189,26 @@ watch(dialogVisible, (bool) => {
}
})
const onUploadImg = async (files: any, callback: any) => {
const res = await Promise.all(
files.map((file: any) => {
return new Promise((rev, rej) => {
const fd = new FormData()
fd.append('file', file)
imageApi
.postImage(fd)
.then((res: any) => {
rev(res)
})
.catch((error) => rej(error))
})
})
)
callback(res.map((item) => item.data))
}
function changeDataset(id: string) {
form.value.document_id = ''
getDocument(id)

View File

@ -170,7 +170,7 @@ const model_form_field = ref<Array<FormField>>([])
const dialogVisible = ref<boolean>(false)
const base_form_data_rule = ref<FormRules>({
name: { required: true, trigger: 'blur', message: '模型名不能为空' },
name: { required: true, trigger: 'blur', message: '模型名不能为空' },
permission_type: { required: true, trigger: 'change', message: '权限不能为空' },
model_type: { required: true, trigger: 'change', message: '模型类型不能为空' },
model_name: { required: true, trigger: 'change', message: '基础模型不能为空' }

View File

@ -164,7 +164,7 @@ const model_form_field = ref<Array<FormField>>([])
const dialogVisible = ref<boolean>(false)
const base_form_data_rule = ref<FormRules>({
name: { required: true, trigger: 'blur', message: '模型名不能为空' },
name: { required: true, trigger: 'blur', message: '模型名不能为空' },
model_type: { required: true, trigger: 'change', message: '模型类型不能为空' },
model_name: { required: true, trigger: 'change', message: '基础模型不能为空' }
})