|
|
@ -20,8 +20,8 @@ |
|
|
<t-space :size="4"> |
|
|
<t-space :size="4"> |
|
|
<t-button size="small" variant="text" @click="openEditDialog(row)">编辑</t-button> |
|
|
<t-button size="small" variant="text" @click="openEditDialog(row)">编辑</t-button> |
|
|
<t-button size="small" variant="text" @click="openRoleDialog(row)">绑定角色</t-button> |
|
|
<t-button size="small" variant="text" @click="openRoleDialog(row)">绑定角色</t-button> |
|
|
<t-button v-if="row.enabled" size="small" variant="text" theme="danger" @click="doRevoke(row.id)">吊销</t-button> |
|
|
|
|
|
<t-button v-else size="small" variant="text" theme="success" @click="doEnable(row.id)">启用</t-button> |
|
|
|
|
|
|
|
|
<t-button v-show="row.enabled" size="small" variant="text" theme="danger" @click="doRevoke(row.id)">吊销</t-button> |
|
|
|
|
|
<t-button v-show="!row.enabled" size="small" variant="text" theme="success" @click="doEnable(row.id)">启用</t-button> |
|
|
<t-button size="small" variant="text" theme="danger" @click="doDelete(row.id)">删除</t-button> |
|
|
<t-button size="small" variant="text" theme="danger" @click="doDelete(row.id)">删除</t-button> |
|
|
</t-space> |
|
|
</t-space> |
|
|
</template> |
|
|
</template> |
|
|
@ -44,7 +44,7 @@ |
|
|
|
|
|
|
|
|
<div class="dialog-footer"> |
|
|
<div class="dialog-footer"> |
|
|
<t-button variant="outline" @click="showCreateDialog=false">关闭</t-button> |
|
|
<t-button variant="outline" @click="showCreateDialog=false">关闭</t-button> |
|
|
<t-button theme="primary" @click="doCreate" :disabled="!form.name">创建</t-button> |
|
|
|
|
|
|
|
|
<t-button theme="primary" @click="doCreate" :loading="creating" :disabled="!form.name || creating">创建</t-button> |
|
|
</div> |
|
|
</div> |
|
|
</t-dialog> |
|
|
</t-dialog> |
|
|
|
|
|
|
|
|
@ -86,7 +86,7 @@ import { useConfirm } from '@/composables/useConfirm' |
|
|
|
|
|
|
|
|
const { confirm } = useConfirm() |
|
|
const { confirm } = useConfirm() |
|
|
|
|
|
|
|
|
const keys=ref<any[]>([]);const loading=ref(false);const page=ref(1);const pageSize=ref(20);const total=ref(0) |
|
|
|
|
|
|
|
|
const keys=ref<any[]>([]);const loading=ref(false);const creating=ref(false);const page=ref(1);const pageSize=ref(20);const total=ref(0) |
|
|
const showCreateDialog=ref(false);const showRoleDialog=ref(false) |
|
|
const showCreateDialog=ref(false);const showRoleDialog=ref(false) |
|
|
const showEditDialog=ref(false) |
|
|
const showEditDialog=ref(false) |
|
|
const editingKeyId=ref<any>(null);const editingKeyName=ref('') |
|
|
const editingKeyId=ref<any>(null);const editingKeyName=ref('') |
|
|
@ -110,7 +110,7 @@ async function loadRoles(){try{const r=await getAllRoles();if(r.success)allRoles |
|
|
|
|
|
|
|
|
function openCreateDialog(){createdKey.value='';form.value={name:'',description:'',rateLimit:60};showCreateDialog.value=true} |
|
|
function openCreateDialog(){createdKey.value='';form.value={name:'',description:'',rateLimit:60};showCreateDialog.value=true} |
|
|
|
|
|
|
|
|
async function doCreate(){try{const r=await createApiKey(form.value);if(r.success){createdKey.value=r.data?.apiKey||r.data?.key||'';toast('创建成功','success');loadList()}else toast(r.message||'创建失败','error')}catch(e:any){toast('创建失败:'+e.message,'error')}} |
|
|
|
|
|
|
|
|
async function doCreate(){if(creating.value)return;creating.value=true;try{const r=await createApiKey(form.value);if(r.success){createdKey.value=r.data?.apiKey||r.data?.key||r.data?.keyValue||'';toast('创建成功,请复制 Key','success');loadList()}else toast(r.message||'创建失败','error')}catch(e:any){toast('创建失败:'+e.message,'error')}finally{creating.value=false}} |
|
|
|
|
|
|
|
|
async function doRevoke(id:string){if(!await confirm('确定吊销?'))return;try{const r=await revokeApiKey(id);if(r.success){toast('已吊销','success');loadList()}else toast(r.message||'吊销失败','error')}catch(e:any){toast('吊销失败:'+e.message,'error')}} |
|
|
async function doRevoke(id:string){if(!await confirm('确定吊销?'))return;try{const r=await revokeApiKey(id);if(r.success){toast('已吊销','success');loadList()}else toast(r.message||'吊销失败','error')}catch(e:any){toast('吊销失败:'+e.message,'error')}} |
|
|
|
|
|
|
|
|
|