Commit efe8b728 authored by gxkai's avatar gxkai

fix: 目录树与页签联动

parent 28600f7d
......@@ -121,13 +121,12 @@ class FileManager extends Plugin {
* @param {string} path path of the directory or file
* @returns {boolean} true if the path exists
*/
exists (path) {
async exists (path) {
try {
path = this.normalize(path)
path = this.limitPluginScope(path)
const provider = this.fileProviderOf(path)
const result = provider.exists(path)
const result = await provider.exists(path)
return result
} catch (e) {
throw new Error(e)
......@@ -301,7 +300,6 @@ class FileManager extends Plugin {
const isFile = await this.isFile(oldPath)
const newPathExists = await this.exists(newPath)
const provider = this.fileProviderOf(oldPath)
if (isFile) {
if (newPathExists) {
modalDialogCustom.alert('File already exists.')
......
......@@ -171,30 +171,6 @@ export class TabProxy extends Plugin {
this.tabsApi.activateTab('')
}
switchNextTab () {
const active = this.tabsApi.active()
if (active && this._handlers[active]) {
const handlers = Object.keys(this._handlers)
let i = handlers.indexOf(active)
if (i >= 0) {
i = handlers[i + 1] ? i + 1 : 0
this.switchTab(handlers[i])
}
}
}
switchPreviousTab () {
const active = this.tabsApi.active()
if (active && this._handlers[active]) {
const handlers = Object.keys(this._handlers)
let i = handlers.indexOf(active)
if (i >= 0) {
i = handlers[i - 1] ? i - 1 : handlers.length - 1
this.switchTab(handlers[i])
}
}
}
switchToActiveTab () {
const active = this.tabsApi.active()
if (active && this._handlers[active]) {
......@@ -217,56 +193,62 @@ export class TabProxy extends Plugin {
addTab (name, title, switchTo, close, icon) {
if (this._handlers[name]) return this.renderComponent()
var slash = name.split('/')
const tabPath = slash.reverse()
const tempTitle = []
if (!title) {
for (let i = 0; i < tabPath.length; i++) {
tempTitle.push(tabPath[i])
const formatPath = [...tempTitle].reverse()
const index = this.loadedTabs.findIndex(({ title }) => title === formatPath.join('/'))
if (index === -1) {
title = formatPath.join('/')
const titleLength = formatPath.length
this.loadedTabs.push({
id: name,
name,
title,
icon,
tooltip: name,
iconClass: helper.getPathIcon(name)
})
formatPath.shift()
if (formatPath.length > 0) {
const duplicateTabName = this.loadedTabs.find(({ title }) => title === formatPath.join('/')).name
const duplicateTabPath = duplicateTabName.split('/')
const duplicateTabFormatPath = [...duplicateTabPath].reverse()
const duplicateTabTitle = duplicateTabFormatPath.slice(0, titleLength).reverse().join('/')
this.loadedTabs.push({
id: duplicateTabName,
name: duplicateTabName,
title: duplicateTabTitle,
icon,
tooltip: duplicateTabName,
iconClass: helper.getPathIcon(duplicateTabName)
})
}
break
}
}
} else {
this.loadedTabs.push({
id: name,
name,
title,
icon,
tooltip: name,
iconClass: helper.getPathIcon(name)
})
}
// var slash = name.split('/')
// const tabPath = slash.reverse()
// const tempTitle = []
// if (!title) {
// for (let i = 0; i < tabPath.length; i++) {
// tempTitle.push(tabPath[i])
// const formatPath = [...tempTitle].reverse()
// const index = this.loadedTabs.findIndex(({ title }) => title === formatPath.join('/'))
//
// if (index === -1) {
// title = formatPath.join('/')
// const titleLength = formatPath.length
// this.loadedTabs.push({
// id: name,
// name,
// title,
// icon,
// tooltip: name,
// iconClass: helper.getPathIcon(name)
// })
// formatPath.shift()
// if (formatPath.length > 0) {
// const duplicateTabName = this.loadedTabs.find(({ title }) => title === formatPath.join('/')).name
// const duplicateTabPath = duplicateTabName.split('/')
// const duplicateTabFormatPath = [...duplicateTabPath].reverse()
// const duplicateTabTitle = duplicateTabFormatPath.slice(0, titleLength).reverse().join('/')
// this.loadedTabs.push({
// id: duplicateTabName,
// name: duplicateTabName,
// title: duplicateTabTitle,
// icon,
// tooltip: duplicateTabName,
// iconClass: helper.getPathIcon(duplicateTabName)
// })
// }
// break
// }
// }
// } else {
// this.loadedTabs.push({
// id: name,
// name,
// title,
// icon,
// tooltip: name,
// iconClass: helper.getPathIcon(name)
// })
// }
this.loadedTabs.push({
id: name,
name,
title: name.split('/').reverse()[0],
icon,
tooltip: name,
iconClass: helper.getPathIcon(name)
})
this.renderComponent()
this.updateImgStyles()
......@@ -274,16 +256,16 @@ export class TabProxy extends Plugin {
}
removeTab (name) {
delete this._handlers[name]
const i = this.loadedTabs.findIndex(tab => tab.name === name)
if (name === this.tabsApi.active()) {
if (i > 0) {
this.switchPreviousTab()
this.switchTab(this.loadedTabs[i - 1].name)
} else if (i === 0 && this.loadedTabs.length > 1) {
this.switchNextTab()
this.switchTab(this.loadedTabs[i + 1].name)
} else {
this.clearTab()
}
delete this._handlers[name]
} else {
this.switchToActiveTab()
}
......
.remix-ui-tabs {
display: -webkit-box;
max-height: 42px
display: -webkit-box;
max-height: 42px;
display:flex;
}
.remix-ui-tabs li {
display: inline-block;
......@@ -44,7 +45,8 @@
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
max-width: 1000px;
flex: 1;
/*max-width: 1000px;*/
}
.left-icon {
width: 70px;
......@@ -55,7 +57,7 @@
.tab-scroll::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.tab-scroll {
-ms-overflow-style: none; /* IE and Edge */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment