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