From e1a30e25ec0f9c545aa41cc89657b6f7406b1b41 Mon Sep 17 00:00:00 2001 From: dark Date: Fri, 6 Sep 2024 23:33:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E5=96=84RForm=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0i18n=E5=9B=BD=E9=99=85=E5=8C=96=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/r-form/index.tsx | 19 ++++---- src/components/r-form/utils/index.tsx | 24 ++++++++-- src/i18n.ts | 89 ++++++++++++++++++++++------------- src/locales/lang/zh-CN.ts | 6 +++ src/types/r-form/model.d.ts | 3 ++ src/utils/index.ts | 2 + 6 files changed, 96 insertions(+), 47 deletions(-) diff --git a/src/components/r-form/index.tsx b/src/components/r-form/index.tsx index 4c9a3cf..41dcc30 100644 --- a/src/components/r-form/index.tsx +++ b/src/components/r-form/index.tsx @@ -14,6 +14,7 @@ import { useApiContext } from '@/context.ts' import { useDeepCompareEffect } from 'react-use' import { RFormTypes } from '@/types/r-form/model' import { ProCoreActionType } from '@ant-design/pro-utils/es/typing' +import { getI18nTitle } from '@/i18n.ts' export interface RFormProps { @@ -66,7 +67,7 @@ const RForm = ( useDeepCompareEffect(() => { - let res = transformAntdTableProColumns(curdModal?.columns || [], propColumns) + let res = transformAntdTableProColumns(curdModal?.columns || [], propColumns, curdModal?.config?.i18n) if (resolveColumns) { res = resolveColumns(res) } @@ -101,7 +102,7 @@ const RForm = ( formItemProps: { hidden: true } } ].concat(res as any).concat([ { - title: '操作', + title: getI18nTitle(curdModal?.config?.i18n, { dataIndex: 'option', title: '操作' },), dataIndex: 'option', valueType: 'option', fixed: 'right', @@ -114,7 +115,7 @@ const RForm = ( } as any ]) setColumns(_columns) - }, [ curdModal?.columns, propColumns, renderColumnOptions, resolveColumns, deleteModel, form, isDeleting, setOpen, ]) + }, [ curdModal?.columns, curdModal?.config?.i18n, propColumns, renderColumnOptions, resolveColumns, deleteModel, form, isDeleting, setOpen, ]) useEffect(() => { if (apiCtx.isApi && apiCtx.api) { @@ -170,7 +171,7 @@ const RForm = ( }) setOpen(true) }} - type={'primary'}>{'添加'} + type={'primary'}>{getI18nTitle('actions.add','添加')} const _renderActions = () => { @@ -209,7 +210,7 @@ const RForm = ( placeholder: '输入关键字搜索', },*/ actions: [ - + , + ]} + > +

{item.description}

+ + + )} + /> + + ) +} + +export default AppPackage \ No newline at end of file diff --git a/src/pages/app/plugin/style.ts b/src/pages/app/plugin/style.ts new file mode 100644 index 0000000..6255d3b --- /dev/null +++ b/src/pages/app/plugin/style.ts @@ -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), + } +}) \ No newline at end of file diff --git a/src/service/app/package.ts b/src/service/app/package.ts index 602bf19..844039f 100644 --- a/src/service/app/package.ts +++ b/src/service/app/package.ts @@ -28,6 +28,18 @@ const appPackage = { getPkgStatus: async (params: any) => { return await request.get(`/package/status`, { ...params }) }, + + getPluginList: async () => { + return await request.get>(`/package/plugin/list`) + }, + + getAppAllList: async () => { + return await request.get>(`/package/allList`) + }, + + buyPlugin: async (params: any) => { + return await request.post(`/package/plugin/buy`, { ...params }) + }, } export default appPackage \ No newline at end of file diff --git a/src/store/app/package.ts b/src/store/app/package.ts index 8ae35b4..9627e00 100644 --- a/src/store/app/package.ts +++ b/src/store/app/package.ts @@ -114,3 +114,45 @@ export const packageAppAtom = atomWithMutation((get) => { } } }) + +/** + * 插件列表 + */ +export const appPluginListAtom = atomWithQuery(() => { + return { + queryKey: [ 'appPlugin' ], + queryFn: async ({ queryKey: [ , ] }) => { + const list = await aPPServ.getPluginList() + return list.data + } + } +}) + +/** + * 插件购买 + */ +export const appPluginBuyAtom = atomWithMutation(() => { + return { + mutationKey: [ 'appPlugin' ], + mutationFn: async (param: any) => { + const list = await aPPServ.buyPlugin(param) + return list.data + }, + onSuccess: () => { + message.success('购买成功') + } + } +}) + +/** + * 获取所有应用 + */ +export const appAllListAtom = atomWithQuery(() => { + return { + queryKey: [ 'appAllList' ], + queryFn: async ({ queryKey: [ , ] }) => { + const list = await aPPServ.getAppAllList() + return list.data.list + } + } +}) diff --git a/src/types/app/package.d.ts b/src/types/app/package.d.ts index 6def281..c1002a4 100644 --- a/src/types/app/package.d.ts +++ b/src/types/app/package.d.ts @@ -32,6 +32,13 @@ export namespace APP { } /** + * Bool类型返回结果 + */ + export interface IBaseArrRes { + list: T[]; + } + + /** * 打包状态 */ export interface IAppPkgStatus { @@ -44,4 +51,24 @@ export namespace APP { position: number; total: number; } + + /** + * 打包状态 + */ + export interface IAppPlugin { + id: number; + name: string; + description: string; + status: number; + month_price: number; + quarter_price: number; + half_year_price: number; + year_price: number; + two_year_price: number; + three_year_price: number; + onetime_price: number; + reset_price: number; + extra: number; //备用字段,如果是流量套餐则是流量额度 + code: string; + } } \ No newline at end of file