mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
improve add new dashboard behavior
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<Sidebar side="left" variant="sidebar" collapsible="icon">
|
<Sidebar side="left" variant="sidebar" collapsible="icon">
|
||||||
<SidebarHeader class="px-2 py-2">
|
<SidebarHeader v-if="!hasDashboards" class="px-2 py-2">
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton
|
<SidebarMenuButton
|
||||||
@@ -264,6 +264,7 @@
|
|||||||
const collapsedDropdownOpenId = ref(null);
|
const collapsedDropdownOpenId = ref(null);
|
||||||
const customNavDialogVisible = ref(false);
|
const customNavDialogVisible = ref(false);
|
||||||
|
|
||||||
|
const hasDashboards = computed(() => dashboards.value.length > 0);
|
||||||
const hasNotifications = computed(() => notifiedMenus.value.length > 0);
|
const hasNotifications = computed(() => notifiedMenus.value.length > 0);
|
||||||
const version = computed(() => appVersion.value?.split('VRCX ')?.[1] || '-');
|
const version = computed(() => appVersion.value?.split('VRCX ')?.[1] || '-');
|
||||||
const vrcxLogo = new URL('../../../images/VRCX.png', import.meta.url).href;
|
const vrcxLogo = new URL('../../../images/VRCX.png', import.meta.url).href;
|
||||||
|
|||||||
@@ -131,6 +131,7 @@
|
|||||||
"instance_not_in_game": "Not in game",
|
"instance_not_in_game": "Not in game",
|
||||||
"time_ago": "{time} ago"
|
"time_ago": "{time} ago"
|
||||||
},
|
},
|
||||||
|
"first_save_tip": "You can create more dashboards. Right-click the Navigation Menu or use the Customize Navigation dialog to add new ones.",
|
||||||
"confirmations": {
|
"confirmations": {
|
||||||
"delete_title": "Delete Dashboard",
|
"delete_title": "Delete Dashboard",
|
||||||
"delete_description": "Are you sure you want to delete this dashboard? This action cannot be undone."
|
"delete_description": "Are you sure you want to delete this dashboard? This action cannot be undone."
|
||||||
|
|||||||
@@ -138,8 +138,23 @@ export const useDashboardStore = defineStore('dashboard', () => {
|
|||||||
return `dashboard-${Date.now()}-${Math.random().toString().slice(2, 8)}`;
|
return `dashboard-${Date.now()}-${Math.random().toString().slice(2, 8)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createDashboard(name = 'Dashboard') {
|
function generateNextDashboardName(baseName = 'Dashboard') {
|
||||||
|
const existingNames = new Set(
|
||||||
|
dashboards.value.map((d) => d.name)
|
||||||
|
);
|
||||||
|
if (!existingNames.has(baseName)) {
|
||||||
|
return baseName;
|
||||||
|
}
|
||||||
|
let n = 1;
|
||||||
|
while (existingNames.has(`${baseName} ${n}`)) {
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return `${baseName} ${n}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createDashboard(baseName = 'Dashboard') {
|
||||||
const id = generateDashboardId();
|
const id = generateDashboardId();
|
||||||
|
const name = generateNextDashboardName(baseName);
|
||||||
const dashboard = {
|
const dashboard = {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { Plus } from 'lucide-vue-next';
|
import { Plus } from 'lucide-vue-next';
|
||||||
|
import { toast } from 'vue-sonner';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
@@ -179,11 +180,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
|
const isFirstSave =
|
||||||
|
dashboardStore.dashboards.length === 1 &&
|
||||||
|
(!dashboard.value?.rows || dashboard.value.rows.length === 0);
|
||||||
|
|
||||||
await dashboardStore.updateDashboard(props.id, {
|
await dashboardStore.updateDashboard(props.id, {
|
||||||
name: editName.value.trim() || dashboard.value?.name || 'Dashboard',
|
name: editName.value.trim() || dashboard.value?.name || 'Dashboard',
|
||||||
rows: editRows.value
|
rows: editRows.value
|
||||||
});
|
});
|
||||||
isEditing.value = false;
|
isEditing.value = false;
|
||||||
|
|
||||||
|
if (isFirstSave) {
|
||||||
|
toast(t('dashboard.first_save_tip'), { duration: 6000 });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancelEdit = () => {
|
const handleCancelEdit = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user