Skip to content

Commit

Permalink
perf: 🚀 Add window position option
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 18, 2023
1 parent f7880ea commit 866aa2c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 22 deletions.
14 changes: 10 additions & 4 deletions src/locales/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,16 @@
"preferences.window.always-top.placeholder": "Keep control window topmost",
"preferences.window.disable-screen-saver.name": "Disable Screensaver",
"preferences.window.disable-screen-saver.placeholder": "Disable computer screensaver",
"preferences.window.size.width": "Window width",
"preferences.window.size.width.placeholder": "The window width may cause the display to be blurred",
"preferences.window.size.height": "Window height",
"preferences.window.size.height.placeholder": "Window height",
"preferences.window.size.width": "Window Width",
"preferences.window.size.width.placeholder": "Device Width",
"preferences.window.size.width.tips": "Note: Changing this setting may result in blurry display.",
"preferences.window.size.height": "Window Height",
"preferences.window.size.height.placeholder": "Device Height",
"preferences.window.size.height.tips": "Note: Changing this setting may result in blurry display.",
"preferences.window.position.x": "Window X Position",
"preferences.window.position.x.placeholder": "Relative to Desktop Center",
"preferences.window.position.y": "Window Y Position",
"preferences.window.position.y.placeholder": "Relative to Desktop Center",

"preferences.record.name": "Recording",
"preferences.record.format.name": "Format",
Expand Down
10 changes: 8 additions & 2 deletions src/locales/languages/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,15 @@
"preferences.window.disable-screen-saver.name": "禁用屏幕保护程序",
"preferences.window.disable-screen-saver.placeholder": "开启后将禁用计算机屏幕保护程序",
"preferences.window.size.width": "窗口宽度",
"preferences.window.size.width.placeholder": "窗口宽度, 可能会导致显示模糊",
"preferences.window.size.width.placeholder": "设备宽度",
"preferences.window.size.width.tips": "注意:更改此设置可能会导致显示模糊",
"preferences.window.size.height": "窗口高度",
"preferences.window.size.height.placeholder": "窗口高度",
"preferences.window.size.height.placeholder": "设备高度",
"preferences.window.size.height.tips": "注意:更改此设置可能会导致显示模糊",
"preferences.window.position.x": "窗口横坐标",
"preferences.window.position.x.placeholder": "相对于桌面中心",
"preferences.window.position.y": "窗口纵坐标",
"preferences.window.position.y.placeholder": "相对于桌面中心",

"preferences.record.name": "音视频录制",
"preferences.record.format.name": "录制视频格式",
Expand Down
7 changes: 5 additions & 2 deletions src/store/preference/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export const usePreferenceStore = defineStore({
this.init()
},
setData(data, scope = this.deviceScope) {
const pickData = pickBy(data, value => !!value)
const pickData = pickBy(
data,
value => !!value || typeof value === 'number',
)

if (data.adbPath === adbPath) {
delete pickData.adbPath
Expand Down Expand Up @@ -136,7 +139,7 @@ export const usePreferenceStore = defineStore({
}

const valueList = Object.entries(data).reduce((arr, [key, value]) => {
if (!value) {
if (!value && typeof value !== 'number') {
return arr
}

Expand Down
44 changes: 30 additions & 14 deletions src/store/preference/model/window/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@ export default {
field: 'scrcpy',

children: {
windowWidth: {
label: 'preferences.window.size.width',
field: '--window-width',
type: 'Input.number',
value: undefined,
placeholder: 'preferences.window.size.width.placeholder',
tips: 'preferences.window.size.width.tips',
},
windowHeight: {
label: 'preferences.window.size.height',
field: '--window-height',
type: 'Input.number',
value: undefined,
placeholder: 'preferences.window.size.height.placeholder',
tips: 'preferences.window.size.height.tips',
},
windowX: {
label: 'preferences.window.position.x',
field: '--window-x',
type: 'Input.number',
value: undefined,
placeholder: 'preferences.window.position.x.placeholder',
},
windowY: {
label: 'preferences.window.position.y',
field: '--window-y',
type: 'Input.number',
value: undefined,
placeholder: 'preferences.window.position.y.placeholder',
},
windowBorderless: {
label: 'preferences.window.borderless.name',
field: '--window-borderless',
Expand Down Expand Up @@ -31,19 +61,5 @@ export default {
value: undefined,
placeholder: 'preferences.window.disable-screen-saver.placeholder',
},
windowWidth: {
label: 'preferences.window.size.width',
field: '--window-width',
type: 'Input.number',
value: undefined,
placeholder: 'preferences.window.size.width.placeholder',
},
windowHeight: {
label: 'preferences.window.size.height',
field: '--window-height',
type: 'Input.number',
value: undefined,
placeholder: 'preferences.window.size.height.placeholder',
},
},
}

0 comments on commit 866aa2c

Please sign in to comment.