Commit efe8b728 authored by gxkai's avatar gxkai

fix: 目录树与页签联动

parent 28600f7d
...@@ -121,13 +121,12 @@ class FileManager extends Plugin { ...@@ -121,13 +121,12 @@ class FileManager extends Plugin {
* @param {string} path path of the directory or file * @param {string} path path of the directory or file
* @returns {boolean} true if the path exists * @returns {boolean} true if the path exists
*/ */
exists (path) { async exists (path) {
try { try {
path = this.normalize(path) path = this.normalize(path)
path = this.limitPluginScope(path) path = this.limitPluginScope(path)
const provider = this.fileProviderOf(path) const provider = this.fileProviderOf(path)
const result = provider.exists(path) const result = await provider.exists(path)
return result return result
} catch (e) { } catch (e) {
throw new Error(e) throw new Error(e)
...@@ -301,7 +300,6 @@ class FileManager extends Plugin { ...@@ -301,7 +300,6 @@ class FileManager extends Plugin {
const isFile = await this.isFile(oldPath) const isFile = await this.isFile(oldPath)
const newPathExists = await this.exists(newPath) const newPathExists = await this.exists(newPath)
const provider = this.fileProviderOf(oldPath) const provider = this.fileProviderOf(oldPath)
if (isFile) { if (isFile) {
if (newPathExists) { if (newPathExists) {
modalDialogCustom.alert('File already exists.') modalDialogCustom.alert('File already exists.')
......
...@@ -171,30 +171,6 @@ export class TabProxy extends Plugin { ...@@ -171,30 +171,6 @@ export class TabProxy extends Plugin {
this.tabsApi.activateTab('') 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 () { switchToActiveTab () {
const active = this.tabsApi.active() const active = this.tabsApi.active()
if (active && this._handlers[active]) { if (active && this._handlers[active]) {
...@@ -217,56 +193,62 @@ export class TabProxy extends Plugin { ...@@ -217,56 +193,62 @@ export class TabProxy extends Plugin {
addTab (name, title, switchTo, close, icon) { addTab (name, title, switchTo, close, icon) {
if (this._handlers[name]) return this.renderComponent() if (this._handlers[name]) return this.renderComponent()
var slash = name.split('/') // var slash = name.split('/')
const tabPath = slash.reverse() // const tabPath = slash.reverse()
const tempTitle = [] // const tempTitle = []
// if (!title) {
if (!title) { // for (let i = 0; i < tabPath.length; i++) {
for (let i = 0; i < tabPath.length; i++) { // tempTitle.push(tabPath[i])
tempTitle.push(tabPath[i]) // const formatPath = [...tempTitle].reverse()
const formatPath = [...tempTitle].reverse() // const index = this.loadedTabs.findIndex(({ title }) => title === formatPath.join('/'))
const index = this.loadedTabs.findIndex(({ title }) => title === formatPath.join('/')) //
// if (index === -1) {
if (index === -1) { // title = formatPath.join('/')
title = formatPath.join('/') // const titleLength = formatPath.length
const titleLength = formatPath.length // this.loadedTabs.push({
this.loadedTabs.push({ // id: name,
id: name, // name,
name, // title,
title, // icon,
icon, // tooltip: name,
tooltip: name, // iconClass: helper.getPathIcon(name)
iconClass: helper.getPathIcon(name) // })
}) // formatPath.shift()
formatPath.shift() // if (formatPath.length > 0) {
if (formatPath.length > 0) { // const duplicateTabName = this.loadedTabs.find(({ title }) => title === formatPath.join('/')).name
const duplicateTabName = this.loadedTabs.find(({ title }) => title === formatPath.join('/')).name // const duplicateTabPath = duplicateTabName.split('/')
const duplicateTabPath = duplicateTabName.split('/') // const duplicateTabFormatPath = [...duplicateTabPath].reverse()
const duplicateTabFormatPath = [...duplicateTabPath].reverse() // const duplicateTabTitle = duplicateTabFormatPath.slice(0, titleLength).reverse().join('/')
const duplicateTabTitle = duplicateTabFormatPath.slice(0, titleLength).reverse().join('/') // this.loadedTabs.push({
// id: duplicateTabName,
this.loadedTabs.push({ // name: duplicateTabName,
id: duplicateTabName, // title: duplicateTabTitle,
name: duplicateTabName, // icon,
title: duplicateTabTitle, // tooltip: duplicateTabName,
icon, // iconClass: helper.getPathIcon(duplicateTabName)
tooltip: duplicateTabName, // })
iconClass: helper.getPathIcon(duplicateTabName) // }
}) // break
} // }
break // }
} // } else {
} // this.loadedTabs.push({
} else { // id: name,
// name,
// title,
// icon,
// tooltip: name,
// iconClass: helper.getPathIcon(name)
// })
// }
this.loadedTabs.push({ this.loadedTabs.push({
id: name, id: name,
name, name,
title, title: name.split('/').reverse()[0],
icon, icon,
tooltip: name, tooltip: name,
iconClass: helper.getPathIcon(name) iconClass: helper.getPathIcon(name)
}) })
}
this.renderComponent() this.renderComponent()
this.updateImgStyles() this.updateImgStyles()
...@@ -274,16 +256,16 @@ export class TabProxy extends Plugin { ...@@ -274,16 +256,16 @@ export class TabProxy extends Plugin {
} }
removeTab (name) { removeTab (name) {
delete this._handlers[name]
const i = this.loadedTabs.findIndex(tab => tab.name === name) const i = this.loadedTabs.findIndex(tab => tab.name === name)
if (name === this.tabsApi.active()) { if (name === this.tabsApi.active()) {
if (i > 0) { if (i > 0) {
this.switchPreviousTab() this.switchTab(this.loadedTabs[i - 1].name)
} else if (i === 0 && this.loadedTabs.length > 1) { } else if (i === 0 && this.loadedTabs.length > 1) {
this.switchNextTab() this.switchTab(this.loadedTabs[i + 1].name)
} else { } else {
this.clearTab() this.clearTab()
} }
delete this._handlers[name]
} else { } else {
this.switchToActiveTab() this.switchToActiveTab()
} }
......
.remix-ui-tabs { .remix-ui-tabs {
display: -webkit-box; display: -webkit-box;
max-height: 42px max-height: 42px;
display:flex;
} }
.remix-ui-tabs li { .remix-ui-tabs li {
display: inline-block; display: inline-block;
...@@ -44,7 +45,8 @@ ...@@ -44,7 +45,8 @@
overflow-x: auto; overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
white-space: nowrap; white-space: nowrap;
max-width: 1000px; flex: 1;
/*max-width: 1000px;*/
} }
.left-icon { .left-icon {
width: 70px; width: 70px;
......
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