Skip to content

Commit

Permalink
#285 [Bug] Doesn't display subfolders in Extra Network tab (Lora)
Browse files Browse the repository at this point in the history
  • Loading branch information
Physton committed Dec 12, 2023
1 parent 9465ea4 commit 0a4f5f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/src/mixins/phystonPrompt/groupTagsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,19 @@ export default {
extraNetwork.items.forEach(item => {
item.dirnameFormat = item.dirname.replaceAll('\\', '/')
})
let dirs = []
let splitArrays = extraNetwork.items.map(item => item.dirnameFormat.split('/'))
let minLength = Math.min(...splitArrays.map(item => item.length))
let prefixPath = common.getSamePrefixPath([...new Set(extraNetwork.items.map(item => item.dirnameFormat))])
let baseDirs = []
extraNetwork.items.forEach(item => {
item.base_dirname = item.dirnameFormat.split('/').slice(minLength).join('/')
dirs.push(item.base_dirname)
let baseDirname = item.dirnameFormat.replace(prefixPath, '')
if (baseDirname === '') baseDirname = '@root'
baseDirname = baseDirname.replace(/^\//, '')
baseDirs.push(baseDirname)
item.base_dirname = baseDirname
})
dirs = [...new Set(dirs)]
dirs = dirs.filter(item => item !== '')
if (dirs.length > 1) {
dirs.forEach(dir => {
baseDirs = [...new Set(baseDirs)]

if (baseDirs.length > 1) {
baseDirs.forEach(dir => {
let subDirGroup = {
color: '',
name: dir,
Expand Down
13 changes: 13 additions & 0 deletions src/src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,4 +632,17 @@ export default {
getTagsColorKey(groupName, subGroupName) {
return groupName + '||' + subGroupName
},

getSamePrefixPath(arr) {
if (arr.length <= 0) return ''
const arr1 = arr.map(item => item.split("/"));
const arr2 = arr1[0];
const arr3 = arr1.slice(1);
const result = arr2.filter((item, index) => {
return arr3.every(item2 => {
return item2[index] === item;
});
});
return result.join("/");
}
}

0 comments on commit 0a4f5f9

Please sign in to comment.