review:【antd/ele】【mp】代码迁移的 review
This commit is contained in:
@@ -10,6 +10,7 @@ import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
|||||||
import { WxVideoPlayer } from '#/views/mp/components';
|
import { WxVideoPlayer } from '#/views/mp/components';
|
||||||
|
|
||||||
import { useVideoGridColumns } from './data';
|
import { useVideoGridColumns } from './data';
|
||||||
|
import {$t} from '@vben/locales';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
list: MpMaterialApi.Material[];
|
list: MpMaterialApi.Material[];
|
||||||
@@ -81,7 +82,7 @@ watch(
|
|||||||
onClick: () => openWindow(row.url),
|
onClick: () => openWindow(row.url),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: $t('common.delete'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { MpMaterialApi } from '#/api/mp/material';
|
|||||||
|
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
|
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
import { openWindow } from '@vben/utils';
|
import { openWindow } from '@vben/utils';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
@@ -81,7 +82,7 @@ watch(
|
|||||||
onClick: () => openWindow(row.url),
|
onClick: () => openWindow(row.url),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: $t('common.delete'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ function handlePageChange(page: number, pageSize: number) {
|
|||||||
function showTotal(total: number) {
|
function showTotal(total: number) {
|
||||||
return `共 ${total} 条`;
|
return `共 ${total} 条`;
|
||||||
}
|
}
|
||||||
|
// TODO @dylan:是不是应该都用 Grid 哈:1)message-table 大部分合并到 index.vue;2)message-table 的 schema 放到 data.ts 里;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -74,4 +74,3 @@ export const useBeforeUpload = (type: UploadType, maxSizeMB?: number) => {
|
|||||||
|
|
||||||
return fn;
|
return fn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const total = ref(0); // 总条数
|
|||||||
const accountId = ref(-1);
|
const accountId = ref(-1);
|
||||||
provide('accountId', accountId);
|
provide('accountId', accountId);
|
||||||
|
|
||||||
|
// TODO @AI:这里是不是应该都用 grid;类似 yudao-ui-admin-vben-v5/apps/web-ele/src/views/mp/autoReply/index.vue
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
accountId,
|
accountId,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { UploadProps, UploadRawFile } from 'element-plus';
|
import type { UploadProps } from 'element-plus';
|
||||||
|
|
||||||
import type { UploadData } from './upload';
|
import type { UploadData } from './upload';
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
|
|
||||||
const props = defineProps<{ type: UploadType }>();
|
const props = defineProps<{ type: UploadType }>();
|
||||||
|
|
||||||
|
// TODO @dylan:是不是要和 antd 的 props 定义相同哈?这样后续两侧维护方便点
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
uploaded: [v: void];
|
uploaded: [v: void];
|
||||||
}>();
|
}>();
|
||||||
@@ -59,6 +60,7 @@ const customRequest: UploadProps['httpRequest'] = async function (options) {
|
|||||||
|
|
||||||
if (res.code !== 0) {
|
if (res.code !== 0) {
|
||||||
ElMessage.error(`上传出错:${res.msg}`);
|
ElMessage.error(`上传出错:${res.msg}`);
|
||||||
|
// TODO @dylan:这里有个 linter 错误。
|
||||||
onError?.(new Error(res.msg));
|
onError?.(new Error(res.msg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,4 +106,3 @@ const customRequest: UploadProps['httpRequest'] = async function (options) {
|
|||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
|
|
||||||
import { beforeVideoUpload, HEADERS, UPLOAD_URL, UploadType } from './upload';
|
import { beforeVideoUpload, HEADERS, UPLOAD_URL, UploadType } from './upload';
|
||||||
|
|
||||||
|
// TODO @dylan:是不是要和 antd 的 props 定义相同哈?这样后续两侧维护方便点
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
modelValue?: boolean;
|
modelValue?: boolean;
|
||||||
@@ -163,4 +164,3 @@ const customRequest: UploadProps['httpRequest'] = async function (options) {
|
|||||||
</ElForm>
|
</ElForm>
|
||||||
</ElDialog>
|
</ElDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import type { MpMaterialApi } from '#/api/mp/material';
|
|||||||
|
|
||||||
import { nextTick, onMounted, watch } from 'vue';
|
import { nextTick, onMounted, watch } from 'vue';
|
||||||
|
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { useImageGridColumns } from './data';
|
import { useImageGridColumns } from './data';
|
||||||
@@ -74,7 +76,7 @@ onMounted(async () => {
|
|||||||
<template>
|
<template>
|
||||||
<Grid class="image-table-grid mt-4 pb-0">
|
<Grid class="image-table-grid mt-4 pb-0">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<slot name="toolbar-tools" />
|
<slot name="toolbar-tools"></slot>
|
||||||
</template>
|
</template>
|
||||||
<template #image="{ row }">
|
<template #image="{ row }">
|
||||||
<div class="flex items-center justify-center" style="height: 192px">
|
<div class="flex items-center justify-center" style="height: 192px">
|
||||||
@@ -89,9 +91,9 @@ onMounted(async () => {
|
|||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: $t('common.delete'),
|
||||||
type: 'link',
|
type: 'primary',
|
||||||
danger: true,
|
link: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['mp:material:delete'],
|
auth: ['mp:material:delete'],
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
@@ -104,4 +106,3 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -44,4 +44,3 @@ export {
|
|||||||
type UploadData,
|
type UploadData,
|
||||||
UploadType,
|
UploadType,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ watch(
|
|||||||
<template>
|
<template>
|
||||||
<Grid class="mt-4">
|
<Grid class="mt-4">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<slot name="toolbar-tools" />
|
<slot name="toolbar-tools"></slot>
|
||||||
</template>
|
</template>
|
||||||
<template #video="{ row }">
|
<template #video="{ row }">
|
||||||
<WxVideoPlayer v-if="row.url" :url="row.url" />
|
<WxVideoPlayer v-if="row.url" :url="row.url" />
|
||||||
@@ -76,14 +76,15 @@ watch(
|
|||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: '下载',
|
label: '下载',
|
||||||
type: 'link',
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
icon: ACTION_ICON.DOWNLOAD,
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
onClick: () => openWindow(row.url),
|
onClick: () => openWindow(row.url),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: $t('common.delete'),
|
||||||
type: 'link',
|
type: 'danger',
|
||||||
danger: true,
|
link: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['mp:material:delete'],
|
auth: ['mp:material:delete'],
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
@@ -96,4 +97,3 @@ watch(
|
|||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { MpMaterialApi } from '#/api/mp/material';
|
|||||||
|
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
|
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
import { openWindow } from '@vben/utils';
|
import { openWindow } from '@vben/utils';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
@@ -76,14 +77,15 @@ watch(
|
|||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: '下载',
|
label: '下载',
|
||||||
type: 'link',
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
icon: ACTION_ICON.DOWNLOAD,
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
onClick: () => openWindow(row.url),
|
onClick: () => openWindow(row.url),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: $t('common.delete'),
|
||||||
type: 'link',
|
type: 'danger',
|
||||||
danger: true,
|
link: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['mp:material:delete'],
|
auth: ['mp:material:delete'],
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
@@ -96,4 +98,3 @@ watch(
|
|||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -109,12 +109,13 @@ function handleSizeChange(pageSize: number) {
|
|||||||
function showTotal(total: number) {
|
function showTotal(total: number) {
|
||||||
return `共 ${total} 条`;
|
return `共 ${total} 条`;
|
||||||
}
|
}
|
||||||
|
// TODO @dylan:是不是应该都用 Grid 哈?
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height class="flex flex-col">
|
<Page auto-content-height class="flex flex-col">
|
||||||
<!-- 搜索工作栏 -->
|
<!-- 搜索工作栏 -->
|
||||||
<div class="bg-background mb-4 rounded-lg p-4">
|
<div class="mb-4 rounded-lg bg-background p-4">
|
||||||
<ElForm
|
<ElForm
|
||||||
ref="queryFormRef"
|
ref="queryFormRef"
|
||||||
:model="queryParams"
|
:model="queryParams"
|
||||||
@@ -174,7 +175,7 @@ function showTotal(total: number) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<div class="bg-background flex-1 rounded-lg p-4">
|
<div class="flex-1 rounded-lg bg-background p-4">
|
||||||
<MessageTable :list="list" :loading="loading" @send="handleSend" />
|
<MessageTable :list="list" :loading="loading" @send="handleSend" />
|
||||||
<div v-show="total > 0" class="mt-4 flex justify-end">
|
<div v-show="total > 0" class="mt-4 flex justify-end">
|
||||||
<ElPagination
|
<ElPagination
|
||||||
@@ -208,4 +209,3 @@ function showTotal(total: number) {
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user