forked from LizardByte/Sunshine
-
-
Notifications
You must be signed in to change notification settings - Fork 124
feat(web/config): consolidate HEVC + AV1 into a single Codec Strategy #645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,119 +12,86 @@ const props = defineProps([ | |
|
|
||
| const config = ref(props.config) | ||
|
|
||
| // Tauri 环境下的 vmouse 驱动管理 | ||
| const hasVmouseDriver = ref(false) | ||
| const vmouseStatus = ref({ installed: false, running: false, status_text: '' }) | ||
| const vmouseLoading = ref(false) | ||
| const vmouseOperating = ref(false) | ||
|
|
||
| // Tauri 环境下的 ViGEmBus 虚拟手柄驱动管理 | ||
| const hasVigemDriver = ref(false) | ||
| const vigemStatus = ref({ installed: false, running: false, version: '', version_ok: false, status_text: '' }) | ||
| const vigemLoading = ref(false) | ||
| const vigemOperating = ref(false) | ||
|
|
||
| onMounted(async () => { | ||
| if (!window.isTauri) return | ||
| hasVmouseDriver.value = !!window.vmouseDriver | ||
| hasVigemDriver.value = !!window.vigemDriver | ||
| if (hasVmouseDriver.value) await refreshVmouseStatus() | ||
| if (hasVigemDriver.value) await refreshVigemStatus() | ||
| }) | ||
|
|
||
| async function refreshVmouseStatus() { | ||
| vmouseLoading.value = true | ||
| try { | ||
| vmouseStatus.value = await window.vmouseDriver.getStatus() | ||
| } catch { /* ignore */ } | ||
| vmouseLoading.value = false | ||
| } | ||
|
|
||
| async function installVmouse() { | ||
| if (!confirm(t('config.vmouse_confirm_install'))) return | ||
| vmouseOperating.value = true | ||
| try { | ||
| await window.vmouseDriver.install() | ||
| setTimeout(() => refreshVmouseStatus(), 2000) | ||
| } catch (e) { | ||
| alert(String(e)) | ||
| /** | ||
| * 创建一个驱动管理器,统一封装状态/加载/操作逻辑,避免 vmouse / vigem 的重复代码。 | ||
| * @param {string} driverKey - window 上挂载的驱动对象属性名(如 'vmouseDriver') | ||
| * @param {object} initialStatus - 初始状态对象 | ||
| */ | ||
| function createDriverManager(driverKey, initialStatus) { | ||
| const available = ref(false) | ||
| const status = ref({ ...initialStatus }) | ||
| const loading = ref(false) | ||
| const operating = ref(false) | ||
|
|
||
| const driver = () => window[driverKey] | ||
|
|
||
| async function refresh() { | ||
| loading.value = true | ||
| try { | ||
| status.value = await driver().getStatus() | ||
| } catch { /* ignore */ } | ||
| loading.value = false | ||
| } | ||
| vmouseOperating.value = false | ||
| } | ||
|
|
||
| async function uninstallVmouse() { | ||
| if (!confirm(t('config.vmouse_confirm_uninstall'))) return | ||
| vmouseOperating.value = true | ||
| try { | ||
| await window.vmouseDriver.uninstall() | ||
| setTimeout(() => refreshVmouseStatus(), 2000) | ||
| } catch (e) { | ||
| alert(String(e)) | ||
| async function runOp(confirmKey, op) { | ||
| if (!confirm(t(confirmKey))) return | ||
| operating.value = true | ||
| try { | ||
| await op(driver()) | ||
| setTimeout(refresh, 2000) | ||
| } catch (e) { | ||
| alert(String(e)) | ||
| } | ||
| operating.value = false | ||
| } | ||
| vmouseOperating.value = false | ||
| } | ||
|
|
||
| async function refreshVigemStatus() { | ||
| vigemLoading.value = true | ||
| try { | ||
| vigemStatus.value = await window.vigemDriver.getStatus() | ||
| } catch { /* ignore */ } | ||
| vigemLoading.value = false | ||
| } | ||
|
|
||
| async function installVigem(force = false) { | ||
| const key = force ? 'config.vigem_confirm_reinstall' : 'config.vigem_confirm_install' | ||
| if (!confirm(t(key))) return | ||
| vigemOperating.value = true | ||
| try { | ||
| await window.vigemDriver.install(force) | ||
| setTimeout(() => refreshVigemStatus(), 2000) | ||
| } catch (e) { | ||
| alert(String(e)) | ||
| } | ||
| vigemOperating.value = false | ||
| } | ||
| const dotClass = computed(() => { | ||
| if (status.value.running) return 'dot-active' | ||
| if (status.value.installed) return 'dot-warning' | ||
| return 'dot-inactive' | ||
| }) | ||
|
|
||
| async function uninstallVigem() { | ||
| if (!confirm(t('config.vigem_confirm_uninstall'))) return | ||
| vigemOperating.value = true | ||
| try { | ||
| await window.vigemDriver.uninstall() | ||
| setTimeout(() => refreshVigemStatus(), 2000) | ||
| } catch (e) { | ||
| alert(String(e)) | ||
| } | ||
| vigemOperating.value = false | ||
| return { available, status, loading, operating, refresh, runOp, dotClass } | ||
| } | ||
|
|
||
| const vmouseDotClass = computed(() => { | ||
| if (vmouseStatus.value.running) return 'dot-active' | ||
| if (vmouseStatus.value.installed) return 'dot-warning' | ||
| return 'dot-inactive' | ||
| }) | ||
| // vmouse 驱动管理 | ||
| const vmouse = createDriverManager('vmouseDriver', { installed: false, running: false, status_text: '' }) | ||
| const installVmouse = () => vmouse.runOp('config.vmouse_confirm_install', d => d.install()) | ||
| const uninstallVmouse = () => vmouse.runOp('config.vmouse_confirm_uninstall', d => d.uninstall()) | ||
|
|
||
| const vmouseStatusLabel = computed(() => { | ||
| if (vmouseStatus.value.running) return t('config.vmouse_status_running') | ||
| if (vmouseStatus.value.installed) return t('config.vmouse_status_installed') | ||
| if (vmouse.status.value.running) return t('config.vmouse_status_running') | ||
| if (vmouse.status.value.installed) return t('config.vmouse_status_installed') | ||
| return t('config.vmouse_status_not_installed') | ||
| }) | ||
|
|
||
| const vigemDotClass = computed(() => { | ||
| if (vigemStatus.value.running) return 'dot-active' | ||
| if (vigemStatus.value.installed) return 'dot-warning' | ||
| return 'dot-inactive' | ||
| }) | ||
| // ViGEmBus 虚拟手柄驱动管理 | ||
| const vigem = createDriverManager('vigemDriver', | ||
| { installed: false, running: false, version: '', version_ok: false, status_text: '' }) | ||
| const installVigem = (force = false) => vigem.runOp( | ||
| force ? 'config.vigem_confirm_reinstall' : 'config.vigem_confirm_install', | ||
| d => d.install(force) | ||
| ) | ||
| const uninstallVigem = () => vigem.runOp('config.vigem_confirm_uninstall', d => d.uninstall()) | ||
|
|
||
| const vigemStatusLabel = computed(() => { | ||
| if (!vigemStatus.value.installed) return t('config.vigem_status_not_installed') | ||
| if (!vigemStatus.value.version_ok) return t('config.vigem_status_outdated') | ||
| if (vigemStatus.value.running) { | ||
| return vigemStatus.value.version | ||
| ? `${t('config.vigem_status_running')} (${vigemStatus.value.version})` | ||
| : t('config.vigem_status_running') | ||
| const s = vigem.status.value | ||
| if (!s.installed) return t('config.vigem_status_not_installed') | ||
| if (!s.version_ok) return t('config.vigem_status_outdated') | ||
| if (s.running) { | ||
| const running = t('config.vigem_status_running') | ||
| return s.version ? `${running} (${s.version})` : running | ||
| } | ||
| return t('config.vigem_status_installed') | ||
| }) | ||
|
|
||
| onMounted(async () => { | ||
| if (!window.isTauri) return | ||
| vmouse.available.value = !!window.vmouseDriver | ||
| vigem.available.value = !!window.vigemDriver | ||
| if (vmouse.available.value) await vmouse.refresh() | ||
| if (vigem.available.value) await vigem.refresh() | ||
| }) | ||
| </script> | ||
|
Comment on lines
+57
to
95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 重构后缺少模板绑定别名,导致页面绑定失效。
建议补充兼容别名(最小改动) // vmouse 驱动管理
const vmouse = createDriverManager('vmouseDriver', { installed: false, running: false, status_text: '' })
const installVmouse = () => vmouse.runOp('config.vmouse_confirm_install', d => d.install())
const uninstallVmouse = () => vmouse.runOp('config.vmouse_confirm_uninstall', d => d.uninstall())
+const hasVmouseDriver = computed(() => vmouse.available.value)
+const vmouseStatus = computed(() => vmouse.status.value)
+const vmouseLoading = computed(() => vmouse.loading.value)
+const vmouseOperating = computed(() => vmouse.operating.value)
+const vmouseDotClass = computed(() => vmouse.dotClass.value)
+const refreshVmouseStatus = () => vmouse.refresh()
// ViGEmBus 虚拟手柄驱动管理
const vigem = createDriverManager('vigemDriver',
{ installed: false, running: false, version: '', version_ok: false, status_text: '' })
const installVigem = (force = false) => vigem.runOp(
force ? 'config.vigem_confirm_reinstall' : 'config.vigem_confirm_install',
d => d.install(force)
)
const uninstallVigem = () => vigem.runOp('config.vigem_confirm_uninstall', d => d.uninstall())
+const hasVigemDriver = computed(() => vigem.available.value)
+const vigemStatus = computed(() => vigem.status.value)
+const vigemLoading = computed(() => vigem.loading.value)
+const vigemOperating = computed(() => vigem.operating.value)
+const vigemDotClass = computed(() => vigem.dotClass.value)
+const refreshVigemStatus = () => vigem.refresh()🤖 Prompt for AI Agents |
||
|
|
||
| <template> | ||
|
|
@@ -565,6 +532,9 @@ const vigemStatusLabel = computed(() => { | |
|
|
||
| /* 面板操作区 */ | ||
| .vmouse-panel-body { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: 0.5rem; | ||
| padding: 0.6rem 0.85rem; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.