|
@@ -1,6 +1,6 @@
|
|
-export * from './hander';
|
|
|
|
|
|
+export * from "./hander";
|
|
import { AddGraph } from "@/api/systemDesigner";
|
|
import { AddGraph } from "@/api/systemDesigner";
|
|
-import { GraphType } from '@/enum';
|
|
|
|
|
|
+import { GraphType } from "@/enum";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 打印图片
|
|
* 打印图片
|
|
@@ -42,16 +42,20 @@ export function uuid() {
|
|
/**
|
|
/**
|
|
* 创建新的图形
|
|
* 创建新的图形
|
|
*/
|
|
*/
|
|
-export const createNew = async (type: string, folderId: string = 'root') => {
|
|
|
|
|
|
+export const createNew = async (type: string, folderId: string = "root") => {
|
|
const res = await AddGraph({ type, folderId });
|
|
const res = await AddGraph({ type, folderId });
|
|
const id = res?.result?.graph?.id;
|
|
const id = res?.result?.graph?.id;
|
|
- if(!id) return false;
|
|
|
|
|
|
+ if (!id) return false;
|
|
const { origin, pathname } = window.location;
|
|
const { origin, pathname } = window.location;
|
|
const enterpriseCode = sessionStorage.getItem("enterpriseCode");
|
|
const enterpriseCode = sessionStorage.getItem("enterpriseCode");
|
|
- if(type === GraphType.mindmap) {
|
|
|
|
- window.open(`${origin}${pathname}#/mindmap/${id}?enterpriseCode=${enterpriseCode}`);
|
|
|
|
|
|
+ if (type === GraphType.mindmap) {
|
|
|
|
+ window.open(
|
|
|
|
+ `${origin}${pathname}#/mindmap/${id}?enterpriseCode=${enterpriseCode}`
|
|
|
|
+ );
|
|
} else {
|
|
} else {
|
|
- window.open(`${origin}${pathname}#/flow/${id}?enterpriseCode=${enterpriseCode}`);
|
|
|
|
|
|
+ window.open(
|
|
|
|
+ `${origin}${pathname}#/flow/${id}?enterpriseCode=${enterpriseCode}`
|
|
|
|
+ );
|
|
}
|
|
}
|
|
return id;
|
|
return id;
|
|
};
|
|
};
|
|
@@ -91,30 +95,44 @@ export const listToTree = (list: TreeNode[], parent: TreeNode): TreeNode => {
|
|
|
|
|
|
/**
|
|
/**
|
|
* base64 转 file
|
|
* base64 转 file
|
|
- * @param base64String
|
|
|
|
- * @param fileName
|
|
|
|
- * @param fileType
|
|
|
|
- * @returns
|
|
|
|
|
|
+ * @param base64String
|
|
|
|
+ * @param fileName
|
|
|
|
+ * @param fileType
|
|
|
|
+ * @returns
|
|
*/
|
|
*/
|
|
-export function base64ToFile(base64String: string, fileName: string, fileType: string): File {
|
|
|
|
|
|
+export function base64ToFile(
|
|
|
|
+ base64String: string,
|
|
|
|
+ fileName: string,
|
|
|
|
+ fileType: string
|
|
|
|
+): File {
|
|
// 移除Base64字符串中的前缀(如"data:image/png;base64,")
|
|
// 移除Base64字符串中的前缀(如"data:image/png;base64,")
|
|
- const base64Data = base64String.split(',')[1];
|
|
|
|
-
|
|
|
|
|
|
+ const base64Data = base64String.split(",")[1];
|
|
|
|
+
|
|
// 解码Base64字符串
|
|
// 解码Base64字符串
|
|
const byteCharacters = atob(base64Data);
|
|
const byteCharacters = atob(base64Data);
|
|
-
|
|
|
|
|
|
+
|
|
// 创建一个Uint8Array来存储二进制数据
|
|
// 创建一个Uint8Array来存储二进制数据
|
|
const byteArrays = new Uint8Array(byteCharacters.length);
|
|
const byteArrays = new Uint8Array(byteCharacters.length);
|
|
-
|
|
|
|
|
|
+
|
|
for (let i = 0; i < byteCharacters.length; i++) {
|
|
for (let i = 0; i < byteCharacters.length; i++) {
|
|
byteArrays[i] = byteCharacters.charCodeAt(i);
|
|
byteArrays[i] = byteCharacters.charCodeAt(i);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 创建Blob对象
|
|
// 创建Blob对象
|
|
const blob = new Blob([byteArrays], { type: fileType });
|
|
const blob = new Blob([byteArrays], { type: fileType });
|
|
-
|
|
|
|
|
|
+
|
|
// 创建File对象
|
|
// 创建File对象
|
|
const file = new File([blob], fileName, { type: fileType });
|
|
const file = new File([blob], fileName, { type: fileType });
|
|
-
|
|
|
|
|
|
+
|
|
return file;
|
|
return file;
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 获取token
|
|
|
|
+ */
|
|
|
|
+export const getToken = () => {
|
|
|
|
+ const enterpriseCode = sessionStorage.getItem("enterpriseCode");
|
|
|
|
+ const token = localStorage.getItem("token_" + enterpriseCode);
|
|
|
|
+
|
|
|
|
+ return token;
|
|
|
|
+};
|