Skip to content

Commit f67058c

Browse files
committed
feat(controller): add controller sensitivity setting and integrate into UI
1 parent eb3ebd7 commit f67058c

File tree

7 files changed

+28
-1
lines changed

7 files changed

+28
-1
lines changed

frontend/src/constant/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ export const DefaultTestURL = 'https://www.gstatic.com/generate_204'
109109
export const DefaultConcurrencyLimit = 20
110110

111111
export const DefaultCardColumns = 5
112+
113+
export const DefaultControllerSensitivity = 2

frontend/src/lang/locale/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ export default {
314314
delay: 'Delay test URL',
315315
concurrencyLimit: 'Latency test concurrency',
316316
cardColumns: 'Number of card columns',
317+
sensitivity: 'Controller Scroll Sensitivity',
317318
closeMode: {
318319
name: 'Controller Close Mode',
319320
all: 'Scroll or Button',

frontend/src/lang/locale/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ export default {
313313
delay: '延迟测试URL',
314314
concurrencyLimit: '延迟测试并发数量',
315315
cardColumns: '卡片展示列数',
316+
sensitivity: '控制器滚动灵敏度',
316317
closeMode: {
317318
name: '控制器关闭模式',
318319
all: '滚动和关闭按钮',

frontend/src/stores/appSettings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Colors,
1414
DefaultCardColumns,
1515
DefaultConcurrencyLimit,
16+
DefaultControllerSensitivity,
1617
DefaultFontFamily,
1718
DefaultTestURL,
1819
UserFilePath,
@@ -73,6 +74,7 @@ export const useAppSettingsStore = defineStore('app-settings', () => {
7374
testUrl: DefaultTestURL,
7475
concurrencyLimit: DefaultConcurrencyLimit,
7576
controllerCloseMode: ControllerCloseMode.All,
77+
controllerSensitivity: DefaultControllerSensitivity,
7678
main: undefined as any,
7779
alpha: undefined as any,
7880
},
@@ -103,6 +105,9 @@ export const useAppSettingsStore = defineStore('app-settings', () => {
103105
if (app.value.kernel.controllerCloseMode === undefined) {
104106
app.value.kernel.controllerCloseMode = ControllerCloseMode.All
105107
}
108+
if (app.value.kernel.controllerSensitivity === undefined) {
109+
app.value.kernel.controllerSensitivity = DefaultControllerSensitivity
110+
}
106111
if (app.value.addGroupToMenu === undefined) {
107112
app.value.addGroupToMenu = false
108113
}

frontend/src/types/app.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type AppSettings = {
7474
testUrl: string
7575
concurrencyLimit: number
7676
controllerCloseMode: ControllerCloseMode
77+
controllerSensitivity: number
7778
main: {
7879
env: Recordable
7980
args: string[]

frontend/src/views/HomeView/components/GroupsController.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ControllerCloseModeOptions,
99
DefaultCardColumns,
1010
DefaultConcurrencyLimit,
11+
DefaultControllerSensitivity,
1112
DefaultTestURL,
1213
} from '@/constant/app'
1314
import { ControllerCloseMode } from '@/enums/app'
@@ -209,6 +210,7 @@ const handleResetMoreSettings = () => {
209210
appSettings.app.kernel.testUrl = DefaultTestURL
210211
appSettings.app.kernel.concurrencyLimit = DefaultConcurrencyLimit
211212
appSettings.app.kernel.controllerCloseMode = ControllerCloseMode.All
213+
appSettings.app.kernel.controllerSensitivity = DefaultControllerSensitivity
212214
appSettings.app.kernel.cardColumns = DefaultCardColumns
213215
message.success('common.success')
214216
}
@@ -396,6 +398,21 @@ onActivated(() => {
396398
/>
397399
</div>
398400

401+
<div
402+
v-if="appSettings.app.kernel.controllerCloseMode === ControllerCloseMode.All"
403+
class="form-item"
404+
>
405+
{{ t('home.controller.sensitivity') }}
406+
<Input
407+
v-model="appSettings.app.kernel.controllerSensitivity"
408+
type="number"
409+
:min="1"
410+
:max="6"
411+
placeholder="1-6"
412+
editable
413+
/>
414+
</div>
415+
399416
<div class="form-item">
400417
{{ t('home.controller.cardColumns') }}
401418
<Radio

frontend/src/views/HomeView/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const onMouseWheel = (e: WheelEvent) => {
6565
if (isScrollingDown || currentScrollTop === 0) {
6666
scrollEventCount += 1
6767
}
68-
if (scrollEventCount >= 2) {
68+
if (scrollEventCount >= appSettingsStore.app.kernel.controllerSensitivity) {
6969
showController.value = isScrollingDown || currentScrollTop !== 0
7070
}
7171
}

0 commit comments

Comments
 (0)