修改笔误build

This commit is contained in:
wenjiarui 2024-01-05 17:58:20 +08:00
parent c27e4ec428
commit d3787d37f4
34 changed files with 944 additions and 216 deletions

View File

@ -1,7 +1,7 @@
import { Style } from '../../../../types/Style';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, false, {
style: Style;
entity: "application" | "system" | "platform";
entity: "application" | "platform" | "system";
entityId: string;
name: string;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;

View File

@ -134,6 +134,56 @@ function QiniuAccount(props) {
]}></Tabs>
</Col>);
}
function CTYunAccount(props) {
const { accounts, setValue, removeItem, addItem } = props;
return (<Col flex="auto">
<Divider orientation="left" className={Styles.title}>
天翼云配置
</Divider>
<Tabs tabPosition={'top'} size={'middle'} type="editable-card" hideAdd={!(accounts.length > 0)} onEdit={(targetKey, action) => {
if (action === 'add') {
addItem('', accounts.length);
}
else {
removeItem('', parseInt(targetKey, 10));
}
}} items={accounts.length > 0
? accounts.map((ele, idx) => ({
key: `${idx}`,
label: `帐号${idx + 1}`,
children: (<Form colon={false} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="accessKey">
<>
<Input placeholder="请输入accessKey" type="text" value={ele.accessKey} onChange={(e) => setValue(`${idx}.accessKey`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="securityKey">
<>
<Input placeholder="请输入securityKey" type="text" value={ele.securityKey} onChange={(e) => setValue(`${idx}.securityKey`, e.target.value)}/>
</>
</Form.Item>
</Form>),
}))
: [
{
label: '新建帐号',
key: '0',
children: (<Form colon={true} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="accessKey">
<>
<Input placeholder="请输入accessKey" type="text" value="" onChange={(e) => setValue(`0.accessKey`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="securityKey">
<>
<Input placeholder="请输入securityKey" type="text" value="" onChange={(e) => setValue(`0.securityKey`, e.target.value)}/>
</>
</Form.Item>
</Form>),
},
]}></Tabs>
</Col>);
}
function AliAccount(props) {
const { accounts, setValue, removeItem, addItem } = props;
return (<Col flex="auto">
@ -274,7 +324,7 @@ function AmapAccount(props) {
}
export default function Account(props) {
const { account, setValue, removeItem } = props;
const { tencent, qiniu, ali, amap } = account;
const { tencent, qiniu, ali, amap, ctyun } = account;
return (<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<Row>
<Card className={Styles.tips}>
@ -283,6 +333,7 @@ export default function Account(props) {
</Row>
<TencentAccount accounts={tencent || []} setValue={(path, value) => setValue(`tencent.${path}`, value)} removeItem={(path, index) => removeItem(`tencent`, index)} addItem={(path, index) => setValue(`tencent.${index}`, {})}/>
<QiniuAccount accounts={qiniu || []} setValue={(path, value) => setValue(`qiniu.${path}`, value)} removeItem={(path, index) => removeItem(`qiniu`, index)} addItem={(path, index) => setValue(`qiniu.${index}`, {})}/>
<CTYunAccount accounts={ctyun || []} setValue={(path, value) => setValue(`ctyun.${path}`, value)} removeItem={(path, index) => removeItem(`ctyun`, index)} addItem={(path, index) => setValue(`ctyun.${index}`, {})}/>
<AliAccount accounts={ali || []} setValue={(path, value) => setValue(`ali.${path}`, value)} removeItem={(path, index) => removeItem(`ali`, index)} addItem={(path, index) => setValue(`ali.${index}`, {})}/>
<AmapAccount accounts={amap || []} setValue={(path, value) => setValue(`amap.${path}`, value)} removeItem={(path, index) => removeItem(`amap`, index)} addItem={(path, index) => setValue(`amap.${index}`, {})}/>
</Space>);

View File

@ -130,9 +130,175 @@ function QiniuCos(props) {
]}></Tabs>
</Col>);
}
const CTYunZoneArray = [
{
label: '郑州',
value: 'hazz',
},
{
label: '沈阳',
value: 'lnsy',
},
{
label: '四川成都',
value: 'sccd',
},
{
label: '乌鲁木齐',
value: 'xjwlmq',
},
{
label: '甘肃兰州',
value: 'gslz',
},
{
label: '山东青岛',
value: 'sdqd',
},
{
label: '贵州贵阳',
value: 'gzgy',
},
{
label: '湖北武汉',
value: 'hbwh',
},
{
label: '西藏拉萨',
value: 'xzls',
},
{
label: '安徽芜湖',
value: 'ahwh',
},
{
label: '广东深圳',
value: 'gdsz',
},
{
label: '江苏苏州',
value: 'jssz',
},
{
label: '上海2',
value: 'sh2',
},
];
function CTYunCos(props) {
const { cos, setValue, removeItem } = props;
return (<Col flex="auto">
<Divider orientation="left" className={Styles.title}>
天翼云配置
</Divider>
<Tabs tabPosition={'top'} size={'middle'} type="card" items={[
{
key: '0',
label: '配置项',
children: (<Form colon={true} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="accessKey">
<>
<Input placeholder="请输入accessKey" type="text" value={cos?.accessKey} onChange={(e) => setValue(`accessKey`, e.target.value)}/>
</>
</Form.Item>
{/* <Form.Item
label="bucket"
//name="bucket"
>
<>
<Input
placeholder="请输入bucket"
type="text"
value={cos?.bucket}
onChange={(e) =>
setValue(
`bucket`,
e.target.value
)
}
/>
</>
</Form.Item> */}
<Divider orientation="left" className={Styles.title}>
bucket配置
</Divider>
<Tabs tabPosition={'top'} size={'middle'} type="editable-card"
// hideAdd={!(sms.length > 0)}
onEdit={(targetKey, action) => {
if (action === 'add') {
setValue(`buckets.${cos?.buckets?.length || 0}`, {});
}
else {
removeItem('buckets', parseInt(targetKey, 10));
}
}} items={cos?.buckets?.length > 0
? cos.buckets.map((ele, idx) => ({
key: `${idx}`,
label: `bucket:${idx + 1}`,
children: (<Form colon={false} labelAlign="left" layout="vertical" style={{
marginTop: 10,
}}>
<Form.Item label="name">
<>
<Input placeholder="请输入name" type="text" value={ele.name} onChange={(e) => setValue(`buckets.${idx}.name`, e
.target
.value)}/>
</>
</Form.Item>
<Form.Item label="zone">
<>
<Select style={{
width: '100%',
}} placeholder="请选择存储区域" value={ele.zone} onChange={(value) => {
setValue(`buckets.${idx}.zone`, value);
}} options={CTYunZoneArray}/>
</>
</Form.Item>
<Form.Item label="domain">
<>
<Input placeholder="请输入domain" type="text" value={ele.domain} onChange={(e) => setValue(`buckets.${idx}.domain`, e
.target
.value)}/>
</>
</Form.Item>
<Form.Item label="protocol">
<>
<Select mode="multiple" allowClear style={{
width: '100%',
}} placeholder="请选择协议" value={ele?.protocol} onChange={(value) => {
setValue(`buckets.${idx}.protocol`, value);
}} options={[
{
label: 'http',
value: 'http',
},
{
label: 'https',
value: 'https',
},
]}/>
</>
</Form.Item>
</Form>),
}))
: []}/>
{cos?.buckets?.length > 0 && (<Form.Item label="defaultBucket">
<>
<Select allowClear style={{ width: '100%' }} placeholder="请选择默认bucket" value={cos.defaultBucket} onChange={(value) => {
setValue(`defaultBucket`, value);
}} options={cos.buckets.map((ele) => ({
label: ele.name,
value: ele.name,
}))}/>
</>
</Form.Item>)}
</Form>),
},
]}></Tabs>
</Col>);
}
export default function Cos(props) {
const { cos, setValue, removeItem } = props;
const { qiniu } = cos;
const { qiniu, ctyun } = cos;
return (<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<Row>
<Card className={Styles.tips}>
@ -140,5 +306,6 @@ export default function Cos(props) {
</Card>
</Row>
<QiniuCos cos={qiniu} setValue={(path, value) => setValue(`qiniu.${path}`, value)} removeItem={(path, index) => removeItem(`qiniu.${path}`, index)}/>
<CTYunCos cos={ctyun} setValue={(path, value) => setValue(`ctyun.${path}`, value)} removeItem={(path, index) => removeItem(`ctyun.${path}`, index)}/>
</Space>);
}

View File

@ -1,7 +1,7 @@
import { Config } from '../../../types/Config';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, false, {
config: Config;
entity: "system" | "platform";
entity: "platform" | "system";
name: string;
entityId: string;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;

View File

@ -25,121 +25,136 @@ function Ali(props) {
key: `${idx}`,
label: `短信${idx + 1}`,
children: (<Form colon={false} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="accessKeyId" name="accessKeyId">
<>
<Input placeholder="请输入accessKeyId" type="text" value={ele.accessKeyId} onChange={(e) => setValue(`${idx}.accessKeyId`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="defaultSignName" name="defaultSignName">
<>
<Input placeholder="请输入defaultSignName" type="text" value={ele.defaultSignName} onChange={(e) => setValue(`${idx}.defaultSignName`, e.target.value)}/>
</>
</Form.Item>
{/* <Form.Item
label="templates"
name="templates"
>
<Tabs
tabPosition={'top'}
size={'middle'}
type="editable-card"
// hideAdd={!(Object.keys(ele.templates).length > 0)}
onEdit={(
targetKey: any,
action: 'add' | 'remove'
) => {
if (action === 'add') {
setSmsIndex(`${idx}`);
setModal(true);
} else {
cleanKey(
`${idx}.templates`,
targetKey
);
}
}}
items={
Object.keys(
ele.templates || {}
).length > 0
? Object.keys(
ele.templates
).map((name, idx) => {
const template =
ele.templates[
name
];
return {
key: `${name}`,
label: `${name}`,
children: (
<Form
colon={
true
}
labelAlign="left"
layout="vertical"
style={{
marginTop: 10,
}}
>
<Form.Item
label="signName"
name="signName"
>
<>
<Input
placeholder="请输入signName"
type="text"
value={
template.signName
}
onChange={(
e
) =>
setValue(
`${idx}.templates.${name}.signName`,
e
.target
.value
)
}
/>
</>
</Form.Item>
<Form.Item
label="code"
name="code"
>
<>
<Input
placeholder="请输入code"
type="text"
value={
template.code
}
onChange={(
e
) =>
setValue(
`${idx}.templates.${name}.code`,
e
.target
.value
)
}
/>
</>
</Form.Item>
</Form>
),
};
})
: []
}
></Tabs>
</Form.Item> */}
</Form>),
<Form.Item label="accessKeyId" name="accessKeyId">
<>
<Input placeholder="请输入accessKeyId" type="text" value={ele.accessKeyId} onChange={(e) => setValue(`${idx}.accessKeyId`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="accessKeySecret" name="accessKeySecret">
<>
<Input placeholder="请输入accessKeySecret" type="text" value={ele.accessKeySecret} onChange={(e) => setValue(`${idx}.accessKeySecret`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="endpoint" name="endpoint">
<>
<Input placeholder="请输入endpoint" type="text" value={ele.endpoint} onChange={(e) => setValue(`${idx}.endpoint`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="apiVersion" name="apiVersion">
<>
<Input placeholder="请输入apiVersion" type="text" value={ele.apiVersion} onChange={(e) => setValue(`${idx}.defaultSignName`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="defaultSignName" name="defaultSignName">
<>
<Input placeholder="请输入defaultSignName" type="text" value={ele.defaultSignName} onChange={(e) => setValue(`${idx}.defaultSignName`, e.target.value)}/>
</>
</Form.Item>
{/* <Form.Item
label="templates"
name="templates"
>
<Tabs
tabPosition={'top'}
size={'middle'}
type="editable-card"
// hideAdd={!(Object.keys(ele.templates).length > 0)}
onEdit={(
targetKey: any,
action: 'add' | 'remove'
) => {
if (action === 'add') {
setSmsIndex(`${idx}`);
setModal(true);
} else {
cleanKey(
`${idx}.templates`,
targetKey
);
}
}}
items={
Object.keys(
ele.templates || {}
).length > 0
? Object.keys(
ele.templates
).map((name, idx) => {
const template =
ele.templates[
name
];
return {
key: `${name}`,
label: `${name}`,
children: (
<Form
colon={
true
}
labelAlign="left"
layout="vertical"
style={{
marginTop: 10,
}}
>
<Form.Item
label="signName"
name="signName"
>
<>
<Input
placeholder="请输入signName"
type="text"
value={
template.signName
}
onChange={(
e
) =>
setValue(
`${idx}.templates.${name}.signName`,
e
.target
.value
)
}
/>
</>
</Form.Item>
<Form.Item
label="code"
name="code"
>
<>
<Input
placeholder="请输入code"
type="text"
value={
template.code
}
onChange={(
e
) =>
setValue(
`${idx}.templates.${name}.code`,
e
.target
.value
)
}
/>
</>
</Form.Item>
</Form>
),
};
})
: []
}
></Tabs>
</Form.Item> */}
</Form>),
}))
: []}></Tabs>
<Modal title="新建模版标签" onCancel={() => {
@ -199,23 +214,38 @@ function Tencent(props) {
key: `${idx}`,
label: `短信${idx + 1}`,
children: (<Form colon={false} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="secretId">
<>
<Input placeholder="请输入secretId" type="text" value={ele.secretId} onChange={(e) => setValue(`${idx}.secretId`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="smsSdkAppId">
<>
<Input placeholder="请输入smsSdkAppId" type="text" value={ele.smsSdkAppId} onChange={(e) => setValue(`${idx}.smsSdkAppId`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="defaultSignName">
<>
<Input placeholder="请输入defaultSignName" type="text" value={ele.defaultSignName} onChange={(e) => setValue(`${idx}.defaultSignName`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="templates">
<Tabs tabPosition={'top'} size={'middle'} type="editable-card"
<Form.Item label="secretId">
<>
<Input placeholder="请输入secretId" type="text" value={ele.secretId} onChange={(e) => setValue(`${idx}.secretId`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="secretKey">
<>
<Input placeholder="请输入secretKey" type="text" value={ele.secretKey} onChange={(e) => setValue(`${idx}.secretKey`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="smsSdkAppId">
<>
<Input placeholder="请输入smsSdkAppId" type="text" value={ele.smsSdkAppId} onChange={(e) => setValue(`${idx}.smsSdkAppId`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="region">
<>
<Input placeholder="请输入region" type="text" value={ele.region} onChange={(e) => setValue(`${idx}.region`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="endpoint">
<>
<Input placeholder="请输入endpoint" type="text" value={ele.endpoint} onChange={(e) => setValue(`${idx}.endpoint`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="defaultSignName">
<>
<Input placeholder="请输入defaultSignName" type="text" value={ele.defaultSignName} onChange={(e) => setValue(`${idx}.defaultSignName`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="templates">
<Tabs tabPosition={'top'} size={'middle'} type="editable-card"
// hideAdd={!(Object.keys(ele.templates).length > 0)}
onEdit={(targetKey, action) => {
if (action === 'add') {
@ -234,26 +264,210 @@ function Tencent(props) {
children: (<Form colon={true} labelAlign="left" layout="vertical" style={{
marginTop: 10,
}}>
<Form.Item label="signName">
<>
<Input placeholder="请输入signName" type="text" value={template.signName} onChange={(e) => setValue(`${idx}.templates.${name}.signName`, e
<Form.Item label="signName">
<>
<Input placeholder="请输入signName" type="text" value={template.signName} onChange={(e) => setValue(`${idx}.templates.${name}.signName`, e
.target
.value)}/>
</>
</Form.Item>
<Form.Item label="code">
<>
<Input placeholder="请输入code" type="text" value={template.code} onChange={(e) => setValue(`${idx}.templates.${name}.code`, e
</>
</Form.Item>
<Form.Item label="code">
<>
<Input placeholder="请输入code" type="text" value={template.code} onChange={(e) => setValue(`${idx}.templates.${name}.code`, e
.target
.value)}/>
</>
</Form.Item>
</Form>),
</>
</Form.Item>
</Form>),
};
})
: []}></Tabs>
</Form.Item>
</Form>),
</Form.Item>
</Form>),
}))
: []}></Tabs>
<Modal title="新建模版标签" onCancel={() => {
setModal(false);
setLabelType('');
}} onOk={() => {
if (!labelType) {
message.error({
content: '请输入标签名称',
});
return;
}
const templates = get(sms, `${smsIndex}.templates`) || {};
if (Object.keys(templates).includes(labelType)) {
message.error({
content: '已存在相同的标签名,请重新输入',
});
return;
}
setValue(`${smsIndex}.templates.${labelType}`, {});
setModal(false);
setLabelType('');
setSmsIndex('');
}} open={open} cancelText="取消" okText="确定" destroyOnClose={true}>
<Form colon={true} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="标签名称"
//name="messageType"
help="只能输入英文和中文">
<>
<Input placeholder="请输入标签名称" type="text" value={labelType} onChange={(e) => setLabelType(e.target.value.replace(/[0-9-.]/g, ''))}/>
</>
</Form.Item>
</Form>
</Modal>
</Col>);
}
function CTYun(props) {
const [open, setModal] = useState(false);
const [smsIndex, setSmsIndex] = useState('');
const [labelType, setLabelType] = useState('');
const { sms, setValue, addItem, removeItem, cleanKey } = props;
return (<Col flex="auto">
<Divider orientation="left" className={Styles.title}>
天翼云云短信配置
</Divider>
<Tabs tabPosition={'top'} size={'middle'} type="editable-card"
// hideAdd={!(sms.length > 0)}
onEdit={(targetKey, action) => {
if (action === 'add') {
addItem('', sms.length);
}
else {
removeItem('', parseInt(targetKey, 10));
}
}} items={sms.length > 0
? sms.map((ele, idx) => ({
key: `${idx}`,
label: `短信${idx + 1}`,
children: (<Form colon={false} labelAlign="left" layout="vertical" style={{ marginTop: 10 }}>
<Form.Item label="accessKey" name="accessKey">
<>
<Input placeholder="请输入accessKey" type="text" value={ele.accessKey} onChange={(e) => setValue(`${idx}.accessKey`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="securityKey" name="securityKey">
<>
<Input placeholder="请输入securityKey" type="text" value={ele.securityKey} onChange={(e) => setValue(`${idx}.securityKey`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="endpoint" name="endpoint">
<>
<Input placeholder="请输入endpoint" type="text" value={ele.endpoint} onChange={(e) => setValue(`${idx}.endpoint`, e.target.value)}/>
</>
</Form.Item>
<Form.Item label="defaultSignName" name="defaultSignName">
<>
<Input placeholder="请输入defaultSignName" type="text" value={ele.defaultSignName} onChange={(e) => setValue(`${idx}.defaultSignName`, e.target.value)}/>
</>
</Form.Item>
{/* <Form.Item
label="templates"
name="templates"
>
<Tabs
tabPosition={'top'}
size={'middle'}
type="editable-card"
// hideAdd={!(Object.keys(ele.templates).length > 0)}
onEdit={(
targetKey: any,
action: 'add' | 'remove'
) => {
if (action === 'add') {
setSmsIndex(`${idx}`);
setModal(true);
} else {
cleanKey(
`${idx}.templates`,
targetKey
);
}
}}
items={
Object.keys(
ele.templates || {}
).length > 0
? Object.keys(
ele.templates
).map((name, idx) => {
const template =
ele.templates[
name
];
return {
key: `${name}`,
label: `${name}`,
children: (
<Form
colon={
true
}
labelAlign="left"
layout="vertical"
style={{
marginTop: 10,
}}
>
<Form.Item
label="signName"
name="signName"
>
<>
<Input
placeholder="请输入signName"
type="text"
value={
template.signName
}
onChange={(
e
) =>
setValue(
`${idx}.templates.${name}.signName`,
e
.target
.value
)
}
/>
</>
</Form.Item>
<Form.Item
label="code"
name="code"
>
<>
<Input
placeholder="请输入code"
type="text"
value={
template.code
}
onChange={(
e
) =>
setValue(
`${idx}.templates.${name}.code`,
e
.target
.value
)
}
/>
</>
</Form.Item>
</Form>
),
};
})
: []
}
></Tabs>
</Form.Item> */}
</Form>),
}))
: []}></Tabs>
<Modal title="新建模版标签" onCancel={() => {
@ -292,7 +506,7 @@ function Tencent(props) {
}
export default function Sms(props) {
const { sms, setValue, removeItem, cleanKey } = props;
const { ali, tencent, mockSend } = sms;
const { ali, tencent, mockSend, ctyun } = sms;
return (<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<Row>
<Card className={Styles.tips}>
@ -315,5 +529,6 @@ export default function Sms(props) {
</Col>
<Tencent sms={tencent || []} setValue={(path, value) => setValue(`tencent.${path}`, value)} removeItem={(path, index) => removeItem(`tencent`, index)} addItem={(path, index) => setValue(`tencent.${index}`, {})} cleanKey={(path, key) => cleanKey(`tencent.${path}`, key)}/>
<Ali sms={ali || []} setValue={(path, value) => setValue(`ali.${path}`, value)} removeItem={(path, index) => removeItem(`ali`, index)} addItem={(path, index) => setValue(`ali.${index}`, {})} cleanKey={(path, key) => cleanKey(`ali.${path}`, key)}/>
<CTYun sms={ctyun || []} setValue={(path, value) => setValue(`ctyun.${path}`, value)} removeItem={(path, index) => removeItem(`ctyun`, index)} addItem={(path, index) => setValue(`ctyun.${index}`, {})} cleanKey={(path, key) => cleanKey(`ctyun.${path}`, key)}/>
</Space>);
}

View File

@ -14,7 +14,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
buttonProps?: (ButtonProps & {
color?: "success" | "default" | "warning" | "primary" | "danger" | undefined;
fill?: "none" | "solid" | "outline" | undefined;
size?: "small" | "large" | "middle" | "mini" | undefined;
size?: "small" | "middle" | "large" | "mini" | undefined;
block?: boolean | undefined;
loading?: boolean | "auto" | undefined;
loadingText?: string | undefined;

View File

@ -14,8 +14,8 @@ export default OakComponent({
printRunningTree() {
console.log(this.features.runningTree.getRoot());
},
resetInitialData() {
this.features.localStorage.clear();
async resetInitialData() {
await this.features.localStorage.clear();
this.features.token.logout();
},
setVisible(visible) {
@ -54,12 +54,12 @@ export default OakComponent({
dialogVisible: false,
});
},
downloadEnv() {
const data = this.features.localStorage.loadAll();
async downloadEnv() {
const data = await this.features.localStorage.loadAll();
return data;
},
resetEnv(data) {
this.features.localStorage.resetAll(data);
async resetEnv(data) {
await this.features.localStorage.resetAll(data);
},
},
});

View File

@ -8,7 +8,7 @@ export default function render(props: WebComponentProps<EntityDict, 'address', t
printDebugStore: () => void;
printCachedStore: () => void;
printRunningTree: () => void;
resetInitialData: () => void;
downloadEnv: () => void;
resetEnv: (data: Record<string, any>) => void;
resetInitialData: () => Promise<void>;
downloadEnv: () => Promise<void>;
resetEnv: (data: Record<string, any>) => Promise<void>;
}>): React.JSX.Element;

View File

@ -32,10 +32,10 @@ export default function render(props) {
else {
const reader = new FileReader();
reader.readAsText(file);
reader.onload = function () {
reader.onload = async function () {
try {
const data = JSON.parse(this.result);
resetEnv(data);
await resetEnv(data);
window.location.reload();
}
catch (err) {
@ -62,8 +62,8 @@ export default function render(props) {
</Button>
</Tooltip>
<Tooltip title="下载Store">
<Button size="large" type="primary" shape="circle" onClick={() => {
const data = downloadEnv();
<Button size="large" type="primary" shape="circle" onClick={async () => {
const data = await downloadEnv();
const element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' +
encodeURIComponent(JSON.stringify(data)));
@ -92,8 +92,8 @@ export default function render(props) {
content: '重置后,原来的数据不可恢复',
okText: '确定',
cancelText: '取消',
onOk: (e) => {
resetInitialData();
onOk: async (e) => {
await resetInitialData();
modal.destroy();
window.location.reload();
},

View File

@ -1,18 +1,9 @@
import { getOrigin } from '../../../utils/sms/index';
export default OakComponent({
isList: false,
properties: {
systemId: '',
},
data: {
originList: [],
},
lifetimes: {
ready() {
const originList = getOrigin();
this.setState({
originList
});
},
originList: ['ali', 'tencent', 'ctyun'],
},
});

View File

@ -13,6 +13,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
entityId: string;
isNew: boolean;
setPasswordConfirm: (value: boolean) => void;
passwordRequire: boolean;
}, {
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;

View File

@ -4,7 +4,7 @@ import UserRelation from './userRelation';
import { EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
import { encryptPasswordSha1 } from '../../../../utils/password';
export default function Render(props) {
const { name, isNew, nickname, password, relations, oakFullpath, entity, entityId, setPasswordConfirm } = props.data;
const { name, isNew, nickname, password, relations, oakFullpath, entity, entityId, setPasswordConfirm, passwordRequire, } = props.data;
const { t, update } = props.methods;
const [password2, setPassword2] = useState('');
const [validateHelp, setValidateHelp] = useState('');
@ -38,6 +38,7 @@ export default function Render(props) {
</Form.Item>) : (<>
<Form.Item label={t('user:attr.password')} name="password" help={validateHelp1} rules={[
{
required: passwordRequire,
message: '请输入密码',
validator: (_, value) => {
if (!value && !password2) {
@ -79,6 +80,7 @@ export default function Render(props) {
</Form.Item>
<Form.Item label={'确认密码'} name="passwordConfirm" rules={[
{
required: passwordRequire,
validator: (_, value) => {
if (!value && !password) {
setValidateHelp('');

View File

@ -1,2 +1,2 @@
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC>)[];
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>>)[];
export default _default;

View File

@ -12,7 +12,7 @@ export declare function createToDo<ED extends EntityDict & BaseEntityDict, T ext
title: string;
description?: string;
redirectTo: EntityDict['toDo']['OpSchema']['redirectTo'];
}, userIds?: string[]): Promise<1 | 0>;
}, userIds?: string[]): Promise<0 | 1>;
/**
* todo例程entity对象上进行action操作时filtertodo完成
* entity的action的后trigger中调用

19
es/types/Config.d.ts vendored
View File

@ -3,10 +3,6 @@ export type QiniuCloudConfig = {
accessKey: string;
secretKey: string;
};
export type CTYunConfig = {
accessKey: string;
secretKey: string;
};
export type QiniuLiveConfig = {
accessKey: string;
liveHost: string;
@ -55,6 +51,11 @@ export type TencentCloudConfig = {
endpoint: string;
smsEndpoint: string;
};
export type CTYunCloudConfig = {
accessKey: string;
securityKey: string;
smsEndpoint: string;
};
export type AmapCloudConfig = {
webApiKey: string;
};
@ -62,6 +63,13 @@ export type AliSmsConfig = {
accessKeyId: string;
accessKeySecret: string;
defaultSignName: string;
apiVersion: string;
endpoint: string;
};
export type CTYunSmsConfig = {
accessKey: string;
securityKey: string;
defaultSignName: string;
endpoint: string;
};
export type TencentSmsConfig = {
@ -82,7 +90,7 @@ export type Config = {
ali?: AliCloudConfig[];
tencent?: TencentCloudConfig[];
qiniu?: QiniuCloudConfig[];
ctyun?: CTYunConfig[];
ctyun?: CTYunCloudConfig[];
amap?: AmapCloudConfig[];
};
Cos?: {
@ -99,6 +107,7 @@ export type Config = {
mockSend?: boolean;
ali?: AliSmsConfig[];
tencent?: TencentSmsConfig[];
ctyun?: CTYunSmsConfig[];
};
App: {
qrCodeType?: QrCodeType;

View File

@ -48,7 +48,7 @@ export function getConfig(context, service, origin) {
case 'ctyun': {
const ctyunAccount = originCloudAccounts.find((ele) => ele.accessKey === originConfig.accessKey);
assert(ctyunAccount, `调用的服务${service}${origin}找不到相应的云平台帐号,请联系管理员`);
const ctyunInstance = CTYunSDk.getInstance(ctyunAccount.accessKey, ctyunAccount.secretKey);
const ctyunInstance = CTYunSDk.getInstance(ctyunAccount.accessKey, ctyunAccount.securityKey);
return {
instance: ctyunInstance,
config: originConfig,

View File

@ -5,8 +5,12 @@ import { EntityDict } from '../../oak-app-domain';
import { AliSmsConfig } from '../../types/Config';
export default class Ali implements Sms<ED, BackendRuntimeContext<ED>> {
name: string;
getConfig(context: BackendRuntimeContext<ED>): AliSmsConfig;
syncTemplate(systemId: string): Promise<never[]>;
getConfig(context: BackendRuntimeContext<ED>, systemId?: string): Promise<AliSmsConfig>;
syncTemplate(systemId: string, context: BackendRuntimeContext<ED>): Promise<{
templateCode: string;
templateName: string;
templateContent: string;
}[]>;
sendSms(params: {
mobile: string;
templateParam?: Record<string, any>;

View File

@ -3,8 +3,24 @@ import { get } from 'oak-domain/lib/utils/lodash';
import SDK from 'oak-external-sdk/lib/SmsSdk';
export default class Ali {
name = 'ali';
getConfig(context) {
const { system } = context.getApplication();
async getConfig(context, systemId) {
let system;
if (systemId) {
[system] = await context.select('system', {
data: {
id: 1,
config: 1,
},
filter: {
id: systemId,
},
}, {
dontCollect: true,
});
}
else {
system = context.getApplication().system;
}
const { config: systemConfig } = system;
const aliConfig = get(systemConfig, 'Sms.ali.0', {});
const { accessKeyId, accessKeySecret, defaultSignName, endpoint } = aliConfig;
@ -14,14 +30,32 @@ export default class Ali {
assert(endpoint, 'endpoint未配置');
return aliConfig;
}
async syncTemplate(systemId) {
// todo
async syncTemplate(systemId, context) {
const { accessKeyId, accessKeySecret, endpoint, apiVersion } = await this.getConfig(context, systemId);
const aliInstance = SDK.getInstance('ali', accessKeyId, accessKeySecret, endpoint, undefined, apiVersion);
const result = await aliInstance.syncTemplate({
PageIndex: 1,
PageSize: 100,
});
// // todo templateName: string,
// templateCode: string,
// templateContent: string
const { smsTemplateList } = result;
if (smsTemplateList) {
return smsTemplateList.map((ele) => {
return {
templateCode: ele.templateCode,
templateName: ele.templateName,
templateContent: ele.templateContent,
};
});
}
return [];
}
async sendSms(params, context) {
const { mobile, templateParam, smsTemplate } = params;
const { templateCode } = smsTemplate;
const { accessKeyId, accessKeySecret, defaultSignName, endpoint } = this.getConfig(context);
const { accessKeyId, accessKeySecret, defaultSignName, endpoint } = await this.getConfig(context);
const aliInstance = SDK.getInstance('ali', accessKeyId, accessKeySecret, endpoint);
const result = await aliInstance.sendSms({
phoneNumbers: [mobile],
@ -30,7 +64,7 @@ export default class Ali {
signName: defaultSignName,
});
const { code, message, requestId } = result;
if (code === 'Ok') {
if (code === 'OK') {
return {
success: true,
res: result,

22
es/utils/sms/ctyun.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
import { BackendRuntimeContext } from '../../context/BackendRuntimeContext';
import Sms from "../../types/Sms";
import { ED } from '../../types/RuntimeCxt';
import { EntityDict } from '../../oak-app-domain';
import { CTYunSmsConfig } from '../../types/Config';
export default class CTYun implements Sms<ED, BackendRuntimeContext<ED>> {
name: string;
getConfig(context: BackendRuntimeContext<ED>, systemId?: string): Promise<CTYunSmsConfig>;
syncTemplate(systemId: string, context: BackendRuntimeContext<ED>): Promise<{
templateCode: string;
templateName: string;
templateContent: string;
}[]>;
sendSms(params: {
mobile: string;
templateParam?: Record<string, string>;
smsTemplate: Partial<EntityDict['smsTemplate']['Schema']>;
}, context: BackendRuntimeContext<ED>): Promise<{
success: boolean;
res: any;
}>;
}

77
es/utils/sms/ctyun.js Normal file
View File

@ -0,0 +1,77 @@
import { assert } from 'oak-domain/lib/utils/assert';
import { get } from 'oak-domain/lib/utils/lodash';
import SDK from 'oak-external-sdk/lib/SmsSdk';
export default class CTYun {
name = 'ctyun';
async getConfig(context, systemId) {
let system;
if (systemId) {
[system] = await context.select('system', {
data: {
id: 1,
config: 1,
},
filter: {
id: systemId,
},
}, {
dontCollect: true,
});
}
else {
system = context.getApplication().system;
}
const { config: systemConfig } = system;
const ctyunConfig = get(systemConfig, 'Sms.ctyun.0', {});
const { accessKey, securityKey, endpoint } = ctyunConfig;
assert(accessKey, 'accessKey未配置');
assert(securityKey, 'securityKey未配置');
return ctyunConfig;
}
async syncTemplate(systemId, context) {
const { accessKey, securityKey, endpoint } = await this.getConfig(context, systemId);
const ctyunInstance = SDK.getInstance('ctyun', accessKey, securityKey, endpoint);
const result = await ctyunInstance.syncTemplate({
pageIndex: 1,
pageSize: 50, // pageSize必须小于或等于50
});
// // todo templateName: string,
// templateCode: string,
// templateContent: string
const { data } = result;
if (data) {
return data.map((ele) => {
return {
templateCode: ele.templateCode,
templateName: ele.templateName,
templateContent: ele.templateContent,
};
});
}
return [];
}
async sendSms(params, context) {
const { mobile, templateParam, smsTemplate } = params;
const { templateCode } = smsTemplate;
const { accessKey, securityKey, endpoint, defaultSignName, } = await this.getConfig(context);
const ctyunInstance = SDK.getInstance('ctyun', accessKey, securityKey, endpoint);
const result = await ctyunInstance.sendSms({
phoneNumber: mobile,
templateParam,
templateCode: templateCode,
signName: defaultSignName,
});
const code = result?.code || '';
if (code === 'OK') {
return {
success: true,
res: result,
};
}
return {
success: false,
res: result,
};
}
}
;

View File

@ -1,11 +1,14 @@
import { assert } from 'oak-domain/lib/utils/assert';
import Ali from './ali';
import Tencent from './tencent';
import CTYun from './ctyun';
const ali = new Ali();
const tencent = new Tencent();
const ctyun = new CTYun();
const SmsDict = {
[ali.name]: ali,
[tencent.name]: tencent,
[ctyun.name]: ctyun,
};
/**
* 注入一个其它OSS上实现的uploader类

View File

@ -1,2 +1,2 @@
declare const checkers: (import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt>)[];
declare const checkers: (import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt>)[];
export default checkers;

View File

@ -1,2 +1,2 @@
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC>)[];
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>>)[];
export default _default;

View File

@ -92,7 +92,6 @@ async function completeToDo(entity, filter, action, context) {
filter: {
targetEntity: entity,
targetFilter: filter,
iState: 'active',
action,
iState: 'active',
}

19
lib/types/Config.d.ts vendored
View File

@ -3,10 +3,6 @@ export type QiniuCloudConfig = {
accessKey: string;
secretKey: string;
};
export type CTYunConfig = {
accessKey: string;
secretKey: string;
};
export type QiniuLiveConfig = {
accessKey: string;
liveHost: string;
@ -55,6 +51,11 @@ export type TencentCloudConfig = {
endpoint: string;
smsEndpoint: string;
};
export type CTYunCloudConfig = {
accessKey: string;
securityKey: string;
smsEndpoint: string;
};
export type AmapCloudConfig = {
webApiKey: string;
};
@ -62,6 +63,13 @@ export type AliSmsConfig = {
accessKeyId: string;
accessKeySecret: string;
defaultSignName: string;
apiVersion: string;
endpoint: string;
};
export type CTYunSmsConfig = {
accessKey: string;
securityKey: string;
defaultSignName: string;
endpoint: string;
};
export type TencentSmsConfig = {
@ -82,7 +90,7 @@ export type Config = {
ali?: AliCloudConfig[];
tencent?: TencentCloudConfig[];
qiniu?: QiniuCloudConfig[];
ctyun?: CTYunConfig[];
ctyun?: CTYunCloudConfig[];
amap?: AmapCloudConfig[];
};
Cos?: {
@ -99,6 +107,7 @@ export type Config = {
mockSend?: boolean;
ali?: AliSmsConfig[];
tencent?: TencentSmsConfig[];
ctyun?: CTYunSmsConfig[];
};
App: {
qrCodeType?: QrCodeType;

View File

@ -51,7 +51,7 @@ function getConfig(context, service, origin) {
case 'ctyun': {
const ctyunAccount = originCloudAccounts.find((ele) => ele.accessKey === originConfig.accessKey);
(0, assert_1.assert)(ctyunAccount, `调用的服务${service}${origin}找不到相应的云平台帐号,请联系管理员`);
const ctyunInstance = oak_external_sdk_1.CTYunSDk.getInstance(ctyunAccount.accessKey, ctyunAccount.secretKey);
const ctyunInstance = oak_external_sdk_1.CTYunSDk.getInstance(ctyunAccount.accessKey, ctyunAccount.securityKey);
return {
instance: ctyunInstance,
config: originConfig,

View File

@ -5,8 +5,12 @@ import { EntityDict } from '../../oak-app-domain';
import { AliSmsConfig } from '../../types/Config';
export default class Ali implements Sms<ED, BackendRuntimeContext<ED>> {
name: string;
getConfig(context: BackendRuntimeContext<ED>): AliSmsConfig;
syncTemplate(systemId: string): Promise<never[]>;
getConfig(context: BackendRuntimeContext<ED>, systemId?: string): Promise<AliSmsConfig>;
syncTemplate(systemId: string, context: BackendRuntimeContext<ED>): Promise<{
templateCode: string;
templateName: string;
templateContent: string;
}[]>;
sendSms(params: {
mobile: string;
templateParam?: Record<string, any>;

View File

@ -6,8 +6,24 @@ const lodash_1 = require("oak-domain/lib/utils/lodash");
const SmsSdk_1 = tslib_1.__importDefault(require("oak-external-sdk/lib/SmsSdk"));
class Ali {
name = 'ali';
getConfig(context) {
const { system } = context.getApplication();
async getConfig(context, systemId) {
let system;
if (systemId) {
[system] = await context.select('system', {
data: {
id: 1,
config: 1,
},
filter: {
id: systemId,
},
}, {
dontCollect: true,
});
}
else {
system = context.getApplication().system;
}
const { config: systemConfig } = system;
const aliConfig = (0, lodash_1.get)(systemConfig, 'Sms.ali.0', {});
const { accessKeyId, accessKeySecret, defaultSignName, endpoint } = aliConfig;
@ -17,14 +33,32 @@ class Ali {
(0, assert_1.assert)(endpoint, 'endpoint未配置');
return aliConfig;
}
async syncTemplate(systemId) {
// todo
async syncTemplate(systemId, context) {
const { accessKeyId, accessKeySecret, endpoint, apiVersion } = await this.getConfig(context, systemId);
const aliInstance = SmsSdk_1.default.getInstance('ali', accessKeyId, accessKeySecret, endpoint, undefined, apiVersion);
const result = await aliInstance.syncTemplate({
PageIndex: 1,
PageSize: 100,
});
// // todo templateName: string,
// templateCode: string,
// templateContent: string
const { smsTemplateList } = result;
if (smsTemplateList) {
return smsTemplateList.map((ele) => {
return {
templateCode: ele.templateCode,
templateName: ele.templateName,
templateContent: ele.templateContent,
};
});
}
return [];
}
async sendSms(params, context) {
const { mobile, templateParam, smsTemplate } = params;
const { templateCode } = smsTemplate;
const { accessKeyId, accessKeySecret, defaultSignName, endpoint } = this.getConfig(context);
const { accessKeyId, accessKeySecret, defaultSignName, endpoint } = await this.getConfig(context);
const aliInstance = SmsSdk_1.default.getInstance('ali', accessKeyId, accessKeySecret, endpoint);
const result = await aliInstance.sendSms({
phoneNumbers: [mobile],
@ -33,7 +67,7 @@ class Ali {
signName: defaultSignName,
});
const { code, message, requestId } = result;
if (code === 'Ok') {
if (code === 'OK') {
return {
success: true,
res: result,

22
lib/utils/sms/ctyun.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
import { BackendRuntimeContext } from '../../context/BackendRuntimeContext';
import Sms from "../../types/Sms";
import { ED } from '../../types/RuntimeCxt';
import { EntityDict } from '../../oak-app-domain';
import { CTYunSmsConfig } from '../../types/Config';
export default class CTYun implements Sms<ED, BackendRuntimeContext<ED>> {
name: string;
getConfig(context: BackendRuntimeContext<ED>, systemId?: string): Promise<CTYunSmsConfig>;
syncTemplate(systemId: string, context: BackendRuntimeContext<ED>): Promise<{
templateCode: string;
templateName: string;
templateContent: string;
}[]>;
sendSms(params: {
mobile: string;
templateParam?: Record<string, string>;
smsTemplate: Partial<EntityDict['smsTemplate']['Schema']>;
}, context: BackendRuntimeContext<ED>): Promise<{
success: boolean;
res: any;
}>;
}

81
lib/utils/sms/ctyun.js Normal file
View File

@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const assert_1 = require("oak-domain/lib/utils/assert");
const lodash_1 = require("oak-domain/lib/utils/lodash");
const SmsSdk_1 = tslib_1.__importDefault(require("oak-external-sdk/lib/SmsSdk"));
class CTYun {
name = 'ctyun';
async getConfig(context, systemId) {
let system;
if (systemId) {
[system] = await context.select('system', {
data: {
id: 1,
config: 1,
},
filter: {
id: systemId,
},
}, {
dontCollect: true,
});
}
else {
system = context.getApplication().system;
}
const { config: systemConfig } = system;
const ctyunConfig = (0, lodash_1.get)(systemConfig, 'Sms.ctyun.0', {});
const { accessKey, securityKey, endpoint } = ctyunConfig;
(0, assert_1.assert)(accessKey, 'accessKey未配置');
(0, assert_1.assert)(securityKey, 'securityKey未配置');
return ctyunConfig;
}
async syncTemplate(systemId, context) {
const { accessKey, securityKey, endpoint } = await this.getConfig(context, systemId);
const ctyunInstance = SmsSdk_1.default.getInstance('ctyun', accessKey, securityKey, endpoint);
const result = await ctyunInstance.syncTemplate({
pageIndex: 1,
pageSize: 50, // pageSize必须小于或等于50
});
// // todo templateName: string,
// templateCode: string,
// templateContent: string
const { data } = result;
if (data) {
return data.map((ele) => {
return {
templateCode: ele.templateCode,
templateName: ele.templateName,
templateContent: ele.templateContent,
};
});
}
return [];
}
async sendSms(params, context) {
const { mobile, templateParam, smsTemplate } = params;
const { templateCode } = smsTemplate;
const { accessKey, securityKey, endpoint, defaultSignName, } = await this.getConfig(context);
const ctyunInstance = SmsSdk_1.default.getInstance('ctyun', accessKey, securityKey, endpoint);
const result = await ctyunInstance.sendSms({
phoneNumber: mobile,
templateParam,
templateCode: templateCode,
signName: defaultSignName,
});
const code = result?.code || '';
if (code === 'OK') {
return {
success: true,
res: result,
};
}
return {
success: false,
res: result,
};
}
}
exports.default = CTYun;
;

View File

@ -5,11 +5,14 @@ const tslib_1 = require("tslib");
const assert_1 = require("oak-domain/lib/utils/assert");
const ali_1 = tslib_1.__importDefault(require("./ali"));
const tencent_1 = tslib_1.__importDefault(require("./tencent"));
const ctyun_1 = tslib_1.__importDefault(require("./ctyun"));
const ali = new ali_1.default();
const tencent = new tencent_1.default();
const ctyun = new ctyun_1.default();
const SmsDict = {
[ali.name]: ali,
[tencent.name]: tencent,
[ctyun.name]: ctyun,
};
/**
* 注入一个其它OSS上实现的uploader类

View File

@ -104,7 +104,7 @@ export default function Render(
help={validateHelp1}
rules={[
{
require: passwordRequire,
required: passwordRequire,
message: '请输入密码',
validator: (_, value) => {
if (!value && !password2) {
@ -171,7 +171,7 @@ export default function Render(
name="passwordConfirm"
rules={[
{
require: passwordRequire,
required: passwordRequire,
validator: (_, value) => {
if (!value && !password) {
setValidateHelp('');

View File

@ -109,7 +109,7 @@ export type Config = {
ali?: AliCloudConfig[];
tencent?: TencentCloudConfig[];
qiniu?: QiniuCloudConfig[];
ctyun?: CTYunConfig[];
ctyun?: CTYunCloudConfig[];
amap?: AmapCloudConfig[];
};
Cos?: {

View File

@ -9,7 +9,7 @@ import {
QiniuCloudConfig,
Service,
TencentCloudConfig,
CTYunConfig
CTYunCloudConfig
} from '../types/Config';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { FrontendRuntimeContext, AspectDict } from '../context/FrontendRuntimeContext';
@ -90,7 +90,7 @@ export function getConfig<
}
case 'ctyun': {
const ctyunAccount = (
originCloudAccounts as CTYunConfig[]
originCloudAccounts as CTYunCloudConfig[]
).find((ele) => ele.accessKey === originConfig.accessKey);
assert(
ctyunAccount,
@ -98,7 +98,7 @@ export function getConfig<
);
const ctyunInstance = CTYunSDk.getInstance(
ctyunAccount!.accessKey,
ctyunAccount!.secretKey,
ctyunAccount!.securityKey,
);
return {
instance: ctyunInstance,