| | |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { deleteApiKey, getApiKeyPage } from '#/api/ai/model/apiKey'; |
| | | import { |
| | | deleteApiKey, |
| | | getApiKeyPage, |
| | | importApiKey, |
| | | importApiKeyTemplate, |
| | | } from '#/api/ai/model/apiKey'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import ImportModalComponent from '#/components/import-modal'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [ImportModal, importModalApi] = useVbenModal({ |
| | | connectedComponent: ImportModalComponent, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | /** 创建 API 密钥 */ |
| | | function handleCreate() { |
| | | formModalApi.setData(null).open(); |
| | | } |
| | | |
| | | /** 导入 API 密钥 */ |
| | | function handleImport() { |
| | | importModalApi |
| | | .setData({ |
| | | title: $t('ui.actionTitle.import', ['API 密钥']), |
| | | fileName: 'API密钥导入模板.xls', |
| | | importFn: importApiKey, |
| | | templateFn: importApiKeyTemplate, |
| | | }) |
| | | .open(); |
| | | } |
| | | |
| | | /** 编辑 API 密钥 */ |
| | |
| | | |
| | | <template> |
| | | <Page auto-content-height><FormModal @success="handleRefresh" /> |
| | | <ImportModal @success="handleRefresh" /> |
| | | <Grid table-title="API 密钥列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | |
| | | auth: ['ai:api-key:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.import', ['API 密钥']), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.UPLOAD, |
| | | auth: ['ai:api-key:import'], |
| | | onClick: handleImport, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |