mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-24 14:34:32 +08:00
refactor(antdv-next): 将message组件调用统一改为window.message
将项目中直接导入的antdv-next的message组件调用改为通过window.message调用,提升代码一致性 移除不再需要的message组件导入 新增api-switch组件用于统一处理状态切换逻辑
This commit is contained in:
@@ -9,7 +9,7 @@ import { AuthenticationCodeLogin, z } from '@vben/common-ui';
|
||||
import { DEFAULT_TENANT_ID } from '@vben/constants';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { Alert, message } from 'antdv-next';
|
||||
import { Alert } from 'antdv-next';
|
||||
|
||||
import { tenantList } from '#/api';
|
||||
import { sendSmsCode } from '#/api/core/captcha';
|
||||
@@ -96,7 +96,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
||||
}
|
||||
// 调用接口发送
|
||||
await sendSmsCode(value);
|
||||
message.success('验证码发送成功');
|
||||
window.message.success('验证码发送成功');
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -5,8 +5,6 @@ import { computed, ref } from 'vue';
|
||||
|
||||
import { ProfilePasswordSetting, z } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
const profilePasswordSettingRef = ref();
|
||||
|
||||
const formSchema = computed((): VbenFormSchema[] => {
|
||||
@@ -53,7 +51,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
||||
});
|
||||
|
||||
function handleSubmit() {
|
||||
message.success('密码修改成功');
|
||||
window.message.success('密码修改成功');
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { preferences } from '@vben/preferences';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
import { cn } from '@vben/utils';
|
||||
|
||||
import { message, Spin } from 'antdv-next';
|
||||
import { Spin } from 'antdv-next';
|
||||
|
||||
import { authCallback } from '#/api';
|
||||
import { useAuthStore } from '#/store';
|
||||
@@ -49,7 +49,7 @@ onMounted(async () => {
|
||||
(item) => item.source === source,
|
||||
);
|
||||
if (!currentClient) {
|
||||
message.error({ content: `未找到${source}平台` });
|
||||
window.message.error({ content: `未找到${source}平台` });
|
||||
return;
|
||||
}
|
||||
const data: AuthApi.OAuthLoginParams = {
|
||||
@@ -62,14 +62,14 @@ onMounted(async () => {
|
||||
// 没有token为登录 有token是授权
|
||||
if (accessStore.accessToken) {
|
||||
await authCallback(data);
|
||||
message.success(`${source}授权成功`);
|
||||
window.message.success(`${source}授权成功`);
|
||||
setTimeout(() => {
|
||||
router.push(preferences.app.defaultHomePath);
|
||||
}, 1500);
|
||||
} else {
|
||||
// 这里内部已经做了跳转到首页的操作
|
||||
await authStore.authLogin(data as any);
|
||||
message.success(`${source}登录成功`);
|
||||
window.message.success(`${source}登录成功`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useVbenDrawer } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
|
||||
import { Button, message, Skeleton } from 'antdv-next';
|
||||
import { Button, Skeleton } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { tenantAdd, tenantInfo, tenantUpdate } from '#/api/system/tenant';
|
||||
@@ -43,7 +43,7 @@ async function setupPackageSelect() {
|
||||
* 检测是否存在租户套餐 你也不想表单填完了发现套餐为0无法选中吧
|
||||
*/
|
||||
if (tenantPackageList.length === 0) {
|
||||
const closeMessage = message.error(
|
||||
const closeMessage = window.message.error(
|
||||
h('span', {}, [
|
||||
'请先配置租户套餐',
|
||||
h(
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
userRemove,
|
||||
userStatusChange,
|
||||
} from '#/api/system/user';
|
||||
import { TableSwitch } from '#/components/table';
|
||||
import ApiSwitch from '#/components/global/api-switch.vue';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import { columns, querySchema } from './data';
|
||||
@@ -199,6 +199,14 @@ function handleMenuClick(key: string, row: any) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleChangeStatus(checked: boolean, row: User) {
|
||||
console.log(checked);
|
||||
await userStatusChange({
|
||||
userId: row.userId,
|
||||
status: checked ? '0' : '1',
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -248,9 +256,10 @@ function handleMenuClick(key: string, row: any) {
|
||||
<Avatar :src="row.avatar || preferences.app.defaultAvatar" />
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<TableSwitch
|
||||
v-model:value="row.status"
|
||||
:api="() => userStatusChange(row)"
|
||||
<!-- value只能接收boolean值 -->
|
||||
<ApiSwitch
|
||||
:value="row.status === '0'"
|
||||
:api="(checked) => handleChangeStatus(checked, row)"
|
||||
:disabled="
|
||||
row.userId === 1 || !hasAccessByCodes(['system:user:edit'])
|
||||
"
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useRouter } from 'vue-router';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import { message, Modal, Popconfirm, Space } from 'antdv-next';
|
||||
import { Modal, Popconfirm, Space } from 'antdv-next';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
|
||||
@@ -125,10 +125,10 @@ async function handleBatchGen() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: any) => row.tableId);
|
||||
if (ids.length === 0) {
|
||||
message.info('请选择需要生成代码的表');
|
||||
window.message.info('请选择需要生成代码的表');
|
||||
return;
|
||||
}
|
||||
const hideLoading = message.loading('下载中...');
|
||||
const hideLoading = window.message.loading('下载中...');
|
||||
try {
|
||||
const params = ids.join(',');
|
||||
const data = await batchGenCode(params);
|
||||
@@ -140,12 +140,12 @@ async function handleBatchGen() {
|
||||
}
|
||||
|
||||
async function handleDownload(record: Recordable<any>) {
|
||||
const hideLoading = message.loading('加载中...');
|
||||
const hideLoading = window.message.loading('加载中...');
|
||||
try {
|
||||
// 路径生成
|
||||
if (record.genType === '1' && record.genPath) {
|
||||
await genWithPath(record.tableId);
|
||||
message.success(`生成成功: ${record.genPath}`);
|
||||
window.message.success(`生成成功: ${record.genPath}`);
|
||||
return;
|
||||
}
|
||||
// zip生成
|
||||
@@ -196,7 +196,7 @@ function handleImport() {
|
||||
<BasicTable table-title="代码生成列表">
|
||||
<template #toolbar-tools>
|
||||
<a
|
||||
class="text-primary mr-2"
|
||||
class="mr-2 text-primary"
|
||||
href="https://dapdap.top/other/template.html"
|
||||
target="_blank"
|
||||
>👉关于代码生成模板
|
||||
|
||||
@@ -11,7 +11,6 @@ import { ref } from 'vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
import { omit } from 'lodash-es';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
@@ -173,7 +172,7 @@ async function handleSubmit() {
|
||||
// 判断是否选中
|
||||
for (const item of nextNodeInfo.value) {
|
||||
if (item.selectUserList.length === 0) {
|
||||
message.warn(`未选择节点[${item.nodeName}]审批人`);
|
||||
window.message.warning(`未选择节点[${item.nodeName}]审批人`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { cn } from '@vben/utils';
|
||||
|
||||
import { CopyOutlined } from '@ant-design/icons-vue';
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { Card, Divider, message, TabPane, Tabs } from 'antdv-next';
|
||||
import { Card, Divider, TabPane, Tabs } from 'antdv-next';
|
||||
|
||||
import { flowInfo } from '#/api/workflow/instance';
|
||||
import { getTaskByTaskId } from '#/api/workflow/task';
|
||||
@@ -130,7 +130,7 @@ watch(() => props.task, handleLoadInfo);
|
||||
const { copy } = useClipboard({ legacy: true });
|
||||
async function handleCopy(text: string) {
|
||||
await copy(text);
|
||||
message.success('复制成功');
|
||||
window.message.success('复制成功');
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -153,7 +153,7 @@ async function handleCopy(text: string) {
|
||||
<template #extra>
|
||||
<a-button size="small" @click="() => handleLoadInfo(task)">
|
||||
<div class="flex items-center justify-center">
|
||||
<span class="icon-[material-symbols--refresh] size-24px"></span>
|
||||
<span class="size-24px icon-[material-symbols--refresh]"></span>
|
||||
</div>
|
||||
</a-button>
|
||||
</template>
|
||||
@@ -174,7 +174,7 @@ async function handleCopy(text: string) {
|
||||
<div class="flex items-center gap-2">
|
||||
<VbenAvatar
|
||||
:alt="task?.createByName ?? ''"
|
||||
class="bg-primary size-[28px] rounded-full text-white"
|
||||
class="size-[28px] rounded-full bg-primary text-white"
|
||||
src=""
|
||||
/>
|
||||
|
||||
|
||||
@@ -14,14 +14,7 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import {
|
||||
message,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
RadioGroup,
|
||||
Space,
|
||||
Switch,
|
||||
} from 'antdv-next';
|
||||
import { Modal, Popconfirm, RadioGroup, Space, Switch } from 'antdv-next';
|
||||
|
||||
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
|
||||
import {
|
||||
@@ -219,7 +212,10 @@ function handleEdit(row: any) {
|
||||
* @param row row
|
||||
*/
|
||||
async function handleExportXml(row: any) {
|
||||
const hideLoading = message.loading($t('pages.common.downloadLoading'), 0);
|
||||
const hideLoading = window.message.loading(
|
||||
$t('pages.common.downloadLoading'),
|
||||
0,
|
||||
);
|
||||
try {
|
||||
const blob = await workflowDefinitionExport(row.id);
|
||||
downloadByData(blob, `${row.flowName}-${Date.now()}.json`);
|
||||
@@ -239,12 +235,12 @@ const [ProcessDefinitionDeployModal, deployModalApi] = useVbenModal({
|
||||
*/
|
||||
function handleDeploy() {
|
||||
if (selectedCode.value.length === 0) {
|
||||
message.warning('请先选择流程分类');
|
||||
window.message.warning('请先选择流程分类');
|
||||
return;
|
||||
}
|
||||
const selectedCategory = selectedCode.value[0];
|
||||
if (selectedCategory === 0) {
|
||||
message.warning('不可选择根目录进行部署, 请选择子分类');
|
||||
window.message.warning('不可选择根目录进行部署, 请选择子分类');
|
||||
return;
|
||||
}
|
||||
deployModalApi.setData({ category: selectedCategory });
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ref } from 'vue';
|
||||
import { JsonPreview, useVbenModal } from '@vben/common-ui';
|
||||
import { cn, getPopupContainer } from '@vben/utils';
|
||||
|
||||
import { message, Modal, Tag } from 'antdv-next';
|
||||
import { Modal, Tag } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { instanceVariable, updateFlowVariable } from '#/api/workflow/instance';
|
||||
@@ -168,7 +168,7 @@ async function handleSubmit(values: any) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Error) {
|
||||
message.error(error.message);
|
||||
window.message.error(error.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,7 @@ import { nextTick, onMounted } from 'vue';
|
||||
|
||||
import { JsonPreview } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
} from 'antdv-next';
|
||||
import { Button, Input, InputNumber, Modal, Select, Space } from 'antdv-next';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
|
||||
@@ -246,9 +238,9 @@ async function handleValidate() {
|
||||
const result = await tableApi.grid.validate(true);
|
||||
console.log(result);
|
||||
if (result) {
|
||||
message.error('校验失败');
|
||||
window.message.error('校验失败');
|
||||
} else {
|
||||
message.success('校验成功');
|
||||
window.message.success('校验成功');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user