diff --git a/es/aspects/AspectDict.d.ts b/es/aspects/AspectDict.d.ts index 3e74a8354..f97811f90 100644 --- a/es/aspects/AspectDict.d.ts +++ b/es/aspects/AspectDict.d.ts @@ -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 { Style } from '../types/Style'; import { MenuType } from '../types/WeChat'; import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; import { WechatPublicEventData, WechatMpEventData } from 'oak-external-sdk'; @@ -65,6 +66,11 @@ export type GeneralAspectDict Promise; + updateStyle: (params: { + entity: 'platform' | 'system' | 'application'; + entityId: string; + style: Style; + }, context: Cxt) => Promise; updateApplicationConfig: (params: { entity: 'application'; entityId: string; diff --git a/es/aspects/index.d.ts b/es/aspects/index.d.ts index dc5f4a4f8..a8085c5cb 100644 --- a/es/aspects/index.d.ts +++ b/es/aspects/index.d.ts @@ -2,6 +2,7 @@ import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCa import { getInfoByUrl } from './extraFile'; import { getApplication, signatureJsSDK, uploadWechatMedia } from './application'; import { updateConfig, updateApplicationConfig } from './config'; +import { updateStyle } from './style2'; import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user'; import { createWechatLogin } from './wechatLogin'; import { unbindingWechat } from './wechatUser'; @@ -22,6 +23,7 @@ declare const aspectDict: { sendCaptcha: typeof sendCaptcha; getApplication: typeof getApplication; updateConfig: typeof updateConfig; + updateStyle: typeof updateStyle; updateApplicationConfig: typeof updateApplicationConfig; getWechatMpUserPhoneNumber: typeof getWechatMpUserPhoneNumber; logout: typeof logout; diff --git a/es/aspects/index.js b/es/aspects/index.js index 2c7e436f7..cb5b00b60 100644 --- a/es/aspects/index.js +++ b/es/aspects/index.js @@ -2,6 +2,7 @@ import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCa import { getInfoByUrl } from './extraFile'; import { getApplication, signatureJsSDK, uploadWechatMedia, } from './application'; import { updateConfig, updateApplicationConfig } from './config'; +import { updateStyle } from './style2'; import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user'; import { createWechatLogin } from './wechatLogin'; import { unbindingWechat } from './wechatUser'; @@ -22,6 +23,7 @@ const aspectDict = { sendCaptcha, getApplication, updateConfig, + updateStyle, updateApplicationConfig, getWechatMpUserPhoneNumber, logout, diff --git a/es/aspects/style.d.ts b/es/aspects/style.d.ts new file mode 100644 index 000000000..cfb2ca66b --- /dev/null +++ b/es/aspects/style.d.ts @@ -0,0 +1,8 @@ +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { EntityDict } from '../oak-app-domain'; +import { Style } from '../types/Style'; +export declare function updateStyle>(params: { + entity: 'platform' | 'system'; + entityId: string; + style: Style; +}, context: Cxt): Promise; diff --git a/es/aspects/style.js b/es/aspects/style.js new file mode 100644 index 000000000..d89968c36 --- /dev/null +++ b/es/aspects/style.js @@ -0,0 +1,14 @@ +import { generateNewId } from 'oak-domain/lib/utils/uuid'; +export async function updateStyle(params, context) { + const { entity, entityId, style } = params; + await context.operate(entity, { + id: generateNewId(), + action: 'update', + data: { + style, + }, + filter: { + id: entityId, + } + }, {}); +} diff --git a/es/aspects/style2.d.ts b/es/aspects/style2.d.ts new file mode 100644 index 000000000..cfb2ca66b --- /dev/null +++ b/es/aspects/style2.d.ts @@ -0,0 +1,8 @@ +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { EntityDict } from '../oak-app-domain'; +import { Style } from '../types/Style'; +export declare function updateStyle>(params: { + entity: 'platform' | 'system'; + entityId: string; + style: Style; +}, context: Cxt): Promise; diff --git a/es/aspects/style2.js b/es/aspects/style2.js new file mode 100644 index 000000000..d89968c36 --- /dev/null +++ b/es/aspects/style2.js @@ -0,0 +1,14 @@ +import { generateNewId } from 'oak-domain/lib/utils/uuid'; +export async function updateStyle(params, context) { + const { entity, entityId, style } = params; + await context.operate(entity, { + id: generateNewId(), + action: 'update', + data: { + style, + }, + filter: { + id: entityId, + } + }, {}); +} diff --git a/es/components/application/panel/web.pc.js b/es/components/application/panel/web.pc.js index 162e24fe9..db8bc56b6 100644 --- a/es/components/application/panel/web.pc.js +++ b/es/components/application/panel/web.pc.js @@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; import { Tabs } from 'antd'; import ApplicationDetail from '../detail'; import ConfigUpsert from '../../config/application'; -import StyleUpsert from '../../config/style'; +import StyleUpsert from '../../config/style/platform'; import Styles from './web.pc.module.less'; export default function Render(props) { const { id, config, oakFullpath, name, style } = props.data; @@ -22,9 +22,7 @@ export default function Render(props) { { label: _jsx("div", { className: Styles.tabLabel, children: t('style') }), key: 'style', - children: (_jsx(StyleUpsert, { value: style, onChange: (s) => { - update({ style: s }); - } })), + children: (_jsx(StyleUpsert, { style: style, entity: 'platform', entityId: id, name: name })), }, ] }) })); } diff --git a/es/components/config/style/platform/index.d.ts b/es/components/config/style/platform/index.d.ts new file mode 100644 index 000000000..551c98f37 --- /dev/null +++ b/es/components/config/style/platform/index.d.ts @@ -0,0 +1,9 @@ +/// +import { Style } from '../../../../types/Style'; +declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => import("react").ReactElement>; +export default _default; diff --git a/es/components/config/style/platform/index.js b/es/components/config/style/platform/index.js new file mode 100644 index 000000000..5b88f3a06 --- /dev/null +++ b/es/components/config/style/platform/index.js @@ -0,0 +1,86 @@ +import { cloneDeep } from 'oak-domain/lib/utils/lodash'; +export default OakComponent({ + isList: false, + properties: { + style: {}, + entity: '', + entityId: '', + name: '', + }, + data: { + initialStyle: {}, + dirty: false, + currentStyle: {}, + }, + // listeners: { + // config(prev, next) { + // if (prev.config !== next.config) { + // const config2 = next.config || {}; + // this.setState({ + // initialConfig: config2, + // dirty: false, + // currentConfig: cloneDeep(config2), + // }); + // } + // }, + // }, + lifetimes: { + ready() { + const { style } = this.props; + this.setState({ + initialStyle: style, + dirty: false, + currentStyle: cloneDeep(style), + }); + } + }, + methods: { + setValue(newStyle) { + const newStyle2 = cloneDeep(newStyle || {}); + this.setState({ + currentStyle: newStyle2, + dirty: true, + }); + }, + // cleanKey(path: string, key: string) { + // const { currentConfig } = this.state; + // const obj = get(currentConfig, path); + // const obj2 = omit(obj, [key]); + // set(currentConfig, path, obj2); + // const newConfig = cloneDeep(currentConfig); + // this.setState({ + // currentConfig: newConfig, + // dirty: true, + // }); + // }, + // removeItem(path: string, index: number) { + // const { currentConfig } = this.state; + // const array = get(currentConfig, path); + // (array as any[]).splice(index, 1); + // const newConfig = cloneDeep(currentConfig || {}); + // this.setState({ + // currentConfig: newConfig, + // dirty: true, + // }); + // }, + resetStyle() { + const { initialStyle } = this.state; + this.setState({ + dirty: false, + currentStyle: cloneDeep(initialStyle), + }); + }, + async updateStyle() { + const { currentStyle } = this.state; + const { entity, entityId } = this.props; + await this.features.style2.updateStyle(entity, entityId, currentStyle); + this.setMessage({ + content: '操作成功', + type: 'success', + }); + this.setState({ + dirty: false, + }); + }, + }, +}); diff --git a/es/components/config/style/platform/web.module.less b/es/components/config/style/platform/web.module.less new file mode 100644 index 000000000..be1b128dd --- /dev/null +++ b/es/components/config/style/platform/web.module.less @@ -0,0 +1,43 @@ +.container { + background: var(--oak-bg-color-container); + // box-shadow: 0 2px 3px #0000001a; + // border-radius: 3px; + padding: 30px 32px; +} + +.padding { + background-color: var(--oak-bg-color-page); + width: 100%; + height: 77px; +} + +.ctrl { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + padding: 10px; + border: solid 0.4px; + border-radius: 3px; + border-color: var(--oak-border-color); + position: absolute; + z-index: 10; + background-color: var(--oak-bg-color-container); + width: calc(100vw - 138px); + top: 85px; + height: 55px; + + text { + color: var(--oak-text-color-secondary); + + .weight { + font-weight: bold; + color: var(--oak-text-color-primary); + text-decoration: underline; + } + } +} + +.contains { + margin-top: 20px; +} \ No newline at end of file diff --git a/es/components/config/style/platform/web.pc.d.ts b/es/components/config/style/platform/web.pc.d.ts new file mode 100644 index 000000000..94f8fdd23 --- /dev/null +++ b/es/components/config/style/platform/web.pc.d.ts @@ -0,0 +1,13 @@ +import { Style as StyleDef } from '../../../../types/Style'; +import { EntityDict } from '../../../../oak-app-domain'; +import { WebComponentProps } from 'oak-frontend-base'; +export default function Render(props: WebComponentProps void; + updateStyle: () => void; + setValue: (style: StyleDef) => void; +}>): import("react/jsx-runtime").JSX.Element; diff --git a/es/components/config/style/platform/web.pc.js b/es/components/config/style/platform/web.pc.js new file mode 100644 index 000000000..0f6ef43bc --- /dev/null +++ b/es/components/config/style/platform/web.pc.js @@ -0,0 +1,13 @@ +import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; +import { Button, Alert, Affix, Space, Typography } from 'antd'; +import Style from './web.module.less'; +import StyleUpsert from '../../style'; +export default function Render(props) { + const { entity, currentStyle, dirty, name } = props.data; + const { resetStyle, updateStyle, setValue, t } = props.methods; + return (_jsxs(_Fragment, { children: [_jsx(Affix, { offsetTop: 64, children: _jsx(Alert, { message: _jsx("div", { children: _jsxs("text", { children: ["\u60A8\u6B63\u5728\u66F4\u65B0", _jsx(Typography.Text, { keyboard: true, className: Style.weight, children: entity }), "\u5BF9\u8C61", _jsx(Typography.Text, { keyboard: true, className: Style.weight, children: name }), "\u7684\u6837\u5F0F\uFF0C\u8BF7\u8C28\u614E\u64CD\u4F5C"] }) }), type: "info", showIcon: true, action: _jsxs(Space, { children: [_jsx(Button, { disabled: !dirty, type: "primary", danger: true, onClick: () => resetStyle(), style: { + marginRight: 10, + }, children: t('common::reset') }), _jsx(Button, { disabled: !dirty, type: "primary", onClick: () => updateStyle(), children: t('common::action.confirm') })] }) }) }), _jsx("div", { className: Style.contains, children: _jsx(StyleUpsert, { value: currentStyle, onChange: (s) => { + setValue(s); + } }) })] })); +} diff --git a/es/components/config/upsert/account/index.js b/es/components/config/upsert/account/index.js index b81cbf2c5..9730188a6 100644 --- a/es/components/config/upsert/account/index.js +++ b/es/components/config/upsert/account/index.js @@ -112,5 +112,5 @@ function AmapAccount(props) { export default function Account(props) { const { account, setValue, removeItem } = props; const { tencent, qiniu, ali, amap } = account; - return (_jsxs(Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [_jsx(Row, { children: _jsx(Card, { className: Styles.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), _jsx(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), _jsx(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), _jsx(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), _jsx(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] })); + return (_jsxs(Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [_jsx(Row, { children: _jsx(Card, { className: Styles.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), _jsx(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`tencent.${index}`, {}) }), _jsx(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`qiniu.${index}`, {}) }), _jsx(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`ali.${index}`, {}) }), _jsx(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] })); } diff --git a/es/components/config/upsert/cos/index.js b/es/components/config/upsert/cos/index.js index 1974a28b5..a4295398a 100644 --- a/es/components/config/upsert/cos/index.js +++ b/es/components/config/upsert/cos/index.js @@ -7,16 +7,16 @@ function QiniuCos(props) { { key: '0', label: '配置项', - children: (_jsxs(Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [_jsx(Form.Item, { label: "accessKey", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), _jsx(Form.Item, { label: "uploadHost", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), _jsx(Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card", + children: (_jsxs(Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [_jsx(Form.Item, { label: "accessKey", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), _jsx(Form.Item, { label: "uploadHost", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), _jsx(Divider, { orientation: "left", className: Styles.title, children: "bucket\u914D\u7F6E" }), _jsx(Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card", // hideAdd={!(sms.length > 0)} onEdit: (targetKey, action) => { if (action === 'add') { - setValue(`buckets.${cos.buckets.length}`, {}); + setValue(`buckets.${cos?.buckets?.length || 0}`, {}); } else { removeItem('buckets', parseInt(targetKey, 10)); } - }, items: cos?.buckets.length > 0 + }, items: cos?.buckets?.length > 0 ? cos.buckets.map((ele, idx) => ({ key: `${idx}`, label: `bucket:${idx + 1}`, @@ -33,9 +33,9 @@ function QiniuCos(props) { }, ] }) }) })] })), })) - : [] }), _jsx(Form.Item, { label: "defaultBucket", children: _jsx(_Fragment, { children: _jsx(Select, { allowClear: true, style: { width: '100%' }, placeholder: "\u8BF7\u9009\u62E9\u9ED8\u8BA4bucket", value: cos.defaultBucket, onChange: (value) => { + : [] }), _jsx(Form.Item, { label: "defaultBucket", children: _jsx(_Fragment, { children: _jsx(Select, { allowClear: true, style: { width: '100%' }, placeholder: "\u8BF7\u9009\u62E9\u9ED8\u8BA4bucket", value: cos?.defaultBucket, onChange: (value) => { setValue(`defaultBucket`, value); - }, options: cos.buckets.map(ele => ({ + }, options: cos?.buckets?.map(ele => ({ label: ele.name, value: ele.name })) }) }) })] })), diff --git a/es/components/extraFile/avatar/index.js b/es/components/extraFile/avatar/index.js index 5f92efedb..0593b34bc 100644 --- a/es/components/extraFile/avatar/index.js +++ b/es/components/extraFile/avatar/index.js @@ -123,7 +123,6 @@ export default OakComponent({ this.addItem(Object.assign({}, updateData, { extra1: null, }), undefined, async () => { - console.log(updateData); await this.features.extraFile.upload(updateData, extra1); }); if (avatar) { diff --git a/es/components/extraFile/gallery/index.js b/es/components/extraFile/gallery/index.js index f4b0152df..68e75e5b3 100644 --- a/es/components/extraFile/gallery/index.js +++ b/es/components/extraFile/gallery/index.js @@ -23,7 +23,6 @@ export default OakComponent({ uploadState: 1, }, formData({ data: originalFiles, features }) { - console.log(originalFiles); let files = originalFiles?.filter((ele) => !ele.$$deleteAt$$).sort((ele1, ele2) => ele1.sort - ele2.sort); if (this.props.tag1) { files = files?.filter((ele) => ele?.tag1 === this.props.tag1); @@ -97,9 +96,7 @@ export default OakComponent({ getUrl(extraFile) { const { fileList } = this.state; if (fileList[extraFile?.id]) { - console.log(fileList[extraFile?.id]); const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, { extra1: fileList[extraFile?.id] })); - console.log(url); return url; } return this.features.extraFile.getUrl(extraFile); diff --git a/es/components/platform/panel/web.pc.js b/es/components/platform/panel/web.pc.js index b816f6ea4..2c8424548 100644 --- a/es/components/platform/panel/web.pc.js +++ b/es/components/platform/panel/web.pc.js @@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; import { Tabs } from 'antd'; import Styles from './web.pc.module.less'; import ConfigUpsert from '../../config/upsert'; -import StyleUpsert from '../../config/style'; +import StyleUpsert from '../../config/style/platform'; import PlatformDetail from '../detail'; import PlatformSystem from '../system'; export default function render(props) { @@ -23,9 +23,7 @@ export default function render(props) { { label: _jsx("div", { className: Styles.tabLabel, children: t('style') }), key: 'style', - children: (_jsx(StyleUpsert, { value: style, onChange: (s) => { - update({ style: s }); - } })), + children: (_jsx(StyleUpsert, { style: style, entity: 'platform', entityId: id, name: name })), }, { label: _jsx("div", { className: Styles.tabLabel, children: t('system-list') }), diff --git a/es/components/system/panel/web.pc.js b/es/components/system/panel/web.pc.js index ef69bf950..f9c8971ec 100644 --- a/es/components/system/panel/web.pc.js +++ b/es/components/system/panel/web.pc.js @@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; import { Tabs } from 'antd'; import SystemDetail from '../detail'; import ConfigUpsert from '../../config/upsert'; -import StyleUpsert from '../../config/style'; +import StyleUpsert from '../../config/style/platform'; import DomainList from '../../domain/list'; import ApplicationList from '../application'; import Styles from './web.pc.module.less'; @@ -24,9 +24,7 @@ export default function Render(props) { { label: _jsx("div", { className: Styles.tabLabel, children: t('style') }), key: 'style', - children: (_jsx(StyleUpsert, { value: style, onChange: (s) => { - update({ style: s }); - } })), + children: (_jsx(StyleUpsert, { style: style, entity: 'system', entityId: id, name: name })), }, { label: _jsx("div", { className: Styles.tabLabel, children: t('application-list') }), diff --git a/es/components/wechatMenu/menuInfo/web.pc.js b/es/components/wechatMenu/menuInfo/web.pc.js index b56c71b08..cc5d49a3f 100644 --- a/es/components/wechatMenu/menuInfo/web.pc.js +++ b/es/components/wechatMenu/menuInfo/web.pc.js @@ -73,7 +73,6 @@ export default function Render(props) { } }; useEffect(() => { - console.log(config); if (config && config.button && config.button[0] && onlyOne) { setMenuName(config.button[0].name); setOnlyOne(false); diff --git a/es/features/index.d.ts b/es/features/index.d.ts index e15a4d429..6cd906462 100644 --- a/es/features/index.d.ts +++ b/es/features/index.d.ts @@ -4,6 +4,7 @@ import { ExtraFile } from './extraFile'; import { ExtraFile2 } from './extraFile2'; import { Application } from './application'; import { Config } from './config'; +import { Style2 } from './style2'; import { WeiXinJsSdk } from './weiXinJsSdk'; import { WechatMenu } from './wechatMenu'; import { WechatPublicTag } from './wechatPublicTag'; @@ -21,6 +22,7 @@ export type GeneralFeatures; application: Application; config: Config; + style2: Style2; weiXinJsSdk: WeiXinJsSdk; theme: Theme; wechatMenu: WechatMenu; diff --git a/es/features/index.js b/es/features/index.js index 9a246afe8..b873b5f34 100644 --- a/es/features/index.js +++ b/es/features/index.js @@ -3,6 +3,7 @@ import { ExtraFile } from './extraFile'; import { ExtraFile2 } from './extraFile2'; import { Application } from './application'; import { Config } from './config'; +import { Style2 } from './style2'; import { WeiXinJsSdk } from './weiXinJsSdk'; import { WechatMenu } from './wechatMenu'; import { WechatPublicTag } from './wechatPublicTag'; @@ -16,6 +17,7 @@ export function initialize(basicFeatures, type, domain) { const extraFile = new ExtraFile(basicFeatures.cache, application, basicFeatures.locales); const extraFile2 = new ExtraFile2(basicFeatures.cache, application, basicFeatures.locales); const config = new Config(basicFeatures.cache); + const style2 = new Style2(basicFeatures.cache); const weiXinJsSdk = new WeiXinJsSdk(basicFeatures.cache, basicFeatures.localStorage, basicFeatures.environment); const theme = new Theme(basicFeatures.cache, basicFeatures.localStorage); return { @@ -24,6 +26,7 @@ export function initialize(basicFeatures, type, domain) { extraFile2, application, config, + style2, weiXinJsSdk, theme, wechatMenu, diff --git a/es/features/style.d.ts b/es/features/style.d.ts new file mode 100644 index 000000000..205369e94 --- /dev/null +++ b/es/features/style.d.ts @@ -0,0 +1,13 @@ +import { Feature } from 'oak-frontend-base'; +import AspectDict from '../aspects/AspectDict'; +import { EntityDict } from '../oak-app-domain'; +import { Cache } from 'oak-frontend-base/es/features/cache'; +import { Style as StyleDef } from '../types/Style'; +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { CommonAspectDict } from 'oak-common-aspect'; +import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext'; +export declare class Style, FrontCxt extends FrontendRuntimeContext, AD extends AspectDict & CommonAspectDict> extends Feature { + private cache; + constructor(cache: Cache>); + updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise; +} diff --git a/es/features/style.js b/es/features/style.js new file mode 100644 index 000000000..41d572f40 --- /dev/null +++ b/es/features/style.js @@ -0,0 +1,16 @@ +import { Feature } from 'oak-frontend-base'; +export class Style extends Feature { + cache; + constructor(cache) { + super(); + this.cache = cache; + } + async updateStyle(entity, entityId, style) { + await this.cache.exec('updateStyle', { + entity, + entityId, + style, + }); + this.publish(); + } +} diff --git a/es/features/style2.d.ts b/es/features/style2.d.ts new file mode 100644 index 000000000..e6913ae14 --- /dev/null +++ b/es/features/style2.d.ts @@ -0,0 +1,13 @@ +import { Feature } from 'oak-frontend-base'; +import AspectDict from '../aspects/AspectDict'; +import { EntityDict } from '../oak-app-domain'; +import { Cache } from 'oak-frontend-base/es/features/cache'; +import { Style as StyleDef } from '../types/Style'; +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { CommonAspectDict } from 'oak-common-aspect'; +import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext'; +export declare class Style2, FrontCxt extends FrontendRuntimeContext, AD extends AspectDict & CommonAspectDict> extends Feature { + private cache; + constructor(cache: Cache>); + updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise; +} diff --git a/es/features/style2.js b/es/features/style2.js new file mode 100644 index 000000000..25accfd15 --- /dev/null +++ b/es/features/style2.js @@ -0,0 +1,16 @@ +import { Feature } from 'oak-frontend-base'; +export class Style2 extends Feature { + cache; + constructor(cache) { + super(); + this.cache = cache; + } + async updateStyle(entity, entityId, style) { + await this.cache.exec('updateStyle', { + entity, + entityId, + style, + }); + this.publish(); + } +} diff --git a/lib/aspects/AspectDict.d.ts b/lib/aspects/AspectDict.d.ts index 3e74a8354..f97811f90 100644 --- a/lib/aspects/AspectDict.d.ts +++ b/lib/aspects/AspectDict.d.ts @@ -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 { Style } from '../types/Style'; import { MenuType } from '../types/WeChat'; import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; import { WechatPublicEventData, WechatMpEventData } from 'oak-external-sdk'; @@ -65,6 +66,11 @@ export type GeneralAspectDict Promise; + updateStyle: (params: { + entity: 'platform' | 'system' | 'application'; + entityId: string; + style: Style; + }, context: Cxt) => Promise; updateApplicationConfig: (params: { entity: 'application'; entityId: string; diff --git a/lib/aspects/index.d.ts b/lib/aspects/index.d.ts index dc5f4a4f8..a8085c5cb 100644 --- a/lib/aspects/index.d.ts +++ b/lib/aspects/index.d.ts @@ -2,6 +2,7 @@ import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCa import { getInfoByUrl } from './extraFile'; import { getApplication, signatureJsSDK, uploadWechatMedia } from './application'; import { updateConfig, updateApplicationConfig } from './config'; +import { updateStyle } from './style2'; import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user'; import { createWechatLogin } from './wechatLogin'; import { unbindingWechat } from './wechatUser'; @@ -22,6 +23,7 @@ declare const aspectDict: { sendCaptcha: typeof sendCaptcha; getApplication: typeof getApplication; updateConfig: typeof updateConfig; + updateStyle: typeof updateStyle; updateApplicationConfig: typeof updateApplicationConfig; getWechatMpUserPhoneNumber: typeof getWechatMpUserPhoneNumber; logout: typeof logout; diff --git a/lib/aspects/index.js b/lib/aspects/index.js index bf4d5cc10..b09434bb0 100644 --- a/lib/aspects/index.js +++ b/lib/aspects/index.js @@ -4,6 +4,7 @@ const token_1 = require("./token"); const extraFile_1 = require("./extraFile"); const application_1 = require("./application"); const config_1 = require("./config"); +const style2_1 = require("./style2"); const user_1 = require("./user"); const wechatLogin_1 = require("./wechatLogin"); const wechatUser_1 = require("./wechatUser"); @@ -24,6 +25,7 @@ const aspectDict = { sendCaptcha: token_1.sendCaptcha, getApplication: application_1.getApplication, updateConfig: config_1.updateConfig, + updateStyle: style2_1.updateStyle, updateApplicationConfig: config_1.updateApplicationConfig, getWechatMpUserPhoneNumber: token_1.getWechatMpUserPhoneNumber, logout: token_1.logout, diff --git a/lib/aspects/style.d.ts b/lib/aspects/style.d.ts new file mode 100644 index 000000000..cfb2ca66b --- /dev/null +++ b/lib/aspects/style.d.ts @@ -0,0 +1,8 @@ +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { EntityDict } from '../oak-app-domain'; +import { Style } from '../types/Style'; +export declare function updateStyle>(params: { + entity: 'platform' | 'system'; + entityId: string; + style: Style; +}, context: Cxt): Promise; diff --git a/lib/aspects/style.js b/lib/aspects/style.js new file mode 100644 index 000000000..7e3bc5667 --- /dev/null +++ b/lib/aspects/style.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.updateStyle = void 0; +const uuid_1 = require("oak-domain/lib/utils/uuid"); +async function updateStyle(params, context) { + const { entity, entityId, style } = params; + await context.operate(entity, { + id: (0, uuid_1.generateNewId)(), + action: 'update', + data: { + style, + }, + filter: { + id: entityId, + } + }, {}); +} +exports.updateStyle = updateStyle; diff --git a/lib/aspects/style2.d.ts b/lib/aspects/style2.d.ts new file mode 100644 index 000000000..cfb2ca66b --- /dev/null +++ b/lib/aspects/style2.d.ts @@ -0,0 +1,8 @@ +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { EntityDict } from '../oak-app-domain'; +import { Style } from '../types/Style'; +export declare function updateStyle>(params: { + entity: 'platform' | 'system'; + entityId: string; + style: Style; +}, context: Cxt): Promise; diff --git a/lib/aspects/style2.js b/lib/aspects/style2.js new file mode 100644 index 000000000..7e3bc5667 --- /dev/null +++ b/lib/aspects/style2.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.updateStyle = void 0; +const uuid_1 = require("oak-domain/lib/utils/uuid"); +async function updateStyle(params, context) { + const { entity, entityId, style } = params; + await context.operate(entity, { + id: (0, uuid_1.generateNewId)(), + action: 'update', + data: { + style, + }, + filter: { + id: entityId, + } + }, {}); +} +exports.updateStyle = updateStyle; diff --git a/lib/components/application/panel/web.pc.js b/lib/components/application/panel/web.pc.js index 94aca9960..1cf0c1027 100644 --- a/lib/components/application/panel/web.pc.js +++ b/lib/components/application/panel/web.pc.js @@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime"); const antd_1 = require("antd"); const detail_1 = tslib_1.__importDefault(require("../detail")); const application_1 = tslib_1.__importDefault(require("../../config/application")); -const style_1 = tslib_1.__importDefault(require("../../config/style")); +const platform_1 = tslib_1.__importDefault(require("../../config/style/platform")); const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less")); function Render(props) { const { id, config, oakFullpath, name, style } = props.data; @@ -25,9 +25,7 @@ function Render(props) { { label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('style') }), key: 'style', - children: ((0, jsx_runtime_1.jsx)(style_1.default, { value: style, onChange: (s) => { - update({ style: s }); - } })), + children: ((0, jsx_runtime_1.jsx)(platform_1.default, { style: style, entity: 'platform', entityId: id, name: name })), }, ] }) })); } diff --git a/lib/components/config/style/platform/index.d.ts b/lib/components/config/style/platform/index.d.ts new file mode 100644 index 000000000..551c98f37 --- /dev/null +++ b/lib/components/config/style/platform/index.d.ts @@ -0,0 +1,9 @@ +/// +import { Style } from '../../../../types/Style'; +declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => import("react").ReactElement>; +export default _default; diff --git a/lib/components/config/style/platform/index.js b/lib/components/config/style/platform/index.js new file mode 100644 index 000000000..f579ddf05 --- /dev/null +++ b/lib/components/config/style/platform/index.js @@ -0,0 +1,88 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const lodash_1 = require("oak-domain/lib/utils/lodash"); +exports.default = OakComponent({ + isList: false, + properties: { + style: {}, + entity: '', + entityId: '', + name: '', + }, + data: { + initialStyle: {}, + dirty: false, + currentStyle: {}, + }, + // listeners: { + // config(prev, next) { + // if (prev.config !== next.config) { + // const config2 = next.config || {}; + // this.setState({ + // initialConfig: config2, + // dirty: false, + // currentConfig: cloneDeep(config2), + // }); + // } + // }, + // }, + lifetimes: { + ready() { + const { style } = this.props; + this.setState({ + initialStyle: style, + dirty: false, + currentStyle: (0, lodash_1.cloneDeep)(style), + }); + } + }, + methods: { + setValue(newStyle) { + const newStyle2 = (0, lodash_1.cloneDeep)(newStyle || {}); + this.setState({ + currentStyle: newStyle2, + dirty: true, + }); + }, + // cleanKey(path: string, key: string) { + // const { currentConfig } = this.state; + // const obj = get(currentConfig, path); + // const obj2 = omit(obj, [key]); + // set(currentConfig, path, obj2); + // const newConfig = cloneDeep(currentConfig); + // this.setState({ + // currentConfig: newConfig, + // dirty: true, + // }); + // }, + // removeItem(path: string, index: number) { + // const { currentConfig } = this.state; + // const array = get(currentConfig, path); + // (array as any[]).splice(index, 1); + // const newConfig = cloneDeep(currentConfig || {}); + // this.setState({ + // currentConfig: newConfig, + // dirty: true, + // }); + // }, + resetStyle() { + const { initialStyle } = this.state; + this.setState({ + dirty: false, + currentStyle: (0, lodash_1.cloneDeep)(initialStyle), + }); + }, + async updateStyle() { + const { currentStyle } = this.state; + const { entity, entityId } = this.props; + await this.features.style2.updateStyle(entity, entityId, currentStyle); + this.setMessage({ + content: '操作成功', + type: 'success', + }); + this.setState({ + dirty: false, + }); + }, + }, +}); diff --git a/lib/components/config/style/platform/web.module.less b/lib/components/config/style/platform/web.module.less new file mode 100644 index 000000000..be1b128dd --- /dev/null +++ b/lib/components/config/style/platform/web.module.less @@ -0,0 +1,43 @@ +.container { + background: var(--oak-bg-color-container); + // box-shadow: 0 2px 3px #0000001a; + // border-radius: 3px; + padding: 30px 32px; +} + +.padding { + background-color: var(--oak-bg-color-page); + width: 100%; + height: 77px; +} + +.ctrl { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + padding: 10px; + border: solid 0.4px; + border-radius: 3px; + border-color: var(--oak-border-color); + position: absolute; + z-index: 10; + background-color: var(--oak-bg-color-container); + width: calc(100vw - 138px); + top: 85px; + height: 55px; + + text { + color: var(--oak-text-color-secondary); + + .weight { + font-weight: bold; + color: var(--oak-text-color-primary); + text-decoration: underline; + } + } +} + +.contains { + margin-top: 20px; +} \ No newline at end of file diff --git a/lib/components/config/style/platform/web.pc.d.ts b/lib/components/config/style/platform/web.pc.d.ts new file mode 100644 index 000000000..94f8fdd23 --- /dev/null +++ b/lib/components/config/style/platform/web.pc.d.ts @@ -0,0 +1,13 @@ +import { Style as StyleDef } from '../../../../types/Style'; +import { EntityDict } from '../../../../oak-app-domain'; +import { WebComponentProps } from 'oak-frontend-base'; +export default function Render(props: WebComponentProps void; + updateStyle: () => void; + setValue: (style: StyleDef) => void; +}>): import("react/jsx-runtime").JSX.Element; diff --git a/lib/components/config/style/platform/web.pc.js b/lib/components/config/style/platform/web.pc.js new file mode 100644 index 000000000..ab4468174 --- /dev/null +++ b/lib/components/config/style/platform/web.pc.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const jsx_runtime_1 = require("react/jsx-runtime"); +const antd_1 = require("antd"); +const web_module_less_1 = tslib_1.__importDefault(require("./web.module.less")); +const style_1 = tslib_1.__importDefault(require("../../style")); +function Render(props) { + const { entity, currentStyle, dirty, name } = props.data; + const { resetStyle, updateStyle, setValue, t } = props.methods; + return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Affix, { offsetTop: 64, children: (0, jsx_runtime_1.jsx)(antd_1.Alert, { message: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("text", { children: ["\u60A8\u6B63\u5728\u66F4\u65B0", (0, jsx_runtime_1.jsx)(antd_1.Typography.Text, { keyboard: true, className: web_module_less_1.default.weight, children: entity }), "\u5BF9\u8C61", (0, jsx_runtime_1.jsx)(antd_1.Typography.Text, { keyboard: true, className: web_module_less_1.default.weight, children: name }), "\u7684\u6837\u5F0F\uFF0C\u8BF7\u8C28\u614E\u64CD\u4F5C"] }) }), type: "info", showIcon: true, action: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !dirty, type: "primary", danger: true, onClick: () => resetStyle(), style: { + marginRight: 10, + }, children: t('common::reset') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !dirty, type: "primary", onClick: () => updateStyle(), children: t('common::action.confirm') })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.contains, children: (0, jsx_runtime_1.jsx)(style_1.default, { value: currentStyle, onChange: (s) => { + setValue(s); + } }) })] })); +} +exports.default = Render; diff --git a/lib/components/config/upsert/account/index.js b/lib/components/config/upsert/account/index.js index e45eac035..ec2bf8ea5 100644 --- a/lib/components/config/upsert/account/index.js +++ b/lib/components/config/upsert/account/index.js @@ -115,6 +115,6 @@ function AmapAccount(props) { function Account(props) { const { account, setValue, removeItem } = props; const { tencent, qiniu, ali, amap } = account; - return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Row, { children: (0, jsx_runtime_1.jsx)(antd_1.Card, { className: web_module_less_1.default.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), (0, jsx_runtime_1.jsx)(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), (0, jsx_runtime_1.jsx)(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] })); + return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Row, { children: (0, jsx_runtime_1.jsx)(antd_1.Card, { className: web_module_less_1.default.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), (0, jsx_runtime_1.jsx)(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`tencent.${index}`, {}) }), (0, jsx_runtime_1.jsx)(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`qiniu.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`ali.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] })); } exports.default = Account; diff --git a/lib/components/config/upsert/cos/index.js b/lib/components/config/upsert/cos/index.js index fb6456a7a..d4406d809 100644 --- a/lib/components/config/upsert/cos/index.js +++ b/lib/components/config/upsert/cos/index.js @@ -10,16 +10,16 @@ function QiniuCos(props) { { key: '0', label: '配置项', - children: ((0, jsx_runtime_1.jsxs)(antd_1.Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "accessKey", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "uploadHost", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card", + children: ((0, jsx_runtime_1.jsxs)(antd_1.Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "accessKey", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "uploadHost", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Divider, { orientation: "left", className: web_module_less_1.default.title, children: "bucket\u914D\u7F6E" }), (0, jsx_runtime_1.jsx)(antd_1.Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card", // hideAdd={!(sms.length > 0)} onEdit: (targetKey, action) => { if (action === 'add') { - setValue(`buckets.${cos.buckets.length}`, {}); + setValue(`buckets.${cos?.buckets?.length || 0}`, {}); } else { removeItem('buckets', parseInt(targetKey, 10)); } - }, items: cos?.buckets.length > 0 + }, items: cos?.buckets?.length > 0 ? cos.buckets.map((ele, idx) => ({ key: `${idx}`, label: `bucket:${idx + 1}`, @@ -36,9 +36,9 @@ function QiniuCos(props) { }, ] }) }) })] })), })) - : [] }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "defaultBucket", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Select, { allowClear: true, style: { width: '100%' }, placeholder: "\u8BF7\u9009\u62E9\u9ED8\u8BA4bucket", value: cos.defaultBucket, onChange: (value) => { + : [] }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "defaultBucket", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Select, { allowClear: true, style: { width: '100%' }, placeholder: "\u8BF7\u9009\u62E9\u9ED8\u8BA4bucket", value: cos?.defaultBucket, onChange: (value) => { setValue(`defaultBucket`, value); - }, options: cos.buckets.map(ele => ({ + }, options: cos?.buckets?.map(ele => ({ label: ele.name, value: ele.name })) }) }) })] })), diff --git a/lib/components/extraFile/avatar/index.js b/lib/components/extraFile/avatar/index.js index 6271ded03..7d5c708f7 100644 --- a/lib/components/extraFile/avatar/index.js +++ b/lib/components/extraFile/avatar/index.js @@ -125,7 +125,6 @@ exports.default = OakComponent({ this.addItem(Object.assign({}, updateData, { extra1: null, }), undefined, async () => { - console.log(updateData); await this.features.extraFile.upload(updateData, extra1); }); if (avatar) { diff --git a/lib/components/extraFile/gallery/index.js b/lib/components/extraFile/gallery/index.js index 77bfcc2a2..cb8e088bd 100644 --- a/lib/components/extraFile/gallery/index.js +++ b/lib/components/extraFile/gallery/index.js @@ -26,7 +26,6 @@ exports.default = OakComponent({ uploadState: 1, }, formData({ data: originalFiles, features }) { - console.log(originalFiles); let files = originalFiles?.filter((ele) => !ele.$$deleteAt$$).sort((ele1, ele2) => ele1.sort - ele2.sort); if (this.props.tag1) { files = files?.filter((ele) => ele?.tag1 === this.props.tag1); @@ -100,9 +99,7 @@ exports.default = OakComponent({ getUrl(extraFile) { const { fileList } = this.state; if (fileList[extraFile?.id]) { - console.log(fileList[extraFile?.id]); const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, { extra1: fileList[extraFile?.id] })); - console.log(url); return url; } return this.features.extraFile.getUrl(extraFile); diff --git a/lib/components/platform/panel/web.pc.js b/lib/components/platform/panel/web.pc.js index 62ead99ed..30880eeac 100644 --- a/lib/components/platform/panel/web.pc.js +++ b/lib/components/platform/panel/web.pc.js @@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime"); const antd_1 = require("antd"); const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less")); const upsert_1 = tslib_1.__importDefault(require("../../config/upsert")); -const style_1 = tslib_1.__importDefault(require("../../config/style")); +const platform_1 = tslib_1.__importDefault(require("../../config/style/platform")); const detail_1 = tslib_1.__importDefault(require("../detail")); const system_1 = tslib_1.__importDefault(require("../system")); function render(props) { @@ -26,9 +26,7 @@ function render(props) { { label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('style') }), key: 'style', - children: ((0, jsx_runtime_1.jsx)(style_1.default, { value: style, onChange: (s) => { - update({ style: s }); - } })), + children: ((0, jsx_runtime_1.jsx)(platform_1.default, { style: style, entity: 'platform', entityId: id, name: name })), }, { label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('system-list') }), diff --git a/lib/components/system/panel/web.pc.js b/lib/components/system/panel/web.pc.js index 56363e93d..d6533c0d1 100644 --- a/lib/components/system/panel/web.pc.js +++ b/lib/components/system/panel/web.pc.js @@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime"); const antd_1 = require("antd"); const detail_1 = tslib_1.__importDefault(require("../detail")); const upsert_1 = tslib_1.__importDefault(require("../../config/upsert")); -const style_1 = tslib_1.__importDefault(require("../../config/style")); +const platform_1 = tslib_1.__importDefault(require("../../config/style/platform")); const list_1 = tslib_1.__importDefault(require("../../domain/list")); const application_1 = tslib_1.__importDefault(require("../application")); const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less")); @@ -27,9 +27,7 @@ function Render(props) { { label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('style') }), key: 'style', - children: ((0, jsx_runtime_1.jsx)(style_1.default, { value: style, onChange: (s) => { - update({ style: s }); - } })), + children: ((0, jsx_runtime_1.jsx)(platform_1.default, { style: style, entity: 'system', entityId: id, name: name })), }, { label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('application-list') }), diff --git a/lib/components/wechatMenu/menuInfo/web.pc.js b/lib/components/wechatMenu/menuInfo/web.pc.js index b216d9c23..1ccc4c0e2 100644 --- a/lib/components/wechatMenu/menuInfo/web.pc.js +++ b/lib/components/wechatMenu/menuInfo/web.pc.js @@ -76,7 +76,6 @@ function Render(props) { } }; (0, react_1.useEffect)(() => { - console.log(config); if (config && config.button && config.button[0] && onlyOne) { setMenuName(config.button[0].name); setOnlyOne(false); diff --git a/lib/features/index.d.ts b/lib/features/index.d.ts index e15a4d429..6cd906462 100644 --- a/lib/features/index.d.ts +++ b/lib/features/index.d.ts @@ -4,6 +4,7 @@ import { ExtraFile } from './extraFile'; import { ExtraFile2 } from './extraFile2'; import { Application } from './application'; import { Config } from './config'; +import { Style2 } from './style2'; import { WeiXinJsSdk } from './weiXinJsSdk'; import { WechatMenu } from './wechatMenu'; import { WechatPublicTag } from './wechatPublicTag'; @@ -21,6 +22,7 @@ export type GeneralFeatures; application: Application; config: Config; + style2: Style2; weiXinJsSdk: WeiXinJsSdk; theme: Theme; wechatMenu: WechatMenu; diff --git a/lib/features/index.js b/lib/features/index.js index 670cdbc56..7130782e5 100644 --- a/lib/features/index.js +++ b/lib/features/index.js @@ -7,6 +7,7 @@ const extraFile_1 = require("./extraFile"); const extraFile2_1 = require("./extraFile2"); const application_1 = require("./application"); const config_1 = require("./config"); +const style2_1 = require("./style2"); const weiXinJsSdk_1 = require("./weiXinJsSdk"); const wechatMenu_1 = require("./wechatMenu"); const wechatPublicTag_1 = require("./wechatPublicTag"); @@ -20,6 +21,7 @@ function initialize(basicFeatures, type, domain) { const extraFile = new extraFile_1.ExtraFile(basicFeatures.cache, application, basicFeatures.locales); const extraFile2 = new extraFile2_1.ExtraFile2(basicFeatures.cache, application, basicFeatures.locales); const config = new config_1.Config(basicFeatures.cache); + const style2 = new style2_1.Style2(basicFeatures.cache); const weiXinJsSdk = new weiXinJsSdk_1.WeiXinJsSdk(basicFeatures.cache, basicFeatures.localStorage, basicFeatures.environment); const theme = new theme_1.default(basicFeatures.cache, basicFeatures.localStorage); return { @@ -28,6 +30,7 @@ function initialize(basicFeatures, type, domain) { extraFile2, application, config, + style2, weiXinJsSdk, theme, wechatMenu, diff --git a/lib/features/style.d.ts b/lib/features/style.d.ts new file mode 100644 index 000000000..205369e94 --- /dev/null +++ b/lib/features/style.d.ts @@ -0,0 +1,13 @@ +import { Feature } from 'oak-frontend-base'; +import AspectDict from '../aspects/AspectDict'; +import { EntityDict } from '../oak-app-domain'; +import { Cache } from 'oak-frontend-base/es/features/cache'; +import { Style as StyleDef } from '../types/Style'; +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { CommonAspectDict } from 'oak-common-aspect'; +import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext'; +export declare class Style, FrontCxt extends FrontendRuntimeContext, AD extends AspectDict & CommonAspectDict> extends Feature { + private cache; + constructor(cache: Cache>); + updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise; +} diff --git a/lib/features/style.js b/lib/features/style.js new file mode 100644 index 000000000..8c9d071d3 --- /dev/null +++ b/lib/features/style.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Style = void 0; +const oak_frontend_base_1 = require("oak-frontend-base"); +class Style extends oak_frontend_base_1.Feature { + cache; + constructor(cache) { + super(); + this.cache = cache; + } + async updateStyle(entity, entityId, style) { + await this.cache.exec('updateStyle', { + entity, + entityId, + style, + }); + this.publish(); + } +} +exports.Style = Style; diff --git a/lib/features/style2.d.ts b/lib/features/style2.d.ts new file mode 100644 index 000000000..e6913ae14 --- /dev/null +++ b/lib/features/style2.d.ts @@ -0,0 +1,13 @@ +import { Feature } from 'oak-frontend-base'; +import AspectDict from '../aspects/AspectDict'; +import { EntityDict } from '../oak-app-domain'; +import { Cache } from 'oak-frontend-base/es/features/cache'; +import { Style as StyleDef } from '../types/Style'; +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { CommonAspectDict } from 'oak-common-aspect'; +import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext'; +export declare class Style2, FrontCxt extends FrontendRuntimeContext, AD extends AspectDict & CommonAspectDict> extends Feature { + private cache; + constructor(cache: Cache>); + updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise; +} diff --git a/lib/features/style2.js b/lib/features/style2.js new file mode 100644 index 000000000..d969f6488 --- /dev/null +++ b/lib/features/style2.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Style2 = void 0; +const oak_frontend_base_1 = require("oak-frontend-base"); +class Style2 extends oak_frontend_base_1.Feature { + cache; + constructor(cache) { + super(); + this.cache = cache; + } + async updateStyle(entity, entityId, style) { + await this.cache.exec('updateStyle', { + entity, + entityId, + style, + }); + this.publish(); + } +} +exports.Style2 = Style2; diff --git a/src/aspects/AspectDict.ts b/src/aspects/AspectDict.ts index 90794bcd8..9390300d2 100644 --- a/src/aspects/AspectDict.ts +++ b/src/aspects/AspectDict.ts @@ -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, Origin } from '../types/Config'; +import { Style } from '../types/Style'; import { MediaType, MenuType } from '../types/WeChat'; import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; import { MediaVideoDescription } from '../types/WeChat' @@ -109,6 +110,14 @@ export type GeneralAspectDict< }, context: Cxt ) => Promise; + updateStyle: ( + params: { + entity: 'platform' | 'system' | 'application'; + entityId: string; + style: Style; + }, + context: Cxt + ) => Promise; updateApplicationConfig: ( params: { entity: 'application'; diff --git a/src/aspects/index.ts b/src/aspects/index.ts index 1b7d6e101..ad2c36eea 100644 --- a/src/aspects/index.ts +++ b/src/aspects/index.ts @@ -18,6 +18,7 @@ import { uploadWechatMedia, } from './application'; import { updateConfig, updateApplicationConfig } from './config'; +import { updateStyle } from './style2'; import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user'; import { createWechatLogin } from './wechatLogin'; import { unbindingWechat } from './wechatUser'; @@ -55,6 +56,7 @@ const aspectDict = { sendCaptcha, getApplication, updateConfig, + updateStyle, updateApplicationConfig, getWechatMpUserPhoneNumber, logout, diff --git a/src/aspects/style2.ts b/src/aspects/style2.ts new file mode 100644 index 000000000..51d98bd1a --- /dev/null +++ b/src/aspects/style2.ts @@ -0,0 +1,22 @@ +import { generateNewId } from 'oak-domain/lib/utils/uuid'; +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { EntityDict } from '../oak-app-domain'; +import { Style } from '../types/Style'; + +export async function updateStyle>(params: { + entity: 'platform' | 'system', + entityId: string, + style: Style +}, context: Cxt) { + const { entity, entityId, style } = params; + await context.operate(entity, { + id: generateNewId(), + action: 'update', + data: { + style, + }, + filter: { + id: entityId, + } + }, {}); +} \ No newline at end of file diff --git a/src/components/application/panel/web.pc.tsx b/src/components/application/panel/web.pc.tsx index adcc1161c..3320698a8 100644 --- a/src/components/application/panel/web.pc.tsx +++ b/src/components/application/panel/web.pc.tsx @@ -3,7 +3,7 @@ import { Tabs } from 'antd'; import { WebComponentProps } from 'oak-frontend-base'; import ApplicationDetail from '../detail'; import ConfigUpsert from '../../config/application'; -import StyleUpsert from '../../config/style'; +import StyleUpsert from '../../config/style/platform'; import { EntityDict } from '../../../oak-app-domain'; import { Style } from '../../../types/Style'; import Styles from './web.pc.module.less'; @@ -51,10 +51,10 @@ export default function Render(props: WebComponentProps { - update({ style: s }); - }} + style={style} + entity={'platform'} + entityId={id} + name={name} /> ), }, diff --git a/src/components/config/style/index.tsx b/src/components/config/style/index.tsx index 559e03957..ef5caee97 100644 --- a/src/components/config/style/index.tsx +++ b/src/components/config/style/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Space, Form, Input, Button, Tooltip, Tabs, ColorPicker } from 'antd'; +import { Space, Form, Input, Button, Tooltip, Tabs, ColorPicker, Affix, Alert, Typography } from 'antd'; import { ClearOutlined } from '@ant-design/icons' import { Style as StyleType, ColorType } from '../../../types/Style'; import { set, get } from 'oak-domain/lib/utils/lodash'; @@ -62,7 +62,7 @@ export default function Render(props: StyleProps) { return (
{}} + onChange={() => { }} type="card" items={[ { diff --git a/src/components/config/style/platform/index.ts b/src/components/config/style/platform/index.ts new file mode 100644 index 000000000..b5f48326f --- /dev/null +++ b/src/components/config/style/platform/index.ts @@ -0,0 +1,99 @@ +import { cloneDeep, set, get, omit } from 'oak-domain/lib/utils/lodash'; +import { Style } from '../../../../types/Style'; + +export default OakComponent({ + isList: false, + properties: { + style: {} as Style, + entity: '' as 'system' | 'platform' | 'application', + entityId: '', + name: '', + }, + data: { + initialStyle: {} as Style, + dirty: false, + currentStyle: {} as Style, + }, + // listeners: { + // config(prev, next) { + // if (prev.config !== next.config) { + // const config2 = next.config || {}; + // this.setState({ + // initialConfig: config2, + // dirty: false, + // currentConfig: cloneDeep(config2), + // }); + // } + // }, + // }, + lifetimes: { + ready() { + const { style } = this.props; + this.setState({ + initialStyle: style, + dirty: false, + currentStyle: cloneDeep(style), + }) + } + }, + methods: { + setValue(newStyle: Style) { + const newStyle2 = cloneDeep(newStyle || {}); + this.setState({ + currentStyle: newStyle2, + dirty: true, + }); + }, + + // cleanKey(path: string, key: string) { + // const { currentConfig } = this.state; + // const obj = get(currentConfig, path); + // const obj2 = omit(obj, [key]); + // set(currentConfig, path, obj2); + // const newConfig = cloneDeep(currentConfig); + // this.setState({ + // currentConfig: newConfig, + // dirty: true, + // }); + // }, + + // removeItem(path: string, index: number) { + // const { currentConfig } = this.state; + // const array = get(currentConfig, path); + // (array as any[]).splice(index, 1); + // const newConfig = cloneDeep(currentConfig || {}); + // this.setState({ + // currentConfig: newConfig, + // dirty: true, + // }); + // }, + + resetStyle() { + const { initialStyle } = this.state; + this.setState({ + dirty: false, + currentStyle: cloneDeep(initialStyle), + }); + }, + + async updateStyle() { + const { currentStyle } = this.state; + const { entity, entityId } = this.props; + + await this.features.style2.updateStyle( + entity!, + entityId!, + currentStyle, + ); + this.setMessage({ + content: '操作成功', + type: 'success', + }); + this.setState( + { + dirty: false, + } + ) + }, + }, +}); diff --git a/src/components/config/style/platform/web.module.less b/src/components/config/style/platform/web.module.less new file mode 100644 index 000000000..be1b128dd --- /dev/null +++ b/src/components/config/style/platform/web.module.less @@ -0,0 +1,43 @@ +.container { + background: var(--oak-bg-color-container); + // box-shadow: 0 2px 3px #0000001a; + // border-radius: 3px; + padding: 30px 32px; +} + +.padding { + background-color: var(--oak-bg-color-page); + width: 100%; + height: 77px; +} + +.ctrl { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + padding: 10px; + border: solid 0.4px; + border-radius: 3px; + border-color: var(--oak-border-color); + position: absolute; + z-index: 10; + background-color: var(--oak-bg-color-container); + width: calc(100vw - 138px); + top: 85px; + height: 55px; + + text { + color: var(--oak-text-color-secondary); + + .weight { + font-weight: bold; + color: var(--oak-text-color-primary); + text-decoration: underline; + } + } +} + +.contains { + margin-top: 20px; +} \ No newline at end of file diff --git a/src/components/config/style/platform/web.pc.tsx b/src/components/config/style/platform/web.pc.tsx new file mode 100644 index 000000000..e837eb579 --- /dev/null +++ b/src/components/config/style/platform/web.pc.tsx @@ -0,0 +1,93 @@ +import React from 'react'; +import { Tabs, Button, Alert, Affix, Space, Typography } from 'antd'; +import Style from './web.module.less'; + +import { Style as StyleDef } from '../../../../types/Style'; + +import { EntityDict } from '../../../../oak-app-domain'; +import { WebComponentProps } from 'oak-frontend-base'; +import StyleUpsert from '../../style'; + +export default function Render( + props: WebComponentProps< + EntityDict, + 'user', + false, + { + entity: string; + name: string; + currentStyle: StyleDef; + dirty: boolean; + }, + { + resetStyle: () => void; + updateStyle: () => void; + setValue: (style: StyleDef) => void; + } + > +) { + const { entity, currentStyle, dirty, name } = props.data; + const { resetStyle, updateStyle, setValue, t } = + props.methods; + return ( + <> + + + + 您正在更新 + + {entity} + + 对象 + + {name} + + 的样式,请谨慎操作 + +
+ } + type="info" + showIcon + action={ + + + + + } + /> + +
+ { + setValue(s) + }} + /> +
+ + ); +} \ No newline at end of file diff --git a/src/components/config/upsert/account/index.tsx b/src/components/config/upsert/account/index.tsx index b5ecc366e..4eebf8b15 100644 --- a/src/components/config/upsert/account/index.tsx +++ b/src/components/config/upsert/account/index.tsx @@ -37,198 +37,198 @@ function TencentAccount(props: { items={ accounts.length > 0 ? accounts.map((ele, idx) => ({ - key: `${idx}`, - label: `帐号${idx + 1}`, - children: ( -
- - <> - - setValue( - `${idx}.secretId`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.secretKey`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.region`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.endpoint`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.smsEndpoint`, - e.target.value - ) - } - /> - - -
- ), - })) + key: `${idx}`, + label: `帐号${idx + 1}`, + children: ( +
+ + <> + + setValue( + `${idx}.secretId`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.secretKey`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.region`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.endpoint`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.smsEndpoint`, + e.target.value + ) + } + /> + + +
+ ), + })) : [ - { - label: '新建帐号', - key: '0', - children: ( -
- - <> - - setValue( - `0.secretId`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.secretKey`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.region`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.smsEndpoint`, - e.target.value - ) - } - /> - - -
- ), - }, - ] + { + label: '新建帐号', + key: '0', + children: ( +
+ + <> + + setValue( + `0.secretId`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.secretKey`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.region`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.smsEndpoint`, + e.target.value + ) + } + /> + + +
+ ), + }, + ] } > @@ -262,105 +262,105 @@ function QiniuAccount(props: { items={ accounts.length > 0 ? accounts.map((ele, idx) => ({ - key: `${idx}`, - label: `帐号${idx + 1}`, - children: ( -
- - <> - - setValue( - `${idx}.accessKey`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.secretKey`, - e.target.value - ) - } - /> - - -
- ), - })) + key: `${idx}`, + label: `帐号${idx + 1}`, + children: ( +
+ + <> + + setValue( + `${idx}.accessKey`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.secretKey`, + e.target.value + ) + } + /> + + +
+ ), + })) : [ - { - label: '新建帐号', - key: '0', - children: ( -
- - <> - - setValue( - `0.accessKey`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.secretKey`, - e.target.value - ) - } - /> - - -
- ), - }, - ] + { + label: '新建帐号', + key: '0', + children: ( +
+ + <> + + setValue( + `0.accessKey`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.secretKey`, + e.target.value + ) + } + /> + + +
+ ), + }, + ] } > @@ -394,253 +394,253 @@ function AliAccount(props: { items={ accounts.length > 0 ? accounts.map((ele, idx) => ({ - key: `${idx}`, - label: `帐号${idx + 1}`, - children: ( -
- - <> - - setValue( - `${idx}.accessKeyId`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.accessKeySecret`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.regionId`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.endpoint`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.apiVersion`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `${idx}.smsEndpoint`, - e.target.value - ) - } - /> - - -
- ), - })) + key: `${idx}`, + label: `帐号${idx + 1}`, + children: ( +
+ + <> + + setValue( + `${idx}.accessKeyId`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.accessKeySecret`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.regionId`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.endpoint`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.apiVersion`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `${idx}.smsEndpoint`, + e.target.value + ) + } + /> + + +
+ ), + })) : [ - { - label: '新建帐号', - key: '0', - children: ( -
- - <> - - setValue( - `0.accessKeyId`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.accessKeySecret`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.regionId`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.endpoint`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.apiVersion`, - e.target.value - ) - } - /> - - - - <> - - setValue( - `0.smsEndpoint`, - e.target.value - ) - } - /> - - -
- ), - }, - ] + { + label: '新建帐号', + key: '0', + children: ( +
+ + <> + + setValue( + `0.accessKeyId`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.accessKeySecret`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.regionId`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.endpoint`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.apiVersion`, + e.target.value + ) + } + /> + + + + <> + + setValue( + `0.smsEndpoint`, + e.target.value + ) + } + /> + + +
+ ), + }, + ] } > @@ -674,69 +674,69 @@ function AmapAccount(props: { items={ accounts.length > 0 ? accounts.map((ele, idx) => ({ - key: `${idx}`, - label: `帐号${idx + 1}`, - children: ( -
- - <> - - setValue( - `${idx}.webApiKey`, - e.target.value - ) - } - /> - - -
- ), - })) + key: `${idx}`, + label: `帐号${idx + 1}`, + children: ( +
+ + <> + + setValue( + `${idx}.webApiKey`, + e.target.value + ) + } + /> + + +
+ ), + })) : [ - { - label: '新建帐号', - key: '0', - children: ( -
- - <> - - setValue( - `0.webApiKey`, - e.target.value - ) - } - /> - - -
- ), - }, - ] + { + label: '新建帐号', + key: '0', + children: ( +
+ + <> + + setValue( + `0.webApiKey`, + e.target.value + ) + } + /> + + +
+ ), + }, + ] } > @@ -761,19 +761,19 @@ export default function Account(props: { accounts={tencent || []} setValue={(path, value) => setValue(`tencent.${path}`, value)} removeItem={(path, index) => removeItem(`tencent`, index)} - addItem={(path, index) => setValue(`amap.${index}`, {})} + addItem={(path, index) => setValue(`tencent.${index}`, {})} /> setValue(`qiniu.${path}`, value)} removeItem={(path, index) => removeItem(`qiniu`, index)} - addItem={(path, index) => setValue(`amap.${index}`, {})} + addItem={(path, index) => setValue(`qiniu.${index}`, {})} /> setValue(`ali.${path}`, value)} removeItem={(path, index) => removeItem(`ali`, index)} - addItem={(path, index) => setValue(`amap.${index}`, {})} + addItem={(path, index) => setValue(`ali.${index}`, {})} /> + + bucket配置 + 0)} onEdit={(targetKey: any, action: 'add' | 'remove') => { if (action === 'add') { - setValue(`buckets.${cos.buckets.length}`, {}); + setValue(`buckets.${cos?.buckets?.length || 0}`, {}); } else { removeItem('buckets', parseInt(targetKey, 10)); } }} items={ - cos?.buckets.length > 0 + cos?.buckets?.length > 0 ? cos.buckets.map((ele, idx) => ({ key: `${idx}`, label: `bucket:${idx + 1}`, @@ -186,6 +189,7 @@ function QiniuCos(props: { : [] } /> + { setValue(`defaultBucket`, value); }} - options={cos.buckets.map( + options={cos?.buckets?.map( ele => ({ label: ele.name, value: ele.name diff --git a/src/components/extraFile/avatar/index.ts b/src/components/extraFile/avatar/index.ts index 6ea8d71e5..616bf9998 100644 --- a/src/components/extraFile/avatar/index.ts +++ b/src/components/extraFile/avatar/index.ts @@ -146,7 +146,6 @@ export default OakComponent({ this.addItem(Object.assign({}, updateData, { extra1: null, }), undefined, async () => { - console.log(updateData); await this.features.extraFile.upload( updateData, extra1 ) diff --git a/src/components/extraFile/gallery/index.ts b/src/components/extraFile/gallery/index.ts index 0cbc9d5a6..a35b3774f 100644 --- a/src/components/extraFile/gallery/index.ts +++ b/src/components/extraFile/gallery/index.ts @@ -32,7 +32,6 @@ export default OakComponent({ uploadState: 1, }, formData({ data: originalFiles, features }) { - console.log(originalFiles); let files = ( originalFiles as Array )?.filter((ele) => !ele.$$deleteAt$$).sort( @@ -112,9 +111,7 @@ export default OakComponent({ getUrl(extraFile: EntityDict['extraFile']['OpSchema']) { const { fileList } = this.state; if (fileList[extraFile?.id]) { - console.log(fileList[extraFile?.id]); const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, { extra1: fileList[extraFile?.id] })); - console.log(url); return url; } return this.features.extraFile.getUrl(extraFile); diff --git a/src/components/platform/panel/web.pc.tsx b/src/components/platform/panel/web.pc.tsx index d2b00e368..dae71dab5 100644 --- a/src/components/platform/panel/web.pc.tsx +++ b/src/components/platform/panel/web.pc.tsx @@ -4,7 +4,7 @@ import { WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../oak-app-domain'; import Styles from './web.pc.module.less'; import ConfigUpsert from '../../config/upsert'; -import StyleUpsert from '../../config/style'; +import StyleUpsert from '../../config/style/platform'; import PlatformDetail from '../detail'; import PlatformSystem from '../system'; import { Style } from '../../../types/Style'; @@ -52,10 +52,10 @@ export default function render(props: WebComponentProps { - update({ style: s }); - }} + style={style} + entity={'platform'} + entityId={id} + name={name} /> ), }, diff --git a/src/components/system/panel/web.pc.tsx b/src/components/system/panel/web.pc.tsx index 797807d04..cae59af73 100644 --- a/src/components/system/panel/web.pc.tsx +++ b/src/components/system/panel/web.pc.tsx @@ -3,7 +3,7 @@ import { Tabs } from 'antd'; import { WebComponentProps } from 'oak-frontend-base'; import SystemDetail from '../detail'; import ConfigUpsert from '../../config/upsert'; -import StyleUpsert from '../../config/style'; +import StyleUpsert from '../../config/style/platform'; import DomainList from '../../domain/list'; import ApplicationList from '../application'; import { EntityDict } from '../../../oak-app-domain'; @@ -54,10 +54,10 @@ export default function Render(props: WebComponentProps { - update({ style: s }); - }} + style={style} + entity={'system'} + entityId={id} + name={name} /> ), }, diff --git a/src/components/wechatMenu/menuInfo/web.pc.tsx b/src/components/wechatMenu/menuInfo/web.pc.tsx index 78b818142..15e1c0831 100644 --- a/src/components/wechatMenu/menuInfo/web.pc.tsx +++ b/src/components/wechatMenu/menuInfo/web.pc.tsx @@ -176,7 +176,6 @@ export default function Render( } }; useEffect(() => { - console.log(config); if (config && config.button && config.button[0] && onlyOne) { setMenuName(config.button[0].name); setOnlyOne(false); @@ -317,11 +316,11 @@ export default function Render( } }, [url]); return ( -
+
{config && - config.button && - config.button.length > 0 && - (selectedBtn !== 0 || selectedSubBtn !== 0) ? ( + config.button && + config.button.length > 0 && + (selectedBtn !== 0 || selectedSubBtn !== 0) ? (
@@ -333,11 +332,9 @@ export default function Render( colon={false} help={
-
{`仅支持中英文和数字,字数不超过${ - selectedSubBtn !== 0 ? 8 : 4 - }个汉字或${ - selectedSubBtn !== 0 ? 16 : 8 - }个字母。`}
+
{`仅支持中英文和数字,字数不超过${selectedSubBtn !== 0 ? 8 : 4 + }个汉字或${selectedSubBtn !== 0 ? 16 : 8 + }个字母。`}
{errorInfo && (
{errorInfo} @@ -387,7 +384,7 @@ export default function Render( {(config.button[currentIndex]?.sub_button?.length === 0 && selectedSubBtn === 0) || - selectedSubBtn > 0 ? ( + selectedSubBtn > 0 ? ( <> } > {!decidedMenuContent && - type !== 'text' ? ( + type !== 'text' ? (
(basicFeatures.cache, application, basicFeatures.locales); const extraFile2 = new ExtraFile2(basicFeatures.cache, application, basicFeatures.locales); const config = new Config(basicFeatures.cache); + const style2 = new Style2(basicFeatures.cache); const weiXinJsSdk = new WeiXinJsSdk( basicFeatures.cache, basicFeatures.localStorage, @@ -64,6 +66,7 @@ export function initialize< extraFile2, application, config, + style2, weiXinJsSdk, theme, wechatMenu, @@ -82,6 +85,7 @@ export type GeneralFeatures< extraFile2: ExtraFile2; application: Application; config: Config; + style2: Style2; weiXinJsSdk: WeiXinJsSdk; theme: Theme; wechatMenu: WechatMenu; diff --git a/src/features/style2.ts b/src/features/style2.ts new file mode 100644 index 000000000..8bfed0be1 --- /dev/null +++ b/src/features/style2.ts @@ -0,0 +1,37 @@ +import { Feature } from 'oak-frontend-base'; +import AspectDict from '../aspects/AspectDict'; +import { EntityDict } from '../oak-app-domain'; +import { Cache } from 'oak-frontend-base/es/features/cache'; +import { Style as StyleDef } from '../types/Style'; +import { BackendRuntimeContext } from '../context/BackendRuntimeContext'; +import { CommonAspectDict } from 'oak-common-aspect'; +import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext'; + +export class Style2< + ED extends EntityDict, + Cxt extends BackendRuntimeContext, + FrontCxt extends FrontendRuntimeContext, + AD extends AspectDict & CommonAspectDict +> extends Feature { + private cache: Cache>; + + constructor( + cache: Cache> + ) { + super(); + this.cache = cache; + } + + async updateStyle( + entity: 'platform' | 'system' | 'application', + entityId: string, + style: StyleDef + ) { + await this.cache.exec('updateStyle', { + entity, + entityId, + style, + }); + this.publish(); + } +}