Skip to content

Commit 55bc499

Browse files
committed
shortcuts and tsgo
1 parent a4c875d commit 55bc499

3 files changed

Lines changed: 58 additions & 7 deletions

File tree

bun.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"dev:local": "PUBLIC_API=http://localhost:9000 rsbuild dev",
77
"build": "NODE_ENV=production rsbuild build",
88
"preview": "rsbuild preview",
9-
"lint": "tsc --noEmit && biome check --write ."
9+
"typecheck": "tsgo --noEmit -p tsconfig.json",
10+
"lint": "tsgo --noEmit -p tsconfig.json && biome check --write ."
1011
},
1112
"dependencies": {
1213
"@ant-design/charts": "^2.6.7",
@@ -36,6 +37,7 @@
3637
"@types/react": "^19",
3738
"@types/react-dom": "^19",
3839
"@types/react-router-dom": "^5.3.3",
40+
"@typescript/native-preview": "^7.0.0-dev.20260330.1",
3941
"mitata": "^1.0.34",
4042
"tailwindcss": "^4.2.2",
4143
"typescript": "^6.0.2"

src/pages/admin-users.tsx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const tierLabelMap = new Map(
4444
tierOptions.map((option) => [option.value, option.label]),
4545
);
4646
const defaultPremiumQuotaText = JSON.stringify(quotas.premium, null, 2);
47+
const expiryShortcutDays = [7, 30, 365] as const;
4748

4849
// JSON Editor wrapper component for quota editing
4950
const JsonEditorWrapper = ({
@@ -187,6 +188,23 @@ export const Component = () => {
187188
}
188189
};
189190

191+
const handleExtendTierExpiry = (
192+
days: (typeof expiryShortcutDays)[number],
193+
) => {
194+
const currentValue = form.getFieldValue('tierExpiresAt');
195+
const currentExpiry = currentValue ? dayjs(currentValue) : null;
196+
const baseDate = currentExpiry?.isValid() ? currentExpiry : dayjs();
197+
198+
form.setFieldValue('tierExpiresAt', baseDate.add(days, 'day'));
199+
};
200+
201+
const handleResetTierExpiry = () => {
202+
form.setFieldValue(
203+
'tierExpiresAt',
204+
editingUser?.tierExpiresAt ? dayjs(editingUser.tierExpiresAt) : null,
205+
);
206+
};
207+
190208
const columns: ColumnsType<AdminUser> = [
191209
{
192210
title: 'ID',
@@ -335,12 +353,26 @@ export const Component = () => {
335353
]}
336354
/>
337355
</Form.Item>
338-
<Form.Item
339-
name="tierExpiresAt"
340-
label="套餐过期时间"
341-
className="mb-0!"
342-
>
343-
<DatePicker showTime className="w-full" />
356+
<Form.Item label="套餐过期时间" className="mb-0!">
357+
<Space direction="vertical" size="small" className="w-full">
358+
<Form.Item name="tierExpiresAt" noStyle>
359+
<DatePicker showTime className="w-full" />
360+
</Form.Item>
361+
<Space wrap size={[8, 8]}>
362+
{expiryShortcutDays.map((days) => (
363+
<Button
364+
key={days}
365+
size="small"
366+
onClick={() => handleExtendTierExpiry(days)}
367+
>
368+
+{days}
369+
</Button>
370+
))}
371+
<Button size="small" onClick={handleResetTierExpiry}>
372+
重置
373+
</Button>
374+
</Space>
375+
</Space>
344376
</Form.Item>
345377
<Form.Item
346378
label="自定义配额 (JSON,留空则使用默认配额)"

0 commit comments

Comments
 (0)