Merge branch 'dev' of gitea.51mars.com:Oak-Team/oak-general-business into dev

This commit is contained in:
Xu Chang 2025-11-04 14:11:22 +08:00
commit e64ce53334
15 changed files with 108 additions and 58 deletions

View File

@ -5,7 +5,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
tocPosition: "none" | "left" | "right";
highlightBgColor: string;
onArticlePreview: (content?: string, title?: string) => void;
origin: import("../../../types/Config").CosOrigin | null;
origin: null | EntityDict["extraFile"]["Schema"]["origin"];
scrollId: string;
height: number | "auto";
activeColor: string | undefined;

View File

@ -97,8 +97,8 @@ export default OakComponent({
async check() {
if (this.state.name &&
this.state.name.length > 0 &&
this.state.content &&
this.state.content.length > 0 &&
this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>') {
const id = this.getId();
await this.execute(undefined, {
@ -116,8 +116,8 @@ export default OakComponent({
type: 'warning',
});
}
else if (this.state.content &&
this.state.content.length > 0 &&
else if (this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>') {
this.setMessage({
content: this.t('check.no name'),
@ -133,9 +133,6 @@ export default OakComponent({
this.setState({
html,
});
if (html && html !== '<p><br></p>' && this.state.oakFullpath) {
this.update({ content: html });
}
},
gotoPreview(content, title) {
const { onArticlePreview } = this.props;

View File

@ -20,6 +20,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'article', f
tocClosed: boolean;
execuable: boolean;
activeColor?: string;
html: string;
}, {
setHtml: (content: string) => void;
setEditor: (editor: any) => void;

View File

@ -31,7 +31,7 @@ function customCheckImageFn(src, alt, url) {
export default function Render(props) {
const { methods, data } = props;
const { t, setEditor, check, uploadFile, update, setHtml, gotoPreview, clearContentTip, } = methods;
const { oakId, oakFullpath, id, name, content, editor, origin, tocPosition = 'none', highlightBgColor, scrollId, tocWidth, tocHeight, height = 600, tocClosed = false, execuable, activeColor, } = data;
const { oakId, oakFullpath, id, name, content, editor, origin, tocPosition = 'none', highlightBgColor, scrollId, tocWidth, tocHeight, height = 600, tocClosed = false, execuable, activeColor, html, oakLoading, oakExecuting, } = data;
const [articleId, setArticleId] = useState('');
const [toc, setToc] = useState([]);
const [showToc, setShowToc] = useState(false);
@ -53,12 +53,14 @@ export default function Render(props) {
<div className={Style.title}>{name}</div>
<Space>
<Button onClick={() => {
gotoPreview(content, data.name);
gotoPreview(html, data.name);
}} icon={<EyeOutlined />}>
{t('preview')}
</Button>
<Button disabled={!data.oakDirty ||
data.oakExecuting || !execuable} type="primary" onClick={() => {
<Button disabled={oakLoading || oakExecuting || !(name && name.length > 0 && html && html.length > 0 && html !== '<p><br></p>')} type="primary" onClick={() => {
update({
content: html,
});
check();
}}>
{t('save')}

View File

@ -5,7 +5,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
tocPosition: "none" | "left" | "right";
highlightBgColor: string;
onArticlePreview: (content?: string, title?: string) => void;
origin: import("../../../types/Config").CosOrigin | null;
origin: EntityDict["extraFile"]["Schema"]["origin"] | null;
scrollId: string;
height: number | "auto";
activeColor: string | undefined;

View File

@ -91,8 +91,8 @@ export default OakComponent({
async check() {
if (this.state.name &&
this.state.name.length > 0 &&
this.state.content &&
this.state.content.length > 0 &&
this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>') {
await this.execute();
if (this.props.changeIsEdit) {
@ -105,8 +105,8 @@ export default OakComponent({
type: 'warning',
});
}
else if (this.state.content &&
this.state.content.length > 0 &&
else if (this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>') {
this.setMessage({
content: '请填写文章标题!',
@ -114,17 +114,10 @@ export default OakComponent({
});
}
},
async reset() {
// 重置
this.clean();
},
setHtml(html) {
this.setState({
html,
});
if (html && html !== '<p><br></p>' && this.state.oakFullpath) {
this.update({ content: html });
}
},
gotoPreview(content, title) {
const { onArticlePreview } = this.props;

View File

@ -18,6 +18,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'article', f
tocHeight?: number | string;
height?: number | string;
activeColor?: string;
html: string;
}, {
setHtml: (content: string) => void;
setEditor: (editor: any) => void;

View File

@ -31,7 +31,7 @@ function customCheckImageFn(src, alt, url) {
export default function Render(props) {
const { methods, data } = props;
const { t, setEditor, check, uploadFile, update, setHtml, gotoPreview, clearContentTip, } = methods;
const { oakId, oakFullpath, id, content, editor, origin, tocPosition = 'none', highlightBgColor, activeColor, scrollId, tocWidth, tocHeight, height = 600 } = data;
const { oakId, oakFullpath, id, content, editor, origin, tocPosition = 'none', highlightBgColor, activeColor, scrollId, tocWidth, tocHeight, height = 600, html, oakLoading, oakExecuting, } = data;
const [articleId, setArticleId] = useState('');
const [toc, setToc] = useState([]);
const [showToc, setShowToc] = useState(false);
@ -154,14 +154,16 @@ export default function Render(props) {
</div>
<div className={Style.footer}>
<Space>
<Button disabled={!data.oakDirty ||
data.oakExecuting} type="primary" onClick={() => {
<Button disabled={oakLoading || oakExecuting || !(data.name && data.name.length > 0 && html && html.length > 0 && html !== '<p><br></p>')} type="primary" onClick={() => {
update({
content: html,
});
check();
}}>
保存
</Button>
<Button onClick={() => {
gotoPreview(content, data.name);
gotoPreview(html, data.name);
}} icon={<EyeOutlined />}>
预览
</Button>

View File

@ -460,5 +460,24 @@ const triggers = [
return 1;
}
},
{
name: 'application创建时为其config附上对应的type',
entity: 'application',
action: 'create',
when: 'before',
fn: async ({ operation }, context, option) => {
const { data } = operation;
assert(!(data instanceof Array));
const { type, config } = data;
const config2 = config || {};
if (!config?.type) {
Object.assign(config2, {
type: type,
});
}
data.config = config2;
return 1;
}
},
];
export default triggers;

View File

@ -462,5 +462,24 @@ const triggers = [
return 1;
}
},
{
name: 'application创建时为其config附上对应的type',
entity: 'application',
action: 'create',
when: 'before',
fn: async ({ operation }, context, option) => {
const { data } = operation;
(0, assert_1.assert)(!(data instanceof Array));
const { type, config } = data;
const config2 = config || {};
if (!config?.type) {
Object.assign(config2, {
type: type,
});
}
data.config = config2;
return 1;
}
},
];
exports.default = triggers;

View File

@ -107,8 +107,8 @@ export default OakComponent({
if (
this.state.name &&
this.state.name.length > 0 &&
this.state.content &&
this.state.content.length > 0 &&
this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>'
) {
const id = this.getId()!;
@ -126,8 +126,8 @@ export default OakComponent({
type: 'warning',
});
} else if (
this.state.content &&
this.state.content.length > 0 &&
this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>'
) {
this.setMessage({
@ -144,9 +144,6 @@ export default OakComponent({
this.setState({
html,
});
if (html && html !== '<p><br></p>' && this.state.oakFullpath) {
this.update({ content: html });
}
},
gotoPreview(content?: string, title?: string) {
const { onArticlePreview } = this.props;

View File

@ -68,6 +68,7 @@ export default function Render(
tocClosed: boolean;
execuable: boolean;
activeColor?: string;
html: string;
},
{
setHtml: (content: string) => void;
@ -110,6 +111,9 @@ export default function Render(
tocClosed = false,
execuable,
activeColor,
html,
oakLoading,
oakExecuting,
} = data;
const [articleId, setArticleId] = useState('');
const [toc, setToc] = useState<TocItem[]>([]);
@ -140,19 +144,19 @@ export default function Render(
<Space>
<Button
onClick={() => {
gotoPreview(content, data.name);
gotoPreview(html, data.name);
}}
icon={<EyeOutlined />}
>
{t('preview')}
</Button>
<Button
disabled={
!data.oakDirty ||
data.oakExecuting || !execuable
}
disabled={oakLoading || oakExecuting || !(name && name.length > 0 && html && html.length > 0 && html !== '<p><br></p>')}
type="primary"
onClick={() => {
update({
content: html,
})
check();
}}
>

View File

@ -100,8 +100,8 @@ export default OakComponent({
if (
this.state.name &&
this.state.name.length > 0 &&
this.state.content &&
this.state.content.length > 0 &&
this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>'
) {
await this.execute();
@ -114,8 +114,8 @@ export default OakComponent({
type: 'warning',
});
} else if (
this.state.content &&
this.state.content.length > 0 &&
this.state.html &&
this.state.html.length > 0 &&
this.state.html !== '<p><br></p>'
) {
this.setMessage({
@ -124,17 +124,10 @@ export default OakComponent({
});
}
},
async reset() {
// 重置
this.clean();
},
setHtml(html: string) {
this.setState({
html,
});
if (html && html !== '<p><br></p>' && this.state.oakFullpath) {
this.update({ content: html });
}
},
gotoPreview(content?: string, title?: string) {
const { onArticlePreview } = this.props;

View File

@ -66,6 +66,7 @@ export default function Render(
tocHeight?: number | string;
height?: number | string;
activeColor?: string;
html: string;
},
{
setHtml: (content: string) => void;
@ -104,7 +105,10 @@ export default function Render(
scrollId,
tocWidth,
tocHeight,
height = 600
height = 600,
html,
oakLoading,
oakExecuting,
} = data;
const [articleId, setArticleId] = useState('');
const [toc, setToc] = useState<TocItem[]>([]);
@ -326,12 +330,12 @@ export default function Render(
<div className={Style.footer}>
<Space>
<Button
disabled={
!data.oakDirty ||
data.oakExecuting
}
disabled={oakLoading || oakExecuting || !(data.name && data.name.length > 0 && html && html.length > 0 && html !== '<p><br></p>')}
type="primary"
onClick={() => {
update({
content: html,
})
check();
}}
>
@ -339,7 +343,7 @@ export default function Render(
</Button>
<Button
onClick={() => {
gotoPreview(content, data.name);
gotoPreview(html, data.name);
}}
icon={<EyeOutlined />}
>

View File

@ -464,7 +464,25 @@ const triggers: Trigger<EntityDict, 'application', BRC<EntityDict>>[] = [
return 1;
}
} as CreateTrigger<EntityDict, 'application', BRC<EntityDict>>,
{
name: 'application创建时为其config附上对应的type',
entity: 'application',
action: 'create',
when: 'before',
fn: async ({ operation }, context, option) => {
const { data } = operation;
assert(!(data instanceof Array));
const { type, config } = data;
const config2 = config || {};
if (!config?.type) {
Object.assign(config2, {
type: type,
});
}
data.config = (config2 as EntityDict['application']['Schema']['config']);
return 1;
}
} as CreateTrigger<EntityDict, 'application', BRC<EntityDict>>,
];