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

View File

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

View File

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