Skip to content

Let's use AI to Earn!

fix: 修改事件追踪

牛文政c3973bc3f4d3
diff --git a/electron/main/api/index.ts b/electron/main/api/index.ts
index 507360e1..4d14ebfc 100644
--- a/electron/main/api/index.ts
+++ b/electron/main/api/index.ts
@@ -1,4 +1,5 @@
import { net } from 'electron';
+import { getUserToken } from '../user/comment';
export interface IRequestNetResult<T> {
status: number;
@@ -12,6 +13,7 @@ export interface IRequestNetParams {
body?: any;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
isFile?: boolean;
+ isToken?: boolean;
}
const netRequest = <T = any>({
@@ -20,6 +22,7 @@ const netRequest = <T = any>({
method,
url,
isFile,
+ isToken,
}: IRequestNetParams): Promise<IRequestNetResult<T>> => {
return new Promise((resolve, reject) => {
const req = net.request({
@@ -35,6 +38,8 @@ const netRequest = <T = any>({
});
}
+ if (isToken) req.setHeader('Authorization', `Bearer ${getUserToken()}`);
+
// 处理响应
req.on('response', (response) => {
let data = '';
diff --git a/electron/main/api/tracing.ts b/electron/main/api/tracing.ts
index 7d90ccd6..4e809664 100644
--- a/electron/main/api/tracing.ts
+++ b/electron/main/api/tracing.ts
@@ -50,11 +50,13 @@ export class TracingApi {
method: 'POST',
url: 'tracing',
body: inData,
+ isToken: true,
});
const {
status,
data: { data, code },
} = res;
+
if (status !== 200 && status !== 201) return null;
if (!!code) return null;
return data;
diff --git a/src/router/index.tsx b/src/router/index.tsx
index c1c432ce..721982b2 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -19,7 +19,6 @@ import {
ShopOutlined,
MessageOutlined,
AuditOutlined,
- MoneyCollectOutlined,
OpenAIOutlined,
} from '@ant-design/icons';
@@ -46,6 +45,7 @@ import AiTool from '@/views/aiTool/index';
import AiRanking from '../views/aiTool/children/aiRanking/index';
import AiToolWebview from '../views/aiTool/children/aiToolWebview';
import ExpectedIncome from '@/views/finance/expectedIncome';
+// import Test from '@/views/test';
interface IRouterMeta {
// 路由名称
@@ -156,7 +156,7 @@ export const router: CustomRouteObject[] = [
{ path: 'userWalletRecord', element: <UserWalletRecord /> },
{ path: 'userWalletAccount', element: <UserWalletAccount /> },
{ path: 'expectedIncome', element: <ExpectedIncome /> },
- ]
+ ],
},
// {
// path: '/interaction',
diff --git a/src/views/test/index.tsx b/src/views/test/index.tsx
index c18e994d..c592bd38 100644
--- a/src/views/test/index.tsx
+++ b/src/views/test/index.tsx
@@ -5,20 +5,11 @@
* @LastEditors: nevin
* @Description: 测试页面
*/
-import { useState } from 'react';
import { Button } from 'antd';
-import { ipcGetLogFlies, ipcUpFlie } from '@/icp/tools';
-import log from 'electron-log/renderer';
export default function Test() {
- const [filePathList, setFilePathList] = useState<string[]>([]);
- const [filePath, setFilePath] = useState<string>('');
-
- function addLog() {
- log.info('------3333333-----');
- }
async function getLogFilePathList() {
- const res = await ipcGetLogFlies();
- setFilePathList(res);
+ const res = await window.ipcRenderer.invoke('ICP_GET_FILE_MATE_INFO');
+ console.log('-----', res);
}
return (
@@ -28,35 +19,8 @@ export default function Test() {
getLogFilePathList();
}}
>
- 获取日志文件列表
- </Button>
-
- <Button
- onClick={() => {
- addLog();
- }}
- >
- 前端产生日志
+ 测试事件
</Button>
-
- <Button
- onClick={() => {
- ipcUpFlie(filePath);
- }}
- >
- 上传日志文件
- </Button>
-
- <div>
- {filePathList.map((item) => (
- <div onClick={() => setFilePath(item)} key={item}>
- {item}
- </div>
- ))}
- </div>
-
- <br />
- <div>当前:{filePath}</div>
</div>
);
}