review:【antd】【mp】菜单优化

This commit is contained in:
YunaiV
2025-11-09 15:31:20 +08:00
parent 15215b4f4c
commit f8abee2b63
5 changed files with 56 additions and 51 deletions

View File

@@ -1,3 +1,4 @@
// TODO @hw如果只有自己组件里用一般是 modules所以这个目录要改成 modules 哈(自己模块的一部分);如果要给外部的组件用,可以叫 components
export { default as MenuEditor } from './menu-editor.vue'; export { default as MenuEditor } from './menu-editor.vue';
export { default as MenuPreviewer } from './menu-previewer.vue'; export { default as MenuPreviewer } from './menu-previewer.vue';
export * from './menuOptions'; export * from './menuOptions';

View File

@@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
// TODO @hw名字可以缩写成 editor.vue文件名
import { computed, nextTick, ref, watch } from 'vue'; import { computed, nextTick, ref, watch } from 'vue';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
@@ -136,6 +137,7 @@ function deleteMaterial() {
allow-clear allow-clear
/> />
</div> </div>
<!-- TODO @hw1左侧 filed 宽度看看要不要统一2右侧的 input 宽度也处理下 -->
<div class="configur-content" v-if="menu.type === 'miniprogram'"> <div class="configur-content" v-if="menu.type === 'miniprogram'">
<div class="applet"> <div class="applet">
<span>小程序的 appid </span> <span>小程序的 appid </span>
@@ -188,6 +190,7 @@ function deleteMaterial() {
</div> </div>
<div v-else> <div v-else>
<Row justify="center"> <Row justify="center">
<!-- TODO @hwhtml 标签里的 style 要用 tindwind 替代下 -->
<Col :span="24" style="text-align: center"> <Col :span="24" style="text-align: center">
<Button type="primary" @click="showNewsDialog = true"> <Button type="primary" @click="showNewsDialog = true">
素材库选择 素材库选择
@@ -210,18 +213,21 @@ function deleteMaterial() {
</Modal> </Modal>
</Row> </Row>
</div> </div>
<!-- TODO @hw貌似这个组件出不来 -->
<div <div
class="configur-content" class="configur-content"
v-if="menu.type === 'click' || menu.type === 'scancode_waitmsg'" v-if="menu.type === 'click' || menu.type === 'scancode_waitmsg'"
> >
<WxReplySelect v-if="hackResetWxReplySelect" v-model="menu.reply" /> <WxReplySelect v-if="hackResetWxReplySelect" v-model="menu.reply" />
</div> </div>
<!-- TODO @hw扫码回复这个帮忙看看是不是有点问题= = 好像 vue3 + element-plus 就有点问题 -->
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
/** TODO @hw尽量使用 tindwind 替代。ps如果多个组件复用那就不用调整 */
:deep(.ant-input) { :deep(.ant-input) {
// width: 70%; // width: 70%;
margin-right: 2%; margin-right: 2%;

View File

@@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
// TODO @hw名字可以缩写成 previewer.vue文件名
import type { Menu } from './types'; import type { Menu } from './types';
import { computed } from 'vue'; import { computed } from 'vue';
@@ -44,6 +45,7 @@ function addMenu() {
/** 添加横向二级菜单parent 表示要操作的父菜单 */ /** 添加横向二级菜单parent 表示要操作的父菜单 */
function addSubMenu(i: number, parent: any) { function addSubMenu(i: number, parent: any) {
const subMenuKeyLength = parent.children.length; // 获取二级菜单 key 长度 const subMenuKeyLength = parent.children.length; // 获取二级菜单 key 长度
// TODO @hw可以 inline 掉。idea 或者 vscode 的一些告警,处理掉会更干净一些。
const addButton = { const addButton = {
name: '子菜单名称', name: '子菜单名称',
reply: { reply: {
@@ -183,6 +185,7 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
/** TODO @hw尽量使用 tindwind 替代。ps如果多个组件复用那就不用调整 */
.menu-bottom { .menu-bottom {
position: relative; position: relative;
float: left; float: left;

View File

@@ -1,3 +1,4 @@
// TODO @hw这个要不合并到 types 里;
export default [ export default [
{ {
value: 'view', value: 'view',

View File

@@ -76,7 +76,9 @@ function handleQuery() {
/** 将后端返回的 menuList转换成前端的 menuList */ /** 将后端返回的 menuList转换成前端的 menuList */
function menuListToFrontend(list: any[]) { function menuListToFrontend(list: any[]) {
if (!list) return []; if (!list) {
return [];
}
const result: RawMenu[] = []; const result: RawMenu[] = [];
list.forEach((item: RawMenu) => { list.forEach((item: RawMenu) => {
@@ -146,7 +148,6 @@ function subMenuClicked(child: Menu, x: number, y: number) {
/** 删除当前菜单 */ /** 删除当前菜单 */
async function onDeleteMenu() { async function onDeleteMenu() {
try {
await confirm('确定要删除吗?'); await confirm('确定要删除吗?');
if (tempSelfObj.value.grand === Level.Parent) { if (tempSelfObj.value.grand === Level.Parent) {
// 一级菜单的删除方法 // 一级菜单的删除方法
@@ -165,13 +166,11 @@ async function onDeleteMenu() {
activeMenu.value = {}; activeMenu.value = {};
showRightPanel.value = false; showRightPanel.value = false;
activeIndex.value = MENU_NOT_SELECTED; activeIndex.value = MENU_NOT_SELECTED;
} catch {}
} }
// ======================== 菜单编辑 ======================== // ======================== 菜单编辑 ========================
/** 保存菜单 */ /** 保存菜单 */
async function onSave() { async function onSave() {
try {
await confirm('确定要保存吗?'); await confirm('确定要保存吗?');
const hideLoading = message.loading({ const hideLoading = message.loading({
content: '保存中...', content: '保存中...',
@@ -179,19 +178,15 @@ async function onSave() {
}); });
try { try {
await saveMenu(accountId.value, menuListToBackend()); await saveMenu(accountId.value, menuListToBackend());
getList(); await getList();
message.success('发布成功'); message.success('发布成功');
} finally { } finally {
hideLoading(); hideLoading();
} }
} catch {
//
}
} }
/** 清空菜单 */ /** 清空菜单 */
async function onClear() { async function onClear() {
try {
await confirm('确定要删除吗?'); await confirm('确定要删除吗?');
const hideLoading = message.loading({ const hideLoading = message.loading({
content: '删除中...', content: '删除中...',
@@ -204,9 +199,6 @@ async function onClear() {
} finally { } finally {
hideLoading(); hideLoading();
} }
} catch {
//
}
} }
/** 将前端的 menuList转换成后端接收的 menuList */ /** 将前端的 menuList转换成后端接收的 menuList */
@@ -247,7 +239,6 @@ function menuToBackend(menu: any) {
result.replyArticles = menu.reply.articles; result.replyArticles = menu.reply.articles;
result.replyMusicUrl = menu.reply.musicUrl; result.replyMusicUrl = menu.reply.musicUrl;
result.replyHqMusicUrl = menu.reply.hqMusicUrl; result.replyHqMusicUrl = menu.reply.hqMusicUrl;
return result; return result;
} }
</script> </script>
@@ -259,6 +250,7 @@ function menuToBackend(menu: any) {
</template> </template>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<!-- TODO @hw是不是少了一个框子哈 -->
<!-- <ContentWrap> --> <!-- <ContentWrap> -->
<Form layout="inline" class="-mb-15px w-240px"> <Form layout="inline" class="-mb-15px w-240px">
<Form.Item label="公众号" prop="accountId" class="w-240px"> <Form.Item label="公众号" prop="accountId" class="w-240px">
@@ -267,6 +259,7 @@ function menuToBackend(menu: any) {
</Form> </Form>
<!-- </ContentWrap> --> <!-- </ContentWrap> -->
<!-- TODO @hw貌似高度高了点就是手机下面部分空了一大块 -->
<ContentWrap> <ContentWrap>
<div class="clearfix public-account-management" v-loading="loading"> <div class="clearfix public-account-management" v-loading="loading">
<!--左边配置菜单--> <!--左边配置菜单-->
@@ -322,6 +315,7 @@ function menuToBackend(menu: any) {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
/** TODO @hw尽量使用 tindwind 替代。ps如果多个组件复用那就不用调整 */
/* 公共颜色变量 */ /* 公共颜色变量 */
.clearfix { .clearfix {
*zoom: 1; *zoom: 1;