mirror of https://github.com/halo-dev/halo
feat: add showCancel prop for dialog component (#4302)
#### What type of PR is this? /area console /kind improvement /milestone 2.8.x #### What this PR does / why we need it: 为 Dialog 组件添加 showCancel 属性用于控制是否显示取消按钮,某些场景下 Dialog 只是用于提示切必须点击确定。 此外,还对以下位置做了对应修改: 1. 进入文章编辑时检查编辑器是否存在的弹框,只允许点击确定并返回。 2. 备份恢复完成之后点击确定关闭 Halo。 #### Does this PR introduce a user-facing change? ```release-note Console 端的 Dialog 组件添加 showCancel 属性用于控制是否显示取消按钮。 ```pull/4301/head^2
parent
cfe77c5ded
commit
25725e520e
|
@ -19,6 +19,7 @@ const props = withDefaults(
|
||||||
description?: string;
|
description?: string;
|
||||||
confirmText?: string;
|
confirmText?: string;
|
||||||
confirmType?: ButtonType;
|
confirmType?: ButtonType;
|
||||||
|
showCancel?: boolean;
|
||||||
cancelText?: string;
|
cancelText?: string;
|
||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
onConfirm?: () => void;
|
onConfirm?: () => void;
|
||||||
|
@ -30,6 +31,7 @@ const props = withDefaults(
|
||||||
description: "",
|
description: "",
|
||||||
confirmText: "确定",
|
confirmText: "确定",
|
||||||
confirmType: "primary",
|
confirmType: "primary",
|
||||||
|
showCancel: true,
|
||||||
cancelText: "取消",
|
cancelText: "取消",
|
||||||
visible: false,
|
visible: false,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
|
@ -126,7 +128,9 @@ const handleClose = () => {
|
||||||
<VButton :loading="loading" :type="confirmType" @click="handleConfirm">
|
<VButton :loading="loading" :type="confirmType" @click="handleConfirm">
|
||||||
{{ confirmText }}
|
{{ confirmText }}
|
||||||
</VButton>
|
</VButton>
|
||||||
<VButton @click="handleCancel">{{ cancelText }}</VButton>
|
<VButton v-if="showCancel" @click="handleCancel">
|
||||||
|
{{ cancelText }}
|
||||||
|
</VButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VModal>
|
</VModal>
|
||||||
|
|
|
@ -2,28 +2,22 @@ export type Type = "success" | "info" | "warning" | "error";
|
||||||
export const DialogProviderProvideKey = "DIALOG_PROVIDER_PROVIDE_KEY";
|
export const DialogProviderProvideKey = "DIALOG_PROVIDER_PROVIDE_KEY";
|
||||||
import type { Type as ButtonType } from "../button/interface";
|
import type { Type as ButtonType } from "../button/interface";
|
||||||
|
|
||||||
export interface useDialogOptions {
|
|
||||||
type?: Type;
|
|
||||||
visible: boolean;
|
|
||||||
title: string;
|
|
||||||
description?: string;
|
|
||||||
confirmType?: ButtonType;
|
|
||||||
confirmText?: string;
|
|
||||||
cancelText?: string;
|
|
||||||
onConfirm?: () => void;
|
|
||||||
onCancel?: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DialogProps {
|
export interface DialogProps {
|
||||||
type?: Type;
|
type?: Type;
|
||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
confirmType?: ButtonType;
|
confirmType?: ButtonType;
|
||||||
|
showCancel?: boolean;
|
||||||
confirmText?: string;
|
confirmText?: string;
|
||||||
cancelText?: string;
|
cancelText?: string;
|
||||||
onConfirm?: () => void;
|
onConfirm?: () => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type useDialogOptions = Omit<DialogProps, "visible" | "title"> & {
|
||||||
|
visible: boolean;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type useDialogUserOptions = Omit<useDialogOptions, "type" | "visible">;
|
export type useDialogUserOptions = Omit<useDialogOptions, "type" | "visible">;
|
||||||
|
|
|
@ -257,13 +257,10 @@ const handleFetchContent = async () => {
|
||||||
raw_type: data.rawType,
|
raw_type: data.rawType,
|
||||||
}),
|
}),
|
||||||
confirmText: t("core.common.buttons.confirm"),
|
confirmText: t("core.common.buttons.confirm"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
showCancel: false,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
router.back();
|
router.back();
|
||||||
},
|
},
|
||||||
onCancel: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
|
@ -269,13 +269,10 @@ const handleFetchContent = async () => {
|
||||||
raw_type: data.rawType,
|
raw_type: data.rawType,
|
||||||
}),
|
}),
|
||||||
confirmText: t("core.common.buttons.confirm"),
|
confirmText: t("core.common.buttons.confirm"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
showCancel: false,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
router.back();
|
router.back();
|
||||||
},
|
},
|
||||||
onCancel: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,10 @@ const onUploaded = () => {
|
||||||
title: t("core.backup.operations.restore.title"),
|
title: t("core.backup.operations.restore.title"),
|
||||||
description: t("core.backup.operations.restore.description"),
|
description: t("core.backup.operations.restore.description"),
|
||||||
confirmText: t("core.common.buttons.confirm"),
|
confirmText: t("core.common.buttons.confirm"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
showCancel: false,
|
||||||
async onConfirm() {
|
async onConfirm() {
|
||||||
await handleShutdown();
|
await handleShutdown();
|
||||||
},
|
},
|
||||||
async onCancel() {
|
|
||||||
await handleShutdown();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue