useMessage
用于操作反馈的消息提示
import { useMessage } from '/@/hooks/web/useMessage';
const {createMessage} = useMessage();
createMessage.success("刷新缓存完成!");
createMessage.error("刷新缓存失败!");
confirm确认弹窗实现
<a-button @click="handleConfirm('warning')" color="warning" class="mr-2"> Warning </a-button>
import { useMessage } from '/@/hooks/web/useMessage';
const {
createMessage,
createConfirm,
createSuccessModal,
createInfoModal,
createErrorModal,
createWarningModal,
notification,
} = useMessage();
function handleConfirm(type: 'warning' | 'error' | 'success' | 'info') {
createConfirm({
iconType: type,
title: 'Tip',
content: 'content message...',
});
}
createConfirm({
title: '删除',
content: `确定要删除这${isImageMode.value ? '张图片' : '个文件'}吗?`,
iconType: 'warning',
onOk: () => resolve(true),
onCancel: () => resolve(false),
})
createConfirm({
iconType: 'warning',
title: '确认操作',
content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
onOk: async () => {
await frozenBatch({ids: unref(selectedRowKeys).join(','), status: status}, reload)
}
})
defHttp
用于网络请求
import {defHttp} from '/@/utils/http/axios';
defHttp.get({url: Api.list, params});
defHttp.get({url: "/user/getById", {id: 1}}).then(res=>{
console.log(res)
});
usePrintJS
用于打印页面内容
import { printJS } from '/@/hooks/web/usePrintJS'
<a-button type="primary" :ignore-print="true" ghost @click="onPrint">打印</a-button>
function onPrint() {
printJS({
printable: '#printContent',
type: 'html',
})
}
枚举的使用
enum Type {
primary = "primary",
success = "success",
warning = "warning",
warn = "warn", // warning alias
danger = "danger",
info = "info",
}