修改请求重试,修改所有的request方法
添加部分权限控制
完善软件授权码设置
This commit is contained in:
lq1405 2025-05-16 17:51:58 +08:00
parent e448cf6c6b
commit 79479bfdc5
36 changed files with 954 additions and 351 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "lms", "name": "lms",
"version": "1.0.6", "version": "1.0.8",
"private": true, "private": true,
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"scripts": { "scripts": {

View File

@ -14,20 +14,32 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
isAdmin: false, isAdmin: false,
isSuperAdmin: false, isSuperAdmin: false,
isAdminOrSuperAdmin: false, isAdminOrSuperAdmin: false,
isAgentUser: false,
canOptions: false, canOptions: false,
canLaiToolOptions : false, canLaiToolOptions: false,
canSystemOptions : false, canSystemOptions: false,
canApplySoftwareControl: false,
canSofrwareControlManagement: false,
canMachineManagement: false, canMachineManagement: false,
canAddMachine: true, canAddMachine: true,
canEditMachine: false, canEditMachine: false,
canDeleteMachine: false, canDeleteMachine: false,
canUpgradeMachine: true, canUpgradeMachine: true,
canDisableMachine: true canDisableMachine: true,
canApplySoftwareControl: false,
canSofrwareControlManagement: false,
canEditSoftwareControl: false,
canAddTrailSoftwareControl: false,
canAddMouthSoftwareControl: false,
canAddQuarterlySoftwareControl: false,
canAddHalfYearSoftwareControl: false,
canAddYearSoftwareControl: false,
canAddForeverSoftwareControl: false,
canDeleteSoftwareControl: false,
} as AccessType.AccessType; } as AccessType.AccessType;
// 更具用户角色返回权限 // 更具用户角色返回权限
@ -54,7 +66,20 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
canMachineManagement: true, canMachineManagement: true,
canUpgradeMachine: true, canUpgradeMachine: true,
isAgentUser: true,
canSofrwareControlManagement: true, canSofrwareControlManagement: true,
canApplySoftwareControl: true,
canEditSoftwareControl: false,
canAddTrailSoftwareControl: false,
canAddMouthSoftwareControl: true,
canAddQuarterlySoftwareControl: false,
canAddHalfYearSoftwareControl: false,
canAddYearSoftwareControl: false,
canAddForeverSoftwareControl: true,
canDeleteSoftwareControl: false,
} }
} }
@ -70,8 +95,8 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
isAdminOrSuperAdmin: true, isAdminOrSuperAdmin: true,
canOptions: true, canOptions: true,
canLaiToolOptions : true, canLaiToolOptions: true,
canSystemOptions : false, canSystemOptions: false,
canMachineManagement: true, canMachineManagement: true,
canEditMachine: true, canEditMachine: true,
@ -79,11 +104,19 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
canUpgradeMachine: true, canUpgradeMachine: true,
canApplySoftwareControl: true, canApplySoftwareControl: true,
canSofrwareControlManagement: true canSofrwareControlManagement: true,
canEditSoftwareControl: true,
canAddTrailSoftwareControl: true,
canAddMouthSoftwareControl: true,
canAddQuarterlySoftwareControl: true,
canAddHalfYearSoftwareControl: true,
canAddYearSoftwareControl: true,
canAddForeverSoftwareControl: true,
canDeleteSoftwareControl: true,
} }
} }
if (currentUser?.roleNames?.includes("Super Admin")) { if (currentUser?.roleNames?.includes("Super Admin") || currentUser?.id == "4") {
return { return {
...access, ...access,
canPrompt: true, canPrompt: true,
@ -97,8 +130,8 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
isAdminOrSuperAdmin: true, isAdminOrSuperAdmin: true,
canOptions: true, canOptions: true,
canLaiToolOptions : true, canLaiToolOptions: true,
canSystemOptions : true, canSystemOptions: true,
canMachineManagement: true, canMachineManagement: true,
canEditMachine: true, canEditMachine: true,
@ -106,7 +139,15 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
canUpgradeMachine: true, canUpgradeMachine: true,
canApplySoftwareControl: true, canApplySoftwareControl: true,
canSofrwareControlManagement: true canSofrwareControlManagement: true,
canEditSoftwareControl: true,
canAddTrailSoftwareControl: true,
canAddMouthSoftwareControl: true,
canAddQuarterlySoftwareControl: true,
canAddHalfYearSoftwareControl: true,
canAddYearSoftwareControl: true,
canAddForeverSoftwareControl: true,
canDeleteSoftwareControl: true,
}; };
} }
console.log("accsee", access); console.log("accsee", access);

View File

@ -3,13 +3,14 @@ import { LinkOutlined } from '@ant-design/icons';
import type { Settings as LayoutSettings } from '@ant-design/pro-components'; import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import { SettingDrawer } from '@ant-design/pro-components'; import { SettingDrawer } from '@ant-design/pro-components';
import type { RunTimeLayoutConfig } from '@umijs/max'; import type { RunTimeLayoutConfig } from '@umijs/max';
import { history, Link, request as q } from '@umijs/max'; import { history, Link } from '@umijs/max';
import defaultSettings from '../config/defaultSettings'; import defaultSettings from '../config/defaultSettings';
import { errorConfig } from './requestErrorConfig'; import { errorConfig } from './requestErrorConfig';
import { UserInfo, getCurrentUser as queryCurrentUser } from './services/services/user'; import { UserInfo, getCurrentUser as queryCurrentUser } from './services/services/user';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { TokenStorage } from './services/define/tokenStorage'; import { TokenStorage } from './services/define/tokenStorage';
import { App, ConfigProvider } from 'antd'; import { App, ConfigProvider } from 'antd';
import cusRequest from './request';
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login'; const loginPath = '/user/login';
@ -37,7 +38,11 @@ export async function getInitialState(): Promise<{
const msg = await queryCurrentUser(id, { const msg = await queryCurrentUser(id, {
skipErrorHandler: true, skipErrorHandler: true,
}); });
if (msg.code != 1) {
console.log('获取用户信息失败: ', msg.message);
} else {
return msg.data; return msg.data;
}
} catch (error) { } catch (error) {
console.log('获取用户信息失败: ', error); console.log('获取用户信息失败: ', error);
history.push(loginPath); history.push(loginPath);
@ -195,7 +200,7 @@ const validateToken = async () => {
try { try {
if (location.href.includes('/user/login')) return; if (location.href.includes('/user/login')) return;
await q('/api/Login/Validate', { await cusRequest('/api/Login/Validate', {
method: 'GET', method: 'GET',
}); });
} catch (error) { } catch (error) {

View File

@ -243,7 +243,7 @@ const MachineManagement: React.FC = () => {
]; ];
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<Spin spinning={spinning} tip={spinTip}> <Spin spinning={spinning} tip={spinTip}>
<Form <Form
layout='inline' layout='inline'

View File

@ -28,6 +28,7 @@ const ModifyMachine: React.FC<ModifyMachineProps> = ({ id, setFormRef, open }) =
setSpinning(true); setSpinning(true);
setSpinTip("加载中。。。"); setSpinTip("加载中。。。");
GetMachineInfo(id).then((res) => { GetMachineInfo(id).then((res) => {
debugger
// 对一些数据做处理 // 对一些数据做处理
form.setFieldsValue({ form.setFieldsValue({
...res, ...res,
@ -37,6 +38,7 @@ const ModifyMachine: React.FC<ModifyMachineProps> = ({ id, setFormRef, open }) =
ownUserName: res.ownUser?.userName, ownUserName: res.ownUser?.userName,
updatedUserName: res.updatedUser?.userName, updatedUserName: res.updatedUser?.userName,
deactivationTime: res.deactivationTime ? moment(res.deactivationTime) : undefined, deactivationTime: res.deactivationTime ? moment(res.deactivationTime) : undefined,
id: id
}); });
}).catch((error: any) => { }).catch((error: any) => {

View File

@ -24,7 +24,7 @@ const LaitoolOptions: React.FC = () => {
}] }]
return ( return (
<TemplateContainer title={false} navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer title={false} navTheme={initialState?.settings?.navTheme ?? "light"}>
<Tabs defaultActiveKey="1" destroyInactiveTabPane={true} items={items} /> <Tabs defaultActiveKey="1" destroyInactiveTabPane={true} items={items} />
</TemplateContainer> </TemplateContainer>
); );

View File

@ -4,7 +4,7 @@ import { MailOutlined } from '@ant-design/icons';
import { useSoftStore } from '@/store/software'; import { useSoftStore } from '@/store/software';
import { GetOptions, getOptionsValue, GetSimpleOptions, SaveOptions } from '@/services/services/options/optionsTool'; import { GetOptions, getOptionsValue, GetSimpleOptions, SaveOptions } from '@/services/services/options/optionsTool';
import { AllOptionKeyName, OptionKeyName } from '@/services/enum/optionEnum'; import { AllOptionKeyName, OptionKeyName } from '@/services/enum/optionEnum';
import { request } from '@umijs/max'; import cusRequest from '@/request';
interface MailSettingProps { interface MailSettingProps {
visible?: boolean; visible?: boolean;
@ -94,7 +94,7 @@ const MailSettingOption: React.FC<MailSettingProps> = ({ visible }) => {
setTopSpinTip('正在发送测试邮件'); setTopSpinTip('正在发送测试邮件');
let res = await request<ApiResponse.SuccessItem<string>>('/lms/LaitoolOptions/TestSendMail', { let res = await cusRequest<string>('/lms/LaitoolOptions/TestSendMail', {
method: 'POST', method: 'POST',
}); });

View File

@ -22,7 +22,7 @@ const LaitoolOptions: React.FC = () => {
}; };
return ( return (
<TemplateContainer title={false} navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer title={false} navTheme={initialState?.settings?.navTheme ?? "light"}>
<Tabs defaultActiveKey="1" destroyInactiveTabPane={true} items={items} onChange={onChange} /> <Tabs defaultActiveKey="1" destroyInactiveTabPane={true} items={items} onChange={onChange} />
</TemplateContainer> </TemplateContainer>
); );

View File

@ -1,12 +1,13 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Table, Button, message, Space, Spin, Form, Input, Select, Modal } from 'antd'; import { Table, Button, message, Space, Spin, Form, Input, Select, Modal } from 'antd';
import TemplateContainer from '@/pages/TemplateContainer'; import TemplateContainer from '@/pages/TemplateContainer';
import { request, useModel } from '@umijs/max'; import { useModel } from '@umijs/max';
import { objectToQueryString } from '@/services/services/common'; import { objectToQueryString } from '@/services/services/common';
import { GetDataInfoTypeOption, GetDataInfoTypeOptions } from '@/services/enum/dataInfo'; import { GetDataInfoTypeOption, GetDataInfoTypeOptions } from '@/services/enum/dataInfo';
import { SearchOutlined } from '@ant-design/icons'; import { SearchOutlined } from '@ant-design/icons';
import { ColumnsType } from 'antd/lib/table'; import { ColumnsType } from 'antd/lib/table';
import JsonView from '@uiw/react-json-view'; import JsonView from '@uiw/react-json-view';
import cusRequest from '@/request';
const DataInfo: React.FC = () => { const DataInfo: React.FC = () => {
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
@ -37,13 +38,17 @@ const DataInfo: React.FC = () => {
pageSize: tableParams.pagination?.pageSize, pageSize: tableParams.pagination?.pageSize,
}; };
let query = objectToQueryString(data); let query = objectToQueryString(data);
let res = await request<ApiResponse.SuccessItem<DataInfoModel.QueryDataInfoData>>(`/lms/Other/QueryDataInfoCollection?${query}`, { let res = await cusRequest<DataInfoModel.QueryDataInfoData>(`/lms/Other/QueryDataInfoCollection?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
let resData = res.data; let resData = res.data;
if (resData?.collection == undefined) {
messageApi.error('请求获取数据为空,请重试!');
return;
}
setDataList(resData.collection); setDataList(resData.collection);
setTableParams({ setTableParams({
pagination: { pagination: {
@ -140,7 +145,7 @@ const DataInfo: React.FC = () => {
]; ];
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? 'realDark'}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? 'light'}>
<Spin spinning={loading}> <Spin spinning={loading}>
<Form <Form
form={form} form={form}

View File

@ -1,20 +1,20 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Form, Input, DatePicker, Select, Button, message, FormInstance } from 'antd'; import { Form, Input, DatePicker, Select, Button, message, FormInstance, Space } from 'antd';
import moment from 'moment'; import moment from 'moment';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { GetMachineAuthorizationTypeOptions } from '@/services/enum/machineAuthorizationEnum'; import { GetMachineAuthorizationTypeOptions } from '@/services/enum/machineAuthorizationEnum';
const { TextArea } = Input; const { TextArea } = Input;
import CryptoJS from 'crypto-js'; // 添加这一行导入 import CryptoJS from 'crypto-js'; // 添加这一行导入
import * as LZString from 'lz-string'; import * as LZString from 'lz-string';
import { request } from '@umijs/max'; import cusRequest from '@/request';
import { AddMachineIdAuthorizationFunc } from '@/services/services/other';
interface AddMachineIdAuthorizationProps { interface AddMachineIdAuthorizationProps {
setFormRef: (form: FormInstance) => void; setFormRef: (form: FormInstance) => void;
id: string;
} }
const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ setFormRef, id }) => { const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ setFormRef }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [messageApi, messageHolder] = message.useMessage(); const [messageApi, messageHolder] = message.useMessage();
@ -22,33 +22,21 @@ const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ s
useEffect(() => { useEffect(() => {
setFormRef(form); setFormRef(form);
form.setFieldsValue({ form.setFieldsValue({
authorizedDate: moment(),
expiryDate: moment().add(1, 'year'),
type: 0, type: 0,
authorizationCode: '123' useType: 0,
expiryTime: 365,
authorizationCode: ""
}) })
}, [form, setFormRef, id]); }, [form, setFormRef]);
const handleSubmit = async () => { const handleSubmit = async () => {
try { try {
setLoading(true); setLoading(true);
// TODO: Implement API call to save the authorization // TODO: Implement API call to save the authorization
let values = form.getFieldsValue(); let values = form.getFieldsValue();
console.log('Form values:', values); await AddMachineIdAuthorizationFunc(values);
let res = await request<ApiResponse.SuccessItem<string>>('lms/Other/AddMachineAuthorization', {
method: "POST",
data: {
...values,
authorizedDate: values.authorizedDate.toISOString(),
expiryDate: values.expiryDate.toISOString()
}
})
if (res.code !== 1) {
throw new Error(res.message);
}
messageApi.success('Machine ID authorization added successfully'); messageApi.success('Machine ID authorization added successfully');
} catch (error : any) { } catch (error: any) {
messageApi.error(error.message); messageApi.error(error.message);
} finally { } finally {
setLoading(false); setLoading(false);
@ -167,13 +155,7 @@ const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ s
onFinish={handleSubmit} onFinish={handleSubmit}
autoComplete="off" autoComplete="off"
> >
<Form.Item
name="machineId"
label="机器码/唯一授权码"
rules={[{ required: true, message: '请输入 machine ID' }]}
>
<Input placeholder="输入 machine ID" />
</Form.Item>
<Form.Item <Form.Item
name="type" name="type"
@ -183,12 +165,23 @@ const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ s
<Select placeholder="选择授权软件类型" options={GetMachineAuthorizationTypeOptions()}></Select> <Select placeholder="选择授权软件类型" options={GetMachineAuthorizationTypeOptions()}></Select>
</Form.Item> </Form.Item>
<Form.Item
name="useType"
label="授权使用类型"
rules={[{ required: true, message: '请输入授权软件类型' }]}
>
<Select placeholder="选择授权软件类型" options={[
{ label: '基础', value: 0 },
{ label: '专业', value: 1 },
]}></Select>
</Form.Item>
<Form.Item <Form.Item
name="authorizedDate" name="authorizedDate"
label="授权时间" label="授权时间"
rules={[{ required: true, message: '请选择授权时间' }]}
> >
<DatePicker <DatePicker
disabled
showTime showTime
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder="选择授权日期和时间" placeholder="选择授权日期和时间"
@ -199,9 +192,9 @@ const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ s
<Form.Item <Form.Item
name="expiryDate" name="expiryDate"
label="到期时间" label="到期时间"
rules={[{ required: true, message: '请选择到期时间' }]}
> >
<DatePicker <DatePicker
disabled
showTime showTime
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder="选择到期日期和时间" placeholder="选择到期日期和时间"
@ -209,18 +202,44 @@ const AddMachineIdAuthorization: React.FC<AddMachineIdAuthorizationProps> = ({ s
/> />
</Form.Item> </Form.Item>
<Form.Item name="authorizationCode" label="请输入授权码"> <Form.Item
<TextArea rows={4} placeholder="请输入授权码" /> name="expiryTime"
label="授权到期时间"
rules={[{ required: true, message: '请选择授权到期时间' }]}
>
<Select
placeholder="请选择授权时间"
showSearch
allowClear
optionFilterProp="children"
options={[
{ label: '0天', value: 0 },
{ label: '30天', value: 30 },
{ label: '90天', value: 90 },
{ label: '180天', value: 180 },
{ label: '365天', value: 365 },
]}
/>
</Form.Item> </Form.Item>
<Form.Item style={{ textAlign: 'right' }}> <Form.Item name="authorizationCode" label="授权码"
rules={[{ required: true, message: '请先生成授权码' }]}
>
<Space.Compact style={{ width: '100%' }}>
<Input
placeholder="授权码将显示在这里"
/>
<Button <Button
style={{ marginRight: 8 }}
type="primary" type="primary"
onClick={GenerateAuthorizationCode} onClick={GenerateAuthorizationCode}
> >
</Button> </Button>
</Space.Compact>
</Form.Item>
<Form.Item style={{ textAlign: 'right' }}>
<Button <Button
style={{ marginRight: 8 }} style={{ marginRight: 8 }}
type="primary" type="primary"

View File

@ -0,0 +1,283 @@
import React, { useEffect, useState } from 'react';
import { Form, Input, DatePicker, Select, Button, message, FormInstance, Space } from 'antd';
import moment from 'moment';
import { useNavigate } from 'react-router-dom';
import { GetMachineAuthorizationTypeOptions } from '@/services/enum/machineAuthorizationEnum';
const { TextArea } = Input;
import CryptoJS from 'crypto-js'; // 添加这一行导入
import * as LZString from 'lz-string';
import cusRequest from '@/request';
import { FormatDate } from '@/util/time';
import { GetMachineAuthorizationById, ModifyMachineAuthorization } from '@/services/services/other';
interface ModifyMachineIdAuthorizationProps {
setFormRef: (form: FormInstance) => void;
id: string;
}
const ModifyMachineIdAuthorization: React.FC<ModifyMachineIdAuthorizationProps> = ({ setFormRef, id }) => {
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const [messageApi, messageHolder] = message.useMessage();
useEffect(() => {
setFormRef(form);
getMachineAuthorizationById(id);
}, [form, setFormRef, id]);
// 先获取数据
const getMachineAuthorizationById = async (id: string) => {
try {
debugger
let data = await GetMachineAuthorizationById(id);
form.setFieldsValue({
...data,
// 使用 moment 对象而不是格式化字符串
authorizedDate: data.authorizedDate ? moment(data.authorizedDate) : null,
expiryDate: data.expiryDate ? moment(data.expiryDate) : null,
});
} catch (error) {
messageApi.error('获取数据失败');
}
}
const handleSubmit = async () => {
try {
debugger
setLoading(true);
let values = form.getFieldsValue();
await ModifyMachineAuthorization(id, values);
messageApi.success('Machine ID authorization added successfully');
} catch (error: any) {
messageApi.error(error.message);
} finally {
setLoading(false);
}
};
function GenerateAuthorizationCode() {
const values = form.getFieldsValue();
const { machineId, type, authorizedDate, expiryDate } = values;
if (!machineId || type === undefined || !authorizedDate || !expiryDate) {
messageApi.error('请先填写必要信息(机器码、类型和日期)');
return;
}
try {
// Format dates to strings
const authDate = moment(authorizedDate).format('YYYY-MM-DD HH:mm:ss');
const expDate = moment(expiryDate).format('YYYY-MM-DD HH:mm:ss');
let obj = {
machineId: machineId,
type: type,
authorizedDate: authDate,
expiryDate: expDate
}
// Create the string to encrypt
const dataToEncrypt = JSON.stringify(obj);
// Assuming CryptoJS is imported
const secretKey = machineId;
// Generate a secure encryption key from machineId
const key = CryptoJS.enc.Utf8.parse(CryptoJS.SHA256(secretKey).toString());
// Generate a random initialization vector
const iv = CryptoJS.lib.WordArray.random(16);
// Encrypt the data using AES encryption
const encrypted = CryptoJS.AES.encrypt(dataToEncrypt, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
// Convert IV to base64 for storage
const ivBase64 = CryptoJS.enc.Base64.stringify(iv);
// Get the encrypted data in base64 format
const encryptedBase64 = encrypted.toString();
// Combine IV and encrypted data with a delimiter for future decryption
const authCode = ivBase64 + ':' + encryptedBase64;
// 使用LZString压缩
const compressedCode = LZString.compressToEncodedURIComponent(authCode);
// Set the encrypted value in the form
form.setFieldsValue({ authorizationCode: compressedCode });
messageApi.success('授权码已生成');
} catch (error) {
console.error('生成授权码时出错:', error);
messageApi.error('生成授权码失败');
}
}
function DecryptAuthorizationCode(authCode: string, machineId: string) {
try {
// 解压缩
const originalAuthCode = LZString.decompressFromEncodedURIComponent(authCode);
// 拆分授权码获取IV和加密数据
const [ivBase64, encryptedBase64] = originalAuthCode.split(':');
if (!ivBase64 || !encryptedBase64) {
throw new Error('无效的授权码格式');
}
// 从Base64转换回IV
const iv = CryptoJS.enc.Base64.parse(ivBase64);
// 使用相同的方法生成密钥
const secretKey = machineId;
const key = CryptoJS.enc.Utf8.parse(CryptoJS.SHA256(secretKey).toString());
// 解密数据
const decrypted = CryptoJS.AES.decrypt(encryptedBase64, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
// 将解密后的数据转换为字符串
const decryptedData = decrypted.toString(CryptoJS.enc.Utf8);
// 将JSON字符串解析为对象
const decodedObject = JSON.parse(decryptedData);
return {
success: true,
data: decodedObject
};
} catch (error) {
console.error('解密授权码时出错:', error);
return {
success: false,
error: error instanceof Error ? error.message : '未知错误'
};
}
}
return (
<Form
form={form}
layout="vertical"
onFinish={handleSubmit}
autoComplete="off"
>
<Form.Item
name="type"
label="授权软件类型"
rules={[{ required: true, message: '请输入授权软件类型' }]}
>
<Select placeholder="选择授权软件类型" options={GetMachineAuthorizationTypeOptions()}></Select>
</Form.Item>
<Form.Item
name="useType"
label="授权使用类型"
rules={[{ required: true, message: '请输入授权软件类型' }]}
>
<Select placeholder="选择授权软件类型" options={[
{ label: '基础', value: 0 },
{ label: '专业', value: 1 },
]}></Select>
</Form.Item>
<Form.Item
name="authorizedDate"
label="授权时间"
>
<DatePicker
disabled
showTime
style={{ width: '100%' }}
placeholder="选择授权日期和时间"
/>
</Form.Item>
<Form.Item
name="expiryDate"
label="到期时间"
>
<DatePicker
showTime
style={{ width: '100%' }}
placeholder="选择到期日期和时间"
/>
</Form.Item>
<Form.Item
name="expiryTime"
label="授权到期时间"
rules={[{ required: true, message: '请选择授权到期时间' }]}
>
<Select
placeholder="请选择授权时间"
showSearch
allowClear
optionFilterProp="children"
options={[
{ label: '0天', value: 0 },
{ label: '30天', value: 30 },
{ label: '90天', value: 90 },
{ label: '180天', value: 180 },
{ label: '365天', value: 365 },
]}
/>
</Form.Item>
<Form.Item name="authorizationCode" label="授权码"
rules={[{ required: true, message: '请先生成授权码' }]}
>
<Input
placeholder="授权码将显示在这里"
/>
</Form.Item>
<Form.Item name="machineID" label="机器码/唯一标识"
>
<Input
placeholder="授权码将显示在这里"
/>
</Form.Item>
<Form.Item style={{ textAlign: 'right' }}>
<Button
style={{ marginRight: 8 }}
type="primary"
onClick={() => {
const values = form.getFieldsValue();
const { machineId, authorizationCode } = values;
if (!machineId || !authorizationCode) {
messageApi.error('请先填写机器码和授权码');
return;
}
const result = DecryptAuthorizationCode(authorizationCode, machineId);
if (result.success) {
messageApi.success('授权码解密成功');
console.log('解密结果:', result.data);
} else {
messageApi.error(`解密失败: ${result.error}`);
}
}}
>
</Button>
<Button type="primary" htmlType="submit" loading={loading}>
</Button>
</Form.Item>
{messageHolder}
</Form >
);
};
export default ModifyMachineIdAuthorization;

View File

@ -1,14 +1,18 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Table, Button, Space, Input, Form, Modal, message, Popconfirm, Tooltip, Select } from 'antd'; import { Table, Button, Space, Input, Form, Modal, message, Popconfirm, Tooltip, Select, Checkbox, Tag } from 'antd';
import { PlusOutlined, SearchOutlined } from '@ant-design/icons'; import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
import TemplateContainer from '@/pages/TemplateContainer'; import TemplateContainer from '@/pages/TemplateContainer';
import { request, useModel } from '@umijs/max'; import { useModel } from '@umijs/max';
import { ColumnsType, FilterValue, SorterResult, TableCurrentDataSource, TablePaginationConfig } from 'antd/es/table/interface'; import { ColumnsType, FilterValue, SorterResult, TableCurrentDataSource, TablePaginationConfig } from 'antd/es/table/interface';
import { objectToQueryString } from '@/services/services/common'; import { objectToQueryString } from '@/services/services/common';
import { FormatDate } from '@/util/time'; import { FormatDate } from '@/util/time';
import { GetMachineAuthorizationTypeOption, GetMachineAuthorizationTypeOptions } from '@/services/enum/machineAuthorizationEnum'; import { GetMachineAuthorizationTypeOption, GetMachineAuthorizationTypeOptions } from '@/services/enum/machineAuthorizationEnum';
import { useFormReset } from '@/hooks/useFormReset'; import { useFormReset } from '@/hooks/useFormReset';
import AddMachineIdAuthorization from './AddMachineIdAuthorization'; import AddMachineIdAuthorization from './AddMachineIdAuthorization';
import cusRequest from '@/request';
import { isEmpty } from 'lodash';
import ModifyMachineIdAuthorization from './ModifyMachineIdAuthorization';
import { BatchDeleteMachine, DeleteMachineAuthorization, QueryMachineAuthorization } from '@/services/services/other';
const MachineIdAuthorization: React.FC = () => { const MachineIdAuthorization: React.FC = () => {
@ -17,7 +21,8 @@ const MachineIdAuthorization: React.FC = () => {
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [modalVisible, setModalVisible] = useState<boolean>(false); const [modalVisible, setModalVisible] = useState<boolean>(false);
const [form] = Form.useForm(); const [form] = Form.useForm();
const [messageApi, messageHolder] = message.useMessage(); const [messageApi, messageHolder,] = message.useMessage();
const [modalApi, modalHolder] = Modal.useModal();
const { setFormRef, resetForm } = useFormReset(); const { setFormRef, resetForm } = useFormReset();
const [id, setId] = useState<string>(''); const [id, setId] = useState<string>('');
const [tableParams, setTableParams] = useState<TableModel.TableParams>({ const [tableParams, setTableParams] = useState<TableModel.TableParams>({
@ -33,23 +38,11 @@ const MachineIdAuthorization: React.FC = () => {
QueryMachineAuthorizationCollection(tableParams, form.getFieldsValue()); QueryMachineAuthorizationCollection(tableParams, form.getFieldsValue());
}, []); }, []);
// 查询数据
async function QueryMachineAuthorizationCollection(tableParams: TableModel.TableParams, options?: any) { async function QueryMachineAuthorizationCollection(tableParams: TableModel.TableParams, options?: any) {
try { try {
setLoading(true); setLoading(true);
let resData = await QueryMachineAuthorization(tableParams, options);
let data = {
...options,
page: tableParams.pagination?.current,
pageSize: tableParams.pagination?.pageSize,
}
let query = objectToQueryString(data)
let res = await request<ApiResponse.SuccessItem<MachineAuthorizationModel.QueryMachineAuthorizationData>>(`/lms/Other/QueryMachineAuthorizationCollection?${query}`, {
method: 'GET',
});
if (res.code != 1) {
throw new Error(res.message);
}
let resData = res.data;
setDataSource(resData.collection); setDataSource(resData.collection);
setTableParams({ setTableParams({
pagination: { pagination: {
@ -57,6 +50,7 @@ const MachineIdAuthorization: React.FC = () => {
total: resData.total total: resData.total
} }
}) })
console.log('获取数据成功', resData);
messageApi.success('Data fetched successfully'); messageApi.success('Data fetched successfully');
} catch (error: any) { } catch (error: any) {
messageApi.error(error.message); messageApi.error(error.message);
@ -67,6 +61,17 @@ const MachineIdAuthorization: React.FC = () => {
const columns: ColumnsType<MachineAuthorizationModel.MachineAuthorizationBase> = [ const columns: ColumnsType<MachineAuthorizationModel.MachineAuthorizationBase> = [
{ {
title: 'ID',
dataIndex: 'id',
key: 'id',
width: '120px',
render: (text) => (
<Tooltip title={text}>
<span>{text?.length > 10 ? `${text.substring(0, 10)}...` : text}</span>
</Tooltip>
),
fixed: 'left',
}, {
title: '机器码/唯一授权码', title: '机器码/唯一授权码',
dataIndex: 'machineID', dataIndex: 'machineID',
key: 'machineId', key: 'machineId',
@ -77,34 +82,59 @@ const MachineIdAuthorization: React.FC = () => {
</Tooltip> </Tooltip>
), ),
}, },
{
title: '授权类型',
dataIndex: 'type',
key: 'type',
render: (text, record) => GetMachineAuthorizationTypeOption(record.type),
},
{
title: '授权时间',
dataIndex: 'authorizedDate',
key: 'authorizedDate',
render: (text) => FormatDate(text),
},
{
title: '授权到期时间',
dataIndex: 'expiryDate',
key: 'expiryDate',
render: (text) => FormatDate(text),
},
{ {
title: '授权码', title: '授权码',
dataIndex: 'authorizationCode', dataIndex: 'authorizationCode',
key: 'authorizationCode', key: 'authorizationCode',
width: '300px',
render: (text) => ( render: (text) => (
<Tooltip title={text}> <Tooltip title={text}>
<span>{text?.length > 30 ? `${text.substring(0, 30)}...` : text}</span> <span>{text?.length > 30 ? `${text.substring(0, 30)}...` : text}</span>
</Tooltip> </Tooltip>
), ),
}, },
{
title: '授权类型',
dataIndex: 'type',
key: 'type',
width: '80px',
render: (text, record) => GetMachineAuthorizationTypeOption(record.type),
},
{
title: '使用类型',
dataIndex: 'useType',
key: 'useType',
width: '80px',
render: (text, record) => {
return <Tag color={record.useType == 0 ? 'green' : 'blue'}>
{record.useType == 0 ? '基础' : '专业'}
</Tag>
}
},
{
title: '授权时间',
dataIndex: 'expiryTime',
key: 'expiryTime',
width: '80px',
render: (text, record) => <Tag color='success'>
{record.expiryTime + '天'}
</Tag>
},
{
title: '授权时间',
dataIndex: 'authorizedDate',
key: 'authorizedDate',
width: '160px',
render: (text) => FormatDate(text),
},
{
title: '授权到期时间',
dataIndex: 'expiryDate',
key: 'expiryDate',
width: '160px',
render: (text) => FormatDate(text),
},
{ {
title: '创建人', title: '创建人',
dataIndex: 'createdUser', dataIndex: 'createdUser',
@ -113,53 +143,49 @@ const MachineIdAuthorization: React.FC = () => {
const userName = text?.userName || ''; const userName = text?.userName || '';
return ( return (
<Tooltip title={userName}> <Tooltip title={userName}>
<span>{userName.length > 10 ? `${userName.substring(0, 10)}...` : userName}</span> <span>{userName.length > 20 ? `${userName.substring(0, 20)}...` : userName}</span>
</Tooltip> </Tooltip>
); );
} }
}, },
{
title: '创建时间',
dataIndex: 'createdDate',
key: 'createdDate',
render: (text, record) => FormatDate(record.createdDate),
},
{ {
title: 'Actions', title: 'Actions',
key: 'actions', key: 'actions',
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
<Button type="link" onClick={() => handleEdit(record)}> <Button color="primary" variant="text" onClick={() => handleEdit(record)}>
Edit
</Button> </Button>
<Popconfirm <Popconfirm
title="Are you sure you want to revoke this authorization?" title="确定要删除当前的授权吗?"
onConfirm={() => handleRevoke(record.id)} description="删除后将无法恢复,请谨慎操作!"
okText="Yes" onConfirm={() => handleDelete(record.id)}
cancelText="No" okText="继续"
cancelText="取消"
> >
<Button type="link" danger> <Button color="danger" variant="text">
Revoke
</Button> </Button>
</Popconfirm> </Popconfirm>
</Space> </Space>
), ),
fixed: 'right',
}, },
]; ];
const handleEdit = (record: MachineAuthorizationModel.MachineAuthorizationBase) => { const handleEdit = (record: MachineAuthorizationModel.MachineAuthorizationBase) => {
setModalVisible(true); setModalVisible(true);
setId(record.id);
}; };
const handleRevoke = async (id: string) => { // 单个删除
const handleDelete = async (id: string) => {
try { try {
const newData = dataSource.map(item => await DeleteMachineAuthorization(id);
item.id === id ? { ...item, status: 'revoked' as const } : item await QueryMachineAuthorizationCollection(tableParams, form.getFieldsValue());
); messageApi.success('删除成功');
setDataSource(newData); } catch (error: any) {
messageApi.success('Authorization revoked successfully'); messageApi.error(error.message);
} catch (error) {
messageApi.error('Failed to revoke authorization');
} }
}; };
@ -168,6 +194,28 @@ const MachineIdAuthorization: React.FC = () => {
setModalVisible(true); setModalVisible(true);
}; };
//
const handleBatchDelete = async () => {
try {
const confirmed = await modalApi.confirm({
title: "确认批量删除",
content: "确定需要批量删除?该操作会删除所有授权到期的机器码授权,请谨慎操作!",
okText: "继续",
});
if (!confirmed) {
messageApi.warning('取消操作');
return;
}
// 开始删除
await BatchDeleteMachine();
messageApi.success('批量删除成功');
// 重新加载数据\
await QueryMachineAuthorizationCollection(tableParams, form.getFieldsValue());
} catch (error: any) {
messageApi.error(error.message);
}
};
async function TableChangeHandle(pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<MachineAuthorizationModel.MachineAuthorizationBase> | SorterResult<MachineAuthorizationModel.MachineAuthorizationBase>[], extra: TableCurrentDataSource<MachineAuthorizationModel.MachineAuthorizationBase>): Promise<void> { async function TableChangeHandle(pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<MachineAuthorizationModel.MachineAuthorizationBase> | SorterResult<MachineAuthorizationModel.MachineAuthorizationBase>[], extra: TableCurrentDataSource<MachineAuthorizationModel.MachineAuthorizationBase>): Promise<void> {
await QueryMachineAuthorizationCollection({ pagination }, form.getFieldsValue()); await QueryMachineAuthorizationCollection({ pagination }, form.getFieldsValue());
@ -189,20 +237,27 @@ const MachineIdAuthorization: React.FC = () => {
} }
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<Form <Form
form={form} form={form}
layout="inline"
onFinish={(values) => QueryMachineAuthorizationCollection(tableParams, values)} onFinish={(values) => QueryMachineAuthorizationCollection(tableParams, values)}
style={{ marginBottom: 16 }} style={{ marginBottom: 8 }}
> >
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', alignItems: 'flex-end' }}>
<Form.Item name="ID" label="id">
<Input placeholder="ID" style={{ width: 200 }} />
</Form.Item>
<Form.Item name="machineID" label="机器码"> <Form.Item name="machineID" label="机器码">
<Input placeholder="Machine ID" style={{ width: 200 }} /> <Input placeholder="Machine ID" style={{ width: 200 }} />
</Form.Item> </Form.Item>
<Form.Item name="emptyMachineId" valuePropName="checked">
<Checkbox></Checkbox>
</Form.Item>
<Form.Item name="authorizationCode" label="授权码"> <Form.Item name="authorizationCode" label="授权码">
<Input placeholder="Authorization Code" style={{ width: 200 }} /> <Input placeholder="Authorization Code" style={{ width: 200 }} />
</Form.Item> </Form.Item>
<Form.Item name="type" label="授权类型"> <Form.Item name="type" label="授权类型">
<Select <Select
placeholder="Authorization Type" placeholder="Authorization Type"
@ -211,12 +266,18 @@ const MachineIdAuthorization: React.FC = () => {
options={GetMachineAuthorizationTypeOptions()} options={GetMachineAuthorizationTypeOptions()}
/> />
</Form.Item> </Form.Item>
<Form.Item>
<Form.Item >
<Space> <Space>
<Button type="primary" htmlType="submit" icon={<SearchOutlined />}> <Button type="primary" htmlType="submit" icon={<SearchOutlined />}>
</Button> </Button>
<Button onClick={() => form.resetFields()}> <Button onClick={() => {
form.resetFields();
QueryMachineAuthorizationCollection(tableParams, form.getFieldsValue())
}
}>
</Button> </Button>
<Button <Button
@ -226,8 +287,16 @@ const MachineIdAuthorization: React.FC = () => {
> >
</Button> </Button>
<Button
danger
onClick={handleBatchDelete}
>
</Button>
</Space> </Space>
</Form.Item> </Form.Item>
</div>
</Form> </Form>
<Table <Table
@ -237,12 +306,18 @@ const MachineIdAuthorization: React.FC = () => {
loading={loading} loading={loading}
pagination={tableParams.pagination} pagination={tableParams.pagination}
onChange={TableChangeHandle} onChange={TableChangeHandle}
scroll={{ x: 1500 }} // 添加这一行,设置表格的最小宽度
/> />
<Modal width={600} title="新增机器码" maskClosable={false} open={modalVisible} footer={null} onCancel={modalCancel}> <Modal width={600} title="新增机器码" maskClosable={false} open={modalVisible} footer={null} onCancel={modalCancel}>
<AddMachineIdAuthorization setFormRef={setFormRef} id={id} /> {
isEmpty(id) ? <AddMachineIdAuthorization setFormRef={setFormRef} /> :
<ModifyMachineIdAuthorization setFormRef={setFormRef} id={id} />
}
</Modal> </Modal>
{messageHolder} {messageHolder}
{modalHolder}
</TemplateContainer> </TemplateContainer>
); );
}; };

View File

@ -203,7 +203,7 @@ const PromptManagement: React.FC = () => {
}; };
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<Card <Card
style={{ style={{
borderRadius: 8, borderRadius: 8,
@ -211,7 +211,7 @@ const PromptManagement: React.FC = () => {
styles={{ styles={{
body: { body: {
backgroundImage: backgroundImage:
initialState?.settings?.navTheme === 'realDark' initialState?.settings?.navTheme === 'light'
? 'background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)' ? 'background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)'
: 'background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)', : 'background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)',
} }

View File

@ -180,7 +180,7 @@ const PromptManagement: React.FC = () => {
}; };
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<Card <Card
style={{ style={{
borderRadius: 8, borderRadius: 8,
@ -188,7 +188,7 @@ const PromptManagement: React.FC = () => {
styles={{ styles={{
body: { body: {
backgroundImage: backgroundImage:
initialState?.settings?.navTheme === 'realDark' initialState?.settings?.navTheme === 'light'
? 'background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)' ? 'background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)'
: 'background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)', : 'background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)',
} }

View File

@ -196,7 +196,7 @@ const RoleManagement: React.FC = () => {
} }
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<div> <div>
<Form <Form
layout='inline' layout='inline'

View File

@ -14,9 +14,11 @@ import { AllOptionKeyName } from '@/services/enum/optionEnum';
interface SoftwareControlManagementProps { interface SoftwareControlManagementProps {
// Add your props here // Add your props here
userId?: number;
cantModify?: boolean;
} }
const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => { const SoftwareControlManagement: FC<SoftwareControlManagementProps> = ({ userId, cantModify }) => {
const { initialState } = useModel('@@initialState'); const { initialState } = useModel('@@initialState');
const [messageApi, messageHolder] = message.useMessage(); const [messageApi, messageHolder] = message.useMessage();
const [loading, setLoading] = React.useState<boolean>(false); const [loading, setLoading] = React.useState<boolean>(false);
@ -101,7 +103,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 100, width: 100,
hidden: !access.isAdminOrSuperAdmin, hidden: !access.isAdminOrSuperAdmin && !access.canSofrwareControlManagement,
render: (_, record) => ( render: (_, record) => (
<Dropdown <Dropdown
menu={{ menu={{
@ -109,6 +111,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
{ {
key: 'edit', key: 'edit',
label: '编辑', label: '编辑',
hidden: !access.canEditSoftwareControl,
icon: <EditOutlined />, icon: <EditOutlined />,
onClick: () => { onClick: () => {
// 编辑 // 编辑
@ -119,6 +122,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
key: 'addTrail', key: 'addTrail',
label: '添加试用', label: '添加试用',
style: { color: '#faad14' }, style: { color: '#faad14' },
hidden: !access.canAddTrailSoftwareControl,
icon: <PlusSquareOutlined />, icon: <PlusSquareOutlined />,
onClick: async () => { onClick: async () => {
// 添加试用 // 添加试用
@ -128,6 +132,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
{ {
key: 'addMouth', key: 'addMouth',
label: '添加月付', label: '添加月付',
hidden: !access.canAddMouthSoftwareControl,
style: { color: '#38a2fc' }, style: { color: '#38a2fc' },
icon: <PlusSquareOutlined />, icon: <PlusSquareOutlined />,
onClick: async () => { onClick: async () => {
@ -139,6 +144,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
key: 'addQuarterly', key: 'addQuarterly',
label: '添加季付', label: '添加季付',
style: { color: '#38a2fc' }, style: { color: '#38a2fc' },
hidden: !access.canAddQuarterlySoftwareControl,
icon: <PlusSquareOutlined />, icon: <PlusSquareOutlined />,
onClick: async () => { onClick: async () => {
// 延长到期时间 // 延长到期时间
@ -148,6 +154,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
{ {
key: 'addHalfYear', key: 'addHalfYear',
label: '添加半年', label: '添加半年',
hidden: !access.canAddHalfYearSoftwareControl,
style: { color: '#38a2fc' }, style: { color: '#38a2fc' },
icon: <PlusSquareOutlined />, icon: <PlusSquareOutlined />,
onClick: async () => { onClick: async () => {
@ -158,6 +165,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
{ {
key: 'addYear', key: 'addYear',
label: '添加年付', label: '添加年付',
hidden: !access.canAddYearSoftwareControl,
style: { color: '#38a2fc' }, style: { color: '#38a2fc' },
icon: <PlusSquareOutlined />, icon: <PlusSquareOutlined />,
onClick: async () => { onClick: async () => {
@ -168,6 +176,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
{ {
key: 'addForever', key: 'addForever',
label: '永久', label: '永久',
hidden: !access.canAddForeverSoftwareControl,
style: { color: '#38a2fc' }, style: { color: '#38a2fc' },
icon: <PlusSquareOutlined />, icon: <PlusSquareOutlined />,
onClick: async () => { onClick: async () => {
@ -179,12 +188,13 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
key: 'delete', key: 'delete',
label: '停用权限', label: '停用权限',
danger: true, danger: true,
hidden: !access.canDeleteSoftwareControl,
icon: <DeleteOutlined />, icon: <DeleteOutlined />,
onClick: async () => { onClick: async () => {
await DeleteSoftwareControl(record.id); await DeleteSoftwareControl(record.id);
} }
}, },
], ].filter(item => !item.hidden)
}} }}
> >
<Button type="text" color="primary" variant="filled" icon={<MenuOutlined />} /> <Button type="text" color="primary" variant="filled" icon={<MenuOutlined />} />
@ -272,6 +282,11 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
} }
useEffect(() => { useEffect(() => {
if (userId) {
form.setFieldsValue({
userId: userId
})
}
QueryUserSoftwareControlCollection(tableParams, form.getFieldsValue()).then(); QueryUserSoftwareControlCollection(tableParams, form.getFieldsValue()).then();
Software.GetSoftwareBaseCollection().then((res) => { Software.GetSoftwareBaseCollection().then((res) => {
setSoftwareBasicInfo(res); setSoftwareBasicInfo(res);
@ -307,10 +322,11 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
} }
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<Form <Form
layout='inline' layout='inline'
form={form} form={form}
disabled={cantModify}
onFinish={QuerySoftwareControlByCondition} onFinish={QuerySoftwareControlByCondition}
> >
<Form.Item label="用户ID" name='userId' style={{ marginBottom: 5 }}> <Form.Item label="用户ID" name='userId' style={{ marginBottom: 5 }}>

View File

@ -1,7 +1,8 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Form, Input, Button, Spin, message, Row, Col } from 'antd'; import { Form, Input, Button, Spin, message, Row, Col } from 'antd';
import { UserRegistr } from '@/services/services/login'; import { UserRegistr } from '@/services/services/login';
import { history, request } from '@umijs/max'; import { history } from '@umijs/max';
import cusRequest from '@/request';
const Register: React.FC = () => { const Register: React.FC = () => {
const [form] = Form.useForm(); const [form] = Form.useForm();
@ -36,7 +37,7 @@ const Register: React.FC = () => {
// 开始请求发送的接口 // 开始请求发送的接口
let res = await request<ApiResponse.SuccessItem<string>>(`/lms/User/SendVerificationCode`, { let res = await cusRequest<string>(`/lms/User/SendVerificationCode`, {
method: 'POST', method: 'POST',
data: { email } data: { email }
}); });

View File

@ -1,6 +1,7 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Form, Input, Button, message, Row, Col } from 'antd'; import { Form, Input, Button, message, Row, Col } from 'antd';
import { request } from '@umijs/max'; import cusRequest from '@/request';
interface ResetPasswordProps { interface ResetPasswordProps {
onCancel: () => void; onCancel: () => void;
@ -31,7 +32,7 @@ const ResetPassword: React.FC<ResetPasswordProps> = ({ onCancel, onSuccess }) =>
setLoading(true); setLoading(true);
// 发送验证码请求 // 发送验证码请求
const res = await request<ApiResponse.SuccessItem<string>>('/lms/User/SendResetPasswordCode', { const res = await cusRequest<string>('/lms/User/SendResetPasswordCode', {
method: 'POST', method: 'POST',
data: { email: emailValue } data: { email: emailValue }
}); });
@ -67,7 +68,7 @@ const ResetPassword: React.FC<ResetPasswordProps> = ({ onCancel, onSuccess }) =>
setLoading(true); setLoading(true);
// 发送重置密码请求 // 发送重置密码请求
const res = await request<ApiResponse.SuccessItem<string>>(`/lms/User/ResetPassword/${values.email}/${values.verificationCode}`, { const res = await cusRequest<string>(`/lms/User/ResetPassword/${values.email}/${values.verificationCode}`, {
method: 'POST' method: 'POST'
}); });

View File

@ -1,8 +1,9 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Form, Input, Button, message, Card, Typography } from 'antd'; import { Form, Input, Button, message, Card, Typography } from 'antd';
import { LockOutlined } from '@ant-design/icons'; import { LockOutlined } from '@ant-design/icons';
import { request, useModel } from '@umijs/max'; import { useModel } from '@umijs/max';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import cusRequest from '@/request';
const { Title } = Typography; const { Title } = Typography;
@ -33,7 +34,7 @@ const ResetPassword: React.FC = () => {
setLoading(true); setLoading(true);
// 发送重置密码请求 // 发送重置密码请求
const res = await request<ApiResponse.SuccessItem<string>>(`/lms/User/ResetPassword/${initialState?.currentUser?.id}`, { const res = await cusRequest<string>(`/lms/User/ResetPassword/${initialState?.currentUser?.id}`, {
method: 'POST', method: 'POST',
data: { data: {
"newPassword": values.newPassword, "newPassword": values.newPassword,

View File

@ -110,7 +110,7 @@ const UserCenter: React.FC = () => {
} }
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"} style={{ minWidth: 600 }}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"} style={{ minWidth: 600 }}>
<div> <div>
<Card hoverable title={renderTitie()} style={{ width: "100%" }}> <Card hoverable title={renderTitie()} style={{ width: "100%" }}>
<Row justify="start" wrap> <Row justify="start" wrap>

View File

@ -9,12 +9,13 @@ import { ColumnsType, TablePaginationConfig } from "antd/es/table";
import { FilterValue, SorterResult, TableCurrentDataSource } from "antd/es/table/interface"; import { FilterValue, SorterResult, TableCurrentDataSource } from "antd/es/table/interface";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import ModifyUser from "../ModifyUser"; import ModifyUser from "../ModifyUser";
import Icon, { DeleteOutlined, EditOutlined, KeyOutlined, MenuOutlined, SyncOutlined } from "@ant-design/icons"; import Icon, { DeleteOutlined, EditOutlined, KeyOutlined, MenuOutlined, SyncOutlined, ToolOutlined } from "@ant-design/icons";
import { SoftwareControl } from "@/services/services/software"; import { SoftwareControl } from "@/services/services/software";
import { CustomIconComponentProps } from "@ant-design/icons/lib/components/Icon"; import { CustomIconComponentProps } from "@ant-design/icons/lib/components/Icon";
import DiceIcon from "@/components/Icon/DiceIcon"; import DiceIcon from "@/components/Icon/DiceIcon";
import { generateRandomPassword } from "@/util/password"; import { generateRandomPassword } from "@/util/password";
import ResetUserPassword from "./ResetUserPassword"; import ResetUserPassword from "./ResetUserPassword";
import SofrwareControlManagement from "@/pages/Software/SofrwareControl/SofrwareControlManagement";
const UserManagement: React.FC = () => { const UserManagement: React.FC = () => {
type TagRender = SelectProps['tagRender']; type TagRender = SelectProps['tagRender'];
@ -158,7 +159,7 @@ const UserManagement: React.FC = () => {
* @returns * @returns
*/ */
async function ApplySoftwareControlHandle(userId: number) { async function ApplySoftwareControlHandle(userId: number) {
if (!access.isAdminOrSuperAdmin) { if (!access.isAdminOrSuperAdmin && !access.isAgentUser) {
messageApi.error("您没有权限执行此操作"); messageApi.error("您没有权限执行此操作");
return; return;
} }
@ -246,7 +247,7 @@ const UserManagement: React.FC = () => {
{ {
title: '操作', title: '操作',
width: '80px', width: '80px',
hidden: !access.isAdminOrSuperAdmin, hidden: !(access.isAdminOrSuperAdmin || access.isAdmin || access.isSuperAdmin || access.isAgentUser),
render: (text, record) => ( render: (text, record) => (
<Dropdown <Dropdown
menu={{ menu={{
@ -281,6 +282,22 @@ const UserManagement: React.FC = () => {
await ApplySoftwareControlHandle(record.id); await ApplySoftwareControlHandle(record.id);
} }
}, },
{
key: 'modifySoftwareControl',
label: '修改软件控制权限',
icon: <ToolOutlined />,
hidden: !access.canApplySoftwareControl,
primary: true,
onClick: async () => {
modal.info({
title: '修改软件控制权限',
width: window.innerWidth * 0.8,
closable: true,
content: <SofrwareControlManagement userId={record.id} cantModify={true} />,
footer: null
});
}
},
{ {
key: 'delete', key: 'delete',
label: '删除', label: '删除',
@ -301,7 +318,7 @@ const UserManagement: React.FC = () => {
]; ];
return ( return (
<TemplateContainer navTheme={initialState?.settings?.navTheme ?? "realDark"}> <TemplateContainer navTheme={initialState?.settings?.navTheme ?? "light"}>
<div> <div>
<Form <Form
layout='inline' layout='inline'

View File

@ -96,7 +96,7 @@ const Welcome: React.FC = () => {
body: { body: {
backgroundImage: backgroundImage:
initialState?.settings?.navTheme === 'realDark' initialState?.settings?.navTheme === 'light'
? 'background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)' ? 'background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)'
: 'background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)', : 'background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)',
} }

82
src/request.ts Normal file
View File

@ -0,0 +1,82 @@
import { request as umiRequest } from '@umijs/max';
import { message } from 'antd';
import { history } from 'umi';
import { errorMessage, successMessage } from './services/services/response';
// 刷新token函数
export const refreshToken = async () => {
try {
let refreshTokenId = localStorage.getItem('refreshToken');
if (!refreshTokenId) {
return false;
}
let userId = JSON.parse(localStorage.getItem('userInfo') ?? "{}").id;
const response = await umiRequest('/lms/User/RefreshToken', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
data: {
refreshToken: refreshTokenId,
"userId": userId,
"deviceInfo": "2"
},
skipErrorHandler: true, // 跳过默认错误处理
});
if (response.code == 1) {
localStorage.setItem('token', response.data);
console.log('刷新token成功', response.data);
return true;
}
return false;
} catch (error) {
console.error('刷新token失败', error);
return false;
}
};
/**
* @name
* @description token
* @param url URL
* @param options
* @returns
*/
export const cusRequest = async <T>(url: string, options?: any): Promise<ApiResponse.SuccessItem<T> | ApiResponse.ErrorItem> => {
try {
let res = await umiRequest<T>(url, options) as any;
if (res.code != 1) {
return errorMessage("请求失败: " + res.message);
} else {
return successMessage(res.data, "请求成功");
}
} catch (error: any) {
if (error?.response?.status === 401 && !url.toLowerCase().includes('/refreshtoken')) {
// 尝试刷新token
const refreshSuccess = await refreshToken();
if (refreshSuccess) {
// 刷新成功,重试请求
let res = await umiRequest<T>(url, {
...options,
headers: {
...options.headers,
'Authorization': `Bearer ${localStorage.getItem('token')}`,
}
});
debugger
return successMessage(res.data, "请求成功");
} else { // 刷新失败,跳转登录页
message.error('授权已过期,请重新登录');
localStorage.removeItem('token');
localStorage.removeItem('refreshToken');
localStorage.removeItem('userInfo');
history.push('/user/login');
}
}
return errorMessage("请求失败: " + error.message);
}
};
export default cusRequest;

View File

@ -1,5 +1,5 @@
import type { RequestOptions } from '@@/plugin-request/request'; import type { RequestOptions } from '@@/plugin-request/request';
import { RequestConfig, request } from '@umijs/max'; import { RequestConfig } from '@umijs/max';
import { message } from 'antd'; import { message } from 'antd';
import { history } from 'umi'; import { history } from 'umi';
@ -18,58 +18,6 @@ interface ResponseStructure {
message?: string; message?: string;
} }
// 添加一个刷新 token 的函数
const refreshToken = async () => {
try {
let refreshTokenId = localStorage.getItem('refreshToken');
if (!refreshTokenId) {
return false;
}
let userId = JSON.parse(localStorage.getItem('userInfo') ?? "{}").id;
// 这里实现刷新 token 的逻辑
const response = await request('/lms/User/RefreshToken', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
data: {
refreshToken: refreshTokenId,
"userId": userId,
"deviceInfo": "2"
},
});
if (response.code == 1) {
localStorage.setItem('token', response.data);
return true;
}
return false;
} catch (error) {
console.error('刷新 token 失败', error);
return false;
}
};
const retryRequest = async (url: string, opts: RequestOptions) => {
if (url) {
try {
const response = await request(url, {
...opts,
headers: {
...opts.headers,
'Authorization': `Bearer ${localStorage.getItem('token')}`,
},
});
return response;
} catch (error) {
console.error('重试请求失败', error);
throw error;
}
} else {
throw new Error('url is required for retryRequest');
}
};
/** /**
* @name * @name
@ -92,6 +40,7 @@ export const errorConfig: RequestConfig = {
}, },
// 错误接收及处理 // 错误接收及处理
errorHandler: async (error: any, opts: any) => { errorHandler: async (error: any, opts: any) => {
debugger
let url = error.config.url; let url = error.config.url;
if (opts?.skipErrorHandler) throw error; if (opts?.skipErrorHandler) throw error;
// 我们的 errorThrower 抛出的错误。 // 我们的 errorThrower 抛出的错误。
@ -99,47 +48,7 @@ export const errorConfig: RequestConfig = {
} else if (error.response) { } else if (error.response) {
// 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围 // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
const { status } = error.response;
if (status === 401) {
if (url.toLowerCase().includes('/refreshtoken')) {
message.error('登录已过期,请重新登录');
localStorage.removeItem('token');
localStorage.removeItem('refreshToken');
localStorage.removeItem('userInfo');
history.push('/user/login');
} else {
// 尝试刷新 token
const refreshSuccess = await refreshToken();
if (refreshSuccess) {
// 刷新成功,重试原请求
// 这里需要实现重试逻辑,可能需要修改您的请求库
message.success('已重新获取授权,正在重试请求');
// 刷新成功,重试原请求
try {
const retryResponse = await retryRequest(url, opts);
// 如果重试成功,返回重试的响应
return retryResponse;
} catch (retryError) {
message.error('重试请求失败,请重新登录');
localStorage.removeItem('token');
localStorage.removeItem('refreshToken');
localStorage.removeItem('userInfo');
history.push('/user/login');
}
// 重试原请求的逻辑
} else {
// 刷新失败,重定向到登录页面
message.error('授权已过期,请重新登录');
localStorage.removeItem('token');
localStorage.removeItem('refreshToken');
localStorage.removeItem('userInfo');
history.push('/user/login');
}
}
// 这边要判断是不是刷新token的时候401如果是刷新token的时候401就不跳转到登录页面
// message.error('未授权,请重新登录');
// history.push('/user/login'); // 重定向到登录页面
}
} else if (error.request) { } else if (error.request) {
// 请求已经成功发起,但没有收到响应 // 请求已经成功发起,但没有收到响应

View File

@ -1,6 +1,7 @@
// @ts-ignore // @ts-ignore
/* eslint-disable */ /* eslint-disable */
import { request, useModel } from '@umijs/max';
import cusRequest from '@/request';
import { TokenStorage } from '../define/tokenStorage'; import { TokenStorage } from '../define/tokenStorage';
import { getCurrentUser } from './user'; import { getCurrentUser } from './user';
import forge from 'node-forge'; import forge from 'node-forge';
@ -16,7 +17,7 @@ export async function getFakeCaptcha(
}, },
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.FakeCaptcha>('/api/login/captcha', { return cusRequest<API.FakeCaptcha>('/api/login/captcha', {
method: 'GET', method: 'GET',
params: { params: {
...params, ...params,
@ -32,7 +33,7 @@ export async function getFakeCaptcha(
export async function getPublicKey(): Promise<UserModel.UserPublicKeyResPonse> { export async function getPublicKey(): Promise<UserModel.UserPublicKeyResPonse> {
try { try {
// 获取加密的公钥 // 获取加密的公钥
let publicKey = await request<ApiResponse.SuccessItem<UserModel.UserPublicKeyResPonse>>("/lms/User/GetPublicKey", { let publicKey = await cusRequest<UserModel.UserPublicKeyResPonse>("/lms/User/GetPublicKey", {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -41,6 +42,9 @@ export async function getPublicKey(): Promise<UserModel.UserPublicKeyResPonse> {
if (publicKey.code != 1) { if (publicKey.code != 1) {
throw new Error(publicKey.message); throw new Error(publicKey.message);
} }
if (publicKey.data == undefined || publicKey.data == null) {
throw new Error("获取公钥失败");
}
return publicKey.data; return publicKey.data;
} catch (error: any) { } catch (error: any) {
throw new Error(error.toString()); throw new Error(error.toString());
@ -86,7 +90,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
loginType: 1, loginType: 1,
tokenId: publicKey.token tokenId: publicKey.token
} }
let res = await request<ApiResponse.SuccessItem<UserModel.UserLoginResponse>>('/lms/User/Login', { let res = await cusRequest<UserModel.UserLoginResponse>('/lms/User/Login', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -106,6 +110,9 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
} else { } else {
throw new Error(userInfo.message); throw new Error(userInfo.message);
} }
if (userInfo.data == null) {
throw new Error("获取用户信息失败");
}
return userInfo.data return userInfo.data
} else { } else {
throw new Error(res.message); throw new Error(res.message);
@ -132,7 +139,7 @@ export async function UserRegistr(params: UserModel.UserRegisterParams): Promise
affiliateCode: params.affiliateCode, affiliateCode: params.affiliateCode,
verificationCode: params.verificationCode verificationCode: params.verificationCode
} }
let res = await request<ApiResponse.SuccessItem<string>>('/lms/User/Register', { let res = await cusRequest<string>('/lms/User/Register', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@ -1,4 +1,4 @@
import { request } from "@umijs/max"; import cusRequest from "@/request";
import { objectToQueryString } from "./common" import { objectToQueryString } from "./common"
/** /**
@ -14,13 +14,13 @@ async function QueryMachineList(tableParams: TableModel.TableParams, userParams:
pageSize: tableParams.pagination?.pageSize, pageSize: tableParams.pagination?.pageSize,
} }
let query = objectToQueryString(data) let query = objectToQueryString(data)
let res = await request<ApiResponse.SuccessItem<MachineModel.QueryMachineData>>(`/lms/Machine/QueryMachineCollection?${query}`, { let res = await cusRequest<MachineModel.QueryMachineData>(`/lms/Machine/QueryMachineCollection?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as MachineModel.QueryMachineData;
} }
/** /**
@ -28,7 +28,7 @@ async function QueryMachineList(tableParams: TableModel.TableParams, userParams:
* @param id * @param id
*/ */
async function MachinePermanent(id: String): Promise<void> { async function MachinePermanent(id: String): Promise<void> {
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/Machine/UpgradeMachine/${id}`, { let res = await cusRequest<null>(`/lms/Machine/UpgradeMachine/${id}`, {
method: 'POST', method: 'POST',
}); });
if (res.code != 1) { if (res.code != 1) {
@ -41,7 +41,7 @@ async function MachinePermanent(id: String): Promise<void> {
* @param id * @param id
*/ */
async function DeactivationMachine(id: string): Promise<void> { async function DeactivationMachine(id: string): Promise<void> {
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/Machine/DeactivateMachine/${id}`, { let res = await cusRequest<null>(`/lms/Machine/DeactivateMachine/${id}`, {
method: 'POST', method: 'POST',
}); });
if (res.code != 1) { if (res.code != 1) {
@ -55,12 +55,15 @@ async function DeactivationMachine(id: string): Promise<void> {
* @returns * @returns
*/ */
async function GetMachineInfo(id: string): Promise<MachineModel.MachineInfo> { async function GetMachineInfo(id: string): Promise<MachineModel.MachineInfo> {
let res = await request<ApiResponse.SuccessItem<MachineModel.MachineInfo>>(`/lms/Machine/GetMachineDetail/${id}`, { let res = await cusRequest<MachineModel.MachineInfo>(`/lms/Machine/GetMachineDetail/${id}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
if (res.data == null) {
throw new Error("获取机器码信息失败");
}
return res.data; return res.data;
} }
@ -75,7 +78,7 @@ async function ModifyMachineData(id: string, params: MachineModel.ModifyMachineP
...params, ...params,
deactivationTime: deactivationTimeString deactivationTime: deactivationTimeString
} }
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/Machine/ModifyMachine/${id}`, { let res = await cusRequest<null>(`/lms/Machine/ModifyMachine/${id}`, {
method: 'POST', method: 'POST',
data: data data: data
}); });
@ -97,7 +100,7 @@ async function AddMachineData(params: MachineModel.AddMachineParams) {
status: 1, status: 1,
} }
console.log(data) console.log(data)
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/Machine/AddMachine`, { let res = await cusRequest<null>(`/lms/Machine/AddMachine`, {
method: 'POST', method: 'POST',
data: data data: data
}); });

View File

@ -1,3 +1,4 @@
import cusRequest from "@/request";
import { AllOptionKeyName, OptionKeyName, OptionType } from "@/services/enum/optionEnum"; import { AllOptionKeyName, OptionKeyName, OptionType } from "@/services/enum/optionEnum";
import { isEmpty } from "lodash"; import { isEmpty } from "lodash";
@ -89,7 +90,6 @@ export function getOptionsStringValue(options: OptionModel.Option[], keyName: st
} }
} }
import { request } from "@umijs/max";
/** /**
* *
@ -97,7 +97,7 @@ import { request } from "@umijs/max";
* @throws {Error} 1 * @throws {Error} 1
*/ */
export async function GetOptions(optionsKey: AllOptionKeyName): Promise<OptionModel.Option[]> { export async function GetOptions(optionsKey: AllOptionKeyName): Promise<OptionModel.Option[]> {
let res = await request<ApiResponse.SuccessItem<OptionModel.Option[]>>(`/lms/LaitoolOptions/GetAllOptions/${optionsKey}`, { let res = await cusRequest<OptionModel.Option[]>(`/lms/LaitoolOptions/GetAllOptions/${optionsKey}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -106,7 +106,7 @@ export async function GetOptions(optionsKey: AllOptionKeyName): Promise<OptionMo
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as OptionModel.Option[];
} }
/** /**
@ -115,7 +115,7 @@ export async function GetOptions(optionsKey: AllOptionKeyName): Promise<OptionMo
* @returns * @returns
*/ */
export async function GetSimpleOptions(optionsKey: OptionKeyName): Promise<OptionModel.Option[]> { export async function GetSimpleOptions(optionsKey: OptionKeyName): Promise<OptionModel.Option[]> {
let res = await request<ApiResponse.SuccessItem<OptionModel.Option[]>>(`/lms/LaitoolOptions/GetSimpleOptions/${optionsKey}`, { let res = await cusRequest<OptionModel.Option[]>(`/lms/LaitoolOptions/GetSimpleOptions/${optionsKey}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -124,7 +124,7 @@ export async function GetSimpleOptions(optionsKey: OptionKeyName): Promise<Optio
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as OptionModel.Option[];
} }
/** /**
@ -141,7 +141,7 @@ export async function SaveOptions(options: object): Promise<void> {
return ""; return "";
}, {}); }, {});
let res = await request<ApiResponse.SuccessItem<boolean>>('/lms/LaitoolOptions/ModifyOptions', { let res = await cusRequest<boolean>('/lms/LaitoolOptions/ModifyOptions', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@ -0,0 +1,105 @@
import cusRequest from "@/request";
import { objectToQueryString } from "./common";
/**
*
* @param values
*/
export async function AddMachineIdAuthorizationFunc(values: any) {
let res = await cusRequest<string>('lms/Other/AddMachineAuthorization', {
method: "POST",
data: {
...values
}
})
if (res.code !== 1) {
throw new Error(res.message);
}
}
/**
*
* @param values
*/
export async function ModifyMachineAuthorization(id: string, values: any) {
debugger
let expiryDateString = values.expiryDate ? values.expiryDate.toISOString() : undefined;
let res = await cusRequest<string>('lms/Other/ModifyMachineAuthorization/' + id, {
method: "POST",
data: {
...values,
expiryDate: expiryDateString
}
})
if (res.code !== 1) {
throw new Error(res.message);
}
}
/**
*
* @param tableParams
* @param options
* @returns
*/
export async function QueryMachineAuthorization(tableParams: TableModel.TableParams, options?: any) {
let data = {
...options,
page: tableParams.pagination?.current,
pageSize: tableParams.pagination?.pageSize,
}
let query = objectToQueryString(data)
let res = await cusRequest<MachineAuthorizationModel.QueryMachineAuthorizationData>(`/lms/Other/QueryMachineAuthorizationCollection?${query}`, {
method: 'GET',
});
if (res.code != 1) {
throw new Error(res.message);
}
let resData = res.data;
if (resData?.collection == undefined) {
throw new Error('请求获取数据为空,请重试!');
}
return resData as MachineAuthorizationModel.QueryMachineAuthorizationData;
}
/**
* ID的机器码授权
* @param id
*/
export async function DeleteMachineAuthorization(id: string) {
let res = await cusRequest<string>(`/lms/Other/DeleteMachineAuthorization/${id}`, {
method: 'DELETE',
});
if (res.code != 1) {
throw new Error(res.message);
}
}
/**
*
*/
export async function BatchDeleteMachine() {
// 开始删除
let res = await cusRequest<string>(`/lms/Other/BatchDeleteMachine`, {
method: 'DELETE',
});
if (res.code != 1) {
throw new Error(res.message);
}
}
/**
* ID的机器码授权
* @param id
*/
export async function GetMachineAuthorizationById(id: string) {
const res = await cusRequest<MachineAuthorizationModel.MachineAuthorizationBase>(`lms/Other/GetMachineAuthorization/${id}`, {
method: 'GET',
});
if (res.code !== 1) {
throw new Error(res.message);
}
return res.data as MachineAuthorizationModel.MachineAuthorizationBase;
}

View File

@ -1,5 +1,5 @@
import { request } from '@umijs/max';
import { errorMessage } from './response'; import cusRequest from '@/request';
import { objectToQueryString } from './common'; import { objectToQueryString } from './common';
//#region 提示词数据相关 //#region 提示词数据相关
@ -11,12 +11,15 @@ import { objectToQueryString } from './common';
*/ */
export async function QueryPromptCollection(param: Prompt.PromptQueryCondition): Promise<Prompt.PromptResponse> { export async function QueryPromptCollection(param: Prompt.PromptQueryCondition): Promise<Prompt.PromptResponse> {
let query = objectToQueryString(param) let query = objectToQueryString(param)
let res = await request<ApiResponse.SuccessItem<Prompt.PromptResponse>>(`/lms/Prompt/QueryPromptStringCollection/?${query}`, { let res = await cusRequest<Prompt.PromptResponse>(`/lms/Prompt/QueryPromptStringCollection/?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
if (res.data == null) {
throw new Error("获取提示词数据失败");
}
return res.data; return res.data;
} }
@ -25,12 +28,15 @@ export async function QueryPromptCollection(param: Prompt.PromptQueryCondition):
* @param id ID * @param id ID
*/ */
export async function GetPromptInfo(id: string): Promise<Prompt.PromptItem> { export async function GetPromptInfo(id: string): Promise<Prompt.PromptItem> {
let res = await request<ApiResponse.SuccessItem<Prompt.PromptItem>>(`/lms/Prompt/GetPromptInfo/${id}`, { let res = await cusRequest<Prompt.PromptItem>(`/lms/Prompt/GetPromptInfo/${id}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
if (res.data == null) {
throw new Error("获取提示词数据失败");
}
return res.data; return res.data;
} }
@ -41,7 +47,7 @@ export async function GetPromptInfo(id: string): Promise<Prompt.PromptItem> {
* @returns * @returns
*/ */
export async function AddPrompt(data: Prompt.PromptItem): Promise<string> { export async function AddPrompt(data: Prompt.PromptItem): Promise<string> {
let res = await request('/lms/Prompt/AddPrompt', { let res = await cusRequest<string>('/lms/Prompt/AddPrompt', {
method: 'POST', method: 'POST',
data: { data: {
name: data.name, name: data.name,
@ -65,7 +71,7 @@ export async function AddPrompt(data: Prompt.PromptItem): Promise<string> {
* @param params * @param params
*/ */
export async function ModifyPrompt(id: string, params: Prompt.PromptItem): Promise<void> { export async function ModifyPrompt(id: string, params: Prompt.PromptItem): Promise<void> {
let res = await request(`/lms/Prompt/ModifyPrompt/${id}`, { let res = await cusRequest<void>(`/lms/Prompt/ModifyPrompt/${id}`, {
method: "POST", method: "POST",
data: { data: {
...params ...params
@ -81,7 +87,7 @@ export async function ModifyPrompt(id: string, params: Prompt.PromptItem): Promi
* @param id ID * @param id ID
*/ */
export async function DeletePrompt(id: string): Promise<void> { export async function DeletePrompt(id: string): Promise<void> {
let res = await request(`/lms/Prompt/DeletePrompt/${id}`, { let res = await cusRequest<void>(`/lms/Prompt/DeletePrompt/${id}`, {
method: 'DELETE', method: 'DELETE',
}) })
if (res.code != 1) { if (res.code != 1) {
@ -102,13 +108,13 @@ export async function DeletePrompt(id: string): Promise<void> {
*/ */
export async function QueryPromptypeCollection(param: Prompt.PromptTypeQueryCondition): Promise<Prompt.PromptTypeResponse> { export async function QueryPromptypeCollection(param: Prompt.PromptTypeQueryCondition): Promise<Prompt.PromptTypeResponse> {
let query = objectToQueryString(param) let query = objectToQueryString(param)
let res = await request<ApiResponse.SuccessItem<Prompt.PromptTypeResponse>>(`/lms/Prompt/QueryPromptypeCollection/?${query}`, { let res = await cusRequest<Prompt.PromptTypeResponse>(`/lms/Prompt/QueryPromptypeCollection/?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as Prompt.PromptTypeResponse;
} }
/** /**
@ -116,13 +122,13 @@ export async function QueryPromptypeCollection(param: Prompt.PromptTypeQueryCond
* @returns * @returns
*/ */
export async function GetPromptTypeOptions(): Promise<Prompt.PromptTypeOptions[]> { export async function GetPromptTypeOptions(): Promise<Prompt.PromptTypeOptions[]> {
let res = await request<ApiResponse.SuccessItem<Prompt.PromptTypeOptions[]>>(`/lms/Prompt/GetPromptTypeOptions`, { let res = await cusRequest<Prompt.PromptTypeOptions[]>(`/lms/Prompt/GetPromptTypeOptions`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as Prompt.PromptTypeOptions[];
} }
/** /**
@ -131,13 +137,13 @@ export async function GetPromptTypeOptions(): Promise<Prompt.PromptTypeOptions[]
* @returns * @returns
*/ */
export async function GetPromptTypeInfo(id: string): Promise<Prompt.PromptTypeItem> { export async function GetPromptTypeInfo(id: string): Promise<Prompt.PromptTypeItem> {
let res = await request<ApiResponse.SuccessItem<Prompt.PromptTypeItem>>(`/lms/Prompt/GetPromptTypeInfo/${id}`, { let res = await cusRequest<Prompt.PromptTypeItem>(`/lms/Prompt/GetPromptTypeInfo/${id}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as Prompt.PromptTypeItem;
} }
/** /**
@ -145,7 +151,7 @@ export async function GetPromptTypeInfo(id: string): Promise<Prompt.PromptTypeIt
* @param data * @param data
*/ */
export async function AddPromptType(data: Prompt.AddPromptType): Promise<string> { export async function AddPromptType(data: Prompt.AddPromptType): Promise<string> {
let res = await request('/lms/Prompt/AddPromptType', { let res = await cusRequest<string>('/lms/Prompt/AddPromptType', {
method: 'POST', method: 'POST',
data: { data: {
name: data.name, name: data.name,
@ -169,7 +175,7 @@ export async function EditPromptType(data: Prompt.AddPromptType): Promise<string
if (id == null || id == undefined) { if (id == null || id == undefined) {
throw new Error("修改提示词类型的ID不能为空") throw new Error("修改提示词类型的ID不能为空")
} }
let res = await request(`/lms/Prompt/ModityPromptType/${id}`, { let res = await cusRequest<string>(`/lms/Prompt/ModityPromptType/${id}`, {
method: 'POST', method: 'POST',
data: { data: {
name: data.name, name: data.name,
@ -190,8 +196,8 @@ export async function EditPromptType(data: Prompt.AddPromptType): Promise<string
* @param deletePrompt * @param deletePrompt
* @returns * @returns
*/ */
export async function DeletePromptType(id: string, deletePrompt: boolean): Promise<API.SuccessItem> { export async function DeletePromptType(id: string, deletePrompt: boolean): Promise<ApiResponse.SuccessItem<any>> {
let res = await request(`/lms/Prompt/DeletePromptType/${id}/${deletePrompt}`, { let res = await cusRequest<any>(`/lms/Prompt/DeletePromptType/${id}/${deletePrompt}`, {
method: 'DELETE', method: 'DELETE',
}) })
return res; return res;

View File

@ -4,7 +4,7 @@
* @param {*} message * @param {*} message
* @returns * @returns
*/ */
export function successMessage(data: any, message: string): API.SuccessItem { export function successMessage<T>(data: T, message: string): ApiResponse.SuccessItem<T> {
return { return {
code: 1, code: 1,
data: data, data: data,
@ -17,9 +17,10 @@ export function successMessage(data: any, message: string): API.SuccessItem {
* @param {*} message * @param {*} message
* @returns * @returns
*/ */
export function errorMessage(message: string): API.ErrorItem { export function errorMessage(message: string): ApiResponse.ErrorItem {
return { return {
code: 0, code: 0,
message: message message: message,
data: undefined
} }
} }

View File

@ -1,4 +1,5 @@
import { request } from "@umijs/max";
import cusRequest from "@/request";
import { isEmpty } from "lodash"; import { isEmpty } from "lodash";
/** /**
@ -18,26 +19,26 @@ export async function QueryRoleList(tableParams: TableModel.TableParams, rolePar
delete data.current; delete data.current;
delete data.total; delete data.total;
let query = new URLSearchParams(data).toString(); let query = new URLSearchParams(data).toString();
let res = await request<ApiResponse.SuccessItem<RoleModel.QueryRoleData>>(`/lms/Role/QueryRoleCollection?${query}`, { let res = await cusRequest<RoleModel.QueryRoleData>(`/lms/Role/QueryRoleCollection?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as RoleModel.QueryRoleData;
} }
/** /**
* *
*/ */
export async function QueryRoleOption() { export async function QueryRoleOption() {
let res = await request<ApiResponse.SuccessItem<string[]>>(`/lms/Role/QueryRoleOption`, { let res = await cusRequest<string[]>(`/lms/Role/QueryRoleOption`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as string[];
} }
@ -47,13 +48,13 @@ export async function QueryRoleOption() {
* @returns * @returns
*/ */
export async function GetRoleById(roleId: number): Promise<RoleModel.Collection> { export async function GetRoleById(roleId: number): Promise<RoleModel.Collection> {
let res = await request<ApiResponse.SuccessItem<RoleModel.Collection>>(`/lms/Role/QueryRoleById/${roleId}`, { let res = await cusRequest<RoleModel.Collection>(`/lms/Role/QueryRoleById/${roleId}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as RoleModel.Collection;
} }
/** /**
@ -63,7 +64,7 @@ export async function GetRoleById(roleId: number): Promise<RoleModel.Collection>
* @param roleRemark * @param roleRemark
*/ */
export async function UpdeteRole(roleId: number, roleName: string, roleRemark: string): Promise<void> { export async function UpdeteRole(roleId: number, roleName: string, roleRemark: string): Promise<void> {
let res = await request<ApiResponse.SuccessItem<void>>(`/lms/Role/UpdateRole/${roleId}`, { let res = await cusRequest<void>(`/lms/Role/UpdateRole/${roleId}`, {
method: 'POST', method: 'POST',
data: { data: {
name: roleName, name: roleName,
@ -81,7 +82,7 @@ export async function UpdeteRole(roleId: number, roleName: string, roleRemark: s
* @param roleId ID * @param roleId ID
*/ */
export async function DeleteRoleById(roleId: number): Promise<void> { export async function DeleteRoleById(roleId: number): Promise<void> {
let res = await request<ApiResponse.SuccessItem<void>>(`/lms/Role/DeleteRole/${roleId}`, { let res = await cusRequest<void>(`/lms/Role/DeleteRole/${roleId}`, {
method: 'DELETE', method: 'DELETE',
}); });
if (res.code != 1) { if (res.code != 1) {
@ -98,7 +99,7 @@ export async function AddRole(roleNmae: string, roleRemark: string): Promise<voi
if (isEmpty(roleNmae)) { if (isEmpty(roleNmae)) {
throw new Error("角色名称不能为空"); throw new Error("角色名称不能为空");
} }
let res = await request<ApiResponse.SuccessItem<void>>(`/lms/Role/AddRole`, { let res = await cusRequest<void>(`/lms/Role/AddRole`, {
method: 'POST', method: 'POST',
data: { data: {
name: roleNmae, name: roleNmae,

View File

@ -1,5 +1,6 @@
import { request } from '@umijs/max';
import cusRequest from '@/request';
import { objectToQueryString } from './common'; import { objectToQueryString } from './common';
/** /**
@ -8,11 +9,11 @@ import { objectToQueryString } from './common';
* @returns * @returns
*/ */
async function GetUserSoftwareControlCount(userId: number) { async function GetUserSoftwareControlCount(userId: number) {
let res = await request<ApiResponse.SuccessItem<number>>(`/lms/SoftWare/GetUserSoftwareControlCount/${userId}`, { let res = await cusRequest<number>(`/lms/SoftWare/GetUserSoftwareControlCount/${userId}`, {
method: 'GET', method: 'GET',
}); });
if (res.code == 1) { if (res.code == 1) {
return res.data; return res.data as number;
} }
throw new Error(res.message); throw new Error(res.message);
} }
@ -23,7 +24,7 @@ async function GetUserSoftwareControlCount(userId: number) {
* @returns * @returns
*/ */
async function ApplyUserSoftwareControl(userId: number) { async function ApplyUserSoftwareControl(userId: number) {
let res = await request<ApiResponse.SuccessItem<boolean>>(`/lms/SoftWare/ApplySoftwareControl/${userId}`, { let res = await cusRequest<boolean>(`/lms/SoftWare/ApplySoftwareControl/${userId}`, {
method: 'POST', method: 'POST',
}); });
if (res.code == 1) { if (res.code == 1) {
@ -45,17 +46,17 @@ async function GetUserSoftwareControlCollection(tableParams: TableModel.TablePar
pageSize: tableParams.pagination?.pageSize, pageSize: tableParams.pagination?.pageSize,
} }
let query = objectToQueryString(data) let query = objectToQueryString(data)
let res = await request<ApiResponse.SuccessItem<SoftwareModel.QuerySoftwareControlData>>(`/lms/SoftWare/GetSoftwareControlCollection?${query}`, { let res = await cusRequest<SoftwareModel.QuerySoftwareControlData>(`/lms/SoftWare/GetSoftwareControlCollection?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as SoftwareModel.QuerySoftwareControlData;
} }
async function AddSoftwareControlExpirationTime(id: string, days: number, isForever: boolean, isTry = false) { async function AddSoftwareControlExpirationTime(id: string, days: number, isForever: boolean, isTry = false) {
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/SoftWare/ModifySoftwareControlValidity/${id}`, { let res = await cusRequest<null>(`/lms/SoftWare/ModifySoftwareControlValidity/${id}`, {
method: 'POST', method: 'POST',
data: { data: {
expirationTime: days, expirationTime: days,
@ -81,11 +82,11 @@ export const SoftwareControl = {
* @returns * @returns
*/ */
async function GetSoftwareBaseCollection() { async function GetSoftwareBaseCollection() {
let res = await request<ApiResponse.SuccessItem<SoftwareModel.SoftwareBasicInfo[]>>(`/lms/SoftWare/GetSoftwareBaseCollection`, { let res = await cusRequest<SoftwareModel.SoftwareBasicInfo[]>(`/lms/SoftWare/GetSoftwareBaseCollection`, {
method: 'GET', method: 'GET',
}); });
if (res.code == 1) { if (res.code == 1) {
return res.data; return res.data as SoftwareModel.SoftwareBasicInfo[];
} }
throw new Error(res.message); throw new Error(res.message);
} }

View File

@ -1,9 +1,10 @@
import { request } from '@umijs/max';
import cusRequest from '@/request';
import { objectToQueryString } from './common'; import { objectToQueryString } from './common';
/** 获取当前的用户 GET /api/currentUser */ /** 获取当前的用户 GET /api/currentUser */
export async function getCurrentUser(id: number, options?: { [key: string]: any }) { export async function getCurrentUser(id: number, options?: { [key: string]: any }) {
return request<ApiResponse.SuccessItem<UserModel.UserInfo>>(`/lms/User/GetUserInfo/${id}`, { return cusRequest<UserModel.UserInfo>(`/lms/User/GetUserInfo/${id}`, {
method: 'GET', method: 'GET',
...(options || {}), ...(options || {}),
}); });
@ -15,13 +16,13 @@ export async function getCurrentUser(id: number, options?: { [key: string]: any
* @returns * @returns
*/ */
async function GetUserInfo(id: number): Promise<UserModel.UserInfo> { async function GetUserInfo(id: number): Promise<UserModel.UserInfo> {
let res = await request<ApiResponse.SuccessItem<UserModel.UserInfo>>(`/lms/User/GetUserInfo/${id}`, { let res = await cusRequest<UserModel.UserInfo>(`/lms/User/GetUserInfo/${id}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as UserModel.UserInfo;
} }
/** /**
@ -46,7 +47,7 @@ async function UpdatedUserInfo(userData: UserModel.UserInfo) {
} }
} }
let res = await request<ApiResponse.SuccessItem<UserModel.UserInfo>>(`/lms/User/UpdatedUser/${userData.id}`, { let res = await cusRequest<UserModel.UserInfo>(`/lms/User/UpdatedUser/${userData.id}`, {
method: 'POST', method: 'POST',
data: data, data: data,
}); });
@ -68,13 +69,13 @@ async function QueryUserList(tableParams: TableModel.TableParams, userParams: Us
pageSize: tableParams.pagination?.pageSize, pageSize: tableParams.pagination?.pageSize,
} }
let query = objectToQueryString(data) let query = objectToQueryString(data)
let res = await request<ApiResponse.SuccessItem<UserModel.QueryUserData>>(`/lms/User/QueryUserCollection?${query}`, { let res = await cusRequest<UserModel.QueryUserData>(`/lms/User/QueryUserCollection?${query}`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as UserModel.QueryUserData;
} }
@ -83,7 +84,7 @@ async function QueryUserList(tableParams: TableModel.TableParams, userParams: Us
* @param id * @param id
*/ */
async function EnableAgent() { async function EnableAgent() {
let res = await request<ApiResponse.SuccessItem<UserModel.UserInfo>>(`/lms/User/EnableAgent`, { let res = await cusRequest<UserModel.UserInfo>(`/lms/User/EnableAgent`, {
method: 'POST', method: 'POST',
}); });
if (res.code != 1) { if (res.code != 1) {
@ -96,13 +97,13 @@ async function EnableAgent() {
* @returns * @returns
*/ */
async function GetUserAgentInfo(): Promise<UserModel.UserAgentInfo> { async function GetUserAgentInfo(): Promise<UserModel.UserAgentInfo> {
let res = await request<ApiResponse.SuccessItem<UserModel.UserAgentInfo>>(`/lms/User/GetUserAgentInfo`, { let res = await cusRequest<UserModel.UserAgentInfo>(`/lms/User/GetUserAgentInfo`, {
method: 'GET', method: 'GET',
}); });
if (res.code != 1) { if (res.code != 1) {
throw new Error(res.message); throw new Error(res.message);
} }
return res.data; return res.data as UserModel.UserAgentInfo;
} }
/** /**
@ -111,7 +112,7 @@ async function GetUserAgentInfo(): Promise<UserModel.UserAgentInfo> {
* @param newPassword * @param newPassword
*/ */
async function ResetUserPassword(userId: number, newPassword: string): Promise<void> { async function ResetUserPassword(userId: number, newPassword: string): Promise<void> {
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/User/ResetPassword/${userId}`, { let res = await cusRequest<null>(`/lms/User/ResetPassword/${userId}`, {
method: 'post', method: 'post',
data: { data: {
newPassword: newPassword, newPassword: newPassword,

View File

@ -14,6 +14,8 @@ declare namespace AccessType {
isAdmin: boolean; isAdmin: boolean;
/**是不是超级管理员 */ /**是不是超级管理员 */
isSuperAdmin: boolean; isSuperAdmin: boolean;
/** 是不是代理 */
isAgentUser: boolean;
/**是不是管理员或者超级管理员 */ /**是不是管理员或者超级管理员 */
isAdminOrSuperAdmin: boolean; isAdminOrSuperAdmin: boolean;
//#endregion //#endregion
@ -26,7 +28,7 @@ declare namespace AccessType {
canLaiToolOptions: boolean; canLaiToolOptions: boolean;
/** 是不是显示系统配置项的菜单 */ /** 是不是显示系统配置项的菜单 */
canSystemOptions : boolean; canSystemOptions: boolean;
//#endregion //#endregion
//#region 机器权限 //#region 机器权限
@ -51,6 +53,23 @@ declare namespace AccessType {
canApplySoftwareControl: boolean; canApplySoftwareControl: boolean;
/** 是否可以查看软件控制管理 */ /** 是否可以查看软件控制管理 */
canSofrwareControlManagement: boolean; canSofrwareControlManagement: boolean;
/** 是否可以编辑软件控制权限 */
canEditSoftwareControl: boolean;
/** 是否可以添加使用软件控制权限 */
canAddTrailSoftwareControl: boolean;
/** 是否可以添加月付软件控制权限 */
canAddMouthSoftwareControl: boolean;
/** 是否可以添加季付软件控制权限 */
canAddQuarterlySoftwareControl: boolean;
/** 是否可以添加半年付软件控制权限 */
canAddHalfYearSoftwareControl: boolean;
/** 是否可以添加年付软件控制权限 */
canAddYearSoftwareControl: boolean;
/** 是否可以添加永久软件控制权限 */
canAddForeverSoftwareControl: boolean;
/** 是否可以删除软件控制权限 */
canDeleteSoftwareControl: boolean;
//#endregion //#endregion
} }
} }

View File

@ -5,9 +5,9 @@ declare namespace ApiResponse {
data: T data: T
} }
type ErrorItem<T> = { type ErrorItem = {
code: number code: number
message: string message: string,
data?: T data: undefined
} }
} }

View File

@ -11,6 +11,8 @@ declare namespace MachineAuthorizationModel {
id: string; id: string;
machineID: string; machineID: string;
type: number; type: number;
useType: number;
expiryTime: number;
authorizedDate: Date; authorizedDate: Date;
expiryDate: Date; expiryDate: Date;
authorizationCode: string; authorizationCode: string;