1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2026-01-23 08:00:22 +08:00

style: lint

This commit is contained in:
zclzone
2024-06-06 18:05:36 +08:00
parent 98f9d5893a
commit a67510fe34
72 changed files with 542 additions and 389 deletions

View File

@@ -18,9 +18,11 @@
>
<n-card :style="modalOptions.contentStyle" :closable="modalOptions.closable" @close="close()">
<template #header>
<header class="modal-header">{{ modalOptions.title }}</header>
<header class="modal-header">
{{ modalOptions.title }}
</header>
</template>
<slot></slot>
<slot />
<!-- 底部按钮 -->
<template #footer>
@@ -46,6 +48,7 @@
<script setup>
import { initDrag } from './utils'
const props = defineProps({
width: {
type: String,
@@ -101,6 +104,17 @@ const show = ref(false)
// 声明一个modalOptions变量用于存储模态框的配置信息
const modalOptions = ref({})
const okLoading = computed({
get() {
return !!modalOptions.value?.okLoading
},
set(v) {
if (modalOptions.value) {
modalOptions.value.okLoading = v
}
},
})
// 打开模态框
async function open(options = {}) {
// 将props和options合并赋值给modalOptions
@@ -111,7 +125,7 @@ async function open(options = {}) {
await nextTick()
initDrag(
Array.prototype.at.call(document.querySelectorAll('.modal-header'), -1),
Array.prototype.at.call(document.querySelectorAll('.modal-box'), -1)
Array.prototype.at.call(document.querySelectorAll('.modal-box'), -1),
)
}
@@ -131,7 +145,8 @@ async function handleOk(data) {
const res = await modalOptions.value.onOk(data)
// 如果onOk函数的返回值不为false则关闭模态框
res !== false && close()
} catch (error) {
}
catch (error) {
okLoading.value = false
console.error(error)
}
@@ -149,7 +164,8 @@ async function handleCancel(data) {
// 如果onCancel函数的返回值不为false则关闭模态框
res !== false && close()
} catch (error) {
}
catch (error) {
okLoading.value = false
console.error(error)
}
@@ -159,21 +175,10 @@ async function onAfterLeave() {
await nextTick()
initDrag(
Array.prototype.at.call(document.querySelectorAll('.modal-header'), -1),
Array.prototype.at.call(document.querySelectorAll('.modal-box'), -1)
Array.prototype.at.call(document.querySelectorAll('.modal-box'), -1),
)
}
const okLoading = computed({
get() {
return !!modalOptions.value?.okLoading
},
set(v) {
if (modalOptions.value) {
modalOptions.value.okLoading = v
}
},
})
// 定义一个defineExpose函数用于暴露open、close、handleOk、handleCancel函数
defineExpose({
open,