feat:移除了弹窗,服务器添加sls
This commit is contained in:
commit
6a295f9a7a
4082 files changed
+1322534
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import { isResultValue, nextResultCount } from '@/lab/recipe-generator/count-display'
|
||||
import type { RecipeSlot, SlotValue } from '@/lab/recipe-generator/types'
|
||||
|
||||
const messages = defineMessages({
|
||||
scrollToAdjust: {
|
||||
id: 'app.lab.recipe-generator.scroll-to-adjust',
|
||||
defaultMessage: 'Scroll to adjust quantity',
|
||||
},
|
||||
})
|
||||
|
||||
export function useResultCountWheel(options: {
|
||||
getSlot: () => RecipeSlot | null
|
||||
getValue: () => SlotValue | undefined
|
||||
getCount: () => number
|
||||
setCount: (count: number) => void
|
||||
}) {
|
||||
const { formatMessage } = useVIntl()
|
||||
const canAdjust = computed(() => Boolean(options.getSlot() && isResultValue(options.getValue())))
|
||||
const hint = computed(() =>
|
||||
canAdjust.value ? formatMessage(messages.scrollToAdjust) : undefined,
|
||||
)
|
||||
|
||||
function onWheel(slot: RecipeSlot, event: WheelEvent) {
|
||||
if (slot !== options.getSlot()) return
|
||||
const value = options.getValue()
|
||||
if (!isResultValue(value)) return
|
||||
if (event.deltaY === 0) return
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
const current = options.getCount()
|
||||
const next = nextResultCount(current, event.deltaY)
|
||||
if (next !== current) options.setCount(next)
|
||||
}
|
||||
|
||||
return { canAdjust, hint, onWheel }
|
||||
}
|
||||
Reference in new issue
Block a user