Implement server commands through control stream
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
v-if="currentTab === 'general'"
|
||||
:config="config"
|
||||
:global-prep-cmd="global_prep_cmd"
|
||||
:server-cmd="server_cmd"
|
||||
:platform="platform">
|
||||
</general>
|
||||
|
||||
@@ -134,6 +135,7 @@
|
||||
currentTab: "general",
|
||||
vdisplayStatus: "1",
|
||||
global_prep_cmd: [],
|
||||
server_cmd: [],
|
||||
tabs: [ // TODO: Move the options to each Component instead, encapsulate.
|
||||
{
|
||||
id: "general",
|
||||
@@ -143,6 +145,7 @@
|
||||
"sunshine_name": "",
|
||||
"min_log_level": 2,
|
||||
"global_prep_cmd": "[]",
|
||||
"server_cmd": "[]",
|
||||
"notify_pre_releases": "disabled",
|
||||
},
|
||||
},
|
||||
@@ -328,7 +331,9 @@
|
||||
});
|
||||
|
||||
this.config.global_prep_cmd = this.config.global_prep_cmd || [];
|
||||
this.config.server_cmd = this.config.server_cmd || [];
|
||||
this.global_prep_cmd = JSON.parse(this.config.global_prep_cmd);
|
||||
this.server_cmd = JSON.parse(this.config.server_cmd);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
@@ -336,7 +341,8 @@
|
||||
this.$forceUpdate()
|
||||
},
|
||||
serialize() {
|
||||
this.config.global_prep_cmd = JSON.stringify(this.global_prep_cmd);
|
||||
this.config.global_prep_cmd = JSON.stringify(this.global_prep_cmd.filter(cmd => cmd.do || cmd.undo));
|
||||
this.config.server_cmd = JSON.stringify(this.server_cmd.filter(cmd => cmd.name && cmd.cmd));
|
||||
},
|
||||
save() {
|
||||
this.saved = false;
|
||||
|
||||
@@ -4,26 +4,35 @@ import { ref } from 'vue'
|
||||
const props = defineProps({
|
||||
platform: String,
|
||||
config: Object,
|
||||
globalPrepCmd: Array
|
||||
globalPrepCmd: Array,
|
||||
serverCmd: Array
|
||||
})
|
||||
|
||||
const config = ref(props.config)
|
||||
const globalPrepCmd = ref(props.globalPrepCmd)
|
||||
const serverCmd = ref(props.serverCmd)
|
||||
|
||||
function addCmd() {
|
||||
let template = {
|
||||
do: "",
|
||||
undo: "",
|
||||
};
|
||||
|
||||
if (props.platform === 'windows') {
|
||||
template = { ...template, elevated: false };
|
||||
}
|
||||
globalPrepCmd.value.push(template);
|
||||
const prepCmdTemplate = {
|
||||
do: "",
|
||||
undo: "",
|
||||
}
|
||||
|
||||
function removeCmd(index) {
|
||||
globalPrepCmd.value.splice(index,1)
|
||||
const serverCmdTemplate = {
|
||||
name: "",
|
||||
cmd: ""
|
||||
}
|
||||
|
||||
function addCmd(cmdArr, template) {
|
||||
const _tpl = Object.assign({}, template);
|
||||
|
||||
if (props.platform === 'windows') {
|
||||
_tpl.elevated = false;
|
||||
}
|
||||
cmdArr.push(_tpl);
|
||||
}
|
||||
|
||||
function removeCmd(cmdArr, index) {
|
||||
cmdArr.splice(index,1)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -114,17 +123,63 @@ function removeCmd(index) {
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger" @click="removeCmd(i)">
|
||||
<button class="btn btn-danger" @click="removeCmd(globalPrepCmd, i)">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
<button class="btn btn-success" @click="addCmd">
|
||||
<button class="btn btn-success" @click="addCmd(globalPrepCmd, prepCmdTemplate)">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="ms-0 mt-2 btn btn-success" style="margin: 0 auto" @click="addCmd">
|
||||
<button class="ms-0 mt-2 btn btn-success" style="margin: 0 auto" @click="addCmd(globalPrepCmd, prepCmdTemplate)">
|
||||
+ {{ $t('config.add') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Server Commands -->
|
||||
<div id="server_cmd" class="mb-3 d-flex flex-column">
|
||||
<label class="form-label">{{ $t('config.server_cmd') }}</label>
|
||||
<div class="form-text">{{ $t('config.server_cmd_desc') }}</div>
|
||||
<table class="table" v-if="serverCmd.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><i class="fas fa-tag"></i> {{ $t('_common.cmd_name') }}</th>
|
||||
<th scope="col"><i class="fas fa-terminal"></i> {{ $t('_common.cmd_val') }}</th>
|
||||
<th scope="col" v-if="platform === 'windows'">
|
||||
<i class="fas fa-shield-alt"></i> {{ $t('_common.run_as') }}
|
||||
</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(c, i) in serverCmd">
|
||||
<td>
|
||||
<input type="text" class="form-control" v-model="c.name" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control monospace" v-model="c.cmd" />
|
||||
</td>
|
||||
<td v-if="platform === 'windows'">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" :id="'server-cmd-admin-' + i" v-model="c.elevated"
|
||||
true-value="true" false-value="false" />
|
||||
<label :for="'server-cmd-admin-' + i" class="form-check-label">{{ $t('_common.elevated') }}</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger" @click="removeCmd(serverCmd, i)">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
<button class="btn btn-success" @click="addCmd(serverCmd, serverCmdTemplate)">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="ms-0 mt-2 btn btn-success" style="margin: 0 auto" @click="addCmd(serverCmd, serverCmdTemplate)">
|
||||
+ {{ $t('config.add') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"autodetect": "Autodetect (recommended)",
|
||||
"beta": "(beta)",
|
||||
"cancel": "Cancel",
|
||||
"cmd_name": "Command Name",
|
||||
"cmd_val": "Command Value",
|
||||
"disabled": "Disabled",
|
||||
"disabled_def": "Disabled (default)",
|
||||
"dismiss": "Dismiss",
|
||||
@@ -308,6 +310,8 @@
|
||||
"qsv_slow_hevc": "Allow Slow HEVC Encoding",
|
||||
"qsv_slow_hevc_desc": "This can enable HEVC encoding on older Intel GPUs, at the cost of higher GPU usage and worse performance.",
|
||||
"restart_note": "Apollo is restarting to apply changes.",
|
||||
"server_cmd": "Server Commands",
|
||||
"server_cmd_desc": "Configure a list of commands to be executed when called from client during streaming.",
|
||||
"sunshine_name": "Apollo Name",
|
||||
"sunshine_name_desc": "The name displayed by Moonlight. If not specified, the PC's hostname is used",
|
||||
"sw_preset": "SW Presets",
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"autodetect": "自动检测 (推荐)",
|
||||
"beta": "(测试版)",
|
||||
"cancel": "取消",
|
||||
"cmd_name": "命令名称",
|
||||
"cmd_val": "命令值",
|
||||
"disabled": "禁用",
|
||||
"disabled_def": "禁用(默认)",
|
||||
"dismiss": "关闭",
|
||||
@@ -308,6 +310,8 @@
|
||||
"res_fps_desc": "由 Apollo 通告的显示模式。 某些版本的 Moonlight,如 Moonlight-nx (Switch),依靠这些清单来确保支持所请求的分辨率和 fps。 此设置不会改变屏幕串流送至 Moonlight 的方式。",
|
||||
"resolutions": "通告分辨率",
|
||||
"restart_note": "正在重启 Apollo 以应用更改。",
|
||||
"server_cmd": "服务端命令",
|
||||
"server_cmd_desc": "配置一个命令列表,当串流时从客户端调用。",
|
||||
"sunshine_name": "Apollo 主机名称",
|
||||
"sunshine_name_desc": "在 Moonlight 中显示的名称。如果未指定,则使用 PC 的主机名",
|
||||
"sw_preset": "软件编码预设",
|
||||
|
||||
Reference in New Issue
Block a user