fix: 修复截图中心菜单/编辑不可用与导航项缺中文
Axolotl desktop CI / guardrails (push) Has been cancelled
Axolotl desktop CI / desktop (macos-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (ubuntu-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (windows-latest) (push) Has been cancelled
Axolotl desktop CI / website (push) Has been cancelled
Repository checks / typos (push) Has been cancelled
Repository checks / tombi (push) Has been cancelled
Rust checks / shear (push) Has been cancelled
Sync source to CNB / Sync Git ref (push) Has been cancelled
Axolotl desktop CI / guardrails (push) Has been cancelled
Axolotl desktop CI / desktop (macos-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (ubuntu-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (windows-latest) (push) Has been cancelled
Axolotl desktop CI / website (push) Has been cancelled
Repository checks / typos (push) Has been cancelled
Repository checks / tombi (push) Has been cancelled
Rust checks / shear (push) Has been cancelled
Sync source to CNB / Sync Git ref (push) Has been cancelled
This commit is contained in:
1 parent
b310018c38
commit
1b487da5c2
5 files changed
+71
-40
No files matched your search
@@ -21,7 +21,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Button,
|
Button,
|
||||||
type ButtonMenuOption,
|
|
||||||
type ComboboxOption,
|
type ComboboxOption,
|
||||||
commonMessages,
|
commonMessages,
|
||||||
ConfirmModal,
|
ConfirmModal,
|
||||||
@@ -1038,7 +1037,6 @@ function activateScreenshot(screenshot: InstanceScreenshot, event: MouseEvent |
|
|||||||
(candidate) => getSelectionKey(candidate) === getSelectionKey(screenshot),
|
(candidate) => getSelectionKey(candidate) === getSelectionKey(screenshot),
|
||||||
)
|
)
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
screenshotOptionsMenu.value?.close()
|
|
||||||
imageViewer.value?.show(index)
|
imageViewer.value?.show(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1055,44 +1053,34 @@ function requestDelete(screenshot: InstanceScreenshot, fromPreview = false) {
|
|||||||
|
|
||||||
function showScreenshotOptions(screenshot: InstanceScreenshot, event: MouseEvent) {
|
function showScreenshotOptions(screenshot: InstanceScreenshot, event: MouseEvent) {
|
||||||
screenshotOptionsTarget.value = screenshot
|
screenshotOptionsTarget.value = screenshot
|
||||||
const options: ButtonMenuOption[] = [
|
const options = [
|
||||||
...(event.type === 'contextmenu'
|
...(event.type === 'contextmenu' ? [{ name: 'edit' }, { name: 'copy' }] : []),
|
||||||
? [
|
{ name: 'open' },
|
||||||
{
|
{ name: 'go-to-instance' },
|
||||||
id: 'edit',
|
|
||||||
label: formatMessage(messages.edit),
|
|
||||||
icon: EditIcon,
|
|
||||||
action: () => editScreenshot(screenshot),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'copy',
|
|
||||||
label: formatMessage(messages.copy),
|
|
||||||
icon: ClipboardCopyIcon,
|
|
||||||
action: () => void copyScreenshot(screenshot),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{
|
|
||||||
id: 'open',
|
|
||||||
label: formatMessage(messages.showInFolder),
|
|
||||||
icon: FolderOpenIcon,
|
|
||||||
action: () => void openScreenshot(screenshot),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'go-to-instance',
|
|
||||||
label: formatMessage(messages.goToInstance),
|
|
||||||
action: () => void goToInstance(screenshot),
|
|
||||||
},
|
|
||||||
{ type: 'divider' },
|
{ type: 'divider' },
|
||||||
{
|
{ name: 'delete', color: 'danger' },
|
||||||
id: 'delete',
|
|
||||||
label: formatMessage(commonMessages.deleteLabel),
|
|
||||||
icon: TrashIcon,
|
|
||||||
tone: 'red',
|
|
||||||
action: () => requestDelete(screenshot),
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
screenshotOptionsMenu.value?.open(event, options)
|
screenshotOptionsMenu.value?.showMenu(event, screenshot, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleScreenshotOptionClicked({ item, option }: { item: InstanceScreenshot; option: string }) {
|
||||||
|
switch (option) {
|
||||||
|
case 'edit':
|
||||||
|
editScreenshot(item)
|
||||||
|
break
|
||||||
|
case 'copy':
|
||||||
|
void copyScreenshot(item)
|
||||||
|
break
|
||||||
|
case 'open':
|
||||||
|
void openScreenshot(item)
|
||||||
|
break
|
||||||
|
case 'go-to-instance':
|
||||||
|
void goToInstance(item)
|
||||||
|
break
|
||||||
|
case 'delete':
|
||||||
|
requestDelete(item)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToInstance(screenshot: InstanceScreenshot) {
|
function goToInstance(screenshot: InstanceScreenshot) {
|
||||||
@@ -1128,7 +1116,6 @@ function editScreenshot(screenshot: InstanceScreenshot) {
|
|||||||
(candidate) => getSelectionKey(candidate) === getSelectionKey(screenshot),
|
(candidate) => getSelectionKey(candidate) === getSelectionKey(screenshot),
|
||||||
)
|
)
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
screenshotOptionsMenu.value?.close()
|
|
||||||
void imageViewer.value?.edit(index)
|
void imageViewer.value?.edit(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1426,7 +1413,23 @@ onBeforeUnmount(() => {
|
|||||||
:markdown="false"
|
:markdown="false"
|
||||||
@proceed="deleteCustomGroup"
|
@proceed="deleteCustomGroup"
|
||||||
/>
|
/>
|
||||||
<ContextMenu ref="screenshotOptionsMenu" :label="formatMessage(commonMessages.actionsLabel)">
|
<ContextMenu
|
||||||
|
ref="screenshotOptionsMenu"
|
||||||
|
:label="formatMessage(commonMessages.actionsLabel)"
|
||||||
|
@option-clicked="handleScreenshotOptionClicked"
|
||||||
|
>
|
||||||
|
<template #edit>
|
||||||
|
<EditIcon />
|
||||||
|
{{ formatMessage(messages.edit) }}
|
||||||
|
</template>
|
||||||
|
<template #copy>
|
||||||
|
<ClipboardCopyIcon />
|
||||||
|
{{ formatMessage(messages.copy) }}
|
||||||
|
</template>
|
||||||
|
<template #open>
|
||||||
|
<FolderOpenIcon />
|
||||||
|
{{ formatMessage(messages.showInFolder) }}
|
||||||
|
</template>
|
||||||
<template #go-to-instance>
|
<template #go-to-instance>
|
||||||
<Avatar
|
<Avatar
|
||||||
:src="getInstanceIconUrl(screenshotOptionsInstance?.icon_path)"
|
:src="getInstanceIconUrl(screenshotOptionsInstance?.icon_path)"
|
||||||
@@ -1437,6 +1440,10 @@ onBeforeUnmount(() => {
|
|||||||
/>
|
/>
|
||||||
{{ formatMessage(messages.goToInstance) }}
|
{{ formatMessage(messages.goToInstance) }}
|
||||||
</template>
|
</template>
|
||||||
|
<template #delete>
|
||||||
|
<TrashIcon />
|
||||||
|
{{ formatMessage(commonMessages.deleteLabel) }}
|
||||||
|
</template>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
<ImageViewerEditor
|
<ImageViewerEditor
|
||||||
ref="imageViewer"
|
ref="imageViewer"
|
||||||
|
|||||||
@@ -9922,5 +9922,8 @@
|
|||||||
},
|
},
|
||||||
"unknown-pack-warning-modal.warning.title": {
|
"unknown-pack-warning-modal.warning.title": {
|
||||||
"message": "Unknown file warning"
|
"message": "Unknown file warning"
|
||||||
|
},
|
||||||
|
"app.navigation.screenshots": {
|
||||||
|
"message": "Screenshots"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10680,5 +10680,8 @@
|
|||||||
},
|
},
|
||||||
"app.starlight-skin.frame-title": {
|
"app.starlight-skin.frame-title": {
|
||||||
"message": "StarLight 皮肤站"
|
"message": "StarLight 皮肤站"
|
||||||
|
},
|
||||||
|
"app.navigation.screenshots": {
|
||||||
|
"message": "截图"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import type { AbstractPopupNotificationManager, AbstractWebNotificationManager }
|
|||||||
import { setupCreationModal } from './setup/creation-modal'
|
import { setupCreationModal } from './setup/creation-modal'
|
||||||
import { setupFileDropProvider } from './setup/file-drop'
|
import { setupFileDropProvider } from './setup/file-drop'
|
||||||
import { setupFilePickerProvider } from './setup/file-picker'
|
import { setupFilePickerProvider } from './setup/file-picker'
|
||||||
|
import { setupImageViewerEditorProvider } from './setup/image-viewer-editor'
|
||||||
import { setupInstanceImportProvider } from './setup/instance-import'
|
import { setupInstanceImportProvider } from './setup/instance-import'
|
||||||
import { setupTagsProvider } from './setup/tags'
|
import { setupTagsProvider } from './setup/tags'
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ export function setupProviders(
|
|||||||
setupTagsProvider(notificationManager, stateInitialization)
|
setupTagsProvider(notificationManager, stateInitialization)
|
||||||
const fileDrop = setupFileDropProvider()
|
const fileDrop = setupFileDropProvider()
|
||||||
const filePicker = setupFilePickerProvider()
|
const filePicker = setupFilePickerProvider()
|
||||||
|
setupImageViewerEditorProvider()
|
||||||
setupInstanceImportProvider(notificationManager)
|
setupInstanceImportProvider(notificationManager)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import {
|
||||||
|
type ImageViewerEditorData,
|
||||||
|
type ImageViewerEditorSource,
|
||||||
|
provideImageViewerEditor,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { readFile } from '@tauri-apps/plugin-fs'
|
||||||
|
|
||||||
|
export function setupImageViewerEditorProvider() {
|
||||||
|
provideImageViewerEditor({
|
||||||
|
async loadEditorData(source: ImageViewerEditorSource): Promise<ImageViewerEditorData> {
|
||||||
|
return {
|
||||||
|
source: new Blob([await readFile(source.path)], { type: 'image/png' }),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user