feat:【antd】【mp】mp 的代码评审(draft)

This commit is contained in:
YunaiV
2025-11-20 18:40:35 +08:00
parent 5b4d3c9820
commit c39a445d77
14 changed files with 76 additions and 28 deletions

View File

@@ -1,5 +1,6 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
/** 获取表格列配置 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [

View File

@@ -35,6 +35,8 @@ function handleAccountChange(accountId: number) {
gridApi.formApi.submitForm();
}
// TODO @hw代码风格要和对应的 antd index.vue 一致,类似方法的顺序,注释等。原因是,这样后续两端迭代,会方便很多。
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -189,7 +191,7 @@ async function handleDelete(row: Article) {
<TableAction
:actions="[
{
label: '新增',
label: $t('ui.actionTitle.create', ['图文草稿']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['mp:draft:create'],

View File

@@ -1,3 +1,4 @@
// TODO @hw要不要删除
export default {
list: [
{

View File

@@ -13,7 +13,7 @@ import { ElButton, ElDialog, ElImage, ElMessage, ElUpload } from 'element-plus';
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
import MaterialSelect from '#/views/mp/components/wx-material-select/wx-material-select.vue';
// 设置上传的请求头部
// TODO @hw代码风格要和对应的 antd index.vue 一致,类似方法的顺序,注释等。原因是,这样后续两端迭代,会方便很多。
const props = defineProps<{
isFirst: boolean;

View File

@@ -3,6 +3,7 @@ import type { Article } from './types';
import News from '#/views/mp/components/wx-news/wx-news.vue';
// TODO @hw按照微信里说的感觉这个可以干掉。少点组件哈。= = mp 模块,小组件可太多了。。。
defineOptions({ name: 'DraftTableCell' });
const props = defineProps<{

View File

@@ -13,6 +13,8 @@ import NewsForm from './news-form.vue';
const emit = defineEmits(['success']);
// TODO @hw代码风格要和对应的 antd index.vue 一致,类似方法的顺序,注释等。原因是,这样后续两端迭代,会方便很多。
const formData = ref<{
accountId: number;
isCreating: boolean;

View File

@@ -3,6 +3,7 @@ import type { NewsItem } from './types';
import { computed, ref } from 'vue';
import { confirm } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
import {
@@ -12,7 +13,6 @@ import {
ElContainer,
ElInput,
ElMain,
ElMessageBox,
ElRow,
} from 'element-plus';
@@ -28,7 +28,6 @@ const props = defineProps<{
modelValue: NewsItem[] | null;
}>();
// v-model=newsList
const emit = defineEmits<{
(e: 'update:modelValue', v: NewsItem[]): void;
}>();
@@ -53,7 +52,7 @@ const activeNewsItem = computed(() => {
return item;
});
// 将图文向下移动
/** 将图文向下移动 */
function moveDownNews(index: number) {
const current = newsList.value[index];
const next = newsList.value[index + 1];
@@ -64,7 +63,7 @@ function moveDownNews(index: number) {
}
}
// 将图文向上移动
/** 将图文向上移动 */
function moveUpNews(index: number) {
const current = newsList.value[index];
const prev = newsList.value[index - 1];
@@ -75,20 +74,16 @@ function moveUpNews(index: number) {
}
}
// 删除指定 index 的图文
/** 删除指定 index 的图文 */
async function removeNews(index: number) {
try {
await ElMessageBox.confirm('确定删除该图文吗?');
newsList.value.splice(index, 1);
if (activeNewsIndex.value === index) {
activeNewsIndex.value = 0;
}
} catch {
// empty
await confirm('确定删除该图文吗?');
newsList.value.splice(index, 1);
if (activeNewsIndex.value === index) {
activeNewsIndex.value = 0;
}
}
// 添加一个图文
/** 添加一个图文 */
function plusNews() {
newsList.value.push(createEmptyNewsItem());
activeNewsIndex.value = newsList.value.length - 1;
@@ -139,6 +134,7 @@ function plusNews() {
</ElButton>
</div>
</div>
<!-- TODO @hw1每个文章的选中框太粗了2没完全覆盖住文章最好首个文章和第个文章的情况都看看 -->
<div
class="group mx-auto w-full cursor-pointer border-t border-gray-200 bg-white py-1.5"
v-if="index > 0"
@@ -153,6 +149,8 @@ function plusNews() {
<img class="h-full w-full" :src="news.thumbUrl" width="100%" />
</div>
</div>
<!-- TODO @hw这里的按钮交互不太对应该在每个卡片的里面或者类似公众号现在的交互放到右侧复现本周如果有 2 个文章的时候 -->
<!-- TODO @hw当有 2 个文章的时候挪到第二个文章的时候卡片会变大期望不变大 -->
<div
class="relative -bottom-6 hidden text-center group-hover:block"
>

View File

@@ -39,11 +39,11 @@ const [Modal, modalApi] = useVbenModal({
return;
}
modalApi.lock();
/** 提交表单 */
// 提交表单
const values = (await formApi.getValues()) as MpUserApi.User;
try {
await updateUser({ ...formData.value, ...values });
/** 关闭并提示 */
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
@@ -56,7 +56,7 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
/** 加载数据 */
// 加载数据
const data = modalApi.getData<{ id: number }>();
if (!data || !data.id) {
return;
@@ -64,7 +64,7 @@ const [Modal, modalApi] = useVbenModal({
modalApi.lock();
try {
formData.value = await getUser(data.id);
/** 设置到 values */
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();