|
@@ -1,3 +1,4 @@
|
|
|
+import { appConstant } from "@/app";
|
|
|
import { SceneTypeDomain, SceneTypePaths } from "@/constant/scene";
|
|
|
import { alert } from "@/helper/message";
|
|
|
import { getCaseSceneList } from "@/store/case";
|
|
@@ -6,16 +7,25 @@ import { SceneType } from "@/store/scene";
|
|
|
import { user } from "@/store/user";
|
|
|
import { base64ToBlob, drawImage } from "@/util";
|
|
|
|
|
|
-export type MenuItem = { key: string; label: string; onClick: (caseId: number) => void };
|
|
|
+export type MenuItem = {
|
|
|
+ key: string;
|
|
|
+ label: string;
|
|
|
+ onClick: (caseId: number) => void;
|
|
|
+};
|
|
|
|
|
|
export const getFuseCodeLink = (caseId: number, query?: boolean) => {
|
|
|
- const params: { token?: string; caseId: string } = {
|
|
|
+ const params: { token?: string; caseId: string; app: string } = {
|
|
|
caseId: caseId.toString(),
|
|
|
+ app: appConstant.deptId.toString(),
|
|
|
};
|
|
|
+
|
|
|
if (!query) {
|
|
|
params.token = user.value.token;
|
|
|
}
|
|
|
- const url = new URL(SceneTypePaths[SceneType.SWMX][0], SceneTypeDomain[SceneType.SWMX]);
|
|
|
+ const url = new URL(
|
|
|
+ SceneTypePaths[SceneType.SWMX][0],
|
|
|
+ SceneTypeDomain[SceneType.SWMX]
|
|
|
+ );
|
|
|
for (const [name, val] of Object.entries(params)) {
|
|
|
url.searchParams.append(name, val || "");
|
|
|
}
|
|
@@ -31,12 +41,12 @@ export const checkScenesOpen = async (caseId: number, url: URL | string) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const getQuery = (caseId: number) =>
|
|
|
- `${getFuseCodeLink(caseId, true)}&share=1#show/summary`;
|
|
|
+export const getQuery = (caseId: number, share: boolean = false) =>
|
|
|
+ `${getFuseCodeLink(caseId, true)}${share ? "&share=1" : ""}#show/summary`;
|
|
|
|
|
|
// 查看
|
|
|
export const gotoQuery = (caseId: number) => {
|
|
|
- checkScenesOpen(caseId, getQuery(caseId));
|
|
|
+ checkScenesOpen(caseId, getQuery(caseId, true));
|
|
|
};
|
|
|
|
|
|
export enum FuseImageType {
|
|
@@ -57,7 +67,9 @@ export const getFuseImage = async (
|
|
|
if (!iframeElement) {
|
|
|
return null;
|
|
|
}
|
|
|
- const extIframe = iframeElement.querySelector(".external") as HTMLIFrameElement;
|
|
|
+ const extIframe = iframeElement.querySelector(
|
|
|
+ ".external"
|
|
|
+ ) as HTMLIFrameElement;
|
|
|
const targetIframe = extIframe || iframe;
|
|
|
const targetWindow: any = targetIframe.contentWindow;
|
|
|
const fuseCnavas = targetWindow.document.querySelector(
|
|
@@ -85,14 +97,15 @@ export const getFuseImage = async (
|
|
|
} else {
|
|
|
const sdk = targetWindow.__sdk;
|
|
|
return new Promise<FuseImageRet>((resolve) => {
|
|
|
- sdk.Camera.screenshot([{ width: width, height: width, name: "2k" }], false).then(
|
|
|
- (result: any) => {
|
|
|
- resolve({
|
|
|
- type: FuseImageType.KANKAN,
|
|
|
- blob: base64ToBlob(result[0].data),
|
|
|
- });
|
|
|
- }
|
|
|
- );
|
|
|
+ sdk.Camera.screenshot(
|
|
|
+ [{ width: width, height: width, name: "2k" }],
|
|
|
+ false
|
|
|
+ ).then((result: any) => {
|
|
|
+ resolve({
|
|
|
+ type: FuseImageType.KANKAN,
|
|
|
+ blob: base64ToBlob(result[0].data),
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
};
|
|
@@ -122,7 +135,9 @@ export const fuseImageJoinHot = async (
|
|
|
) as HTMLDivElement[];
|
|
|
hotItems.forEach((hot) => {
|
|
|
const hotTitle = (hot.querySelector(".tip") as HTMLDivElement).innerText;
|
|
|
- const index = showTags.findIndex((tag) => tag.tagTitle.trim() === hotTitle.trim());
|
|
|
+ const index = showTags.findIndex(
|
|
|
+ (tag) => tag.tagTitle.trim() === hotTitle.trim()
|
|
|
+ );
|
|
|
if (index !== -1) {
|
|
|
const bound = hot.getBoundingClientRect();
|
|
|
const size = (img.width / width) * 32;
|
|
@@ -151,7 +166,16 @@ export const fuseImageJoinHot = async (
|
|
|
$ccanvas.width = width;
|
|
|
$ccanvas.height = width;
|
|
|
const cctx = $ccanvas.getContext("2d")!;
|
|
|
- drawImage(cctx, $ccanvas.width, $ccanvas.height, $canvas, img.width, img.height, 0, 0);
|
|
|
+ drawImage(
|
|
|
+ cctx,
|
|
|
+ $ccanvas.width,
|
|
|
+ $ccanvas.height,
|
|
|
+ $canvas,
|
|
|
+ img.width,
|
|
|
+ img.height,
|
|
|
+ 0,
|
|
|
+ 0
|
|
|
+ );
|
|
|
|
|
|
const blob = await new Promise<Blob | null>((resolve) =>
|
|
|
$ccanvas.toBlob(resolve, "png")
|