refactor(editor): 补全ts类型

This commit is contained in:
parisma 2022-11-17 11:48:19 +08:00
parent 8271a3b497
commit bc4b62a4c1
3 changed files with 12 additions and 12 deletions

View File

@ -112,7 +112,7 @@ const saveAndClose = (): void => {
};
//
const close = async () => {
const close = async (): Promise<void> => {
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
if (codeDraft) {
tMagicMessageBox
@ -136,7 +136,7 @@ const close = async () => {
};
//
const toggleFullScreen = () => {
const toggleFullScreen = (): void => {
isFullScreen.value = !isFullScreen.value;
if (codeEditor.value) {
codeEditor.value.focus();

View File

@ -90,7 +90,7 @@ watchEffect(() => {
codeContent.value = props.content;
});
const initTableModel = () => {
const initTableModel = (): void => {
const codeDsl = services?.codeBlockService.getCodeDslSync();
if (!codeDsl) return;
tableModel.value = {
@ -131,7 +131,7 @@ const saveCode = async (codeValue: string): Promise<void> => {
};
//
const saveAndClose = async (codeValue: string) => {
const saveAndClose = async (codeValue: string): Promise<void> => {
await saveCode(codeValue);
if (evalRes.value) {
close();
@ -139,7 +139,7 @@ const saveAndClose = async (codeValue: string) => {
};
//
const close = () => {
const close = (): void => {
services?.codeBlockService.setCodeEditorShowStatus(false);
};
</script>

View File

@ -173,7 +173,7 @@ class CodeBlock extends BaseService {
*
* @returns {CodeBlockContent | null}
*/
public async getCurrentDsl() {
public async getCurrentDsl(): Promise<CodeBlockContent | null> {
return await this.getCodeContentById(this.state.id);
}
@ -199,7 +199,7 @@ class CodeBlock extends BaseService {
* @param {Id} id id
* @returns {void}
*/
public setId(id: Id) {
public setId(id: Id): void {
if (!id) return;
this.state.id = id;
}
@ -248,7 +248,7 @@ class CodeBlock extends BaseService {
/**
*
* @returns {void}
* @returns {CodeRelation | null}
*/
public refreshCombineInfo(): CodeRelation | null {
const root = editorService.get<MApp | null>('root');
@ -335,14 +335,14 @@ class CodeBlock extends BaseService {
* @param {MNode} compId
* @returns void
*/
public async deleteCompsInRelation(node: MNode) {
public async deleteCompsInRelation(node: MNode): Promise<void> {
const codeDsl = cloneDeep(await this.getCodeDsl());
if (!codeDsl) return;
this.refreshRelationDeep(node, codeDsl);
this.setCodeDsl(codeDsl);
}
public destroy() {
public destroy(): void {
this.state.isShowCodeEditor = false;
this.state.codeDsl = null;
this.state.id = '';
@ -358,7 +358,7 @@ class CodeBlock extends BaseService {
* @param {CodeBlockDSL} codeDsl
* @returns void
*/
private refreshRelationDeep(node: MNode, codeDsl: CodeBlockDSL) {
private refreshRelationDeep(node: MNode, codeDsl: CodeBlockDSL): void {
if (!node.id) return;
forIn(codeDsl, (codeBlockContent) => {
const compsContent = codeBlockContent.comps || {};
@ -376,7 +376,7 @@ class CodeBlock extends BaseService {
* @param {MContainer} node
* @returns void
*/
private recurseMNode(node: MNode, relations: CodeRelation) {
private recurseMNode(node: MNode, relations: CodeRelation): void {
forIn(node, (value, key) => {
if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
value.hookData.forEach((relationItem: HookData) => {