张延森 3 jaren geleden
bovenliggende
commit
be22becce7
5 gewijzigde bestanden met toevoegingen van 8 en 76 verwijderingen
  1. 1
    1
      index.html
  2. 0
    4
      src/store/index.js
  3. 0
    19
      src/store/model/menu.js
  4. 7
    1
      src/store/model/note.js
  5. 0
    51
      src/store/model/repo.js

+ 1
- 1
index.html Bestand weergeven

@@ -5,7 +5,7 @@
5 5
     <link rel="icon" href="/favicon.ico" />
6 6
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 7
     <script src="./tinymce/tinymce.min.js"></script>
8
-    <title>Vite App</title>
8
+    <title>MyNote</title>
9 9
   </head>
10 10
   <body>
11 11
     <div id="app"></div>

+ 0
- 4
src/store/index.js Bestand weergeven

@@ -1,13 +1,9 @@
1 1
 import createStore from '@zjxpcyc/vue-tiny-store'
2
-import useRepo from './model/repo'
3 2
 import useUser from './model/user'
4
-import useMenu from './model/menu'
5 3
 import useNote from './model/note'
6 4
 
7 5
 const store = createStore({
8 6
   'user': useUser,
9
-  'repo': useRepo,
10
-  'menu': useMenu,
11 7
   'note': useNote,
12 8
 })
13 9
 

+ 0
- 19
src/store/model/menu.js Bestand weergeven

@@ -1,19 +0,0 @@
1
-import { reactive, ref } from "vue";
2
-import * as gitee from '@/service/gitee'
3
-
4
-export default function useMenu() {
5
-  const menus = reactive([])
6
-  const curMenu = ref()
7
-
8
-  const getMenus = (user, repo = 'my-note') => {
9
-    return gitee.getFiles(user, '', repo).then(res => {
10
-      menus.push(...res)
11
-    })
12
-  }
13
-
14
-  return {
15
-    curMenu,
16
-    menus,
17
-    getMenus,
18
-  }
19
-}

+ 7
- 1
src/store/model/note.js Bestand weergeven

@@ -74,9 +74,15 @@ export default function useNote() {
74 74
   }
75 75
 
76 76
   const newFolder = (user, path, repo = 'my-note') => {
77
-    gitee.newFolder(user, path, repo).then(() => {
77
+    const filePath = `${path}/.gitignore`
78
+    const content = encodeData('#')
79
+    gitee.newFile(user, content, filePath, repo).then(() => {
78 80
       getFiles(user, getParentPath(path), repo)
79 81
     })
82
+
83
+    // gitee.newFolder(user, path, repo).then(() => {
84
+    //   getFiles(user, getParentPath(path), repo)
85
+    // })
80 86
   }
81 87
 
82 88
   const deleteNote = (user, path, repo = 'my-note') => {

+ 0
- 51
src/store/model/repo.js Bestand weergeven

@@ -1,51 +0,0 @@
1
-import { reactive, ref } from "vue";
2
-import * as gitee from '@/service/gitee'
3
-
4
-export default function useRepo() {
5
-  const repo = reactive({})
6
-  const branches = ref([])
7
-  const user = ref()
8
-
9
-  // 获取仓库信息
10
-  const getRepo = (user, repo = 'my-note') => {
11
-    return gitee.getRepo(user, repo).then(res => Object.assign(repo, res))
12
-  }
13
-
14
-  // 新增仓库
15
-  const newRepo = (user, name = 'my-note') => {
16
-    return gitee.newRepo(data).then(res => Object.assign(repo, res))
17
-  }
18
-  
19
-  // 获取所有分支
20
-  const getBranches = (user, repo = 'my-note') => {
21
-    return gitee.getBranches(user, repo).then(res => {
22
-      branches.value = res
23
-      return res;
24
-    })
25
-  }
26
-
27
-  const newBranch = (user, branch_name = 'master', repo = 'my-note') => {
28
-    return gitee.newBranch(user, branch_name, repo).then(res => Object.assign(repo, res))
29
-  }
30
-
31
-  // 新增文件
32
-  const newFile = (content, path, user, repo = 'my-note') => {
33
-    return gitee.newFile(user, content, path, repo)
34
-  }
35
-  
36
-  // 新增目录, 其实就是新增一个 内容是 # 的 .gitignore 文件
37
-  const newFolder = (path, user, repo = 'my-note') => {
38
-    return gitee.newFile(user, path, repo)
39
-  }
40
-
41
-  return {
42
-    repo,
43
-    user,
44
-    getRepo,
45
-    newRepo,
46
-    getBranches,
47
-    newBranch,
48
-    newFile,
49
-    newFolder,
50
-  }
51
-}