[Fix] Fix the missing name entry. (#14)

diff --git a/studio/components/files/index.tsx b/studio/components/files/index.tsx
index 5bbf3c1..f9ded12 100644
--- a/studio/components/files/index.tsx
+++ b/studio/components/files/index.tsx
@@ -26,6 +26,7 @@
 } from 'vue'
 import { NTree, NInput, NDropdown } from 'naive-ui'
 import { FILE_TYPES_SUFFIX } from '@/constants/file'
+import { getNameByType } from '@/utils/file'
 import { useLocale } from '@/hooks'
 import styles from './index.module.scss'
 import type { IFileRecord, TreeOption } from '@/types/file'
@@ -73,11 +74,7 @@
     const renderLabel = (info: { option: TreeOption }): VNodeChild => {
       const { isEditing, name, type, id } = info.option as IFileRecord
       return !isEditing
-        ? h(
-            'div',
-            { 'data-id': id },
-            `${name}${type ? '.' + FILE_TYPES_SUFFIX[type] : ''}`
-          )
+        ? h('div', { 'data-id': id }, type ? getNameByType(type, name) : '')
         : h(
             NInput,
             {
diff --git a/studio/components/studio-sider/use-file.ts b/studio/components/studio-sider/use-file.ts
index ca3b6c3..a585387 100644
--- a/studio/components/studio-sider/use-file.ts
+++ b/studio/components/studio-sider/use-file.ts
@@ -20,6 +20,8 @@
 import { useLocale } from '@/hooks'
 import { remove } from 'lodash'
 import { sameNameValidator } from './helper'
+import { useFileStore } from '@/store/file'
+import { getNameByType } from '@/utils/file'
 import type { IFileState, FileType, IFileRecord } from './types'
 
 export const useFile = (inputRef: Ref, fileRef: Ref) => {
@@ -31,10 +33,9 @@
 
   const message = useMessage()
   const { t } = useLocale()
+  const fileStore = useFileStore()
 
-  const filesCached = {
-    1: { type: '', id: 1, name: '123', pid: 0, children: [] }
-  } as { [key: number]: IFileRecord }
+  const filesCached = {} as { [key: number]: IFileRecord }
 
   const refreshFiles = () => {
     fileRef.value.refresh()
@@ -49,6 +50,15 @@
   const pullFiles = async () => {
     const files = await getFiles()
     state.files = files
+
+    const loop = (list: IFileRecord[]) => {
+      list.forEach((file) => {
+        filesCached[file.id] = file
+        if (file.type) delete file.children
+        if (file.children) loop(file.children)
+      })
+    }
+    loop(files)
   }
 
   const create = async (isFile: boolean, type: FileType | '') => {
@@ -80,15 +90,25 @@
     inputRef.value?.focus()
   }
 
-  const save = async () => {
+  const save = async (name: string) => {
     const currentRecord = filesCached[state.currentKey]
     try {
       const { id } = await addFile(currentRecord.pid, {
         type: currentRecord.type || '',
-        name: currentRecord.name
+        name
       })
       message.success(t('saved_successfully'))
       currentRecord.id = id
+      state.currentKey = id
+      delete filesCached[state.currentKey]
+      filesCached[id] = currentRecord
+      if (currentRecord.type) {
+        fileStore.openFile({
+          id,
+          name: getNameByType(currentRecord.type, name),
+          content: ''
+        })
+      }
       return true
     } catch (err) {
       return false
@@ -110,7 +130,6 @@
       refreshFiles()
       return
     }
-
     const pid = filesCached[state.currentKey].pid
     const isSame = sameNameValidator(
       value,
@@ -121,7 +140,7 @@
       return
     }
 
-    const result = await save()
+    const result = await save(value)
     if (result) {
       filesCached[state.currentKey].isEditing = false
       filesCached[state.currentKey].name = value
diff --git a/studio/utils/file.ts b/studio/utils/file.ts
new file mode 100644
index 0000000..a90e0c1
--- /dev/null
+++ b/studio/utils/file.ts
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FILE_TYPES_SUFFIX } from '@/constants/file'
+import type { FileType } from '../types/file'
+
+export function getNameByType(type: FileType, name: string) {
+  return `${name}${type ? '.' + FILE_TYPES_SUFFIX[type] : ''}`
+}