2026-04-13 12:15:16 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
|
|
import { NButton, NSpin } from 'naive-ui'
|
2026-04-13 15:15:14 +08:00
|
|
|
import { useI18n } from 'vue-i18n'
|
2026-04-13 12:15:16 +08:00
|
|
|
import ProvidersPanel from '@/components/models/ProvidersPanel.vue'
|
|
|
|
|
import ProviderFormModal from '@/components/models/ProviderFormModal.vue'
|
|
|
|
|
import { useModelsStore } from '@/stores/models'
|
|
|
|
|
|
2026-04-13 15:15:14 +08:00
|
|
|
const { t } = useI18n()
|
2026-04-13 12:15:16 +08:00
|
|
|
const modelsStore = useModelsStore()
|
|
|
|
|
const showModal = ref(false)
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
modelsStore.fetchProviders()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function openCreateModal() {
|
|
|
|
|
showModal.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleModalClose() {
|
|
|
|
|
showModal.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleSaved() {
|
|
|
|
|
await modelsStore.fetchProviders()
|
|
|
|
|
handleModalClose()
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="models-view">
|
2026-04-15 08:50:10 +08:00
|
|
|
<header class="page-header">
|
2026-04-13 15:15:14 +08:00
|
|
|
<h2 class="header-title">{{ t('models.title') }}</h2>
|
2026-04-15 08:50:10 +08:00
|
|
|
<NButton type="primary" size="small" @click="openCreateModal">
|
2026-04-13 12:15:16 +08:00
|
|
|
<template #icon>
|
|
|
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
|
|
|
|
</template>
|
2026-04-13 15:15:14 +08:00
|
|
|
{{ t('models.addProvider') }}
|
2026-04-13 12:15:16 +08:00
|
|
|
</NButton>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div class="models-content">
|
|
|
|
|
<NSpin :show="modelsStore.loading && modelsStore.providers.length === 0">
|
|
|
|
|
<ProvidersPanel />
|
|
|
|
|
</NSpin>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ProviderFormModal
|
|
|
|
|
v-if="showModal"
|
|
|
|
|
@close="handleModalClose"
|
|
|
|
|
@saved="handleSaved"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
@use '@/styles/variables' as *;
|
|
|
|
|
|
|
|
|
|
.models-view {
|
|
|
|
|
height: 100vh;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.models-content {
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|