fix: 💄 add icon
This commit is contained in:
parent
d0e8f9efe0
commit
68614fc9bd
13
src/init.ts
13
src/init.ts
@ -1,4 +1,5 @@
|
||||
import {
|
||||
DefaultType,
|
||||
FileAction,
|
||||
FileType,
|
||||
Node,
|
||||
@ -7,27 +8,24 @@ import {
|
||||
} from '@nextcloud/files'
|
||||
import cores from './mime.json'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import icon from '../img/app.svg?raw'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
|
||||
const getCore = (file: Node) => {
|
||||
if (
|
||||
!file.fileid ||
|
||||
file.type !== FileType.File ||
|
||||
!(file.permissions & Permission.READ)
|
||||
)
|
||||
return false
|
||||
if (file.type === FileType.File && file.permissions & Permission.READ) {
|
||||
const extension = file.extension?.substring(1)
|
||||
for (const core in cores) {
|
||||
if (cores[core].types.includes(file.mime)) return core
|
||||
if (cores[core].extensions.includes(extension)) return core
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const action = new FileAction({
|
||||
id: 'retro',
|
||||
displayName: () => t('repod', 'Play'),
|
||||
iconSvgInline: () => '',
|
||||
iconSvgInline: () => icon,
|
||||
enabled: (files: Node[]) => {
|
||||
if (files.length !== 1) return false
|
||||
return !!getCore(files[0])
|
||||
@ -39,6 +37,7 @@ const action = new FileAction({
|
||||
})
|
||||
return true
|
||||
},
|
||||
default: DefaultType.DEFAULT,
|
||||
})
|
||||
|
||||
registerFileAction(action)
|
||||
|
@ -10,5 +10,6 @@
|
||||
"rootDir": ".",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"types": ["vite/client"],
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user