mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-10 22:19:23 +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);
|
||||
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();
|
||||
|
@ -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>
|
||||
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user