Download apps/web-ele/src/views/source/index.vue from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 3.85 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-ele/src/views/source/index.vue
- Command line
-
hf download hf://spaces/binhugg3/admin/apps/web-ele/src/views/source/index.vue
-
curl -L -o index.vue https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-ele/src/views/source/index.vue
3.85 kB
| <script lang="ts" setup> | |
| import { onMounted, ref } from 'vue'; | |
| import { ElMessage, ElMessageBox } from 'element-plus'; | |
| import { requestClient } from '#/api/request'; | |
| const loading = ref(false); | |
| const tableData = ref([]); | |
| const total = ref(0); | |
| const page = ref(1); | |
| const pageSize = ref(20); | |
| async function fetchData() { | |
| loading.value = true; | |
| try { | |
| const data = await requestClient.get('/admin/source', { | |
| params: { page: page.value, page_size: pageSize.value }, | |
| }); | |
| tableData.value = data.list || []; | |
| total.value = data.total || 0; | |
| } finally { | |
| loading.value = false; | |
| } | |
| } | |
| async function handleTest(row: any) { | |
| try { | |
| const data = await requestClient.post(`/admin/source/${row.id}/test`); | |
| if (data.status === 'ok') { | |
| ElMessage.success( | |
| `连通成功,资源总数: ${data.total},分类数: ${data.category_count}`, | |
| ); | |
| } else { | |
| ElMessage.error(`连接失败: ${data.error}`); | |
| } | |
| } catch { | |
| ElMessage.error('测试失败'); | |
| } | |
| } | |
| async function handleToggleEnable(row: any) { | |
| try { | |
| const data = await requestClient.put(`/admin/source/${row.id}/enable`); | |
| row.is_active = data.is_active; | |
| ElMessage.success(data.is_active ? '已启用' : '已禁用'); | |
| } catch {} | |
| } | |
| async function handleSync(row: any) { | |
| try { | |
| await ElMessageBox.confirm( | |
| `确认同步 ${row.name} 的每日增量数据?`, | |
| '触发同步', | |
| ); | |
| const data = await requestClient.post('/admin/sync/trigger', undefined, { | |
| params: { range_type: 'daily', source_id: row.id }, | |
| }); | |
| ElMessage.success( | |
| `同步完成: 新增${data.new_vods}条,更新${data.updated_vods}条`, | |
| ); | |
| fetchData(); | |
| } catch {} | |
| } | |
| function handlePageChange(val: number) { | |
| page.value = val; | |
| fetchData(); | |
| } | |
| onMounted(fetchData); | |
| </script> | |
| <template> | |
| <div class="p-4"> | |
| <div class="mb-4 flex items-center justify-between"> | |
| <h2 class="text-lg font-semibold">资源站管理</h2> | |
| </div> | |
| <el-table :data="tableData" border stripe v-loading="loading"> | |
| <el-table-column label="ID" prop="id" width="60" /> | |
| <el-table-column label="站点名称" prop="name" width="120" /> | |
| <el-table-column label="编码" prop="code" width="80" /> | |
| <el-table-column | |
| label="API地址" | |
| min-width="200" | |
| prop="base_url" | |
| show-overflow-tooltip | |
| /> | |
| <el-table-column label="M3U8来源" prop="play_from_m3u8" width="120" /> | |
| <el-table-column label="云播来源" prop="play_from_yun" width="120" /> | |
| <el-table-column label="状态" width="80"> | |
| <template #default="{ row }"> | |
| <el-tag :type="row.is_active ? 'success' : 'info'" size="small"> | |
| {{ row.is_active ? '启用' : '禁用' }} | |
| </el-tag> | |
| </template> | |
| </el-table-column> | |
| <el-table-column label="同步状态" prop="last_sync_status" width="100" /> | |
| <el-table-column label="新增数" prop="last_sync_count" width="80" /> | |
| <el-table-column fixed="right" label="操作" width="260"> | |
| <template #default="{ row }"> | |
| <el-button size="small" @click="handleTest(row)">测试</el-button> | |
| <el-button | |
| :type="row.is_active ? 'warning' : 'success'" | |
| size="small" | |
| @click="handleToggleEnable(row)" | |
| > | |
| {{ row.is_active ? '禁用' : '启用' }} | |
| </el-button> | |
| <el-button size="small" type="primary" @click="handleSync(row)"> | |
| 同步 | |
| </el-button> | |
| </template> | |
| </el-table-column> | |
| </el-table> | |
| <div class="mt-4 flex justify-end"> | |
| <el-pagination | |
| :current-page="page" | |
| :page-size="pageSize" | |
| :total="total" | |
| layout="total, prev, pager, next" | |
| @current-change="handlePageChange" | |
| /> | |
| </div> | |
| </div> | |
| </template> | |