From e448cf6c6bfbd39a3f27b39431c3e3d7f0d24e29 Mon Sep 17 00:00:00 2001 From: lq1405 <2769838458@qq.com> Date: Thu, 15 May 2025 14:05:03 +0800 Subject: [PATCH] v 1.0.8 --- config/routes.ts | 20 ++ src/locales/zh-CN/menu.ts | 5 + .../BasicOptions/ResetFreeCountOption.tsx | 83 ++++++ .../LaitoolOptions/BasicOptions/index.tsx | 12 +- src/pages/Other/DataInfo/index.tsx | 221 +++++++++++++++ .../AddMachineIdAuthorization.tsx | 255 ++++++++++++++++++ .../Other/MachineIdAuthorization/index.tsx | 250 +++++++++++++++++ .../Prompt/PromptManagement/Untitled-2.ini | 44 --- .../SofrwareControlManagement.tsx | 1 - src/pages/User/Register/index.tsx | 2 - src/pages/User/ResetPassword/index.tsx | 1 - src/pages/User/UserCenter/ModifyPassword.tsx | 1 - src/services/enum/dataInfo.ts | 36 +++ src/services/enum/machineAuthorizationEnum.ts | 36 +++ src/services/enum/optionEnum.ts | 6 + src/services/services/machine.ts | 1 - src/services/services/options/optionsTool.ts | 4 +- src/services/services/software.ts | 1 - src/services/typing/dataInfo.d.ts | 17 ++ src/services/typing/machineAuthorization.d.ts | 23 ++ tsconfig.json | 2 +- 21 files changed, 964 insertions(+), 57 deletions(-) create mode 100644 src/pages/Options/LaitoolOptions/BasicOptions/ResetFreeCountOption.tsx create mode 100644 src/pages/Other/DataInfo/index.tsx create mode 100644 src/pages/Other/MachineIdAuthorization/AddMachineIdAuthorization.tsx create mode 100644 src/pages/Other/MachineIdAuthorization/index.tsx delete mode 100644 src/pages/Prompt/PromptManagement/Untitled-2.ini create mode 100644 src/services/enum/dataInfo.ts create mode 100644 src/services/enum/machineAuthorizationEnum.ts create mode 100644 src/services/typing/dataInfo.d.ts create mode 100644 src/services/typing/machineAuthorization.d.ts diff --git a/config/routes.ts b/config/routes.ts index 0188c33..0ce0ff4 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -111,6 +111,26 @@ export default [ access: 'canSofrwareControlManagement', component: './Software/SofrwareControl/SofrwareControlManagement', }, + { + name: 'other', + path: '/other', + icon: 'Profile', + access: 'canSystemOptions', + routes: [ + { + name: 'machine-id-authorization', + path: '/other/machine-id-authorization', + component: './Other/MachineIdAuthorization/index', + access: 'canSystemOptions', + }, + { + name: 'data-info', + path: '/other/data-info', + component: './Other/DataInfo/index', + access: 'canSystemOptions', + } + ] + }, { path: '/', redirect: '/welcome', diff --git a/src/locales/zh-CN/menu.ts b/src/locales/zh-CN/menu.ts index 22f8d17..6ea7047 100644 --- a/src/locales/zh-CN/menu.ts +++ b/src/locales/zh-CN/menu.ts @@ -18,6 +18,11 @@ export default { 'menu.machineManagement': '机器码管理', 'menu.sofrwareControlManagement': '软件控制管理', + + 'menu.other': '其他管理', + 'menu.other.machine-id-authorization': '机器码授权', + 'menu.other.data-info': '数据信息', + 'menu.more-blocks': '更多区块', 'menu.home': '首页', 'menu.admin': '管理页', diff --git a/src/pages/Options/LaitoolOptions/BasicOptions/ResetFreeCountOption.tsx b/src/pages/Options/LaitoolOptions/BasicOptions/ResetFreeCountOption.tsx new file mode 100644 index 0000000..569dadf --- /dev/null +++ b/src/pages/Options/LaitoolOptions/BasicOptions/ResetFreeCountOption.tsx @@ -0,0 +1,83 @@ +import React, { useEffect } from 'react'; +import { Form, Card, Row, Col, InputNumber, Button, message, Switch } from 'antd'; +import { useSoftStore } from '@/store/software'; +import { GetOptions, getOptionsStringValue, getOptionsValue, SaveOptions } from '@/services/services/options/optionsTool'; +import { AllOptionKeyName, OptionKeyName } from '@/services/enum/optionEnum'; + +interface ResetFreeCountOptionsProps { + visible?: boolean; +} + +const ResetFreeCountOption: React.FC = ({ visible }) => { + const [form] = Form.useForm(); + const { setTopSpinning, setTopSpinTip } = useSoftStore(); + const [messageApi, messageHolder] = message.useMessage(); + + useEffect(() => { + if (!visible) return; + setTopSpinning(true); + setTopSpinTip("加载信息中"); + GetOptions(AllOptionKeyName.ResetFreeCount).then((res) => { + form.setFieldsValue(getOptionsValue(res, OptionKeyName.ResetFreeCountSetting, { + onceFreeCount: 5, + enableMonthlyReset: true + })); + }).catch((err: any) => { + messageApi.error(err.message); + }).finally(() => { + setTopSpinning(false); + }); + }, [visible]); + + const onFinish = async (values: any) => { + setTopSpinning(true); + setTopSpinTip("正在保存重置设置"); + try { + // 将boolean转为字符串 + const saveValues = { + [OptionKeyName.ResetFreeCountSetting]: JSON.stringify(values) + }; + await SaveOptions(saveValues); + messageApi.success('保存免费次数重置设置成功'); + } catch (error: any) { + messageApi.error(error.message); + } finally { + setTopSpinning(false); + } + } + + return ( + +
+ + + + + + + + + + + + + + + +
+ + {messageHolder} +
+ ); +}; + +export default ResetFreeCountOption; + diff --git a/src/pages/Options/LaitoolOptions/BasicOptions/index.tsx b/src/pages/Options/LaitoolOptions/BasicOptions/index.tsx index 12fa4d0..e7df30a 100644 --- a/src/pages/Options/LaitoolOptions/BasicOptions/index.tsx +++ b/src/pages/Options/LaitoolOptions/BasicOptions/index.tsx @@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react'; import SimpleOptions from './SimpleOptions'; import TrailOptions from './TrialOptions'; import ImageOptions from './ImageOptions'; +import ResetFreeCountOption from './ResetFreeCountOption'; const DubSetting: React.FC = () => { @@ -17,14 +18,21 @@ const DubSetting: React.FC = () => { key: 'simpleOptions', label: 通用配置, children: , - }, { + }, + { key: 'trailOptions', label: 试用设置, children: , - }, { + }, + { key: 'imageOptions', label: 绘图设置, children: , + }, + { + key: 'freeCountResetOptions', + label: 重置换绑设置, + children: , } ]; diff --git a/src/pages/Other/DataInfo/index.tsx b/src/pages/Other/DataInfo/index.tsx new file mode 100644 index 0000000..0765643 --- /dev/null +++ b/src/pages/Other/DataInfo/index.tsx @@ -0,0 +1,221 @@ +import React, { useState, useEffect } from 'react'; +import { Table, Button, message, Space, Spin, Form, Input, Select, Modal } from 'antd'; +import TemplateContainer from '@/pages/TemplateContainer'; +import { request, useModel } from '@umijs/max'; +import { objectToQueryString } from '@/services/services/common'; +import { GetDataInfoTypeOption, GetDataInfoTypeOptions } from '@/services/enum/dataInfo'; +import { SearchOutlined } from '@ant-design/icons'; +import { ColumnsType } from 'antd/lib/table'; +import JsonView from '@uiw/react-json-view'; + +const DataInfo: React.FC = () => { + const [loading, setLoading] = useState(false); + const [dataList, setDataList] = useState([]); + const { initialState } = useModel('@@initialState'); + const [messageApi, messageHolder] = message.useMessage(); + const [form] = Form.useForm(); + + const [tableParams, setTableParams] = useState({ + pagination: { + current: 1, + pageSize: 10, + showQuickJumper: true, + totalBoundaryShowSizeChanger: true, + }, + }); + + useEffect(() => { + QueryDataInfoCollection(tableParams, form.getFieldsValue()); + }, []); + + async function QueryDataInfoCollection(tableParams: TableModel.TableParams, options?: any) { + try { + setLoading(true); + let data = { + ...options, + page: tableParams.pagination?.current, + pageSize: tableParams.pagination?.pageSize, + }; + let query = objectToQueryString(data); + let res = await request>(`/lms/Other/QueryDataInfoCollection?${query}`, { + method: 'GET', + }); + if (res.code != 1) { + throw new Error(res.message); + } + let resData = res.data; + setDataList(resData.collection); + setTableParams({ + pagination: { + ...tableParams.pagination, + total: resData.total, + }, + }); + messageApi.success('Data fetched successfully'); + } catch (error: any) { + messageApi.error(error.message); + } finally { + setLoading(false); + } + } + + const [isModalVisible, setIsModalVisible] = useState(false); + const [currentJsonData, setCurrentJsonData] = useState(null); + const [isJsonFormat, setIsJsonFormat] = useState(false); + + function CheckJson(str: string) { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; + } + + // Function to handle clicking on data + const handleDataClick = (dataString: string) => { + let isJsonString = CheckJson(dataString); + + if (isJsonString) { + const jsonData = JSON.parse(dataString); + setCurrentJsonData(jsonData); + setIsJsonFormat(true); + } else { + // 不是JSON格式,直接展示原始字符串 + setCurrentJsonData(dataString); + setIsJsonFormat(false); + } + setIsModalVisible(true); + }; + + // 关闭Modal的函数 + const handleModalClose = () => { + setIsModalVisible(false); + setCurrentJsonData(null); + }; + + const columns: ColumnsType = [ + { + title: 'ID', + dataIndex: 'id', + key: 'id', + }, + { + title: '类型', + dataIndex: 'type', + key: 'type', + render: (text, record) => GetDataInfoTypeOption(record.type), + }, + { + title: '数据字符串', + dataIndex: 'dataString', + key: 'dataString', + width: 250, + ellipsis: { + showTitle: false, + }, + render: (text) => ( + handleDataClick(text)} style={{ cursor: 'pointer', color: 'black' }}> + {text} + + ), + }, + { + title: '创建时间', + dataIndex: 'createdTime', + key: 'createdTime', + width: 180, + }, + { + title: 'Actions', + key: 'actions', + render: (_: any) => ( + + + + ), + }, + ]; + + return ( + + +
QueryDataInfoCollection(tableParams, values)} + style={{ marginBottom: 16 }} + > + {/* + + + + + + */} + + + + + + + + + + + + + + + + + +