Add .art file export w/ optimize app list page

This commit is contained in:
Yukino Song
2025-06-05 21:11:25 +08:00
parent 0f9e7aa17f
commit e15eec1f4e
3 changed files with 58 additions and 22 deletions

View File

@@ -85,12 +85,27 @@
<body id="app" v-cloak>
<Navbar></Navbar>
<div class="container">
<div class="my-4">
<div class="my-4" v-if="!showEditForm">
<h1>{{ $t('apps.applications_title') }}</h1>
<div>{{ $t('apps.applications_desc') }}</div>
<div>{{ $t('apps.applications_reorder_desc') }}</div>
<div class="pre-wrap">{{ $t('apps.applications_tips') }}</div>
</div>
<div class="card p-4">
<div class="my-4" v-else>
<h1>{{ editForm.name || "&lt; NO NAME &gt;"}}</h1>
<div>
<button @click="showEditForm = false" class="btn btn-secondary me-2 mt-2">
<i class="fas fa-xmark"></i> {{ $t('_common.cancel') }}
</button>
<button class="btn btn-primary me-2 mt-2" :disabled="actionDisabled || !editForm.name.trim()" @click="save">
<i class="fas fa-floppy-disk"></i> {{ $t('_common.save') }}
</button>
<button class="btn btn-success mt-2" @click="exportLauncherFile(editForm)" :disabled="!editForm.uuid">
<i class="fas fa-arrow-up-from-bracket"></i> {{ $t('apps.export_launcher_file') }}
</button>
</div>
</div>
<div class="card p-4" v-if="!showEditForm">
<table class="table">
<thead>
<tr>
@@ -111,7 +126,7 @@
@dragend="onDragEnd()"
@drop="onDrop($event, app, i)"
>
<td>{{app.name || ' '}}</td>
<td @dblclick="exportLauncherFile(app)">{{app.name || ' '}}</td>
<td v-if="app.uuid" class="text-end">
<button class="btn btn-primary me-1" :disabled="actionDisabled" @click="editApp(app)">
<i class="fas fa-edit"></i>
@@ -122,16 +137,27 @@
<button class="btn btn-warning" :disabled="actionDisabled" @click="closeApp()" v-if="currentApp === app.uuid">
<i class="fas fa-stop"></i>
</button>
<button class="btn btn-success" :disabled="actionDisabled" @click="launchApp(app)" v-else>
<a class="btn btn-success" :disabled="actionDisabled" @click.prevent="launchApp(event, app)" :href="'art://launch?host_uuid=' + hostUUID + '&host_name=' + hostName + '&app_uuid=' + app.uuid + '&app_name=' + app.name" v-else>
<i class="fas fa-play"></i>
</button>
</a>
</td>
<td v-else></td>
</tr>
</tbody>
</table>
<div class="mt-2">
<button class="btn btn-primary" @click="newApp" :disabled="actionDisabled">
<i class="fas fa-plus"></i> {{ $t('apps.add_new') }}
</button>
<button class="btn btn-secondary float-end" @click="alphabetizeApps" :disabled="actionDisabled" v-if="!listReordered">
<i class="fas fa-sort-alpha-up"></i> {{ $t('apps.alphabetize') }}
</button>
<button class="btn btn-warning float-end" @click="saveOrder" :disabled="actionDisabled" v-if="listReordered">
<i class="fas fa-floppy-disk"></i> {{ $t('apps.save_order') }}
</button>
</div>
</div>
<div class="edit-form card mt-2" v-if="showEditForm">
<div class="edit-form card mt-2" v-else>
<div class="p-4">
<!-- Application Name -->
<div class="mb-3">
@@ -484,24 +510,15 @@
<!-- Save buttons -->
<div class="d-flex">
<button @click="showEditForm = false" class="btn btn-secondary m-2">
{{ $t('_common.cancel') }}
<button @click="showEditForm = false" class="btn btn-secondary me-2">
<i class="fas fa-xmark"></i> {{ $t('_common.cancel') }}
</button>
<button class="btn btn-primary" :disabled="actionDisabled || !editForm.name.trim()" @click="save">
<i class="fas fa-floppy-disk"></i> {{ $t('_common.save') }}
</button>
<button class="btn btn-primary m-2" :disabled="actionDisabled || !editForm.name.trim()" @click="save">{{ $t('_common.save') }}</button>
</div>
</div>
</div>
<div class="mt-2" v-else>
<button class="btn btn-primary" @click="newApp" :disabled="actionDisabled">
<i class="fas fa-plus"></i> {{ $t('apps.add_new') }}
</button>
<button class="btn btn-secondary float-end" @click="alphabetizeApps" :disabled="actionDisabled" v-if="!listReordered">
<i class="fas fa-sort-alpha-up"></i> {{ $t('apps.alphabetize') }}
</button>
<button class="btn btn-warning float-end" @click="saveOrder" :disabled="actionDisabled" v-if="listReordered">
<i class="fas fa-floppy-disk"></i> {{ $t('apps.save_order') }}
</button>
</div>
</div>
</body>
<script type="module">
@@ -681,12 +698,12 @@
this.editForm = Object.assign({}, newApp);
this.showEditForm = true;
},
launchApp(app) {
launchApp(event, app) {
const isLocalHost = ['localhost', '127.0.0.1', '[::1]'].indexOf(location.hostname) >= 0
if (!isLocalHost && confirm(this.$t('apps.launch_local_client'))) {
const link = document.createElement('a');
link.href = `art://launch?host_uuid=${this.hostUUID}&host_name=${this.hostName}&app_uuid=${app.uuid}&app_name=${app.name}`;
link.href = event.target.href;
link.click();
return;
}
@@ -736,6 +753,21 @@
this.editForm = Object.assign({}, newApp, JSON.parse(JSON.stringify(app)));
this.showEditForm = true;
},
exportLauncherFile(app) {
const link = document.createElement('a');
const fileContent = `# Artemis app entry
# Exported by Apollo
# https://github.com/ClassicOldSong/Apollo
[host_uuid] ${this.hostUUID}
[host_name] ${this.hostName}
[app_uuid] ${app.uuid}
[app_name] ${app.name}
`;
link.href = `data:text/plain;charset=utf-8,${encodeURIComponent(fileContent)}`;
link.download = `${app.name}.art`;
link.click();
},
showDeleteForm(app) {
const resp = confirm(
"Are you sure to delete " + app.name + "?"

View File

@@ -42,6 +42,7 @@
"app_name_desc": "Application Name, as shown on Moonlight",
"applications_desc": "Applications are refreshed when a session is terminated.",
"applications_reorder_desc": "Drag and drop apps to reorder the apps. Any changes made will terminate the current running app.",
"applications_tips": "Tip: You can also right click the launch app button to copy the launch link, and send it to your friends. They need to use Artemis and have already paired with you.\nYou can also double click the app name to export the app entry to a file, to add them to your favorite emulator frontends.",
"applications_title": "Applications",
"auto_detach": "Continue streaming if the application exits quickly",
"auto_detach_desc": "This will attempt to automatically detect launcher-type apps that close quickly after launching another program or instance of themselves. When a launcher-type app is detected, it is treated as a detached app.",
@@ -86,6 +87,7 @@
"env_vars_about": "About Environment Variables",
"env_vars_desc": "All commands get these environment variables by default:",
"env_xrandr_example": "Example - Xrandr for Resolution Automation:",
"export_launcher_file": "Export Launcher File",
"exit_timeout": "Exit Timeout",
"exit_timeout_desc": "Number of seconds to wait for all app processes to gracefully exit when requested to quit. If unset, the default is to wait up to 5 seconds. If set to zero or a negative value, the app will be immediately terminated.",
"find_cover": "Find Cover",

View File

@@ -42,6 +42,7 @@
"app_name_desc": "在 Moonlight 显示的应用名称",
"applications_desc": "应用列表在会话终止时刷新",
"applications_reorder_desc": "拖动应用以重新排序。任何更改都会终止当前正在运行的APP。",
"applications_tips": "提示:您也可以右键点击启动应用按钮来复制启动链接,并将其发送给朋友。他们需要使用 Artemis 并已经与您配对。\n您也可以双击应用名称来导出应用启动文件添加到您最喜欢的模拟器前端。",
"applications_title": "应用",
"auto_detach": "启动串流后应用突然关闭时不退出串流",
"auto_detach_desc": "这将尝试自动检测在启动另一个程序或自身实例后很快关闭的启动类应用。 检测到启动型应用程序时,它会被视为一个分离的应用程序。",
@@ -86,6 +87,7 @@
"env_vars_about": "关于环境变量",
"env_vars_desc": "默认情况下,所有命令都会得到这些环境变量:",
"env_xrandr_example": "示例 - Xrandr 用于分辨率自动化:",
"export_launcher_file": "导出启动器文件",
"exit_timeout": "退出超时",
"exit_timeout_desc": "请求退出时,等待所有应用进程正常关闭的秒数。 如果未设置默认等待5秒钟。如果设置为零或负值应用程序将立即终止。",
"find_cover": "查找封面",