mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-19 12:25:00 +03:00
cb37dd55ca
Closes the index page's i18n coverage. Combined with the page-chrome
commit, every label users see on the dashboard is now sourced from
the TOML translation files.
Per file:
- IndexPage.vue: loading-spinner tip (initial + dynamic).
- BackupModal.vue: modal title, both list-item titles + descriptions
("Back up" / "Restore"), in-flight busy tips ("Importing database…"
/ "Restarting panel…").
- PanelUpdateModal.vue: modal title, update-available alert,
current/latest version row labels, "Up to date" tag + label,
primary action button. Modal.confirm now uses the translated
panelUpdateDialog / panelUpdateDialogDesc with #version#
substitution; success toast uses panelUpdateStartedPopover.
- LogModal.vue: title slot ("Logs"). The Debug/Info/Notice/Warning/
Error log-level options stay literal — they're xray's wire values,
not user-facing labels (matches the existing settings-page choice).
- XrayLogModal.vue: title + Filter label. Direct/Blocked/Proxy stay
literal for the same reason.
- VersionModal.vue: modal title + xray-switch alert + per-file
tooltip + "Update all" button + custom-geo collapse header. The
Modal.confirm flows for switchXrayVersion + updateGeofile use
translated dialog/desc with #version# / #filename# substitution.
- CpuHistoryModal.vue: title slot.
- CustomGeoSection.vue: routing-hint alert, Add / Update-all buttons,
every column title (computed for live locale), copy/edit/download/
delete tooltips, copy toast, delete-confirm modal, empty-state
text.
- CustomGeoFormModal.vue: add/edit titles, OK/cancel labels, Type/
Alias/URL field labels, alias placeholder, all three validation
toasts.
Total: ~50 strings localised across 8 index-page files. The Hello /
Welcome login headline cycle and a handful of literal xray wire
values (Direct/Blocked/Proxy/log levels) are intentionally kept
hardcoded.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
91 lines
2.7 KiB
Vue
91 lines
2.7 KiB
Vue
<script setup>
|
|
import { useI18n } from 'vue-i18n';
|
|
import { DownloadOutlined, UploadOutlined } from '@ant-design/icons-vue';
|
|
import { HttpUtil, PromiseUtil } from '@/utils';
|
|
|
|
const { t } = useI18n();
|
|
|
|
defineProps({
|
|
open: { type: Boolean, default: false },
|
|
basePath: { type: String, default: '' },
|
|
});
|
|
|
|
const emit = defineEmits(['update:open', 'busy']);
|
|
|
|
function close() {
|
|
emit('update:open', false);
|
|
}
|
|
|
|
function exportDb() {
|
|
// The Go endpoint streams x-ui.db as a download. Setting
|
|
// window.location triggers a browser download without leaving
|
|
// the page (the Go side responds with Content-Disposition: attachment).
|
|
window.location = '/panel/api/server/getDb';
|
|
}
|
|
|
|
function importDb() {
|
|
const fileInput = document.createElement('input');
|
|
fileInput.type = 'file';
|
|
fileInput.accept = '.db';
|
|
fileInput.addEventListener('change', async (e) => {
|
|
const dbFile = e.target.files?.[0];
|
|
if (!dbFile) return;
|
|
|
|
const formData = new FormData();
|
|
formData.append('db', dbFile);
|
|
|
|
close();
|
|
emit('busy', { busy: true, tip: t('pages.index.importDatabase') + '…' });
|
|
|
|
const upload = await HttpUtil.post('/panel/api/server/importDB', formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
});
|
|
if (!upload?.success) {
|
|
emit('busy', { busy: false });
|
|
return;
|
|
}
|
|
|
|
emit('busy', { busy: true, tip: t('pages.settings.restartPanel') + '…' });
|
|
const restart = await HttpUtil.post('/panel/setting/restartPanel');
|
|
if (restart?.success) {
|
|
await PromiseUtil.sleep(5000);
|
|
window.location.reload();
|
|
} else {
|
|
emit('busy', { busy: false });
|
|
}
|
|
});
|
|
fileInput.click();
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<a-modal :open="open" :title="t('pages.index.backupTitle')" :closable="true" :footer="null" @cancel="close">
|
|
<a-list bordered class="backup-list">
|
|
<a-list-item class="backup-item">
|
|
<a-list-item-meta>
|
|
<template #title>{{ t('pages.index.exportDatabase') }}</template>
|
|
<template #description>{{ t('pages.index.exportDatabaseDesc') }}</template>
|
|
</a-list-item-meta>
|
|
<a-button type="primary" @click="exportDb">
|
|
<template #icon><DownloadOutlined /></template>
|
|
</a-button>
|
|
</a-list-item>
|
|
|
|
<a-list-item class="backup-item">
|
|
<a-list-item-meta>
|
|
<template #title>{{ t('pages.index.importDatabase') }}</template>
|
|
<template #description>{{ t('pages.index.importDatabaseDesc') }}</template>
|
|
</a-list-item-meta>
|
|
<a-button type="primary" @click="importDb">
|
|
<template #icon><UploadOutlined /></template>
|
|
</a-button>
|
|
</a-list-item>
|
|
</a-list>
|
|
</a-modal>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.backup-list { width: 100%; }
|
|
.backup-item { display: flex; align-items: center; gap: 16px; }
|
|
</style>
|