wechatmenu

This commit is contained in:
qsc 2023-09-22 19:18:02 +08:00
parent 9c08856b6d
commit 6881bea7f7
349 changed files with 905 additions and 737 deletions

View File

@ -2,6 +2,7 @@ import { WebEnv, WechatMpEnv } from 'oak-domain/lib/types/Environment';
import { AppType } from '../oak-app-domain/Application/Schema';
import { EntityDict } from '../oak-app-domain';
import { Config } from '../types/Config';
import { MenuType } from '../types/WeChat';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
export type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
mergeUser: (params: {
@ -105,6 +106,9 @@ export type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeC
result: string;
times?: number;
}>;
uploadWechatMedia: (params: any, context: Cxt) => Promise<{
mediaId: string;
}>;
getCurrentMenu: (params: {
applicationId: string;
}, context: Cxt) => Promise<any>;
@ -133,21 +137,15 @@ export type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeC
applicationId: string;
article_id: string;
}, context: Cxt) => Promise<any>;
createMaterial: (params: {
applicationId: string;
type: 'image' | 'voice' | 'video' | 'thumb';
media: FormData;
description?: FormData;
}, context: Cxt) => Promise<any>;
batchGetMaterialList: (params: {
applicationId: string;
type: 'image' | 'video' | 'voice' | 'news';
type: MenuType;
offset?: number;
count: number;
}, context: Cxt) => Promise<any>;
getMaterial: (params: {
applicationId: string;
type: 'image' | 'video' | 'voice' | 'news';
type: MenuType;
media_id: string;
}, context: Cxt) => Promise<any>;
};

View File

@ -1,6 +1,7 @@
import { EntityDict } from "../oak-app-domain";
import { AppType } from "../oak-app-domain/Application/Schema";
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
import { MediaType } from '../types/WeChat';
import { WebEnv } from 'oak-domain/lib/types/Environment';
export declare function getApplication<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
type: AppType;
@ -18,6 +19,10 @@ export declare function signatureJsSDK<ED extends EntityDict, Cxt extends Backen
export declare function uploadWechatMedia<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
applicationId: string;
file: any;
}, context: Cxt): Promise<{
type: MediaType;
isPermanent?: string;
description?: string;
}, // FormData表单提交 isPermanent 变成 'true' | 'false'
context: Cxt): Promise<{
mediaId: string;
}>;

View File

@ -1,6 +1,7 @@
import { assert } from 'oak-domain/lib/utils/assert';
import { applicationProjection } from '../types/Projection';
import { WechatSDK, } from 'oak-external-sdk';
import fs from 'fs';
export async function getApplication(params, context) {
const { type, domain } = params;
const url = context.getHeader('host');
@ -56,6 +57,38 @@ export async function signatureJsSDK({ url, env }, context) {
const result = await wechatInstance.signatureJsSDK({ url });
return result;
}
export async function uploadWechatMedia(params, context) {
throw new Error('method not implemented');
export async function uploadWechatMedia(params, // FormData表单提交 isPermanent 变成 'true' | 'false'
context) {
const { applicationId, file, type: mediaType, isPermanent, description, } = params;
const file2 = fs.createReadStream(file.filepath);
const [application] = await context.select('application', {
data: applicationProjection,
filter: {
id: applicationId,
},
}, {
dontCollect: true,
});
const { type, config } = application;
assert(type === 'wechatPublic' && config.type === 'wechatPublic');
const config2 = config;
const { appId, appSecret } = config2;
const wechatInstance = WechatSDK.getInstance(appId, 'wechatPublic', appSecret);
if (isPermanent === 'true') {
const result = (await wechatInstance.createMaterial({
type: mediaType,
media: file2,
description: description ? JSON.parse(description) : null,
}));
return {
mediaId: result.media_id,
};
}
const result = (await wechatInstance.createTemporaryMaterial({
type: mediaType,
media: file2,
}));
return {
mediaId: result.media_id,
};
}

View File

@ -1,13 +1,13 @@
import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCaptcha, switchTo, refreshWechatPublicUserInfo, getWechatMpUserPhoneNumber, logout, loginByWechat, wakeupParasite } from './token';
import { getInfoByUrl } from './extraFile';
import { getApplication, signatureJsSDK } from './application';
import { getApplication, signatureJsSDK, uploadWechatMedia } from './application';
import { updateConfig, updateApplicationConfig } from './config';
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
import { createWechatLogin } from './wechatLogin';
import { unbindingWechat } from './wechatUser';
import { getMpUnlimitWxaCode } from './wechatQrCode';
import { confirmUserEntityGrant } from './userEntityGrant';
import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteConditionalMenu, batchGetArticle, getArticle, createMaterial, batchGetMaterialList, getMaterial } from './wechatMenu';
import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteConditionalMenu, batchGetArticle, getArticle, batchGetMaterialList, getMaterial } from './wechatMenu';
declare const aspectDict: {
mergeUser: typeof mergeUser;
switchTo: typeof switchTo;
@ -32,6 +32,7 @@ declare const aspectDict: {
updateUserPassword: typeof updateUserPassword;
getMpUnlimitWxaCode: typeof getMpUnlimitWxaCode;
confirmUserEntityGrant: typeof confirmUserEntityGrant;
uploadWechatMedia: typeof uploadWechatMedia;
getCurrentMenu: typeof getCurrentMenu;
getMenu: typeof getMenu;
createMenu: typeof createMenu;
@ -39,7 +40,6 @@ declare const aspectDict: {
deleteConditionalMenu: typeof deleteConditionalMenu;
batchGetArticle: typeof batchGetArticle;
getArticle: typeof getArticle;
createMaterial: typeof createMaterial;
batchGetMaterialList: typeof batchGetMaterialList;
getMaterial: typeof getMaterial;
};

View File

@ -1,13 +1,13 @@
import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCaptcha, switchTo, refreshWechatPublicUserInfo, getWechatMpUserPhoneNumber, logout, loginByWechat, wakeupParasite, } from './token';
import { getInfoByUrl } from './extraFile';
import { getApplication, signatureJsSDK } from './application';
import { getApplication, signatureJsSDK, uploadWechatMedia, } from './application';
import { updateConfig, updateApplicationConfig } from './config';
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
import { createWechatLogin } from './wechatLogin';
import { unbindingWechat } from './wechatUser';
import { getMpUnlimitWxaCode } from './wechatQrCode';
import { confirmUserEntityGrant } from './userEntityGrant';
import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteConditionalMenu, batchGetArticle, getArticle, createMaterial, batchGetMaterialList, getMaterial, } from './wechatMenu';
import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteConditionalMenu, batchGetArticle, getArticle, batchGetMaterialList, getMaterial, } from './wechatMenu';
const aspectDict = {
mergeUser,
switchTo,
@ -32,6 +32,7 @@ const aspectDict = {
updateUserPassword,
getMpUnlimitWxaCode,
confirmUserEntityGrant,
uploadWechatMedia,
getCurrentMenu,
getMenu,
createMenu,
@ -39,7 +40,6 @@ const aspectDict = {
deleteConditionalMenu,
batchGetArticle,
getArticle,
createMaterial,
batchGetMaterialList,
getMaterial,
};

View File

@ -1,5 +1,6 @@
import { EntityDict } from '../oak-app-domain';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { MenuType } from '../types/WeChat';
export declare function getCurrentMenu<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
applicationId: string;
}, context: Cxt): Promise<any>;
@ -28,20 +29,14 @@ export declare function getArticle<ED extends EntityDict, Cxt extends BackendRun
applicationId: string;
article_id: string;
}, context: Cxt): Promise<any>;
export declare function createMaterial<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
applicationId: string;
type: 'image' | 'voice' | 'video' | 'thumb';
media: FormData;
description?: FormData;
}, context: Cxt): Promise<any>;
export declare function batchGetMaterialList<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
applicationId: string;
type: 'image' | 'video' | 'voice' | 'news';
type: MenuType;
offset?: number;
count: number;
}, context: Cxt): Promise<any>;
export declare function getMaterial<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
applicationId: string;
type: 'image' | 'video' | 'voice' | 'news';
type: MenuType;
media_id: string;
}, context: Cxt): Promise<any>;

View File

@ -1,4 +1,5 @@
import { WechatSDK, } from 'oak-external-sdk';
import { assert } from 'oak-domain/lib/utils/assert';
async function getWechatPublicConfig(applicationId, context) {
const [application] = await context.select('application', {
data: {
@ -8,7 +9,6 @@ async function getWechatPublicConfig(applicationId, context) {
},
filter: {
id: applicationId,
type: 'wechatPublic'
},
}, {
dontCollect: true
@ -17,131 +17,118 @@ async function getWechatPublicConfig(applicationId, context) {
}
export async function getCurrentMenu(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getCurrentMenu();
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getCurrentMenu();
return result;
}
export async function getMenu(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getMenu();
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getMenu();
return result;
}
export async function createMenu(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.createMenu(params.menuConfig);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.createMenu(params.menuConfig);
return result;
}
export async function createConditionalMenu(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.createConditionalMenu(params.menuConfig);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.createConditionalMenu(params.menuConfig);
return result;
}
export async function deleteConditionalMenu(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.deleteConditionalMenu(params.menuid);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.deleteConditionalMenu(params.menuid);
return result;
}
export async function batchGetArticle(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.batchGetArticle(params);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.batchGetArticle(params);
return result;
}
export async function getArticle(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getArticle(params);
return result;
}
}
export async function createMaterial(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.createMaterial(params);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getArticle(params);
return result;
}
export async function batchGetMaterialList(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.batchGetMaterialList(params);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.batchGetMaterialList(params);
return result;
}
export async function getMaterial(params, context) {
const application = await getWechatPublicConfig(params.applicationId, context);
if (application) {
const { type, config, systemId } = application;
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getMaterial(params);
return result;
}
assert(application);
const { type, config, systemId } = application;
assert(type === 'wechatPublic');
let appId, appSecret;
const config2 = config;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
const result = await wechatInstance.getMaterial(params);
return result;
}

View File

@ -37,5 +37,5 @@ export type Poi = {
email?: string;
businessArea?: string;
};
declare const Location: (props: LocationProps) => JSX.Element;
declare const Location: (props: LocationProps) => import("react/jsx-runtime").JSX.Element;
export default Location;

View File

@ -29,5 +29,5 @@ export interface AMapProps extends APILoaderProps {
securityJsCode?: string;
serviceHost?: string;
}
declare const memo: (props: AMapProps) => JSX.Element;
declare const memo: (props: AMapProps) => import("react/jsx-runtime").JSX.Element;
export default memo;

View File

@ -7,4 +7,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'article', f
name: string;
width: string;
editor: any;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'article', f
content?: string;
html?: string;
origin?: string;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'article', f
content?: string;
html?: string;
origin?: string;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -19,4 +19,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'articleMenu
setCurrentArticle: (id: string) => void;
}, {
createOne: () => Promise<void>;
}>): JSX.Element | null;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -26,4 +26,4 @@ export default function Render(props: WebComponentProps<EntityDict, "article", f
}>;
clearContentTip: () => void;
gotoPreview: (content?: string, title?: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -34,4 +34,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'articleMenu
createSubArticle: (name: string) => Promise<void>;
createSubArticleMenu: (name: string) => Promise<void>;
gotoDoc: (articleMenuId: string) => void;
}>): JSX.Element | null;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -33,4 +33,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'articleMenu
createOne: (name?: string) => Promise<void>;
getDefaultArticle: (rows: EntityDict['articleMenu']['OpSchema'][]) => void;
getSearchArticle: () => Promise<string[]>;
}>): JSX.Element | null;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -14,4 +14,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'articleMenu
searchArticle: (searchValue: string) => void;
getArticleMenuIdByArticle: (articleId: string, type: string) => void;
gotoSearchArticleAndArticleMenu: (articleMenuId: string, articleId: string) => void;
}>): JSX.Element | null;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -10,4 +10,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
setMobile: (value: string) => void;
sendCaptcha: (mobile: string) => Promise<void>;
onConfirmByMobile: (mobile: string, captcha: string, newPassword: string) => Promise<void>;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -5,4 +5,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
failTimes: number;
}, {
onConfirm: (prevPassword: string, password: string) => Promise<void>;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -6,4 +6,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
oakId: string;
}, {
goToMobile: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -7,7 +7,7 @@ type IDownloadProps = {
style?: React.CSSProperties;
filename?: string;
};
declare function Download(props: IDownloadProps): JSX.Element;
declare function Download(props: IDownloadProps): import("react/jsx-runtime").JSX.Element;
declare namespace Download {
var onDownload: (arrayBuffer: ArrayBuffer, filename: string) => void;
var base64ToBlob: (base64String: string) => Blob;

View File

@ -1,3 +1,3 @@
import './index.less';
declare const Empty: () => JSX.Element;
declare const Empty: () => import("react/jsx-runtime").JSX.Element;
export default Empty;

View File

@ -1,3 +1,3 @@
import './index.less';
declare const Empty: () => JSX.Element;
declare const Empty: () => import("react/jsx-runtime").JSX.Element;
export default Empty;

View File

@ -15,5 +15,5 @@ interface IErrorPageProps {
children?: React.ReactNode;
icon?: React.ReactNode;
}
declare function ErrorPage(props: IErrorPageProps): JSX.Element;
declare function ErrorPage(props: IErrorPageProps): import("react/jsx-runtime").JSX.Element;
export default ErrorPage;

View File

@ -15,5 +15,5 @@ type GridProps = {
list: Array<Item>;
onChange?: (index: number, event?: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
};
declare const _default: React.MemoExoticComponent<(props: GridProps) => JSX.Element>;
declare const _default: React.MemoExoticComponent<(props: GridProps) => import("react/jsx-runtime").JSX.Element>;
export default _default;

View File

@ -17,5 +17,5 @@ type PageHeaderProps = {
children?: React.ReactNode;
showHeader?: boolean;
};
declare const _default: React.MemoExoticComponent<(props: PageHeaderProps) => JSX.Element>;
declare const _default: React.MemoExoticComponent<(props: PageHeaderProps) => import("react/jsx-runtime").JSX.Element>;
export default _default;

View File

@ -14,5 +14,5 @@ type IQrCodeProps = {
successed?: boolean;
type?: EntityDict['wechatLogin']['Schema']['type'];
};
declare function QrCode(props: IQrCodeProps): JSX.Element;
declare function QrCode(props: IQrCodeProps): import("react/jsx-runtime").JSX.Element;
export default QrCode;

View File

@ -5,5 +5,5 @@ type Props = {
description?: string;
children?: React.ReactNode;
};
declare const _default: React.MemoExoticComponent<(props: Props) => JSX.Element>;
declare const _default: React.MemoExoticComponent<(props: Props) => import("react/jsx-runtime").JSX.Element>;
export default _default;

View File

@ -5,5 +5,5 @@ type Props = {
description?: string;
children?: React.ReactNode;
};
declare const _default: React.MemoExoticComponent<(props: Props) => JSX.Element>;
declare const _default: React.MemoExoticComponent<(props: Props) => import("react/jsx-runtime").JSX.Element>;
export default _default;

View File

@ -14,5 +14,5 @@ interface GrantProps {
rootStyle?: React.CSSProperties;
rootClassName?: string;
}
declare function Grant(props: GrantProps): JSX.Element;
declare function Grant(props: GrantProps): import("react/jsx-runtime").JSX.Element;
export default Grant;

View File

@ -14,5 +14,5 @@ interface QrCodeProps {
rootStyle?: React.CSSProperties;
rootClassName?: string;
}
declare function QrCode(props: QrCodeProps): JSX.Element;
declare function QrCode(props: QrCodeProps): import("react/jsx-runtime").JSX.Element;
export default QrCode;

View File

@ -15,5 +15,5 @@ export default function render(props: WebComponentProps<EntityDict, 'user', fals
setValue: (path: string, value: string) => void;
removeItem: (path: string, index: number) => void;
cleanKey: (path: string, key: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;
export {};

View File

@ -4,4 +4,4 @@ export default function Web(props: {
setValue: (path: string, value: any) => void;
removeItem: (path: string, index: number) => void;
cleanKey: (path: string, key: string) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -4,4 +4,4 @@ export default function WechatMp(props: {
setValue: (path: string, value: any) => void;
removeItem: (path: string, index: number) => void;
cleanKey: (path: string, key: string) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -5,4 +5,4 @@ export default function WechatPublic(props: {
setValue: (path: string, value: any) => void;
removeItem: (path: string, index: number) => void;
cleanKey: (path: string, key: string) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -3,5 +3,5 @@ type StyleProps = {
value?: StyleType | null;
onChange: (value: StyleType) => void;
};
export default function Render(props: StyleProps): JSX.Element;
export default function Render(props: StyleProps): import("react/jsx-runtime").JSX.Element;
export {};

View File

@ -3,4 +3,4 @@ export default function Account(props: {
account: Required<Config>['Account'];
setValue: (path: string, value: any) => void;
removeItem: (path: string, index: number) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -2,4 +2,4 @@ import { Config } from '../../../../types/Config';
export default function Cos(props: {
cos: Required<Config>['Cos'];
setValue: (path: string, value: any) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -2,4 +2,4 @@ import { Config } from '../../../../types/Config';
export default function Cos(props: {
live: Required<Config>['Live'];
setValue: (path: string, value: any) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -2,4 +2,4 @@ import { Config } from '../../../../types/Config';
export default function Cos(props: {
map: Required<Config>['Map'];
setValue: (path: string, value: any) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -4,4 +4,4 @@ export default function Sms(props: {
setValue: (path: string, value: any) => void;
removeItem: (path: string, index: number) => void;
cleanKey: (path: string, key: string) => void;
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -12,4 +12,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
setValue: (path: string, value: string) => void;
removeItem: (path: string, index: number) => void;
cleanKey: (path: string, key: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -6,4 +6,4 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
avatarUrl?: string;
}, {
onPickByWeb: (files: File[]) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -1 +1 @@
export default function render(): JSX.Element;
export default function render(): import("react/jsx-runtime").JSX.Element;

View File

@ -19,5 +19,5 @@ export default function render(props: WebComponentProps<EntityDict, "extraFile",
closeModal: () => void;
onModal1Confirm: (value: number) => void;
setSelectedId: (id: number) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;
export {};

View File

@ -3,7 +3,6 @@ import { WebComponentProps } from "oak-frontend-base";
import { EntityDict } from "../../../oak-app-domain";
interface NewUploadFile extends UploadFile {
id?: string;
status?: 'done' | 'uploading' | 'error' | 'success' | 'removed';
}
type Theme = "file" | "image" | "image-flow" | "custom";
export default function render(props: WebComponentProps<EntityDict, "extraFile", true, {
@ -34,5 +33,5 @@ export default function render(props: WebComponentProps<EntityDict, "extraFile",
getUrl: (extraFile: EntityDict['extraFile']['OpSchema']) => string;
getFileName: (extraFile: EntityDict['extraFile']['OpSchema']) => string;
eFFormatBytes: (value: number) => string;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;
export {};

View File

@ -27,4 +27,4 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
}, {
onDeleteByWeb: (file: UploadFile) => void;
addFileByWeb: (file: UploadFile) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -9,4 +9,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
action: string;
}>;
onActionClick: (action: string) => void;
}>): JSX.Element | null;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -9,4 +9,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
action: string;
}>;
onActionClick: (action: string) => void;
}>): JSX.Element | null;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -10,4 +10,4 @@ export default function render(props: WebComponentProps<EntityDict, 'address', t
resetInitialData: () => void;
downloadEnv: () => void;
resetEnv: (data: Record<string, any>) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
size?: string;
className?: string;
style?: React.CSSProperties;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -11,4 +11,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
router: EntityDict['message']['Schema']['router'];
visitState: EntityDict['message']['Schema']['visitState'];
id: string;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -10,4 +10,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
router: EntityDict['message']['Schema']['router'];
}, {
goPage: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -10,4 +10,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
router: EntityDict['message']['Schema']['router'];
}, {
goPage: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -4,4 +4,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', t
messages: EntityDict['message']['Schema'][];
}, {
goDetailById: (id: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -4,4 +4,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', t
messages: RowWithActions<EntityDict, 'message'>[];
}, {
goDetailById: (id: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -7,4 +7,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'message', f
}, {
goDetailById: (id: string) => void;
goMessageList: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -3,4 +3,4 @@ export default function render(props: {
data: {
data: MessageProps;
};
}): JSX.Element;
}): import("react/jsx-runtime").JSX.Element;

View File

@ -5,4 +5,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'messageType
dirtyIds: string[];
messageTypes: string[];
applicationId: string;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -9,4 +9,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'token', fal
iconName?: string;
iconLarger?: string;
onClick?: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -13,4 +13,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'token', fal
}, {
logout: () => void;
updateAttribute: (attr: string, value: any) => Promise<void>;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -13,4 +13,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'token', fal
}, {
logout: () => void;
updateAttribute: (attr: string, value: any) => Promise<void>;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
style?: React.CSSProperties;
}, {
goMessageList: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -10,4 +10,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
buttonClassName?: string;
}, {
goMessageList: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -6,4 +6,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'userEntityG
url: string;
expiresAt: number;
title?: string;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -4,4 +4,4 @@ export default function render(props: WebComponentProps<EntityDict, 'parasite',
loading: boolean;
illegal: boolean;
expired: boolean;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -7,4 +7,4 @@ export default function render(props: WebComponentProps<EntityDict, 'parasite',
}, {
cancel: () => void;
getQrCode: () => Promise<void>;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -19,4 +19,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'parasite',
onSearch: (value: string) => void;
onSelect: (value: string) => void;
setSearchValue: (value: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -16,4 +16,4 @@ export default function render(props: WebComponentProps<EntityDict, 'area', true
setCheckedList: (station: string, flag: boolean) => void;
cancel: () => void;
confirm: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -3,5 +3,5 @@ interface IProps {
defaultValue?: number | string;
onChange: (color: string) => void;
}
declare const _default: React.MemoExoticComponent<(props: IProps) => JSX.Element>;
declare const _default: React.MemoExoticComponent<(props: IProps) => import("react/jsx-runtime").JSX.Element>;
export default _default;

View File

@ -9,5 +9,5 @@ interface IProps {
onChange: (value?: any) => void;
options: IOption[];
}
declare const _default: React.MemoExoticComponent<(props: IProps) => JSX.Element>;
declare const _default: React.MemoExoticComponent<(props: IProps) => import("react/jsx-runtime").JSX.Element>;
export default _default;

View File

@ -1 +1 @@
export default function Render(this: any): JSX.Element;
export default function Render(this: any): import("react/jsx-runtime").JSX.Element;

View File

@ -19,4 +19,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'token', fal
sendCaptcha: (mobile: string) => Promise<void>;
loginByMobile: (mobile: string, password?: string, captcha?: string) => Promise<void>;
setLoginMode: (value: number) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -17,4 +17,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', true
goUpsert: () => void;
confirmDelete: (id: string) => Promise<void>;
goUpdate: (id: string) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -11,4 +11,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', true
goUpsert: () => void;
goUpdate: (id: string) => void;
confirmDelete: (id: string) => Promise<void>;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -1 +1 @@
export default function render(this: any): JSX.Element;
export default function render(this: any): import("react/jsx-runtime").JSX.Element;

View File

@ -11,4 +11,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'mobile', fa
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -13,4 +13,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'mobile', fa
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
}, {
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
}, {
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -14,5 +14,5 @@ export default function render(props: WebComponentProps<EntityDict, 'userEntityG
setInit: () => void;
setPeriod: (p: number) => void;
setUnit: (u: Unit) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;
export {};

View File

@ -18,5 +18,5 @@ export default function render(props: WebComponentProps<EntityDict, 'userEntityG
setInit: () => void;
setPeriod: (p: number) => void;
setUnit: (u: Unit) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;
export {};

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
}[];
}, {
onRelationChange: (relation: EntityDict['relation']['OpSchema'], checked: boolean) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -8,4 +8,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
}[];
}, {
onRelationChange: (relation: EntityDict['relation']['OpSchema'], checked: boolean) => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -15,4 +15,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -16,4 +16,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -11,4 +11,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'relation',
entityId: string;
relations: EntityDict['relation']['OpSchema'][];
qrCodeType?: QrCodeType;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -6,4 +6,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'wechatLogin
loading: boolean;
successed: boolean;
type: EntityDict['wechatLogin']['Schema']['type'];
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -1,6 +1,7 @@
/// <reference types="react" />
import { MenuType } from '../../types/WeChat';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../oak-app-domain").EntityDict, keyof import("../../oak-app-domain").EntityDict, false, {
type: "image" | "video" | "news" | "voice";
type: MenuType;
getMenuContent: (menuContent: any) => void;
applicationId: string;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;

View File

@ -11,26 +11,29 @@ export default OakComponent({
let result;
if (type === 'news') {
result = await this.features.wechatMenu.batchGetArticle({ applicationId: applicationId, offset: 0, count: 10, noContent: 0 });
const modifiedResult = await Promise.all(result.item.map(async (ele) => {
const news_item = await Promise.all(ele.content.news_item.map(async (ele2) => {
const coverUrl = await this.getMaterialImg(ele2.thumb_media_id);
const news = JSON.parse(result);
if (news && news.item.length > 0) {
const modifiedResult = await Promise.all(news.item.map(async (ele) => {
const news_item = await Promise.all(ele.content.news_item.map(async (ele2) => {
const coverUrl = await this.getMaterialImg(ele2.thumb_media_id);
return {
...ele2,
coverUrl
};
}));
return {
...ele2,
coverUrl
...ele,
content: {
...ele.content,
news_item
}
};
}));
return {
...ele,
content: {
...ele.content,
news_item
}
};
}));
this.setState({
materials: modifiedResult,
total: result.total_count,
});
this.setState({
materials: modifiedResult,
total: news.total_count,
});
}
}
else {
result = await this.features.wechatMenu.batchGetMaterialList({ applicationId: applicationId, type: type, offset: 0, count: 10 });
@ -81,8 +84,8 @@ export default OakComponent({
const { applicationId } = this.props;
const { type } = this.props;
console.log(media);
const result = await this.features.wechatMenu.createMaterial({ applicationId: applicationId, type: type, media, description });
if (result && result.media_id) {
const result = await this.features.wechatMenu.createMaterial({ applicationId: applicationId, type: type, file: media, description, isPermanent: true });
if (result && result.mediaId) {
this.setMessage({
type: 'success',
content: '上传成功',

View File

@ -1,5 +1,6 @@
import { EntityDict } from "../../oak-app-domain";
import { WebComponentProps } from 'oak-frontend-base';
import { MediaVideoDescription } from '../../types/WeChat';
export default function Render(props: WebComponentProps<EntityDict, keyof EntityDict, true, {
type: string;
materials: any[];
@ -8,5 +9,5 @@ export default function Render(props: WebComponentProps<EntityDict, keyof Entity
}, {
getMaterialList: (page: number) => void;
getArticleList: (page: number) => void;
upload: (media: FormData, description?: FormData) => boolean;
upload: (media: File, description?: MediaVideoDescription) => boolean;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -14,7 +14,7 @@ export default function Render(props) {
const [title, setTitle] = useState('');
const [introduction, setIntroduction] = useState('');
const [fileList, setFileList] = useState([]);
const [video, setVideo] = useState(new FormData);
const [video, setVideo] = useState();
const checkFileType = (filename) => {
const fileExtension = filename?.split('.')?.pop()?.toLowerCase();
let allowedExtensions = [];
@ -40,10 +40,8 @@ export default function Render(props) {
};
const uploadFile = async (file) => {
if (checkFileType(file.name)) {
const formData = new FormData();
formData.append('media', file);
console.log(file);
upload(formData);
const newFile = { ...file };
upload(file);
}
else {
return;
@ -54,9 +52,7 @@ export default function Render(props) {
};
const uploadVideo = async (file) => {
if (checkFileType(file.name)) {
const formData = new FormData();
formData.append('media', file);
setVideo(formData);
setVideo(file);
const updataFileList = fileList.map((ele) => {
return {
...ele,
@ -215,8 +211,7 @@ export default function Render(props) {
title,
introduction,
};
formData.append('description', JSON.stringify(descriptionData));
if (upload(video, formData)) {
if (upload(video, descriptionData)) {
setUpsertOpen(false);
}
}, children: "\u4E0A\u4F20" }), _jsx(Button, { onClick: () => setUpsertOpen(false), children: "\u53D6\u6D88" })] }), children: _jsxs("div", { children: [_jsx(Form.Item, { label: _jsx("div", { className: Style.label, children: "\u6807\u9898" }), required: true, labelAlign: 'right', labelCol: { span: 4 }, children: _jsx(Input, { showCount: true, maxLength: 20, value: title, onChange: (val) => setTitle(val.target.value) }) }), _jsx(Form.Item, { label: _jsx("div", { className: Style.label, children: "\u89C6\u9891\u4ECB\u7ECD" }), required: true, children: _jsx(TextArea, { showCount: true, maxLength: 300, value: introduction, autoSize: { minRows: 5 }, onChange: (val) => setIntroduction(val.target.value) }) }), _jsx(Form.Item, { label: _jsx("div", { className: Style.label, children: "\u4E0A\u4F20\u89C6\u9891" }), required: true, children: _jsx(Upload, { customRequest: ({ file }) => uploadVideo(file), maxCount: 1, onChange: fileChange, fileList: fileList, children: _jsxs(Button, { children: [_jsx(DownloadOutlined, {}), fileList.length > 0 ? '重新' : '', "\u4E0A\u4F20"] }) }) })] }) })] }), _jsx("div", { className: Style.list, children: _jsx(Table, { rowKey: type === 'news' ? 'article_id' : 'media_id', dataSource: materials, columns: type === 'news' ? newsColumns : columns, pagination: {

View File

@ -65,6 +65,12 @@ export default OakComponent({
}
return '';
},
confirmUrl(url) {
const pattern = /^(https:\/\/|http:\/\/)/;
if (!pattern.test(url)) {
return '公众号链接需要以https://或http://开头';
}
},
editMenuName(index, name, currentIndex) {
const { config, changeConfig } = this.props;
if (typeof currentIndex === 'number') {
@ -170,7 +176,21 @@ export default OakComponent({
getErrorIndex(errorIndex);
return errorIndex;
},
async createMenu() {
async createMenu(errorInfo, errorUrlInfo) {
if (errorInfo) {
this.setMessage({
type: 'warning',
content: '菜单名称有误'
});
return;
}
if (errorUrlInfo) {
this.setMessage({
type: 'warning',
content: '公众号链接有误'
});
return;
}
const { applicationId, config, changeConfig, changePublishState, createMenu, menuType, changeMenuId } = this.props;
if (this.checkError(config.button).length === 0 && config.button.length > 0) {
changeConfig(config);

View File

@ -32,6 +32,7 @@ export default function Render(props: WebComponentProps<EntityDict, keyof Entity
getMaterialVideo: (media_id: string) => void;
decideMenuContentLabel: (obj: any, type: 'news' | 'image' | 'video' | 'voice' | 'text') => string;
getArticle: (article_id: string) => void;
createMenu: () => void;
createMenu: (errorInfo: string, errorUrlInfo: string) => void;
deleteConditionalMenu: () => void;
confirmUrl: (url: string) => string;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -14,9 +14,10 @@ import TextClick from '../textClick';
export default function Render(props) {
const { data, methods } = props;
const { config, menuIndex, selectedBtn, selectedSubBtn, currentIndex, changeIsPreview, getOpen, menuType, applicationId, menuId } = data;
const { setConfig, confirmName, confirmSubName, editMenuName, deleteMenuContent, getMaterialImgAndVoice, getMaterialVideo, decideMenuContentLabel, getArticle, createMenu, deleteConditionalMenu } = methods;
const { setConfig, confirmName, confirmSubName, editMenuName, deleteMenuContent, getMaterialImgAndVoice, getMaterialVideo, decideMenuContentLabel, getArticle, createMenu, deleteConditionalMenu, confirmUrl, } = methods;
const [msgType, setMsgType] = useState('sendMsg');
const [errorInfo, setErrorInfo] = useState('');
const [errorUrlInfo, setErrorUrlInfo] = useState('');
const [onlyOne, setOnlyOne] = useState(true);
const [menuName, setMenuName] = useState('');
const [open, setOpen] = useState(false);
@ -377,11 +378,14 @@ export default function Render(props) {
setOpen(false);
getOpen(false);
setMenuContent(null);
}, destroyOnClose: true, width: 960, children: _jsx(WechatMaterialLibrary, { oakAutoUnmount: true, type: type, getMenuContent: getMenuContent, applicationId: applicationId }) })] })) : msgType === 'view' ? (_jsxs(Form.Item, { colon: false, label: _jsx("div", { className: Style.label, children: "\u7F51\u9875\u94FE\u63A5" }), children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(Input, { placeholder: '\u516C\u4F17\u53F7\u94FE\u63A5', style: { width: 340 }, value: url, onChange: (val) => setUrl(val.target.value) }), _jsx("a", { style: { padding: '10px 0' }, onClick: () => { setOpen(true); getOpen(true); }, children: "\u9009\u62E9\u56FE\u6587\u94FE\u63A5" })] }), _jsx(Modal, { open: open, footer: null, title: '选择图文链接', onCancel: () => { setOpen(false); getOpen(false); }, width: 600, children: _jsx(SelectArticle, { oakAutoUnmount: true, changeOpen: changeOpen, getUrl: getUrl, applicationId: applicationId }) })] })) : (_jsxs(Form.Item, { colon: false, label: _jsx("div", { className: Style.label, children: "\u5C0F\u7A0B\u5E8F" }), children: [_jsx(Button, { onClick: () => {
}, destroyOnClose: true, width: 960, children: _jsx(WechatMaterialLibrary, { oakAutoUnmount: true, type: type, getMenuContent: getMenuContent, applicationId: applicationId }) })] })) : msgType === 'view' ? (_jsxs(Form.Item, { colon: false, label: _jsx("div", { className: Style.label, children: "\u7F51\u9875\u94FE\u63A5" }), help: _jsx(_Fragment, { children: errorUrlInfo && _jsx("div", { style: { color: '#fa5151' }, children: errorUrlInfo }) }), children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(Input, { placeholder: '\u516C\u4F17\u53F7\u94FE\u63A5:\u8BF7\u4EE5https://\u6216http://\u5F00\u5934', style: { width: 340 }, value: url, onChange: (val) => {
setUrl(val.target.value);
setErrorUrlInfo(confirmUrl(val.target.value));
}, status: errorUrlInfo ? 'error' : '' }), _jsx("a", { style: { padding: '10px 0' }, onClick: () => { setOpen(true); getOpen(true); }, children: "\u9009\u62E9\u56FE\u6587\u94FE\u63A5" })] }), _jsx(Modal, { open: open, footer: null, title: '选择图文链接', onCancel: () => { setOpen(false); getOpen(false); }, width: 600, children: _jsx(SelectArticle, { oakAutoUnmount: true, changeOpen: changeOpen, getUrl: getUrl, applicationId: applicationId }) })] })) : (_jsxs(Form.Item, { colon: false, label: _jsx("div", { className: Style.label, children: "\u5C0F\u7A0B\u5E8F" }), children: [_jsx(Button, { onClick: () => {
setOpen(true);
getOpen(true);
}, children: "\u9009\u62E9\u5C0F\u7A0B\u5E8F" }), menuContent && menuContent.appid && _jsx("div", { children: menuContent.appid }), _jsx(Modal, { title: '添加小程序', open: open, footer: null, onCancel: () => { setOpen(false); getOpen(false); }, children: _jsx(SelectMiniprogram, { oakAutoUnmount: true, getMenuContent: getMenuContent, changeOpen: changeOpen }) })] }))] })) : (null)] }), _jsx("div", { className: Style.actionBar, children: _jsxs(Space, { children: [_jsxs(Button, { onClick: () => changeIsPreview(true), children: [_jsx(EyeOutlined, {}), "\u9884\u89C8"] }), _jsxs(Button, { type: 'primary', onClick: async () => {
createMenu();
createMenu(errorInfo, errorUrlInfo);
}, children: [_jsx(CheckOutlined, {}), "\u53D1\u5E03"] }), menuType === 'conditional' && config && menuId && _jsxs(Button, { type: 'primary', danger: true, onClick: () => {
const modal = confirm({
title: '确定删除该个性化菜单吗?',
@ -394,6 +398,6 @@ export default function Render(props) {
},
});
}, children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] })] }) })] })) : (_jsxs("div", { className: Style.empty, children: [_jsx("div", { className: Style.content, children: "\u4F60\u672A\u6DFB\u52A0\u81EA\u5B9A\u4E49\u83DC\u5355\uFF0C\u70B9\u51FB\u5DE6\u4FA7\u6DFB\u52A0\u83DC\u5355\u4E3A\u516C\u4F17\u53F7\u521B\u5EFA\u83DC\u5355\u680F\u3002" }), _jsx("div", { className: Style.actionBar, children: _jsxs(Space, { children: [_jsxs(Button, { onClick: () => changeIsPreview(true), children: [_jsx(EyeOutlined, {}), "\u9884\u89C8"] }), _jsxs(Button, { type: 'primary', onClick: async () => {
createMenu();
createMenu(errorInfo, errorUrlInfo);
}, children: [_jsx(CheckOutlined, {}), "\u53D1\u5E03"] })] }) })] })) }));
}

View File

@ -2,4 +2,4 @@ import { EntityDict } from '../../../oak-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function Render(props: WebComponentProps<EntityDict, 'wechatUser', true, {
wechatUsers: EntityDict['wechatUser']['Schema'][];
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -4,4 +4,4 @@ export default function Render(props: WebComponentProps<EntityDict, 'wechatUser'
wechatLoginId: string;
qrCodeUrl: string;
loading: boolean;
}, {}>): JSX.Element;
}, {}>): import("react/jsx-runtime").JSX.Element;

View File

@ -22,4 +22,5 @@ export declare class Application<ED extends EntityDict, Cxt extends BackendRunti
initialize(appId?: string | null, projection?: EntityDict['application']['Selection']['data']): Promise<void>;
getApplication(): Partial<import("../oak-app-domain/Application/Schema").Schema> | undefined;
getApplicationId(): string | undefined;
uploadWechatMedia(formData: FormData): Promise<ReturnType<(AD & CommonAspectDict<ED, Cxt>)["uploadWechatMedia"]>>;
}

View File

@ -77,4 +77,16 @@ export class Application extends Feature {
getApplicationId() {
return this.applicationId;
}
async uploadWechatMedia(
// params: {
// applicationId: string;
// file: any;
// type: MediaType;
// isPermanent?: boolean; //上传临时素材 或永久素材
// description?: MediaVideoDescription;
// }
formData) {
const callBack = await this.cache.exec('uploadWechatMedia', formData);
return callBack.result;
}
}

View File

@ -6,6 +6,7 @@ import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
import { Cache } from 'oak-frontend-base/es/features/cache';
import { LocalStorage } from 'oak-frontend-base/es/features/localStorage';
import { MediaType, MediaVideoDescription, MenuType } from '../types/WeChat';
export declare class WechatMenu<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
private cache;
private storage;
@ -40,19 +41,20 @@ export declare class WechatMenu<ED extends EntityDict, Cxt extends BackendRuntim
}): Promise<ReturnType<(AD & CommonAspectDict<ED, Cxt>)["getArticle"]>>;
createMaterial(params: {
applicationId: string;
type: 'image' | 'voice' | 'video' | 'thumb';
media: FormData;
description?: FormData;
}): Promise<ReturnType<(AD & CommonAspectDict<ED, Cxt>)["createMaterial"]>>;
type: MediaType;
file: File;
description?: MediaVideoDescription;
isPermanent?: boolean;
}): Promise<ReturnType<(AD & CommonAspectDict<ED, Cxt>)["uploadWechatMedia"]>>;
batchGetMaterialList(params: {
applicationId: string;
type: 'image' | 'video' | 'voice' | 'news';
type: MenuType;
offset?: number;
count: number;
}): Promise<ReturnType<(AD & CommonAspectDict<ED, Cxt>)["batchGetMaterialList"]>>;
getMaterial(params: {
applicationId: string;
type: 'image' | 'video' | 'voice' | 'news';
type: MenuType;
media_id: string;
}): Promise<ReturnType<(AD & CommonAspectDict<ED, Cxt>)["getMaterial"]>>;
}

Some files were not shown because too many files have changed in this diff Show More