lk
3 months ago
11 changed files with 269 additions and 47 deletions
-
19src/components/r-form/index.tsx
-
24src/components/r-form/utils/index.tsx
-
89src/i18n.ts
-
6src/locales/lang/zh-CN.ts
-
77src/pages/app/plugin/index.tsx
-
15src/pages/app/plugin/style.ts
-
12src/service/app/package.ts
-
42src/store/app/package.ts
-
27src/types/app/package.d.ts
-
3src/types/r-form/model.d.ts
-
2src/utils/index.ts
@ -0,0 +1,77 @@ |
|||
import {Button, Card, List, message, Select} from 'antd' |
|||
import React, {useState} from 'react' |
|||
import {useStyle} from './style' |
|||
import {useAtomValue} from "jotai"; |
|||
import {appAllListAtom, appPluginBuyAtom, appPluginListAtom} from "@/store/app/package.ts"; |
|||
import ListPageLayout from "@/layout/ListPageLayout.tsx"; |
|||
import {DollarOutlined} from "@ant-design/icons"; |
|||
import {APP} from "@/types/app/package"; |
|||
|
|||
const i18nPrefix = 'appPackages.list' |
|||
|
|||
const AppPackage = () => { |
|||
|
|||
const {styles, cx} = useStyle() |
|||
const {data} = useAtomValue(appPluginListAtom) |
|||
|
|||
const {mutate: buyPlugin, isPending: buyPending} = useAtomValue(appPluginBuyAtom) |
|||
const {data: allApp} = useAtomValue(appAllListAtom) |
|||
|
|||
const [whitelistApp, setWhitelistApp] = useState(0); |
|||
|
|||
const buy = (item: APP.IAppPlugin) => { |
|||
if (item.code == "traffic") { |
|||
buyPlugin({plugin_id: item.id, code: item.code}) |
|||
} else if (item.code == "whitelist") { |
|||
if (whitelistApp == 0) { |
|||
message.warning('请先选择应用') |
|||
return |
|||
} |
|||
buyPlugin({plugin_id: item.id, code: item.code, app_id: whitelistApp}) |
|||
} |
|||
} |
|||
|
|||
return ( |
|||
<ListPageLayout className={styles.container}> |
|||
<List |
|||
grid={{ |
|||
gutter: 16, |
|||
xs: 1, |
|||
sm: 2, |
|||
md: 2, |
|||
lg: 3, |
|||
xl: 4, |
|||
xxl: 6, |
|||
}} |
|||
dataSource={data?.rows} |
|||
renderItem={(item) => ( |
|||
<List.Item> |
|||
<Card |
|||
title={item.name} |
|||
style={{height: 400}} |
|||
styles={{body: {height: 300, overflow: 'hidden'}}} |
|||
actions={[ |
|||
item.code == "whitelist" ? ( |
|||
<Select placeholder="请选择应用"> |
|||
{allApp?.map((item) => ( |
|||
<option key={item.id} value={item.id}> |
|||
{item.app_name} |
|||
</option> |
|||
))}</Select> |
|||
) : null, |
|||
<Button type="primary" icon={<DollarOutlined/>} onClick={() => buy(item)} |
|||
loading={buyPending}> |
|||
月付 ${item.month_price} |
|||
</Button>, |
|||
]} |
|||
> |
|||
<p>{item.description}</p> |
|||
</Card> |
|||
</List.Item> |
|||
)} |
|||
/> |
|||
</ListPageLayout> |
|||
) |
|||
} |
|||
|
|||
export default AppPackage |
@ -0,0 +1,15 @@ |
|||
import { createStyles } from '@/theme' |
|||
|
|||
export const useStyle = createStyles(({ token, css, cx, prefixCls }, props: any) => { |
|||
const prefix = `${prefixCls}-${token?.proPrefix}-appPackage-plugin-page` |
|||
|
|||
const container = css`
|
|||
.zcss-kfly0u{ |
|||
background: transparent; |
|||
} |
|||
`
|
|||
|
|||
return { |
|||
container: cx(prefix, props?.className, container), |
|||
} |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue