公众号菜单配置问题修改

This commit is contained in:
lxy 2025-04-09 18:56:57 +08:00
parent 1e2a44523c
commit b9405c265b
7 changed files with 49 additions and 31 deletions

View File

@ -27,13 +27,13 @@ export default OakComponent({
setConfig(index, content, currentIndex) {
const { config, changeConfig } = this.props;
if (typeof currentIndex === 'number') {
content.name =
config.button[currentIndex].sub_button[index].name;
content.name = config.button[currentIndex].sub_button[index].name;
content.key = config.button[currentIndex].sub_button[index].key || content.key;
config.button[currentIndex].sub_button[index] = content;
changeConfig(config);
}
else {
} else {
content.name = config.button[index].name;
content.key = config.button[index].key || content.key;
content.sub_button = [...config.button[index].sub_button];
config.button[index] = content;
changeConfig(config);

View File

@ -2,6 +2,7 @@ import React from 'react';
import Style from './web.module.less';
import "@wangeditor/editor/dist/css/style.css"; // 引入 css
import { Editor, Toolbar } from "@wangeditor/editor-for-react";
import { Input } from 'antd';
const toolbarConfig = {
excludeKeys: [
"blockquote",
@ -24,7 +25,7 @@ export default function Render(props) {
const { value, editor, getDecidedMenuContent } = props.data;
const { setEditor, setHtml } = props.methods;
return (<div className={Style.container}>
<Toolbar editor={editor} defaultConfig={toolbarConfig} mode="default" style={{
{/* <Toolbar editor={editor} defaultConfig={toolbarConfig} mode="default" style={{
borderBottom: '1px solid #ccc',
}}/>
<Editor defaultConfig={{
@ -38,6 +39,11 @@ export default function Render(props) {
minHeight: 200,
maxHeight: 400,
overflowY: 'auto',
}}/>
</div>);
}}/> */}
<Input.TextArea rows={4}
value={value}
onChange={(e) => {
getDecidedMenuContent(e.target.value.trim());
}} />
</div>);
}

View File

@ -33,6 +33,7 @@ export function registerWeChatPublicEventCallback(appId, callback) {
* @returns
*/
async function setUserUnsubscribed(openId, context) {
const { id: applicationId, type: applicationType } = context.getApplication();
const list = await context.select('wechatUser', {
data: {
id: 1,
@ -40,7 +41,7 @@ async function setUserUnsubscribed(openId, context) {
subscribedAt: 1,
},
filter: {
applicationId: context.getApplicationId(),
applicationId: applicationId,
openId,
},
indexFrom: 0,
@ -70,8 +71,9 @@ async function setUserUnsubscribed(openId, context) {
data: {
id: await generateNewIdAsync(),
subscribed: false,
applicationId: context.getApplicationId(),
applicationId: applicationId,
openId,
origin: applicationType === 'wechatPublic' ? 'public' : 'web',
},
}, { dontCollect: true });
}

View File

@ -38,6 +38,7 @@ exports.registerWeChatPublicEventCallback = registerWeChatPublicEventCallback;
* @returns
*/
async function setUserUnsubscribed(openId, context) {
const { id: applicationId, type: applicationType } = context.getApplication();
const list = await context.select('wechatUser', {
data: {
id: 1,
@ -45,7 +46,7 @@ async function setUserUnsubscribed(openId, context) {
subscribedAt: 1,
},
filter: {
applicationId: context.getApplicationId(),
applicationId: applicationId,
openId,
},
indexFrom: 0,
@ -75,8 +76,9 @@ async function setUserUnsubscribed(openId, context) {
data: {
id: await (0, uuid_1.generateNewIdAsync)(),
subscribed: false,
applicationId: context.getApplicationId(),
applicationId: applicationId,
openId,
origin: applicationType === 'wechatPublic' ? 'public' : 'web',
},
}, { dontCollect: true });
}

View File

@ -25,15 +25,16 @@ export default OakComponent({
},
data: {},
methods: {
setConfig(index: number, content: any, currentIndex?: number) {
setConfig(index: number, content: Record<string, any>, currentIndex?: number) {
const { config, changeConfig } = this.props;
if (typeof currentIndex === 'number') {
content.name =
config!.button![currentIndex].sub_button[index].name;
content.name = config!.button![currentIndex].sub_button[index].name;
content.key = config!.button![currentIndex].sub_button[index].key || content.key;
config!.button![currentIndex].sub_button[index] = content;
changeConfig!(config);
} else {
content.name = config!.button![index].name;
content.key = config!.button![index].key || content.key;
content.sub_button = [...config!.button![index].sub_button];
config!.button![index] = content;
changeConfig!(config);

View File

@ -15,19 +15,19 @@ import {
const toolbarConfig: Partial<IToolbarConfig> = {
excludeKeys: [
"blockquote",
"fullScreen",
"headerSelect",
"|",
"bold",
"group-more-style",
"bgColor",
"bulletedList",
"numberedList",
"todo",
"group-image",
"group-video",
"insertTable",
"blockquote",
"fullScreen",
"headerSelect",
"|",
"bold",
"group-more-style",
"bgColor",
"bulletedList",
"numberedList",
"todo",
"group-image",
"group-video",
"insertTable",
"codeBlock",
],
}; // TS 语法
@ -52,7 +52,7 @@ export default function Render(
const { setEditor, setHtml } = props.methods;
return (
<div className={Style.container}>
<Toolbar
{/* <Toolbar
editor={editor}
defaultConfig={toolbarConfig}
mode="default"
@ -78,7 +78,12 @@ export default function Render(
maxHeight: 400,
overflowY: 'auto',
}}
/>
/> */}
<Input.TextArea rows={4}
value={value}
onChange={(e) => {
getDecidedMenuContent(e.target.value?.trim());
}} />
</div >
);
}

View File

@ -59,6 +59,7 @@ export function registerWeChatPublicEventCallback(
* @returns
*/
async function setUserUnsubscribed(openId: string, context: BRC<EntityDict>) {
const { id: applicationId, type: applicationType } = context.getApplication()!;
const list = await context.select(
'wechatUser',
{
@ -68,7 +69,7 @@ async function setUserUnsubscribed(openId: string, context: BRC<EntityDict>) {
subscribedAt: 1,
},
filter: {
applicationId: context.getApplicationId(),
applicationId: applicationId,
openId,
},
indexFrom: 0,
@ -106,8 +107,9 @@ async function setUserUnsubscribed(openId: string, context: BRC<EntityDict>) {
data: {
id: await generateNewIdAsync(),
subscribed: false,
applicationId: context.getApplicationId(),
applicationId: applicationId,
openId,
origin: applicationType === 'wechatPublic' ? 'public' : 'web',
},
},
{ dontCollect: true }