Skip to content

Commit

Permalink
文件管理调整
Browse files Browse the repository at this point in the history
  • Loading branch information
WangNingkai committed Jul 14, 2020
1 parent ba62e5d commit 7f4d5dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
27 changes: 25 additions & 2 deletions app/Http/Controllers/ManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public function query(Request $request, $hash, $query = '')
$perPage = array_get($config, 'list_limit', 10);

$list = $this->paginate($list, $perPage, false);

return view(config('olaindex.theme') . 'admin.file-manage', compact('accounts', 'hash', 'path', 'item', 'list', 'doc'));
}

Expand Down Expand Up @@ -163,7 +162,7 @@ public function edit(Request $request, $hash, $query = '')
$content = '';
}

$file['content'] = $content;
$file['content'] = $content;;
return view(config('olaindex.theme') . 'editor', compact('accounts', 'hash', 'path', 'file'));
}

Expand Down Expand Up @@ -200,6 +199,30 @@ public function create(Request $request, $hash, $query = '')
return redirect()->route('home');
}

public function delete(Request $request, $hash, $query = '')
{
$accounts = Cache::remember('ac:list', 600, static function () {
return Account::query()
->select(['id', 'remark'])
->where('status', 1)->get();
});
if (blank($accounts)) {
Cache::forget('ac:list');
abort(404, '请先绑定账号!');
}
$account_id = HashidsHelper::decode($hash);
if (!$account_id) {
abort(404, '账号不存在');
}
$service = OneDrive::account($account_id);
$eTag = $request->get('eTag');
$resp = $service->delete($query, $eTag);
if (array_key_exists('code', $resp)) {
$this->showMessage(array_get($resp, 'message', '404NotFound'), true);
}
return redirect()->back();
}

/**
* 过滤
* @param array $list
Expand Down
7 changes: 6 additions & 1 deletion resources/views/default/admin/file-manage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class="ri-arrow-go-back-fill"></i> 返回</a>
<td class="d-none d-md-block d-md-none">{{ convert_size($data['size']) }}</td>
<td>{{ date('Y-m-d H:i:s', strtotime($data['lastModifiedDateTime'])) }}</td>
<td>
-
<a href="#" style="text-decoration: none">删除</a>
@if(!array_has($data,'folder'))
{{--todo:加密隐藏--}}
@endif
</td>
</tr>
@endforeach
Expand Down Expand Up @@ -85,6 +88,8 @@ class="ri-arrow-go-back-fill"></i> 返回</a>
<a class="dropdown-item"
href="{{ route('admin.file.edit', ['hash' => $hash, 'query' => $doc['head']['id']]) }}">编辑HEAD</a>
@endif
{{--todo:加密隐藏--}}
<a class="dropdown-item" href="#">删除</a>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
Route::any('manage/{hash}/q/{query?}', 'ManageController@query')->name('admin.file.manage');
Route::any('manage/{hash}/edit/{query?}', 'ManageController@edit')->name('admin.file.edit');
Route::any('manage/{hash}/create/{query?}', 'ManageController@create')->name('admin.file.create');
Route::any('manage/{hash}/delete/{query?}', 'ManageController@delete')->name('admin.file.delete');
});
// 短网址
Route::get('t/{code}', 'IndexController')->name('short');
Expand Down

0 comments on commit 7f4d5dd

Please sign in to comment.