签入版本
This commit is contained in:
@@ -104,7 +104,7 @@ export function exampleBatchDelete(data: any) {
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { getExamplePage, exampleDelete } from '@/api/tool/example';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Modal, message } from 'ant-design-vue';
|
||||
|
||||
const tableData = ref([]);
|
||||
|
||||
@@ -116,10 +116,15 @@ const fetchData = async () => {
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (id) => {
|
||||
await ElMessageBox.confirm('确认删除?', '提示', { type: 'warning' });
|
||||
await exampleDelete(id);
|
||||
ElMessage.success('删除成功');
|
||||
fetchData();
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确认删除?',
|
||||
onOk: async () => {
|
||||
await exampleDelete(id);
|
||||
message.success('删除成功');
|
||||
fetchData();
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -30,6 +30,8 @@ config.headers['Authorization'] = `Bearer ${token}`;
|
||||
### 响应拦截器(统一错误处理)
|
||||
|
||||
```typescript
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
// 响应处理逻辑
|
||||
const { code, data, msg } = res.data;
|
||||
|
||||
@@ -43,7 +45,7 @@ if (code === 401) {
|
||||
}
|
||||
|
||||
// 其他错误,显示提示
|
||||
ElMessage.error(msg || '操作失败');
|
||||
message.error(msg || '操作失败');
|
||||
```
|
||||
|
||||
:::tip 响应处理规则
|
||||
|
||||
@@ -80,8 +80,8 @@ export default {
|
||||
<template>
|
||||
<div>
|
||||
<!-- 基础翻译 -->
|
||||
<el-button>{{ $t('common.search') }}</el-button>
|
||||
<el-button>{{ $t('common.reset') }}</el-button>
|
||||
<a-button>{{ $t('common.search') }}</a-button>
|
||||
<a-button>{{ $t('common.reset') }}</a-button>
|
||||
|
||||
<!-- 带参数翻译 -->
|
||||
<p>{{ $t('message.welcome', { name: 'Admin' }) }}</p>
|
||||
@@ -134,15 +134,17 @@ const columns = computed(() => [
|
||||
```vue
|
||||
<!-- ui/src/components/LangSwitch/index.vue -->
|
||||
<template>
|
||||
<el-dropdown @command="switchLang">
|
||||
<el-button :icon="Icon" circle />
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="zh-CN">中文</el-dropdown-item>
|
||||
<el-dropdown-item command="en-US">English</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
<a-dropdown>
|
||||
<a-button>
|
||||
<GlobeOutlined />
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu @click="({ key }) => switchLang(key)">
|
||||
<a-menu-item key="zh-CN">中文</a-menu-item>
|
||||
<a-menu-item key="en-US">English</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
Reference in New Issue
Block a user