diff --git a/views/admin/share_manage.php b/views/admin/share_manage.php new file mode 100644 index 0000000..9780427 --- /dev/null +++ b/views/admin/share_manage.php @@ -0,0 +1,76 @@ +title = '文件分享管理'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ + 'attribute' => 'share_id', + 'headerOptions' => ['style' => 'width:6%;'], + ], + [ + 'attribute' => 'sharer_id', + 'label' => '分享者', + 'value' => function ($model) { + return $model->getSharerUsername() . ' (ID:' . $model->sharer_id . ')'; + }, + ], + [ + 'attribute' => 'file_relative_path', + ], + [ + 'attribute' => 'access_code', + 'enableSorting' => false, + 'headerOptions' => ['style' => 'width:7%;'], + ], + [ + 'attribute' => 'creation_date', + 'headerOptions' => ['style' => 'width:15%;'], + ], + [ + 'attribute' => 'status', + 'label' => '分享状态', + 'value' => function ($model) { + return $model->status == 1 ? '有效' : '失效'; + }, + 'filter' => [1 => '有效', 0 => '失效'], + ], + [ + 'attribute' => 'dl_count', + 'label' => '下载次数', + ], + [ + 'class' => ActionColumn::class, + 'template' => '{view} {delete}', // 只显示查看和删除按钮 + 'urlCreator' => function ($action, Share $model, $key, $index, $column) { + if ($action === 'view') { + // 返回查看按钮的链接 + return $model->status != 0 ? Url::toRoute(['share-manage-view', 'share_id' => $model->share_id]): null; + } elseif ($action === 'delete') { + // 如果 status 为 0,禁用删除按钮 + return $model->status != 0 ? Url::toRoute(['share-manage-delete', 'share_id' => $model->share_id]) : null; + } + } + ], + ], + ]); ?> + + +
diff --git a/views/admin/share_manage_view.php b/views/admin/share_manage_view.php new file mode 100644 index 0000000..6acaae5 --- /dev/null +++ b/views/admin/share_manage_view.php @@ -0,0 +1,69 @@ +title = '分享ID ' . $model->share_id; +$this->params['breadcrumbs'][] = ['label' => '文件分享管理', 'url' => ['share-manage']]; +$this->params['breadcrumbs'][] = $this->title; +YiiAsset::register($this); +JqueryAsset::register($this); +?> +
+ +

title) ?>

+ +

+ status != 0): ?> + 'btn btn-primary', 'id' => 'copy-link-button']) ?> + $model->share_id, 'access_code' => $model->access_code], ['class' => 'btn btn-primary', 'target' => '_blank']) ?> + $model->share_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => '确定要取消分享?', + 'method' => 'post', + ], + ]) ?> + + 'btn btn-primary disabled', 'id' => 'copy-link-button', 'aria-disabled' => 'true']) ?> + 'btn btn-primary disabled', 'target' => '_blank', 'aria-disabled' => 'true']) ?> + 'btn btn-danger disabled', + 'aria-disabled' => 'true' + ]) ?> + + + +

+ + $model, + 'attributes' => [ + 'share_id', + 'sharer_id', + 'file_relative_path', + 'access_code', + 'creation_date', + [ + 'attribute' => 'status', + 'label' => '分享状态', + 'value' => function ($model) { + return $model->status == 1 ? '有效' : '失效'; + }, + ], + [ + 'attribute' => 'dl_count', + ], + ], + ]) ?> + +
+registerJsFile('@web/js/share_view.js', ['depends' => [JqueryAsset::class], 'position' => View::POS_END]); +?>