mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-14 17:06:03 +08:00
refactor(editor): 补全ts类型
This commit is contained in:
parent
8271a3b497
commit
bc4b62a4c1
@ -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();
|
||||||
|
@ -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>
|
||||||
|
@ -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) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user