mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-06-28 10:41:33 +08:00
feat: add expired share cleanup functionality
This commit is contained in:
@@ -23,10 +23,15 @@ export interface ShareCreatePayload {
|
||||
password?: string;
|
||||
}
|
||||
|
||||
export interface ClearExpiredResult {
|
||||
deleted_count: number;
|
||||
}
|
||||
|
||||
export const shareApi = {
|
||||
create: (payload: ShareCreatePayload) => request<ShareInfoWithPassword>('/shares', { method: 'POST', json: payload }),
|
||||
list: () => request<ShareInfo[]>('/shares'),
|
||||
remove: (shareId: number) => request<void>(`/shares/${shareId}`, { method: 'DELETE' }),
|
||||
clearExpired: () => request<ClearExpiredResult>(`/shares/expired`, { method: 'DELETE' }),
|
||||
get: (token: string) => request<ShareInfo>(`/s/${token}`),
|
||||
verifyPassword: (token: string, password: string) => request<void>(`/s/${token}/verify`, { method: 'POST', json: { password } }),
|
||||
listDir: (token: string, path: string = '/', password?: string) => {
|
||||
@@ -40,4 +45,4 @@ export const shareApi = {
|
||||
const url = `${API_BASE_URL}/s/${token}/download?path=${encodeURIComponent(path)}`;
|
||||
return password ? `${url}&password=${encodeURIComponent(password)}` : url;
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -53,6 +53,9 @@ export const en = {
|
||||
'Cancel failed': 'Cancel failed',
|
||||
'Load failed': 'Load failed',
|
||||
'Are you sure to cancel share?': 'Are you sure to cancel share?',
|
||||
'Clear expired shares': 'Clear expired shares',
|
||||
'Confirm clear expired shares?': 'Confirm clear expired shares?',
|
||||
'Cleared {count} expired shares': 'Cleared {count} expired shares',
|
||||
|
||||
'Share Name': 'Share Name',
|
||||
'Share Content': 'Share Content',
|
||||
|
||||
@@ -25,7 +25,7 @@ export const zh = {
|
||||
'Account Settings': '账户设置',
|
||||
'Language': '语言',
|
||||
'Chinese': '中文',
|
||||
'English': '英文',
|
||||
'English': 'English',
|
||||
'Full Name': '昵称',
|
||||
'Email': '邮箱',
|
||||
'Change Password': '修改密码',
|
||||
@@ -57,6 +57,9 @@ export const zh = {
|
||||
'Cancel failed': '取消失败',
|
||||
'Load failed': '加载失败',
|
||||
'Are you sure to cancel share?': '确认取消分享?',
|
||||
'Clear expired shares': '清空过期分享',
|
||||
'Confirm clear expired shares?': '确认清空过期分享?',
|
||||
'Cleared {count} expired shares': '已清理 {count} 个过期分享',
|
||||
'Share Name': '分享名称',
|
||||
'Share Content': '分享内容',
|
||||
'Created At': '创建时间',
|
||||
|
||||
@@ -44,6 +44,16 @@ const SharePage = memo(function SharePage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearExpired = async () => {
|
||||
try {
|
||||
const res = await shareApi.clearExpired();
|
||||
message.success(t('Cleared {count} expired shares', { count: String(res.deleted_count) }));
|
||||
fetchList();
|
||||
} catch (e: any) {
|
||||
message.error(e.message || t('Clear failed'));
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t('Share Name'),
|
||||
@@ -100,7 +110,14 @@ const SharePage = memo(function SharePage() {
|
||||
return (
|
||||
<PageCard
|
||||
title={t('My Shares')}
|
||||
extra={<Button onClick={fetchList} loading={loading}>{t('Refresh')}</Button>}
|
||||
extra={
|
||||
<Space>
|
||||
<Button onClick={fetchList} loading={loading}>{t('Refresh')}</Button>
|
||||
<Popconfirm title={t('Confirm clear expired shares?')} onConfirm={handleClearExpired}>
|
||||
<Button danger>{t('Clear expired shares')}</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
rowKey="id"
|
||||
|
||||
Reference in New Issue
Block a user