mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix(console): use toast for pip-install error display (#8462)
* fix(console): use toast for pip-install error display The pip-install dialog displayed error messages as unstyled inline <small> text with no color differentiation from success messages. Replaced with useToast() to show errors as red snackbar, consistent with the rest of the dashboard. * fix(console): use i18n for pip-install toast fallback messages
This commit is contained in:
@@ -10,7 +10,10 @@
|
||||
"packageLabel": "*Package name, e.g. llmtuner",
|
||||
"mirrorLabel": "Force PyPI repository URL (optional)",
|
||||
"mirrorHint": "Force PyPI repository URL > Config item `PyPI Repository Address`",
|
||||
"installButton": "Install"
|
||||
"installButton": "Install",
|
||||
"installSuccess": "Installation successful.",
|
||||
"installFailed": "Installation failed.",
|
||||
"requestFailed": "Request failed."
|
||||
},
|
||||
"debugHint": {
|
||||
"text": "Debug logs can be enabled in \"Configuration File → System → Console Log Level\""
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
"packageLabel": "*Имя пакета, например: llmtuner",
|
||||
"mirrorLabel": "Использовать зеркало PyPI (опционально)",
|
||||
"mirrorHint": "Приоритет зеркала PyPI > настройки «Зеркало репозитория PyPI»",
|
||||
"installButton": "Установить"
|
||||
"installButton": "Установить",
|
||||
"installSuccess": "Установка выполнена успешно.",
|
||||
"installFailed": "Ошибка установки.",
|
||||
"requestFailed": "Ошибка запроса."
|
||||
},
|
||||
"debugHint": {
|
||||
"text": "Для отображения Debug-логов необходимо установить соответствующий уровень в «Конфигурация → Система → Уровень логирования»"
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
"packageLabel": "*库名,如 llmtuner",
|
||||
"mirrorLabel": "强制 PyPI 软件仓库链接(可选)",
|
||||
"mirrorHint": "强制 PyPI 软件仓库链接 > 配置项 `PyPI 软件仓库地址`",
|
||||
"installButton": "安装"
|
||||
"installButton": "安装",
|
||||
"installSuccess": "安装成功。",
|
||||
"installFailed": "安装失败。",
|
||||
"requestFailed": "请求失败。"
|
||||
},
|
||||
"debugHint": {
|
||||
"text": "Debug 日志需要在「配置文件 → 系统 → 控制台日志级别」中开启"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import ConsoleDisplayer from '@/components/shared/ConsoleDisplayer.vue';
|
||||
import { useModuleI18n } from '@/i18n/composables';
|
||||
import axios from 'axios';
|
||||
import { useToast } from '@/utils/toast';
|
||||
|
||||
const { tm } = useModuleI18n('features/console');
|
||||
</script>
|
||||
@@ -37,10 +38,6 @@ const { tm } = useModuleI18n('features/console');
|
||||
<v-text-field v-model="pipInstallPayload.package" :label="tm('pipInstall.packageLabel')" variant="outlined"></v-text-field>
|
||||
<v-text-field v-model="pipInstallPayload.mirror" :label="tm('pipInstall.mirrorLabel')" variant="outlined"></v-text-field>
|
||||
<small>{{ tm('pipInstall.mirrorHint') }}</small>
|
||||
<div>
|
||||
<small>{{ status }}</small>
|
||||
</div>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
@@ -69,8 +66,7 @@ export default {
|
||||
package: '',
|
||||
mirror: ''
|
||||
},
|
||||
loading: false,
|
||||
status: ''
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -88,17 +84,19 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
pipInstall() {
|
||||
const toast = useToast();
|
||||
this.loading = true;
|
||||
axios.post('/api/update/pip-install', this.pipInstallPayload)
|
||||
.then(res => {
|
||||
this.status = res.data.message;
|
||||
setTimeout(() => {
|
||||
this.status = '';
|
||||
if (res.data.status === 'ok') {
|
||||
toast.success(res.data.message || tm('pipInstall.installSuccess'));
|
||||
this.pipDialog = false;
|
||||
}, 2000);
|
||||
} else {
|
||||
toast.error(res.data.message || tm('pipInstall.installFailed'));
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.status = err.response.data.message;
|
||||
toast.error(err.response?.data?.message || tm('pipInstall.requestFailed'));
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user