mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: 获取目录树出错增加错误提示
This commit is contained in:
@@ -17,6 +17,7 @@ import * as api from '@fe/support/api'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
import { getThemeName, setTheme } from '@fe/services/theme'
|
||||
import { fetchSettings, getSchema, writeSettings } from '@fe/services/setting'
|
||||
import { refreshRepo } from '@fe/services/tree'
|
||||
|
||||
JSONEditor.defaults.language = 'zh'
|
||||
JSONEditor.defaults.languages.zh = { ...JSONEditor.defaults.languages.en }
|
||||
@@ -99,7 +100,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
await writeSettings({ ...value })
|
||||
store.dispatch('fetchRepositories')
|
||||
refreshRepo()
|
||||
}
|
||||
emit('close')
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export default {
|
||||
})
|
||||
|
||||
whenEditorReady().then(initRepo)
|
||||
store.dispatch('fetchRepositories')
|
||||
ctx.tree.refreshRepo()
|
||||
|
||||
store.watch(() => store.state.repositories, ctx.statusBar.refreshMenu)
|
||||
store.watch(() => store.state.currentRepo, ctx.statusBar.refreshMenu)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import type { Ref } from 'vue'
|
||||
import type { Components } from '@fe/types'
|
||||
import { registerAction } from '@fe/core/action'
|
||||
import store from '@fe/support/store'
|
||||
import { registerAction } from '../core/action'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
import * as api from '@fe/support/api'
|
||||
|
||||
export type MenuItem = Components.ContextMenu.Item
|
||||
export type VueCtx = { localMarked: Ref<boolean | null> }
|
||||
@@ -36,16 +38,33 @@ export function getContextMenuItems (node: Components.Tree.Node, vueCtx: VueCtx)
|
||||
/**
|
||||
* 刷新目录树
|
||||
*/
|
||||
export function refreshTree () {
|
||||
store.dispatch('fetchTree')
|
||||
export async function refreshTree () {
|
||||
const repo = store.state.currentRepo
|
||||
if (!repo) {
|
||||
console.warn('未选择仓库')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const tree = await api.fetchTree(repo.name)
|
||||
store.commit('setTree', tree)
|
||||
} catch (error: any) {
|
||||
useToast().show('warning', error.message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新仓库
|
||||
*/
|
||||
export function refreshRepo () {
|
||||
export async function refreshRepo () {
|
||||
refreshTree()
|
||||
store.dispatch('fetchRepositories')
|
||||
|
||||
try {
|
||||
const repos = await api.fetchRepositories()
|
||||
store.commit('setRepositories', repos)
|
||||
} catch (error: any) {
|
||||
useToast().show('warning', error.message)
|
||||
}
|
||||
}
|
||||
|
||||
registerAction({ name: 'tree.refresh', handler: refreshTree })
|
||||
|
||||
@@ -110,19 +110,5 @@ export default createStore({
|
||||
const files = await api.fetchMarkedFiles()
|
||||
commit('setMarkedFiles', files)
|
||||
},
|
||||
async fetchRepositories ({ commit }) {
|
||||
const repos = await api.fetchRepositories()
|
||||
commit('setRepositories', repos)
|
||||
},
|
||||
async fetchTree ({ commit, state }) {
|
||||
const repo = state.currentRepo
|
||||
if (!repo) {
|
||||
console.warn('未选择仓库')
|
||||
return
|
||||
}
|
||||
|
||||
const tree = await api.fetchTree(repo.name)
|
||||
commit('setTree', tree)
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user