@rxdrag/website-studio 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LeftDrawer/PagesPanel/ImportPageModal/usePagesImport.d.ts +2 -0
- package/dist/components/LeftDrawer/PagesPanel/useResetPage.d.ts +2 -0
- package/dist/components/StatusBar/StopButton.d.ts +1 -1
- package/dist/components/common/ImportComponentModal/ImportComponentsTask.d.ts +23 -0
- package/dist/components/common/ImportComponentModal/useComponentsImportTask.d.ts +2 -4
- package/dist/{cssMode-3b37fb1f.js → cssMode-8bdd5502.js} +2 -3
- package/dist/{cssMode-3b37fb1f.js.map → cssMode-8bdd5502.js.map} +1 -1
- package/dist/{freemarker2-1fbc5bf0.js → freemarker2-24b36fc1.js} +2 -3
- package/dist/{freemarker2-1fbc5bf0.js.map → freemarker2-24b36fc1.js.map} +1 -1
- package/dist/{handlebars-0d2d8087.js → handlebars-53295c7b.js} +2 -3
- package/dist/{handlebars-0d2d8087.js.map → handlebars-53295c7b.js.map} +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useStopTask.d.ts +3 -0
- package/dist/hooks/useTranlateComponents.d.ts +1 -0
- package/dist/hooks/useTranslateBuiltinPage.d.ts +1 -0
- package/dist/hooks/useTranslateCustomizedPages.d.ts +1 -0
- package/dist/hooks/useTranslateRequest.d.ts +5 -0
- package/dist/{html-1f416956.js → html-70d8042e.js} +2 -3
- package/dist/{html-1f416956.js.map → html-70d8042e.js.map} +1 -1
- package/dist/{htmlMode-f8f5f503.js → htmlMode-fabb16ce.js} +2 -3
- package/dist/{htmlMode-f8f5f503.js.map → htmlMode-fabb16ce.js.map} +1 -1
- package/dist/{index-525006cd.js → index-a0e7f111.js} +593 -299
- package/dist/{index-525006cd.js.map → index-a0e7f111.js.map} +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{javascript-fa1a44fb.js → javascript-d190129b.js} +3 -4
- package/dist/{javascript-fa1a44fb.js.map → javascript-d190129b.js.map} +1 -1
- package/dist/{jsonMode-c7e6869c.js → jsonMode-04d036a7.js} +2 -3
- package/dist/{jsonMode-c7e6869c.js.map → jsonMode-04d036a7.js.map} +1 -1
- package/dist/{liquid-f59e1243.js → liquid-9ba71888.js} +2 -3
- package/dist/{liquid-f59e1243.js.map → liquid-9ba71888.js.map} +1 -1
- package/dist/{mdx-831aab9e.js → mdx-a1e1cc3f.js} +2 -3
- package/dist/{mdx-831aab9e.js.map → mdx-a1e1cc3f.js.map} +1 -1
- package/dist/{python-c08d64d5.js → python-e2f4ad56.js} +2 -3
- package/dist/{python-c08d64d5.js.map → python-e2f4ad56.js.map} +1 -1
- package/dist/{razor-c37a2ffd.js → razor-e8f995b7.js} +2 -3
- package/dist/{razor-c37a2ffd.js.map → razor-e8f995b7.js.map} +1 -1
- package/dist/{tsMode-fe874300.js → tsMode-dff5ab28.js} +2 -3
- package/dist/{tsMode-fe874300.js.map → tsMode-dff5ab28.js.map} +1 -1
- package/dist/{typescript-37e16b75.js → typescript-44b6e68e.js} +2 -3
- package/dist/{typescript-37e16b75.js.map → typescript-44b6e68e.js.map} +1 -1
- package/dist/{xml-68f06860.js → xml-3f4949e5.js} +2 -3
- package/dist/{xml-68f06860.js.map → xml-3f4949e5.js.map} +1 -1
- package/dist/{yaml-11d37d04.js → yaml-c6242439.js} +2 -3
- package/dist/{yaml-11d37d04.js.map → yaml-c6242439.js.map} +1 -1
- package/package.json +18 -18
- package/dist/components/LeftDrawer/PagesPanel/ImportPageModal/usePagesImportTask.d.ts +0 -7
- package/dist/components/LeftDrawer/PagesPanel/useResetPageTask.d.ts +0 -7
|
@@ -7,7 +7,7 @@ var __publicField = (obj, key2, value) => {
|
|
|
7
7
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$2, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa;
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { createContext, useContext, useMemo, memo, useEffect, useCallback, useState, useRef, forwardRef as forwardRef$2, Component, useImperativeHandle, isValidElement, cloneElement } from "react";
|
|
10
|
-
import { ThemeFields, PageQueryOptions, PageFields, FrontComponentQueryOptions, FrontComponentFields, ComponentCategoryFields, SectionTemplateQueryOptions, SectionTemplateFields, ComponentCategoryQueryOptions, TemplateCategoryQueryOptions, TemplateCategoryFields, ThemeQueryOptions, StyleConfigFields, LangFields, ThemeConfigQueryOptions, ThemeConfigFields, PageAssciations, TaskQueryOptions, TaskFields, AppModule, TaskStatus, PageType, ProductCategoryEntityName, ProductCategoryQueryOptions, ProductCategoryFields, ProductQueryOptions, ProductFields, PublishableStatus, websiteToInput, TaskType, LangQueryOptions, WebsiteAssciations, ExtendFieldType, ThemeConfigAssciations, MediaQueryOptions, WebsiteSettingsQueryOptions, WebsiteSettingsFields, themeConfigToInputCascade, ThemeConfigEntityName, MediaType, themeConfigToInput, websiteSettingsToInput, WebsiteSettingsEntityName, WebsiteSettingsAssciations, PageEntityName, ThemeEntityName, themeToInputCascade, ThemeCategoryFields, themeToInput, frontComponentToInput, sectionTemplateToInput, pageToInputCascade, ComponentCategoryEntityName, SectionTemplateEntityName, FrontComponentEntityName, TaskEntityName,
|
|
10
|
+
import { ThemeFields, PageQueryOptions, PageFields, FrontComponentQueryOptions, FrontComponentFields, ComponentCategoryFields, SectionTemplateQueryOptions, SectionTemplateFields, ComponentCategoryQueryOptions, TemplateCategoryQueryOptions, TemplateCategoryFields, ThemeQueryOptions, StyleConfigFields, LangFields, ThemeConfigQueryOptions, ThemeConfigFields, PageAssciations, TaskQueryOptions, TaskFields, AppModule, TaskStatus, PageType, ProductCategoryEntityName, ProductCategoryQueryOptions, ProductCategoryFields, ProductQueryOptions, ProductFields, PublishableStatus, websiteToInput, TaskType, LangQueryOptions, WebsiteAssciations, ExtendFieldType, ThemeConfigAssciations, MediaQueryOptions, WebsiteSettingsQueryOptions, WebsiteSettingsFields, themeConfigToInputCascade, ThemeConfigEntityName, MediaType, themeConfigToInput, websiteSettingsToInput, WebsiteSettingsEntityName, WebsiteSettingsAssciations, PageEntityName, ThemeEntityName, themeToInputCascade, ThemeCategoryFields, themeToInput, frontComponentToInput, sectionTemplateToInput, pageToInputCascade, ComponentCategoryEntityName, SectionTemplateEntityName, FrontComponentEntityName, TaskEntityName, pageToInput, PageMetaQueryOptions, PageMetaFields, PageMetaAssciations, componentCategoryToInput, TemplateCategoryEntityName, templateCategoryToInput } from "@rxdrag/rxcms-models";
|
|
11
11
|
import { GlobalLoading, EntityForm, SubmitButton, useListData, SearchInput, EntityPagination, useIsLoading, QueryListScope, RemoveButton, EntityTable, useRemoveRow, useEditRow, EntityEditModal, useSelectionsState, EntityListScope, NewButton, EntityRowScope, EntitySelectField, useNewRow } from "@rxdrag/rxcms-models-ui";
|
|
12
12
|
import { useOneTheme, usePageList, useTemplateCategoryList, useSectionTemplateList, useComponentCategoryList, useFrontComponentList, useOneThemeById, useTaskList, useUpsertOneWebsite, useDeleteThemeById, useUpsertOneTheme, useLangList, useOneWebsiteSettings, useOneThemeConfig, useUpsertOneThemeConfig, useUpsertOneWebsiteSettings, useUpsertOnePage, useUpsertOneFrontComponent, useUpsertOneSectionTemplate, useDeletePageById } from "@rxdrag/rxcms-model-hooks";
|
|
13
13
|
import { newPageMetaOptions, useWebsite, useCurrentLang, ComponentType, currentLangState, useCurrentLangId, MediaSingleSelectField, FullImageSelectField, useSiteId, usePreviewUrl, LangSelect, TitleAndSlug, TitleViewField, DescriptionViewField, SiteRoot } from "@rxdrag/biz-components";
|
|
@@ -24,7 +24,7 @@ import { ErrorBoundary, ColorPicker, useSave, CheckCircleIcon as CheckCircleIcon
|
|
|
24
24
|
import { PageLoader, PopoverController, ModalController, AnimateController, TabsController, NumberController, FlipController, CollapseController, AosController } from "@rxdrag/website-lib-core";
|
|
25
25
|
import gsap$2 from "gsap";
|
|
26
26
|
import { Input, Textarea, StringArrayInput, ImageSelect, TargetSetter, propSetters, DeviceBreakpoints, DeviceContext } from "@rxdrag/schema-setters";
|
|
27
|
-
import { Switch, Card, CardBody, Button as Button$2, CircularProgress, CardHeader, Select, SelectItem, Dropdown, DropdownTrigger, DropdownMenu as DropdownMenu$1, DropdownItem, Accordion, AccordionItem, Input as Input$1, Tabs, Tab, Divider, cn, Checkbox, Chip, Skeleton, CardFooter, Image, useDisclosure, Modal as Modal$2, ModalContent as ModalContent$2, ModalHeader as ModalHeader$1, ModalBody as ModalBody$1, RadioGroup, ModalFooter as ModalFooter$1, Radio, Popover, PopoverTrigger, PopoverContent } from "@heroui/react";
|
|
27
|
+
import { Switch, Card, CardBody, Button as Button$2, CircularProgress, addToast, CardHeader, Select, SelectItem, Dropdown, DropdownTrigger, DropdownMenu as DropdownMenu$1, DropdownItem, Accordion, AccordionItem, Input as Input$1, Tabs, Tab, Divider, cn, Checkbox, Chip, Skeleton, CardFooter, Image, useDisclosure, Modal as Modal$2, ModalContent as ModalContent$2, ModalHeader as ModalHeader$1, ModalBody as ModalBody$1, RadioGroup, ModalFooter as ModalFooter$1, Radio, Popover, PopoverTrigger, PopoverContent } from "@heroui/react";
|
|
28
28
|
import { useEntifyWrapperStore, useUpsertEntityWithIndicator } from "@rxdrag/rxcms-entify-wrapper";
|
|
29
29
|
import JSZip from "jszip";
|
|
30
30
|
import { create as create$4 } from "zustand";
|
|
@@ -39,7 +39,6 @@ import $4AOtR$reactdom, { createPortal } from "react-dom";
|
|
|
39
39
|
import { DeployType, useExportWebsite as useExportWebsite$1 } from "@rxdrag/code-generator";
|
|
40
40
|
import { ComponentRender } from "@rxdrag/react-runner-pro";
|
|
41
41
|
import tinycolor from "tinycolor2";
|
|
42
|
-
import { useInprogressTaskByKey, useUpdateTask, taskPool, ResetPageTask, ImportPagesTask, ImportComponentsTask } from "@rxdrag/ai-tasks";
|
|
43
42
|
var jsxRuntime = { exports: {} };
|
|
44
43
|
var reactJsxRuntime_production_min = {};
|
|
45
44
|
/**
|
|
@@ -6725,48 +6724,140 @@ function useIsBaseLangTheme() {
|
|
|
6725
6724
|
const website = useWebsite();
|
|
6726
6725
|
return ((_a3 = theme == null ? void 0 : theme.lang) == null ? void 0 : _a3.id) === ((_b3 = website == null ? void 0 : website.baseLang) == null ? void 0 : _b3.id);
|
|
6727
6726
|
}
|
|
6728
|
-
function
|
|
6727
|
+
function useTranslateRequest() {
|
|
6729
6728
|
const baseURL = useAiUrl();
|
|
6730
6729
|
const token = useEntifyToken();
|
|
6731
6730
|
const website = useWebsite();
|
|
6731
|
+
const isAxiosError = useCallback((err) => {
|
|
6732
|
+
return typeof err === "object" && err !== null;
|
|
6733
|
+
}, []);
|
|
6734
|
+
const extractErrorMessage = useCallback((responseData) => {
|
|
6735
|
+
if (!responseData)
|
|
6736
|
+
return "翻译请求失败";
|
|
6737
|
+
if (typeof responseData === "string") {
|
|
6738
|
+
return responseData;
|
|
6739
|
+
}
|
|
6740
|
+
if (typeof responseData === "object" && responseData !== null) {
|
|
6741
|
+
const data = responseData;
|
|
6742
|
+
return data.error || data.message || data.msg || "翻译请求失败";
|
|
6743
|
+
}
|
|
6744
|
+
return "翻译请求失败";
|
|
6745
|
+
}, []);
|
|
6746
|
+
const getStatusErrorMessage = useCallback((status2) => {
|
|
6747
|
+
switch (status2) {
|
|
6748
|
+
case 400:
|
|
6749
|
+
return "请求参数错误";
|
|
6750
|
+
case 401:
|
|
6751
|
+
return "认证失败,请重新登录";
|
|
6752
|
+
case 403:
|
|
6753
|
+
return "没有权限执行此操作";
|
|
6754
|
+
case 404:
|
|
6755
|
+
return "翻译服务不存在";
|
|
6756
|
+
case 429:
|
|
6757
|
+
return "请求过于频繁,请稍后再试";
|
|
6758
|
+
case 500:
|
|
6759
|
+
return "服务器内部错误";
|
|
6760
|
+
case 502:
|
|
6761
|
+
case 503:
|
|
6762
|
+
case 504:
|
|
6763
|
+
return "服务暂时不可用,请稍后再试";
|
|
6764
|
+
default:
|
|
6765
|
+
return `请求失败 (${status2})`;
|
|
6766
|
+
}
|
|
6767
|
+
}, []);
|
|
6768
|
+
const handleError = useCallback(
|
|
6769
|
+
(error, context) => {
|
|
6770
|
+
var _a3, _b3;
|
|
6771
|
+
if (isAxiosError(error) && (error.code === "NETWORK_ERROR" || ((_a3 = error.message) == null ? void 0 : _a3.includes("fetch")))) {
|
|
6772
|
+
console.error(`${context}网络错误:`, error);
|
|
6773
|
+
throw new Error("网络连接失败,请检查网络连接");
|
|
6774
|
+
}
|
|
6775
|
+
if (isAxiosError(error) && ((_b3 = error.response) == null ? void 0 : _b3.status)) {
|
|
6776
|
+
const status2 = error.response.status;
|
|
6777
|
+
const responseData = error.response.data;
|
|
6778
|
+
let errorMsg2 = extractErrorMessage(responseData);
|
|
6779
|
+
if (errorMsg2 === "翻译请求失败") {
|
|
6780
|
+
errorMsg2 = getStatusErrorMessage(status2);
|
|
6781
|
+
}
|
|
6782
|
+
console.error(`${context}HTTP错误:`, {
|
|
6783
|
+
status: status2,
|
|
6784
|
+
statusText: error.response.statusText,
|
|
6785
|
+
responseData,
|
|
6786
|
+
error
|
|
6787
|
+
});
|
|
6788
|
+
throw new Error(errorMsg2);
|
|
6789
|
+
}
|
|
6790
|
+
const errorMsg = isAxiosError(error) && error.message ? error.message : "翻译过程中发生未知错误";
|
|
6791
|
+
console.error(`${context}未知错误:`, error);
|
|
6792
|
+
throw new Error(errorMsg);
|
|
6793
|
+
},
|
|
6794
|
+
[isAxiosError, extractErrorMessage, getStatusErrorMessage]
|
|
6795
|
+
);
|
|
6796
|
+
const translateRequest = useCallback(
|
|
6797
|
+
async (endpoint, params) => {
|
|
6798
|
+
try {
|
|
6799
|
+
const http = createHttpClient({ baseURL, token });
|
|
6800
|
+
const websiteId = website.id;
|
|
6801
|
+
const requestParams = {
|
|
6802
|
+
websiteId,
|
|
6803
|
+
...params
|
|
6804
|
+
};
|
|
6805
|
+
const response = await http.post(endpoint, requestParams);
|
|
6806
|
+
return response;
|
|
6807
|
+
} catch (error) {
|
|
6808
|
+
handleError(error, "翻译");
|
|
6809
|
+
}
|
|
6810
|
+
},
|
|
6811
|
+
[baseURL, token, website, handleError]
|
|
6812
|
+
);
|
|
6813
|
+
return translateRequest;
|
|
6814
|
+
}
|
|
6815
|
+
function useTranslateTheme() {
|
|
6816
|
+
const translateRequest = useTranslateRequest();
|
|
6732
6817
|
const translate = useCallback(
|
|
6733
6818
|
async (langId, title) => {
|
|
6819
|
+
return await translateRequest("/api/studio/translate-theme", {
|
|
6820
|
+
targetLangId: langId,
|
|
6821
|
+
title
|
|
6822
|
+
});
|
|
6823
|
+
},
|
|
6824
|
+
[translateRequest]
|
|
6825
|
+
);
|
|
6826
|
+
return translate;
|
|
6827
|
+
}
|
|
6828
|
+
function useStopTask() {
|
|
6829
|
+
const baseURL = useAiUrl();
|
|
6830
|
+
const token = useEntifyToken();
|
|
6831
|
+
const [isMutating, setIsMutating] = useState(false);
|
|
6832
|
+
const stopTask = useCallback(
|
|
6833
|
+
async (taskId) => {
|
|
6734
6834
|
var _a3, _b3;
|
|
6735
|
-
if (!(
|
|
6736
|
-
throw new Error("
|
|
6737
|
-
}
|
|
6738
|
-
if (!(title == null ? void 0 : title.trim())) {
|
|
6739
|
-
throw new Error("标题不能为空");
|
|
6835
|
+
if (!(taskId == null ? void 0 : taskId.trim())) {
|
|
6836
|
+
throw new Error("任务ID不能为空");
|
|
6740
6837
|
}
|
|
6741
6838
|
if (!token) {
|
|
6742
6839
|
throw new Error("用户未登录或token已过期");
|
|
6743
6840
|
}
|
|
6744
|
-
if (!(website == null ? void 0 : website.id)) {
|
|
6745
|
-
throw new Error("未找到网站信息");
|
|
6746
|
-
}
|
|
6747
6841
|
if (!baseURL) {
|
|
6748
6842
|
throw new Error("AI服务URL未配置");
|
|
6749
6843
|
}
|
|
6750
6844
|
try {
|
|
6845
|
+
setIsMutating(true);
|
|
6751
6846
|
const http = createHttpClient({ baseURL, token });
|
|
6752
|
-
const response = await http.post(
|
|
6753
|
-
websiteId: website.id,
|
|
6754
|
-
langId: langId.trim(),
|
|
6755
|
-
title: title.trim()
|
|
6756
|
-
});
|
|
6847
|
+
const response = await http.post(`/api/stop-task/${taskId.trim()}`);
|
|
6757
6848
|
return response;
|
|
6758
6849
|
} catch (error) {
|
|
6759
6850
|
const isAxiosError = (err) => {
|
|
6760
6851
|
return typeof err === "object" && err !== null;
|
|
6761
6852
|
};
|
|
6762
6853
|
if (isAxiosError(error) && (error.code === "NETWORK_ERROR" || ((_a3 = error.message) == null ? void 0 : _a3.includes("fetch")))) {
|
|
6763
|
-
console.error("
|
|
6854
|
+
console.error("停止任务网络错误:", error);
|
|
6764
6855
|
throw new Error("网络连接失败,请检查网络连接");
|
|
6765
6856
|
}
|
|
6766
6857
|
if (isAxiosError(error) && ((_b3 = error.response) == null ? void 0 : _b3.status)) {
|
|
6767
6858
|
const status2 = error.response.status;
|
|
6768
6859
|
const responseData = error.response.data;
|
|
6769
|
-
let errorMsg2 = "
|
|
6860
|
+
let errorMsg2 = "停止任务失败";
|
|
6770
6861
|
if (responseData) {
|
|
6771
6862
|
if (typeof responseData === "string") {
|
|
6772
6863
|
errorMsg2 = responseData;
|
|
@@ -6778,7 +6869,7 @@ function useTranslateTheme() {
|
|
|
6778
6869
|
errorMsg2 = responseData.msg;
|
|
6779
6870
|
}
|
|
6780
6871
|
}
|
|
6781
|
-
if (errorMsg2 === "
|
|
6872
|
+
if (errorMsg2 === "停止任务失败") {
|
|
6782
6873
|
switch (status2) {
|
|
6783
6874
|
case 400:
|
|
6784
6875
|
errorMsg2 = "请求参数错误";
|
|
@@ -6790,7 +6881,7 @@ function useTranslateTheme() {
|
|
|
6790
6881
|
errorMsg2 = "没有权限执行此操作";
|
|
6791
6882
|
break;
|
|
6792
6883
|
case 404:
|
|
6793
|
-
errorMsg2 = "
|
|
6884
|
+
errorMsg2 = "任务不存在或已完成";
|
|
6794
6885
|
break;
|
|
6795
6886
|
case 429:
|
|
6796
6887
|
errorMsg2 = "请求过于频繁,请稍后再试";
|
|
@@ -6807,7 +6898,7 @@ function useTranslateTheme() {
|
|
|
6807
6898
|
errorMsg2 = `请求失败 (${status2})`;
|
|
6808
6899
|
}
|
|
6809
6900
|
}
|
|
6810
|
-
console.error("
|
|
6901
|
+
console.error("停止任务HTTP错误:", {
|
|
6811
6902
|
status: status2,
|
|
6812
6903
|
statusText: error.response.statusText,
|
|
6813
6904
|
responseData,
|
|
@@ -6815,12 +6906,27 @@ function useTranslateTheme() {
|
|
|
6815
6906
|
});
|
|
6816
6907
|
throw new Error(errorMsg2);
|
|
6817
6908
|
}
|
|
6818
|
-
const errorMsg = isAxiosError(error) && error.message ? error.message : "
|
|
6819
|
-
console.error("
|
|
6909
|
+
const errorMsg = isAxiosError(error) && error.message ? error.message : "停止任务过程中发生未知错误";
|
|
6910
|
+
console.error("停止任务未知错误:", error);
|
|
6820
6911
|
throw new Error(errorMsg);
|
|
6912
|
+
} finally {
|
|
6913
|
+
setIsMutating(false);
|
|
6821
6914
|
}
|
|
6822
6915
|
},
|
|
6823
|
-
[baseURL, token
|
|
6916
|
+
[baseURL, token]
|
|
6917
|
+
);
|
|
6918
|
+
return [stopTask, { isMutating }];
|
|
6919
|
+
}
|
|
6920
|
+
function useTranslateCustomizedPages() {
|
|
6921
|
+
const translateRequest = useTranslateRequest();
|
|
6922
|
+
const translate = useCallback(
|
|
6923
|
+
async (langId, ids) => {
|
|
6924
|
+
return await translateRequest("/api/studio/translate-customized-pages", {
|
|
6925
|
+
targetLangId: langId,
|
|
6926
|
+
sourcePageIds: ids
|
|
6927
|
+
});
|
|
6928
|
+
},
|
|
6929
|
+
[translateRequest]
|
|
6824
6930
|
);
|
|
6825
6931
|
return translate;
|
|
6826
6932
|
}
|
|
@@ -6895,8 +7001,6 @@ function MultiLangPanel() {
|
|
|
6895
7001
|
const [linkType, setLinkType] = useState("subdomain");
|
|
6896
7002
|
const [confirmOpen, setConfirmOpen] = useState(false);
|
|
6897
7003
|
const [currentLangId, setCurrentLangId] = useCurrentLangId();
|
|
6898
|
-
const setError = useEntifyWrapperStore((state) => state.setGlobalError);
|
|
6899
|
-
const setSuccess = useEntifyWrapperStore((state) => state.setGlobalSuccess);
|
|
6900
7004
|
const tasksNotDone = useTasksNotDone();
|
|
6901
7005
|
const lastTask = useStudioStore((state) => state.lastedTaskEvent);
|
|
6902
7006
|
const selectedContent = useStudioStore((state) => state.selectedContent);
|
|
@@ -7024,13 +7128,19 @@ function MultiLangPanel() {
|
|
|
7024
7128
|
const title = `网站代码翻译到:${(lang == null ? void 0 : lang.cnName) || (lang == null ? void 0 : lang.enName) || (lang == null ? void 0 : lang.localName) || (lang == null ? void 0 : lang.abbr) || ""}`;
|
|
7025
7129
|
const task2 = await translateTheme(currentLangId, title);
|
|
7026
7130
|
setTask(task2);
|
|
7027
|
-
|
|
7131
|
+
addToast({
|
|
7132
|
+
title: "翻译任务已提交",
|
|
7133
|
+
color: "success"
|
|
7134
|
+
});
|
|
7028
7135
|
} catch (error) {
|
|
7029
7136
|
console.error("翻译主题失败:", error);
|
|
7030
7137
|
const errorString = error instanceof Error ? error.message : String(error);
|
|
7031
|
-
|
|
7138
|
+
addToast({
|
|
7139
|
+
title: errorString,
|
|
7140
|
+
color: "danger"
|
|
7141
|
+
});
|
|
7032
7142
|
}
|
|
7033
|
-
}, [currentLangId, allLangs == null ? void 0 : allLangs.items, translateTheme
|
|
7143
|
+
}, [currentLangId, allLangs == null ? void 0 : allLangs.items, translateTheme]);
|
|
7034
7144
|
const isRunning = (task == null ? void 0 : task.status) === TaskStatus.B_Pending || (task == null ? void 0 : task.status) === TaskStatus.A_Progress;
|
|
7035
7145
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
7036
7146
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalBody, { className: "flex-1 p-4 min-h-0 overflow-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
@@ -138390,7 +138500,7 @@ registerLanguage({
|
|
|
138390
138500
|
aliases: ["FreeMarker2", "Apache FreeMarker2"],
|
|
138391
138501
|
loader: () => {
|
|
138392
138502
|
{
|
|
138393
|
-
return import("./freemarker2-
|
|
138503
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagAutoInterpolationDollar);
|
|
138394
138504
|
}
|
|
138395
138505
|
}
|
|
138396
138506
|
});
|
|
@@ -138399,7 +138509,7 @@ registerLanguage({
|
|
|
138399
138509
|
aliases: ["FreeMarker2 (Angle/Dollar)", "Apache FreeMarker2 (Angle/Dollar)"],
|
|
138400
138510
|
loader: () => {
|
|
138401
138511
|
{
|
|
138402
|
-
return import("./freemarker2-
|
|
138512
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagAngleInterpolationDollar);
|
|
138403
138513
|
}
|
|
138404
138514
|
}
|
|
138405
138515
|
});
|
|
@@ -138408,7 +138518,7 @@ registerLanguage({
|
|
|
138408
138518
|
aliases: ["FreeMarker2 (Bracket/Dollar)", "Apache FreeMarker2 (Bracket/Dollar)"],
|
|
138409
138519
|
loader: () => {
|
|
138410
138520
|
{
|
|
138411
|
-
return import("./freemarker2-
|
|
138521
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagBracketInterpolationDollar);
|
|
138412
138522
|
}
|
|
138413
138523
|
}
|
|
138414
138524
|
});
|
|
@@ -138417,7 +138527,7 @@ registerLanguage({
|
|
|
138417
138527
|
aliases: ["FreeMarker2 (Angle/Bracket)", "Apache FreeMarker2 (Angle/Bracket)"],
|
|
138418
138528
|
loader: () => {
|
|
138419
138529
|
{
|
|
138420
|
-
return import("./freemarker2-
|
|
138530
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagAngleInterpolationBracket);
|
|
138421
138531
|
}
|
|
138422
138532
|
}
|
|
138423
138533
|
});
|
|
@@ -138426,7 +138536,7 @@ registerLanguage({
|
|
|
138426
138536
|
aliases: ["FreeMarker2 (Bracket/Bracket)", "Apache FreeMarker2 (Bracket/Bracket)"],
|
|
138427
138537
|
loader: () => {
|
|
138428
138538
|
{
|
|
138429
|
-
return import("./freemarker2-
|
|
138539
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagBracketInterpolationBracket);
|
|
138430
138540
|
}
|
|
138431
138541
|
}
|
|
138432
138542
|
});
|
|
@@ -138435,7 +138545,7 @@ registerLanguage({
|
|
|
138435
138545
|
aliases: ["FreeMarker2 (Auto/Dollar)", "Apache FreeMarker2 (Auto/Dollar)"],
|
|
138436
138546
|
loader: () => {
|
|
138437
138547
|
{
|
|
138438
|
-
return import("./freemarker2-
|
|
138548
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagAutoInterpolationDollar);
|
|
138439
138549
|
}
|
|
138440
138550
|
}
|
|
138441
138551
|
});
|
|
@@ -138444,7 +138554,7 @@ registerLanguage({
|
|
|
138444
138554
|
aliases: ["FreeMarker2 (Auto/Bracket)", "Apache FreeMarker2 (Auto/Bracket)"],
|
|
138445
138555
|
loader: () => {
|
|
138446
138556
|
{
|
|
138447
|
-
return import("./freemarker2-
|
|
138557
|
+
return import("./freemarker2-24b36fc1.js").then((m2) => m2.TagAutoInterpolationBracket);
|
|
138448
138558
|
}
|
|
138449
138559
|
}
|
|
138450
138560
|
});
|
|
@@ -138494,7 +138604,7 @@ registerLanguage({
|
|
|
138494
138604
|
mimetypes: ["text/x-handlebars-template"],
|
|
138495
138605
|
loader: () => {
|
|
138496
138606
|
{
|
|
138497
|
-
return import("./handlebars-
|
|
138607
|
+
return import("./handlebars-53295c7b.js");
|
|
138498
138608
|
}
|
|
138499
138609
|
}
|
|
138500
138610
|
});
|
|
@@ -138527,7 +138637,7 @@ registerLanguage({
|
|
|
138527
138637
|
mimetypes: ["text/html", "text/x-jshtm", "text/template", "text/ng-template"],
|
|
138528
138638
|
loader: () => {
|
|
138529
138639
|
{
|
|
138530
|
-
return import("./html-
|
|
138640
|
+
return import("./html-70d8042e.js");
|
|
138531
138641
|
}
|
|
138532
138642
|
}
|
|
138533
138643
|
});
|
|
@@ -138580,7 +138690,7 @@ registerLanguage({
|
|
|
138580
138690
|
mimetypes: ["text/javascript"],
|
|
138581
138691
|
loader: () => {
|
|
138582
138692
|
{
|
|
138583
|
-
return import("./javascript-
|
|
138693
|
+
return import("./javascript-d190129b.js");
|
|
138584
138694
|
}
|
|
138585
138695
|
}
|
|
138586
138696
|
});
|
|
@@ -138679,7 +138789,7 @@ registerLanguage({
|
|
|
138679
138789
|
mimetypes: ["application/liquid"],
|
|
138680
138790
|
loader: () => {
|
|
138681
138791
|
{
|
|
138682
|
-
return import("./liquid-
|
|
138792
|
+
return import("./liquid-9ba71888.js");
|
|
138683
138793
|
}
|
|
138684
138794
|
}
|
|
138685
138795
|
});
|
|
@@ -138727,7 +138837,7 @@ registerLanguage({
|
|
|
138727
138837
|
aliases: ["MDX", "mdx"],
|
|
138728
138838
|
loader: () => {
|
|
138729
138839
|
{
|
|
138730
|
-
return import("./mdx-
|
|
138840
|
+
return import("./mdx-a1e1cc3f.js");
|
|
138731
138841
|
}
|
|
138732
138842
|
}
|
|
138733
138843
|
});
|
|
@@ -138986,7 +139096,7 @@ registerLanguage({
|
|
|
138986
139096
|
firstLine: "^#!/.*\\bpython[0-9.-]*\\b",
|
|
138987
139097
|
loader: () => {
|
|
138988
139098
|
{
|
|
138989
|
-
return import("./python-
|
|
139099
|
+
return import("./python-e2f4ad56.js");
|
|
138990
139100
|
}
|
|
138991
139101
|
}
|
|
138992
139102
|
});
|
|
@@ -139035,7 +139145,7 @@ registerLanguage({
|
|
|
139035
139145
|
mimetypes: ["text/x-cshtml"],
|
|
139036
139146
|
loader: () => {
|
|
139037
139147
|
{
|
|
139038
|
-
return import("./razor-
|
|
139148
|
+
return import("./razor-e8f995b7.js");
|
|
139039
139149
|
}
|
|
139040
139150
|
}
|
|
139041
139151
|
});
|
|
@@ -139371,7 +139481,7 @@ registerLanguage({
|
|
|
139371
139481
|
mimetypes: ["text/typescript"],
|
|
139372
139482
|
loader: () => {
|
|
139373
139483
|
{
|
|
139374
|
-
return import("./typescript-
|
|
139484
|
+
return import("./typescript-44b6e68e.js");
|
|
139375
139485
|
}
|
|
139376
139486
|
}
|
|
139377
139487
|
});
|
|
@@ -139455,7 +139565,7 @@ registerLanguage({
|
|
|
139455
139565
|
mimetypes: ["text/xml", "application/xml", "application/xaml+xml", "application/xml-dtd"],
|
|
139456
139566
|
loader: () => {
|
|
139457
139567
|
{
|
|
139458
|
-
return import("./xml-
|
|
139568
|
+
return import("./xml-3f4949e5.js");
|
|
139459
139569
|
}
|
|
139460
139570
|
}
|
|
139461
139571
|
});
|
|
@@ -139472,7 +139582,7 @@ registerLanguage({
|
|
|
139472
139582
|
mimetypes: ["application/x-yaml", "text/x-yaml"],
|
|
139473
139583
|
loader: () => {
|
|
139474
139584
|
{
|
|
139475
|
-
return import("./yaml-
|
|
139585
|
+
return import("./yaml-c6242439.js");
|
|
139476
139586
|
}
|
|
139477
139587
|
}
|
|
139478
139588
|
});
|
|
@@ -139596,7 +139706,7 @@ var lessDefaults = new LanguageServiceDefaultsImpl$3(
|
|
|
139596
139706
|
monaco_editor_core_exports$3.languages.css = { cssDefaults, lessDefaults, scssDefaults };
|
|
139597
139707
|
function getMode$3() {
|
|
139598
139708
|
{
|
|
139599
|
-
return import("./cssMode-
|
|
139709
|
+
return import("./cssMode-8bdd5502.js");
|
|
139600
139710
|
}
|
|
139601
139711
|
}
|
|
139602
139712
|
monaco_editor_core_exports$3.languages.onLanguage("less", () => {
|
|
@@ -139727,7 +139837,7 @@ monaco_editor_core_exports$2.languages.html = {
|
|
|
139727
139837
|
};
|
|
139728
139838
|
function getMode$2() {
|
|
139729
139839
|
{
|
|
139730
|
-
return import("./htmlMode-
|
|
139840
|
+
return import("./htmlMode-fabb16ce.js");
|
|
139731
139841
|
}
|
|
139732
139842
|
}
|
|
139733
139843
|
function registerHTMLLanguageService(languageId, options = optionsDefault, modeConfiguration = getConfigurationDefault(languageId)) {
|
|
@@ -139825,7 +139935,7 @@ var getWorker = () => getMode$1().then((mode) => mode.getWorker());
|
|
|
139825
139935
|
monaco_editor_core_exports$1.languages.json = { jsonDefaults, getWorker };
|
|
139826
139936
|
function getMode$1() {
|
|
139827
139937
|
{
|
|
139828
|
-
return import("./jsonMode-
|
|
139938
|
+
return import("./jsonMode-04d036a7.js");
|
|
139829
139939
|
}
|
|
139830
139940
|
}
|
|
139831
139941
|
monaco_editor_core_exports$1.languages.register({
|
|
@@ -140101,7 +140211,7 @@ monaco_editor_core_exports.languages.typescript = {
|
|
|
140101
140211
|
};
|
|
140102
140212
|
function getMode() {
|
|
140103
140213
|
{
|
|
140104
|
-
return import("./tsMode-
|
|
140214
|
+
return import("./tsMode-dff5ab28.js");
|
|
140105
140215
|
}
|
|
140106
140216
|
}
|
|
140107
140217
|
monaco_editor_core_exports.languages.onLanguage("typescript", () => {
|
|
@@ -198625,21 +198735,35 @@ const RightPanel = memo(() => {
|
|
|
198625
198735
|
});
|
|
198626
198736
|
const StopButton = forwardRef$2(
|
|
198627
198737
|
(props, ref2) => {
|
|
198628
|
-
const { confirm,
|
|
198738
|
+
const { confirm, taskId, ...rest } = props;
|
|
198629
198739
|
const [open, setOpen] = useState(false);
|
|
198740
|
+
const [stopTask, { isMutating }] = useStopTask();
|
|
198630
198741
|
const handleClick = useCallback(() => {
|
|
198631
198742
|
if (confirm) {
|
|
198632
198743
|
setOpen(true);
|
|
198633
198744
|
} else {
|
|
198634
|
-
|
|
198745
|
+
if (taskId) {
|
|
198746
|
+
stopTask(taskId);
|
|
198747
|
+
}
|
|
198635
198748
|
}
|
|
198636
|
-
}, [confirm,
|
|
198749
|
+
}, [confirm, stopTask, taskId]);
|
|
198637
198750
|
const handleConfirm = useCallback(() => {
|
|
198638
|
-
|
|
198751
|
+
if (taskId) {
|
|
198752
|
+
stopTask(taskId);
|
|
198753
|
+
}
|
|
198639
198754
|
setOpen(false);
|
|
198640
|
-
}, [
|
|
198755
|
+
}, [stopTask, taskId]);
|
|
198641
198756
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
198642
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(StyledTooltip, { content: "停止任务", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
198757
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(StyledTooltip, { content: "停止任务", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
198758
|
+
Button$2,
|
|
198759
|
+
{
|
|
198760
|
+
ref: ref2,
|
|
198761
|
+
isDisabled: !taskId,
|
|
198762
|
+
onPress: handleClick,
|
|
198763
|
+
loading: isMutating,
|
|
198764
|
+
...rest
|
|
198765
|
+
}
|
|
198766
|
+
) }),
|
|
198643
198767
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
198644
198768
|
ConfirmDialog,
|
|
198645
198769
|
{
|
|
@@ -198773,7 +198897,7 @@ function TaskTable() {
|
|
|
198773
198897
|
width: 80,
|
|
198774
198898
|
title: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full text-center", children: "操作" }),
|
|
198775
198899
|
cellRender: (text2, row) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-0.5 items-center", children: [
|
|
198776
|
-
(row == null ? void 0 : row.status) === TaskStatus.A_Progress && /* @__PURE__ */ jsxRuntimeExports.jsx(StopButton, { isIconOnly: true, size: "sm", variant: "light", children: /* @__PURE__ */ jsxRuntimeExports.jsx(StopOutlineIcon, { className: "size-4 text-default-500" }) }),
|
|
198900
|
+
(row == null ? void 0 : row.status) === TaskStatus.A_Progress && /* @__PURE__ */ jsxRuntimeExports.jsx(StopButton, { taskId: row.id, isIconOnly: true, size: "sm", variant: "light", children: /* @__PURE__ */ jsxRuntimeExports.jsx(StopOutlineIcon, { className: "size-4 text-default-500" }) }),
|
|
198777
198901
|
(row == null ? void 0 : row.status) !== TaskStatus.A_Progress && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
198778
198902
|
RemoveButton,
|
|
198779
198903
|
{
|
|
@@ -198910,6 +199034,34 @@ function StatusBar({ doc }) {
|
|
|
198910
199034
|
requested: event,
|
|
198911
199035
|
response: event
|
|
198912
199036
|
});
|
|
199037
|
+
if (event.type === TaskType.TranslateTheme) {
|
|
199038
|
+
emit(EVENT_ENTITY_POSTED, {
|
|
199039
|
+
entityName: ThemeEntityName,
|
|
199040
|
+
requested: event,
|
|
199041
|
+
response: event
|
|
199042
|
+
});
|
|
199043
|
+
}
|
|
199044
|
+
if (event.type === TaskType.TranslateCusomizedPage || event.type === TaskType.TranslateBuiltinPage || event.type === TaskType.TranslateTheme) {
|
|
199045
|
+
console.log("===>收到页面任务事件:", event);
|
|
199046
|
+
emit(EVENT_ENTITY_POSTED, {
|
|
199047
|
+
entityName: PageEntityName,
|
|
199048
|
+
requested: event,
|
|
199049
|
+
response: event
|
|
199050
|
+
});
|
|
199051
|
+
}
|
|
199052
|
+
if (event.type === TaskType.TranslateComponent || event.type === TaskType.TranslateTheme) {
|
|
199053
|
+
console.log("===>收到组件任务事件:", event);
|
|
199054
|
+
emit(EVENT_ENTITY_POSTED, {
|
|
199055
|
+
entityName: FrontComponentEntityName,
|
|
199056
|
+
requested: event,
|
|
199057
|
+
response: event
|
|
199058
|
+
});
|
|
199059
|
+
emit(EVENT_ENTITY_POSTED, {
|
|
199060
|
+
entityName: ComponentCategoryEntityName,
|
|
199061
|
+
requested: event,
|
|
199062
|
+
response: event
|
|
199063
|
+
});
|
|
199064
|
+
}
|
|
198913
199065
|
},
|
|
198914
199066
|
[setLastedTaskEvent]
|
|
198915
199067
|
);
|
|
@@ -200944,52 +201096,48 @@ function CustomizedPageCard(props) {
|
|
|
200944
201096
|
}
|
|
200945
201097
|
);
|
|
200946
201098
|
}
|
|
200947
|
-
function
|
|
201099
|
+
function useResetPage() {
|
|
200948
201100
|
const theme = useStudioTheme();
|
|
200949
|
-
const
|
|
200950
|
-
const appKey = (theme == null ? void 0 : theme.id) || "";
|
|
200951
|
-
const taskState = useInprogressTaskByKey(taskKey, appKey);
|
|
200952
|
-
const setTask = useUpdateTask(appKey);
|
|
200953
|
-
const entifyClient = useCreateEntityClient();
|
|
200954
|
-
const task = taskState && taskState.status !== "done" ? taskPool[taskState.taskId] : void 0;
|
|
200955
|
-
const aiUrl = useAiUrl();
|
|
200956
|
-
const handleTaskChange = useCallback(
|
|
200957
|
-
(data) => {
|
|
200958
|
-
setTask(data);
|
|
200959
|
-
},
|
|
200960
|
-
[setTask]
|
|
200961
|
-
);
|
|
201101
|
+
const [upsertPage] = useUpsertOnePage();
|
|
200962
201102
|
const resetPage = useCallback(
|
|
200963
|
-
(basePage, targetPageId
|
|
201103
|
+
async (basePage, targetPageId) => {
|
|
200964
201104
|
if (!(theme == null ? void 0 : theme.id)) {
|
|
200965
201105
|
console.error("没设置Theme");
|
|
200966
201106
|
return;
|
|
200967
201107
|
}
|
|
200968
|
-
|
|
200969
|
-
|
|
200970
|
-
|
|
200971
|
-
|
|
200972
|
-
|
|
200973
|
-
|
|
200974
|
-
|
|
200975
|
-
|
|
200976
|
-
|
|
200977
|
-
|
|
200978
|
-
|
|
200979
|
-
|
|
200980
|
-
|
|
201108
|
+
await upsertPage(
|
|
201109
|
+
pageToInput({
|
|
201110
|
+
id: targetPageId,
|
|
201111
|
+
theme: { id: theme.id },
|
|
201112
|
+
title: basePage.title,
|
|
201113
|
+
slug: basePage.slug,
|
|
201114
|
+
description: basePage.description,
|
|
201115
|
+
code: basePage.code,
|
|
201116
|
+
pageType: basePage.pageType,
|
|
201117
|
+
meta: basePage.meta ? {
|
|
201118
|
+
...basePage.meta,
|
|
201119
|
+
id: void 0
|
|
201120
|
+
} : void 0
|
|
201121
|
+
})
|
|
201122
|
+
);
|
|
201123
|
+
},
|
|
201124
|
+
[theme == null ? void 0 : theme.id, upsertPage]
|
|
201125
|
+
);
|
|
201126
|
+
return resetPage;
|
|
201127
|
+
}
|
|
201128
|
+
function useTranslateBuiltinPage() {
|
|
201129
|
+
const translateRequest = useTranslateRequest();
|
|
201130
|
+
const translate = useCallback(
|
|
201131
|
+
async (sourcePageId, targetPageId, title) => {
|
|
201132
|
+
return await translateRequest("/api/studio/translate-builtin-page", {
|
|
201133
|
+
sourcePageId,
|
|
200981
201134
|
targetPageId,
|
|
200982
|
-
|
|
200983
|
-
lang,
|
|
200984
|
-
aiUrl
|
|
201135
|
+
title
|
|
200985
201136
|
});
|
|
200986
|
-
taskPool[task2.id] = task2;
|
|
200987
|
-
task2.onDataChange(handleTaskChange);
|
|
200988
|
-
task2.start();
|
|
200989
201137
|
},
|
|
200990
|
-
[
|
|
201138
|
+
[translateRequest]
|
|
200991
201139
|
);
|
|
200992
|
-
return
|
|
201140
|
+
return translate;
|
|
200993
201141
|
}
|
|
200994
201142
|
function PredefinedPageCard(props) {
|
|
200995
201143
|
const { pages, pageType } = props;
|
|
@@ -200998,6 +201146,7 @@ function PredefinedPageCard(props) {
|
|
|
200998
201146
|
void 0
|
|
200999
201147
|
);
|
|
201000
201148
|
const theme = useStudioTheme();
|
|
201149
|
+
const currentLang = useCurrentLang();
|
|
201001
201150
|
const parentTheme = useParentTheme();
|
|
201002
201151
|
const isBaseTheme = useIsBaseLangTheme();
|
|
201003
201152
|
const baseThemeId = useBaseLangThemeId();
|
|
@@ -201007,11 +201156,12 @@ function PredefinedPageCard(props) {
|
|
|
201007
201156
|
const page = pages.find((page2) => page2.pageType === (pageType == null ? void 0 : pageType.pageType));
|
|
201008
201157
|
const setEditingPage = useStudioStore((state) => state.setEditingPage);
|
|
201009
201158
|
const selectedContent = useStudioStore((state) => state.selectedContent);
|
|
201010
|
-
const setSelectedContent = useStudioStore(
|
|
201011
|
-
|
|
201012
|
-
"reset-page" + ((page == null ? void 0 : page.id) || "")
|
|
201159
|
+
const setSelectedContent = useStudioStore(
|
|
201160
|
+
(state) => state.setSelectedContent
|
|
201013
201161
|
);
|
|
201162
|
+
const resetPage = useResetPage();
|
|
201014
201163
|
const queryPage = useLazyQueryOneEntity();
|
|
201164
|
+
const translatePage = useTranslateBuiltinPage();
|
|
201015
201165
|
const confirmResolveRef = useRef();
|
|
201016
201166
|
const selected = (selectedContent == null ? void 0 : selectedContent.type) === ContentType.PredefinedPage && (selectedContent == null ? void 0 : selectedContent.id) === (page == null ? void 0 : page.id);
|
|
201017
201167
|
const [remove, { isMutating: removing }] = useDeletePageById();
|
|
@@ -201087,22 +201237,24 @@ function PredefinedPageCard(props) {
|
|
|
201087
201237
|
}
|
|
201088
201238
|
}
|
|
201089
201239
|
}
|
|
201090
|
-
).meta(
|
|
201091
|
-
|
|
201092
|
-
|
|
201093
|
-
|
|
201094
|
-
|
|
201095
|
-
|
|
201096
|
-
|
|
201097
|
-
|
|
201098
|
-
|
|
201099
|
-
|
|
201100
|
-
|
|
201101
|
-
|
|
201102
|
-
|
|
201103
|
-
|
|
201104
|
-
|
|
201105
|
-
|
|
201240
|
+
).meta(
|
|
201241
|
+
new PageMetaQueryOptions([
|
|
201242
|
+
PageMetaFields.id,
|
|
201243
|
+
PageMetaFields.ogDescription,
|
|
201244
|
+
PageMetaFields.ogSiteName,
|
|
201245
|
+
PageMetaFields.ogTitle,
|
|
201246
|
+
PageMetaFields.ogType,
|
|
201247
|
+
PageMetaFields.ogUrl,
|
|
201248
|
+
PageMetaFields.seoAuthor,
|
|
201249
|
+
PageMetaFields.seoDescription,
|
|
201250
|
+
PageMetaFields.seoKeywords,
|
|
201251
|
+
PageMetaFields.seoRobots,
|
|
201252
|
+
PageMetaFields.seoTitle,
|
|
201253
|
+
PageMetaFields.xCard,
|
|
201254
|
+
PageMetaFields.xSite,
|
|
201255
|
+
PageMetaFields.xUrl
|
|
201256
|
+
]).ogImage()
|
|
201257
|
+
).setNoQuery(!page || !(page == null ? void 0 : page.pageType)).toGqlOptions()
|
|
201106
201258
|
);
|
|
201107
201259
|
if (!parentPage) {
|
|
201108
201260
|
setResetting(false);
|
|
@@ -201111,17 +201263,29 @@ function PredefinedPageCard(props) {
|
|
|
201111
201263
|
}
|
|
201112
201264
|
const result = await confirmOverride();
|
|
201113
201265
|
if (result && (page == null ? void 0 : page.id)) {
|
|
201114
|
-
|
|
201115
|
-
{ ...parentPage, title: pageType == null ? void 0 : pageType.title },
|
|
201116
|
-
|
|
201117
|
-
|
|
201118
|
-
|
|
201266
|
+
if (isBaseTheme) {
|
|
201267
|
+
await resetPage({ ...parentPage, title: pageType == null ? void 0 : pageType.title }, page.id);
|
|
201268
|
+
} else {
|
|
201269
|
+
await translatePage(
|
|
201270
|
+
parentPage.id,
|
|
201271
|
+
page.id,
|
|
201272
|
+
`${page == null ? void 0 : page.title}的${currentLang == null ? void 0 : currentLang.cnName}版重置`
|
|
201273
|
+
);
|
|
201274
|
+
addToast({
|
|
201275
|
+
title: "翻译并重置任务已添加",
|
|
201276
|
+
color: "success"
|
|
201277
|
+
});
|
|
201278
|
+
}
|
|
201119
201279
|
}
|
|
201120
201280
|
if (selected) {
|
|
201121
201281
|
setSelectedContent(void 0);
|
|
201122
201282
|
}
|
|
201123
201283
|
} catch (error) {
|
|
201124
201284
|
setResetting(false);
|
|
201285
|
+
addToast({
|
|
201286
|
+
title: "重置页面失败",
|
|
201287
|
+
color: "danger"
|
|
201288
|
+
});
|
|
201125
201289
|
console.error("重置页面失败", error);
|
|
201126
201290
|
} finally {
|
|
201127
201291
|
setResetting(false);
|
|
@@ -201129,6 +201293,7 @@ function PredefinedPageCard(props) {
|
|
|
201129
201293
|
}, [
|
|
201130
201294
|
baseThemeId,
|
|
201131
201295
|
confirmOverride,
|
|
201296
|
+
currentLang == null ? void 0 : currentLang.cnName,
|
|
201132
201297
|
isBaseTheme,
|
|
201133
201298
|
page,
|
|
201134
201299
|
pageType == null ? void 0 : pageType.title,
|
|
@@ -201136,7 +201301,8 @@ function PredefinedPageCard(props) {
|
|
|
201136
201301
|
queryPage,
|
|
201137
201302
|
resetPage,
|
|
201138
201303
|
selected,
|
|
201139
|
-
setSelectedContent
|
|
201304
|
+
setSelectedContent,
|
|
201305
|
+
translatePage
|
|
201140
201306
|
]);
|
|
201141
201307
|
const handleConfirm = useCallback(() => {
|
|
201142
201308
|
setConfirmTitle(void 0);
|
|
@@ -201145,7 +201311,6 @@ function PredefinedPageCard(props) {
|
|
|
201145
201311
|
confirmResolveRef.current = void 0;
|
|
201146
201312
|
}
|
|
201147
201313
|
}, []);
|
|
201148
|
-
const taskRunning = (taskState == null ? void 0 : taskState.status) === "in-progress";
|
|
201149
201314
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
201150
201315
|
page ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
201151
201316
|
PageCard,
|
|
@@ -201153,12 +201318,12 @@ function PredefinedPageCard(props) {
|
|
|
201153
201318
|
onClick: handleDesign,
|
|
201154
201319
|
page,
|
|
201155
201320
|
selected,
|
|
201156
|
-
fiexdAction: removing || open || resetting
|
|
201321
|
+
fiexdAction: removing || open || resetting,
|
|
201157
201322
|
actions: page ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Dropdown, { isOpen: open, onOpenChange: handleOpenChange, children: [
|
|
201158
201323
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownTrigger, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
201159
201324
|
Button$2,
|
|
201160
201325
|
{
|
|
201161
|
-
isLoading: resetting
|
|
201326
|
+
isLoading: resetting,
|
|
201162
201327
|
isIconOnly: true,
|
|
201163
201328
|
variant: "light",
|
|
201164
201329
|
size: "sm",
|
|
@@ -201351,90 +201516,107 @@ function PageModal(props) {
|
|
|
201351
201516
|
}
|
|
201352
201517
|
);
|
|
201353
201518
|
}
|
|
201354
|
-
|
|
201355
|
-
function usePagesImportTask() {
|
|
201519
|
+
function usePagesImport() {
|
|
201356
201520
|
const theme = useStudioTheme();
|
|
201357
|
-
const lang = useCurrentLang();
|
|
201358
201521
|
const pages = usePages();
|
|
201359
|
-
const appKey = (theme == null ? void 0 : theme.id) || "";
|
|
201360
|
-
const taskState = useInprogressTaskByKey(IMPORT_PAGES_KEY, appKey);
|
|
201361
|
-
const setTask = useUpdateTask(appKey);
|
|
201362
201522
|
const entifyClient = useCreateEntityClient();
|
|
201363
|
-
const
|
|
201364
|
-
const
|
|
201365
|
-
|
|
201366
|
-
|
|
201367
|
-
|
|
201523
|
+
const [upsertPage] = useUpsertOnePage();
|
|
201524
|
+
const importOnePage = useCallback(
|
|
201525
|
+
async (page, overrideId) => {
|
|
201526
|
+
await upsertPage(
|
|
201527
|
+
pageToInput({
|
|
201528
|
+
id: overrideId,
|
|
201529
|
+
theme: { id: theme == null ? void 0 : theme.id },
|
|
201530
|
+
title: page.title,
|
|
201531
|
+
slug: page.slug,
|
|
201532
|
+
description: page.description,
|
|
201533
|
+
code: page.code,
|
|
201534
|
+
pageType: page.pageType,
|
|
201535
|
+
meta: page.meta ? { ...page.meta, id: void 0 } : void 0
|
|
201536
|
+
})
|
|
201537
|
+
);
|
|
201368
201538
|
},
|
|
201369
|
-
[
|
|
201539
|
+
[theme == null ? void 0 : theme.id, upsertPage]
|
|
201370
201540
|
);
|
|
201371
201541
|
const importPages = useCallback(
|
|
201372
|
-
(ids
|
|
201542
|
+
async (ids) => {
|
|
201543
|
+
var _a3;
|
|
201373
201544
|
if (!(theme == null ? void 0 : theme.id)) {
|
|
201374
201545
|
console.error("没设置Theme");
|
|
201375
201546
|
return;
|
|
201376
201547
|
}
|
|
201377
|
-
|
|
201378
|
-
|
|
201379
|
-
|
|
201380
|
-
|
|
201381
|
-
|
|
201382
|
-
|
|
201383
|
-
|
|
201548
|
+
for (const pageId of ids) {
|
|
201549
|
+
const page = await (entifyClient == null ? void 0 : entifyClient.oneEntity(
|
|
201550
|
+
new PageQueryOptions(
|
|
201551
|
+
[
|
|
201552
|
+
PageFields.id,
|
|
201553
|
+
PageFields.id,
|
|
201554
|
+
PageFields.pageType,
|
|
201555
|
+
PageFields.code,
|
|
201556
|
+
PageFields.description,
|
|
201557
|
+
PageFields.slug,
|
|
201558
|
+
PageFields.title
|
|
201559
|
+
],
|
|
201560
|
+
{
|
|
201561
|
+
where: {
|
|
201562
|
+
id: {
|
|
201563
|
+
_eq: pageId
|
|
201564
|
+
}
|
|
201565
|
+
}
|
|
201566
|
+
}
|
|
201567
|
+
).meta(
|
|
201568
|
+
new PageMetaQueryOptions([
|
|
201569
|
+
PageMetaFields.id,
|
|
201570
|
+
PageMetaFields.ogDescription,
|
|
201571
|
+
PageMetaFields.ogSiteName,
|
|
201572
|
+
PageMetaFields.ogTitle,
|
|
201573
|
+
PageMetaFields.ogType,
|
|
201574
|
+
PageMetaFields.ogUrl,
|
|
201575
|
+
PageMetaFields.seoAuthor,
|
|
201576
|
+
PageMetaFields.seoDescription,
|
|
201577
|
+
PageMetaFields.seoKeywords,
|
|
201578
|
+
PageMetaFields.seoRobots,
|
|
201579
|
+
PageMetaFields.seoTitle,
|
|
201580
|
+
PageMetaFields.xCard,
|
|
201581
|
+
PageMetaFields.xSite,
|
|
201582
|
+
PageMetaFields.xUrl
|
|
201583
|
+
]).ogImage()
|
|
201584
|
+
)
|
|
201585
|
+
));
|
|
201586
|
+
if (!page) {
|
|
201587
|
+
throw Error("没有找到要导入的页面");
|
|
201588
|
+
}
|
|
201589
|
+
const overrideId = (_a3 = pages == null ? void 0 : pages.find((p2) => p2.slug === page.slug)) == null ? void 0 : _a3.id;
|
|
201590
|
+
await importOnePage(page, overrideId);
|
|
201384
201591
|
}
|
|
201385
|
-
const task2 = new ImportPagesTask(
|
|
201386
|
-
{
|
|
201387
|
-
key: IMPORT_PAGES_KEY,
|
|
201388
|
-
ids,
|
|
201389
|
-
entifyClient,
|
|
201390
|
-
needTranslate,
|
|
201391
|
-
themeId: theme == null ? void 0 : theme.id,
|
|
201392
|
-
lang,
|
|
201393
|
-
aiUrl
|
|
201394
|
-
},
|
|
201395
|
-
pages || []
|
|
201396
|
-
);
|
|
201397
|
-
taskPool[task2.id] = task2;
|
|
201398
|
-
task2.onDataChange(handleTaskChange);
|
|
201399
|
-
task2.start();
|
|
201400
201592
|
},
|
|
201401
|
-
[
|
|
201593
|
+
[entifyClient, importOnePage, pages, theme == null ? void 0 : theme.id]
|
|
201402
201594
|
);
|
|
201403
|
-
return
|
|
201595
|
+
return importPages;
|
|
201404
201596
|
}
|
|
201405
201597
|
function PagesModalContent(props) {
|
|
201406
|
-
var _a3, _b3, _c2, _d2
|
|
201598
|
+
var _a3, _b3, _c2, _d2;
|
|
201407
201599
|
const { onClose } = props;
|
|
201408
201600
|
const pages = usePages();
|
|
201409
201601
|
const isBaseLangTheme = useIsBaseLangTheme();
|
|
201602
|
+
const [importing, setImporting] = useState(false);
|
|
201410
201603
|
const currentLang = useCurrentLang();
|
|
201411
201604
|
const parentTheme = useParentTheme();
|
|
201412
201605
|
const [pagesToImport, setPagesToImport] = useState();
|
|
201413
201606
|
const [confirmTitle, setConfirmTitle] = useState(
|
|
201414
201607
|
void 0
|
|
201415
201608
|
);
|
|
201416
|
-
const
|
|
201609
|
+
const importPages = usePagesImport();
|
|
201610
|
+
const tranlatePages = useTranslateCustomizedPages();
|
|
201417
201611
|
const data = useListData();
|
|
201418
201612
|
const [selection, setSelections] = useSelectionsState() || [];
|
|
201419
|
-
useEffect(() => {
|
|
201420
|
-
var _a4;
|
|
201421
|
-
setSelections == null ? void 0 : setSelections((_a4 = taskState == null ? void 0 : taskState.data) == null ? void 0 : _a4.ids);
|
|
201422
|
-
}, [setSelections, taskState == null ? void 0 : taskState.data]);
|
|
201423
201613
|
const confirmResolveRef = useRef();
|
|
201424
|
-
const importing = (taskState == null ? void 0 : taskState.status) === "in-progress";
|
|
201425
|
-
useEffect(() => {
|
|
201426
|
-
if ((taskState == null ? void 0 : taskState.status) === "done") {
|
|
201427
|
-
setSelections == null ? void 0 : setSelections([]);
|
|
201428
|
-
}
|
|
201429
|
-
}, [setSelections, taskState]);
|
|
201430
201614
|
useEffect(() => {
|
|
201431
201615
|
var _a4;
|
|
201432
|
-
|
|
201433
|
-
|
|
201434
|
-
|
|
201435
|
-
|
|
201436
|
-
}
|
|
201437
|
-
}, [selection, data == null ? void 0 : data.items, setPagesToImport, taskState == null ? void 0 : taskState.status, importing]);
|
|
201616
|
+
setPagesToImport(
|
|
201617
|
+
((_a4 = data == null ? void 0 : data.items) == null ? void 0 : _a4.filter((item) => selection == null ? void 0 : selection.includes((item == null ? void 0 : item.id) || ""))) || []
|
|
201618
|
+
);
|
|
201619
|
+
}, [selection, data == null ? void 0 : data.items, setPagesToImport]);
|
|
201438
201620
|
const cols = useMemo(() => {
|
|
201439
201621
|
return [
|
|
201440
201622
|
{
|
|
@@ -201477,22 +201659,41 @@ function PagesModalContent(props) {
|
|
|
201477
201659
|
return;
|
|
201478
201660
|
}
|
|
201479
201661
|
}
|
|
201480
|
-
|
|
201662
|
+
if (!(currentLang == null ? void 0 : currentLang.id)) {
|
|
201663
|
+
throw new Error("当前语言ID不能为空");
|
|
201664
|
+
}
|
|
201665
|
+
setImporting(true);
|
|
201666
|
+
if (needTranslate) {
|
|
201667
|
+
await tranlatePages((currentLang == null ? void 0 : currentLang.id) || "", selection || []);
|
|
201668
|
+
addToast({
|
|
201669
|
+
title: "成功添加导入任务",
|
|
201670
|
+
color: "success"
|
|
201671
|
+
});
|
|
201672
|
+
} else {
|
|
201673
|
+
await importPages(selection || []);
|
|
201674
|
+
}
|
|
201675
|
+
onClose == null ? void 0 : onClose();
|
|
201481
201676
|
} catch (error) {
|
|
201482
201677
|
console.error("导入页面时出错:", error);
|
|
201483
|
-
|
|
201678
|
+
addToast({
|
|
201679
|
+
title: "导入页面时出错:" + (error == null ? void 0 : error.message),
|
|
201680
|
+
color: "danger"
|
|
201681
|
+
});
|
|
201484
201682
|
} finally {
|
|
201485
201683
|
setPagesToImport([]);
|
|
201486
201684
|
setSelections == null ? void 0 : setSelections(void 0);
|
|
201685
|
+
setImporting(false);
|
|
201487
201686
|
}
|
|
201488
201687
|
}, [
|
|
201489
201688
|
pages,
|
|
201490
|
-
|
|
201491
|
-
selection,
|
|
201689
|
+
currentLang == null ? void 0 : currentLang.id,
|
|
201492
201690
|
needTranslate,
|
|
201691
|
+
onClose,
|
|
201493
201692
|
pagesToImport,
|
|
201494
201693
|
confirmOverride,
|
|
201495
|
-
|
|
201694
|
+
tranlatePages,
|
|
201695
|
+
selection,
|
|
201696
|
+
importPages,
|
|
201496
201697
|
setSelections
|
|
201497
201698
|
]);
|
|
201498
201699
|
const handleConfirm = useCallback(() => {
|
|
@@ -201517,30 +201718,15 @@ function PagesModalContent(props) {
|
|
|
201517
201718
|
columns: cols,
|
|
201518
201719
|
selectionMode: "multiple",
|
|
201519
201720
|
removeWrapper: true,
|
|
201520
|
-
disabledKeys: importing ? (_c2 = data == null ? void 0 : data.items) == null ? void 0 : _c2.map((item) => (item == null ? void 0 : item.id) || "") : [],
|
|
201521
201721
|
bottomContent: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
201522
|
-
!!((
|
|
201722
|
+
!!((_c2 = data == null ? void 0 : data.items) == null ? void 0 : _c2.length) && ((_d2 = data == null ? void 0 : data.items) == null ? void 0 : _d2.length) < (data.total || 0) && /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, { className: "opacity-30" }),
|
|
201523
201723
|
/* @__PURE__ */ jsxRuntimeExports.jsx(EntityPagination, {})
|
|
201524
201724
|
] })
|
|
201525
201725
|
}
|
|
201526
201726
|
) }),
|
|
201527
201727
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Divider, {}),
|
|
201528
201728
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(ModalFooter, { className: "justify-between", children: [
|
|
201529
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
201530
|
-
taskState == null ? void 0 : taskState.infoMessage,
|
|
201531
|
-
(taskState == null ? void 0 : taskState.status) === "in-progress" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
201532
|
-
Button$2,
|
|
201533
|
-
{
|
|
201534
|
-
variant: "light",
|
|
201535
|
-
size: "sm",
|
|
201536
|
-
isIconOnly: true,
|
|
201537
|
-
onPress: () => {
|
|
201538
|
-
task == null ? void 0 : task.stop();
|
|
201539
|
-
},
|
|
201540
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(TaskStopIcon, { className: "size-9 text-primary" })
|
|
201541
|
-
}
|
|
201542
|
-
)
|
|
201543
|
-
] }),
|
|
201729
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-default-500 flex items-center gap-2" }),
|
|
201544
201730
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-1", children: [
|
|
201545
201731
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
201546
201732
|
Button$2,
|
|
@@ -202746,89 +202932,172 @@ function ComponentCategoryModal(props) {
|
|
|
202746
202932
|
function ComponentsSkeletons() {
|
|
202747
202933
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "space-y-4", children: Array.from({ length: 6 }).map((_2, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: "flex items-center py-0.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-full h-12 rounded-md" }) }, index2)) }) });
|
|
202748
202934
|
}
|
|
202749
|
-
|
|
202935
|
+
class ImportComponentsTask {
|
|
202936
|
+
constructor(options, components, categories) {
|
|
202937
|
+
__publicField(this, "entifyClient");
|
|
202938
|
+
__publicField(this, "taskData");
|
|
202939
|
+
__publicField(this, "importOneComponent", async (component, overrideId, existCategory) => {
|
|
202940
|
+
var _a3;
|
|
202941
|
+
await this.entifyClient.upsertEntity(FrontComponentEntityName, {
|
|
202942
|
+
id: overrideId,
|
|
202943
|
+
theme: { sync: { id: (_a3 = this.taskData) == null ? void 0 : _a3.themeId } },
|
|
202944
|
+
category: (existCategory == null ? void 0 : existCategory.id) ? { sync: { id: existCategory.id } } : { clear: true },
|
|
202945
|
+
name: component.name,
|
|
202946
|
+
title: component.title,
|
|
202947
|
+
description: component.description,
|
|
202948
|
+
code: component.code,
|
|
202949
|
+
props: component.props,
|
|
202950
|
+
testConfig: component.testConfig
|
|
202951
|
+
});
|
|
202952
|
+
});
|
|
202953
|
+
this.components = components;
|
|
202954
|
+
this.categories = categories;
|
|
202955
|
+
this.entifyClient = options.entifyClient;
|
|
202956
|
+
this.taskData = {
|
|
202957
|
+
ids: options.ids,
|
|
202958
|
+
themeId: options.themeId,
|
|
202959
|
+
lang: options.lang
|
|
202960
|
+
};
|
|
202961
|
+
}
|
|
202962
|
+
/**
|
|
202963
|
+
* 实际执行导入页面的逻辑
|
|
202964
|
+
* @returns Promise
|
|
202965
|
+
*/
|
|
202966
|
+
async importComponents() {
|
|
202967
|
+
var _a3;
|
|
202968
|
+
for (const comId of this.taskData.ids) {
|
|
202969
|
+
const com = await this.entifyClient.oneEntity(
|
|
202970
|
+
new FrontComponentQueryOptions(
|
|
202971
|
+
[
|
|
202972
|
+
FrontComponentFields.id,
|
|
202973
|
+
FrontComponentFields.id,
|
|
202974
|
+
FrontComponentFields.name,
|
|
202975
|
+
FrontComponentFields.code,
|
|
202976
|
+
FrontComponentFields.description,
|
|
202977
|
+
FrontComponentFields.title,
|
|
202978
|
+
FrontComponentFields.seqValue,
|
|
202979
|
+
FrontComponentFields.testConfig,
|
|
202980
|
+
FrontComponentFields.props
|
|
202981
|
+
],
|
|
202982
|
+
{
|
|
202983
|
+
where: {
|
|
202984
|
+
id: {
|
|
202985
|
+
_eq: comId
|
|
202986
|
+
}
|
|
202987
|
+
}
|
|
202988
|
+
}
|
|
202989
|
+
).category([
|
|
202990
|
+
ComponentCategoryFields.id,
|
|
202991
|
+
ComponentCategoryFields.name,
|
|
202992
|
+
ComponentCategoryFields.seqValue
|
|
202993
|
+
])
|
|
202994
|
+
);
|
|
202995
|
+
if (!com) {
|
|
202996
|
+
throw Error("没有找到要导入的页面");
|
|
202997
|
+
}
|
|
202998
|
+
const existCom = (_a3 = this.components) == null ? void 0 : _a3.find((p2) => p2.name === com.name);
|
|
202999
|
+
let existCategory = this.categories.find(
|
|
203000
|
+
(c) => {
|
|
203001
|
+
var _a4;
|
|
203002
|
+
return c.name === ((_a4 = com.category) == null ? void 0 : _a4.name);
|
|
203003
|
+
}
|
|
203004
|
+
);
|
|
203005
|
+
if (!existCategory && com.category) {
|
|
203006
|
+
existCategory = await this.entifyClient.upsertEntity(
|
|
203007
|
+
ComponentCategoryEntityName,
|
|
203008
|
+
{
|
|
203009
|
+
...com.category,
|
|
203010
|
+
id: void 0,
|
|
203011
|
+
theme: { sync: { id: this.taskData.themeId } }
|
|
203012
|
+
}
|
|
203013
|
+
);
|
|
203014
|
+
if (existCategory) {
|
|
203015
|
+
this.categories.push({ ...existCategory, name: com.category.name });
|
|
203016
|
+
}
|
|
203017
|
+
}
|
|
203018
|
+
await this.importOneComponent(com, existCom == null ? void 0 : existCom.id, existCategory);
|
|
203019
|
+
}
|
|
203020
|
+
const msg = `成功导入 ${this.taskData.ids.length} 个文件`;
|
|
203021
|
+
addToast({
|
|
203022
|
+
title: "导入完成",
|
|
203023
|
+
description: msg,
|
|
203024
|
+
color: "success"
|
|
203025
|
+
});
|
|
203026
|
+
}
|
|
203027
|
+
}
|
|
202750
203028
|
function useComponentsImportTask() {
|
|
203029
|
+
const [isImporting, setIsImporting] = useState(false);
|
|
202751
203030
|
const theme = useStudioTheme();
|
|
202752
203031
|
const lang = useCurrentLang();
|
|
202753
203032
|
const components = useFrontComponents();
|
|
202754
|
-
const appKey = (theme == null ? void 0 : theme.id) || "";
|
|
202755
|
-
const taskState = useInprogressTaskByKey(IMPORT_COMPONENTS_KEY, appKey);
|
|
202756
|
-
const setTask = useUpdateTask(appKey);
|
|
202757
|
-
const setTaskRef = useRef(setTask);
|
|
202758
|
-
setTaskRef.current = setTask;
|
|
202759
203033
|
const entifyClient = useCreateEntityClient();
|
|
202760
|
-
const task = taskState && taskState.status !== "done" ? taskPool[taskState.taskId] : void 0;
|
|
202761
|
-
const aiUrl = useAiUrl();
|
|
202762
203034
|
const componentCategories = useComponentCategories();
|
|
202763
|
-
const handleTaskChange = useCallback((data) => {
|
|
202764
|
-
setTaskRef.current(data);
|
|
202765
|
-
}, []);
|
|
202766
203035
|
const importComponents = useCallback(
|
|
202767
|
-
(ids
|
|
202768
|
-
|
|
202769
|
-
|
|
202770
|
-
|
|
202771
|
-
|
|
202772
|
-
|
|
202773
|
-
|
|
202774
|
-
|
|
202775
|
-
|
|
202776
|
-
|
|
202777
|
-
|
|
202778
|
-
|
|
203036
|
+
async (ids) => {
|
|
203037
|
+
setIsImporting(true);
|
|
203038
|
+
try {
|
|
203039
|
+
if (!(theme == null ? void 0 : theme.id)) {
|
|
203040
|
+
console.error("没设置Theme");
|
|
203041
|
+
return;
|
|
203042
|
+
}
|
|
203043
|
+
if (!entifyClient) {
|
|
203044
|
+
console.error("entifyClient 创建失败");
|
|
203045
|
+
return;
|
|
203046
|
+
}
|
|
203047
|
+
const task = new ImportComponentsTask(
|
|
203048
|
+
{
|
|
203049
|
+
ids,
|
|
203050
|
+
entifyClient,
|
|
203051
|
+
themeId: theme == null ? void 0 : theme.id,
|
|
203052
|
+
lang
|
|
203053
|
+
},
|
|
203054
|
+
components || [],
|
|
203055
|
+
(componentCategories == null ? void 0 : componentCategories.items) || []
|
|
203056
|
+
);
|
|
203057
|
+
await task.importComponents();
|
|
203058
|
+
} catch (error) {
|
|
203059
|
+
console.error("导入组件失败", error);
|
|
203060
|
+
} finally {
|
|
203061
|
+
setIsImporting(false);
|
|
202779
203062
|
}
|
|
202780
|
-
const task2 = new ImportComponentsTask(
|
|
202781
|
-
{
|
|
202782
|
-
key: IMPORT_COMPONENTS_KEY,
|
|
202783
|
-
ids,
|
|
202784
|
-
entifyClient,
|
|
202785
|
-
needTranslate,
|
|
202786
|
-
themeId: theme == null ? void 0 : theme.id,
|
|
202787
|
-
lang,
|
|
202788
|
-
aiUrl
|
|
202789
|
-
//categoryId,
|
|
202790
|
-
},
|
|
202791
|
-
components || [],
|
|
202792
|
-
(componentCategories == null ? void 0 : componentCategories.items) || []
|
|
202793
|
-
);
|
|
202794
|
-
taskPool[task2.id] = task2;
|
|
202795
|
-
task2.onDataChange(handleTaskChange);
|
|
202796
|
-
task2.start();
|
|
202797
203063
|
},
|
|
202798
|
-
[
|
|
202799
|
-
|
|
202800
|
-
|
|
202801
|
-
|
|
202802
|
-
|
|
202803
|
-
|
|
202804
|
-
|
|
202805
|
-
|
|
202806
|
-
|
|
203064
|
+
[theme == null ? void 0 : theme.id, entifyClient, lang, components, componentCategories]
|
|
203065
|
+
);
|
|
203066
|
+
return {
|
|
203067
|
+
importComponents,
|
|
203068
|
+
isImporting
|
|
203069
|
+
};
|
|
203070
|
+
}
|
|
203071
|
+
function useTranlateComponents() {
|
|
203072
|
+
const translateRequest = useTranslateRequest();
|
|
203073
|
+
const translate = useCallback(
|
|
203074
|
+
async (langId, ids) => {
|
|
203075
|
+
return await translateRequest("/api/studio/translate-components", {
|
|
203076
|
+
targetLangId: langId,
|
|
203077
|
+
sourceComponentIds: ids
|
|
203078
|
+
});
|
|
203079
|
+
},
|
|
203080
|
+
[translateRequest]
|
|
202807
203081
|
);
|
|
202808
|
-
return
|
|
203082
|
+
return translate;
|
|
202809
203083
|
}
|
|
202810
203084
|
function ImportComponentModal({
|
|
202811
203085
|
open,
|
|
202812
203086
|
onClose
|
|
202813
203087
|
}) {
|
|
203088
|
+
var _a3;
|
|
202814
203089
|
const [selection, setSelections] = useState([]);
|
|
203090
|
+
const [loading, setLoading] = useState(false);
|
|
202815
203091
|
const [confirmTitle, setConfirmTitle] = useState(
|
|
202816
203092
|
void 0
|
|
202817
203093
|
);
|
|
202818
203094
|
const baseThemeId = useBaseLangThemeId();
|
|
203095
|
+
const theme = useStudioTheme();
|
|
202819
203096
|
const isBaseTheme = useIsBaseLangTheme();
|
|
202820
203097
|
const parentTheme = useParentTheme();
|
|
202821
203098
|
const themeComs = useFrontComponents();
|
|
202822
|
-
const {
|
|
202823
|
-
|
|
202824
|
-
var _a3;
|
|
202825
|
-
setSelections == null ? void 0 : setSelections(((_a3 = taskState == null ? void 0 : taskState.data) == null ? void 0 : _a3.ids) || []);
|
|
202826
|
-
}, [setSelections, taskState == null ? void 0 : taskState.data]);
|
|
202827
|
-
useEffect(() => {
|
|
202828
|
-
if ((taskState == null ? void 0 : taskState.status) === "done") {
|
|
202829
|
-
setSelections == null ? void 0 : setSelections([]);
|
|
202830
|
-
}
|
|
202831
|
-
}, [setSelections, taskState]);
|
|
203099
|
+
const { importComponents } = useComponentsImportTask();
|
|
203100
|
+
const translateComponents = useTranlateComponents();
|
|
202832
203101
|
const confirmResolveRef = useRef();
|
|
202833
203102
|
const { data: baseTheme, isLoading } = useOneThemeById(
|
|
202834
203103
|
baseThemeId || void 0,
|
|
@@ -202858,8 +203127,8 @@ function ImportComponentModal({
|
|
|
202858
203127
|
}, [baseTheme == null ? void 0 : baseTheme.components, parentTheme == null ? void 0 : parentTheme.components, isBaseTheme]);
|
|
202859
203128
|
const noCategoryComponents = useMemo(() => {
|
|
202860
203129
|
return components.filter((component) => {
|
|
202861
|
-
var
|
|
202862
|
-
return !((
|
|
203130
|
+
var _a4;
|
|
203131
|
+
return !((_a4 = component.category) == null ? void 0 : _a4.id);
|
|
202863
203132
|
});
|
|
202864
203133
|
}, [components]);
|
|
202865
203134
|
const handleToggleSelect = React__default.useCallback((id) => {
|
|
@@ -202885,26 +203154,51 @@ function ImportComponentModal({
|
|
|
202885
203154
|
});
|
|
202886
203155
|
}, []);
|
|
202887
203156
|
const handleImport = useCallback(async () => {
|
|
202888
|
-
|
|
202889
|
-
|
|
202890
|
-
|
|
202891
|
-
|
|
202892
|
-
|
|
202893
|
-
|
|
202894
|
-
|
|
202895
|
-
|
|
202896
|
-
|
|
202897
|
-
|
|
203157
|
+
var _a4;
|
|
203158
|
+
setLoading(true);
|
|
203159
|
+
try {
|
|
203160
|
+
const comsToImport = components.filter(
|
|
203161
|
+
(c) => selection.includes(c.id || "")
|
|
203162
|
+
);
|
|
203163
|
+
const existings = themeComs == null ? void 0 : themeComs.filter(
|
|
203164
|
+
(c) => comsToImport == null ? void 0 : comsToImport.find((com) => c.name === com.name)
|
|
203165
|
+
);
|
|
203166
|
+
if (existings == null ? void 0 : existings.length) {
|
|
203167
|
+
const result = await confirmOverride(existings.length);
|
|
203168
|
+
if (!result) {
|
|
203169
|
+
return;
|
|
203170
|
+
}
|
|
203171
|
+
}
|
|
203172
|
+
if (isBaseTheme) {
|
|
203173
|
+
await importComponents(selection);
|
|
203174
|
+
} else {
|
|
203175
|
+
await translateComponents(((_a4 = theme == null ? void 0 : theme.lang) == null ? void 0 : _a4.id) || "", selection);
|
|
203176
|
+
addToast({
|
|
203177
|
+
title: "成功添加导入任务",
|
|
203178
|
+
color: "success"
|
|
203179
|
+
});
|
|
202898
203180
|
}
|
|
203181
|
+
setSelections([]);
|
|
203182
|
+
onClose();
|
|
203183
|
+
} catch (error) {
|
|
203184
|
+
console.error("导入组件失败:", error);
|
|
203185
|
+
addToast({
|
|
203186
|
+
title: "导入组件失败",
|
|
203187
|
+
color: "danger"
|
|
203188
|
+
});
|
|
203189
|
+
} finally {
|
|
203190
|
+
setLoading(false);
|
|
202899
203191
|
}
|
|
202900
|
-
importComponents(selection, !isBaseTheme);
|
|
202901
203192
|
}, [
|
|
202902
203193
|
components,
|
|
202903
203194
|
confirmOverride,
|
|
202904
203195
|
importComponents,
|
|
202905
203196
|
isBaseTheme,
|
|
203197
|
+
onClose,
|
|
202906
203198
|
selection,
|
|
202907
|
-
|
|
203199
|
+
(_a3 = theme == null ? void 0 : theme.lang) == null ? void 0 : _a3.id,
|
|
203200
|
+
themeComs,
|
|
203201
|
+
translateComponents
|
|
202908
203202
|
]);
|
|
202909
203203
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Modal$1, { isOpen: open, onClose, children: [
|
|
202910
203204
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalOverlay$1, { className: "z-10" }),
|
|
@@ -202922,8 +203216,8 @@ function ImportComponentModal({
|
|
|
202922
203216
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalBody, { className: "flex-1 overflow-y-auto min-h-0 p-2", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ComponentsSkeletons, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs(TreeView, { children: [
|
|
202923
203217
|
categories == null ? void 0 : categories.map((category) => /* @__PURE__ */ jsxRuntimeExports.jsx(GroupNode, { title: category.name, icon: false, children: components.filter(
|
|
202924
203218
|
(component) => {
|
|
202925
|
-
var
|
|
202926
|
-
return ((
|
|
203219
|
+
var _a4;
|
|
203220
|
+
return ((_a4 = component.category) == null ? void 0 : _a4.id) === category.id;
|
|
202927
203221
|
}
|
|
202928
203222
|
).map((component) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
202929
203223
|
LeafNode,
|
|
@@ -202958,22 +203252,7 @@ function ImportComponentModal({
|
|
|
202958
203252
|
] }) }),
|
|
202959
203253
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Divider, {}),
|
|
202960
203254
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(ModalFooter, { className: "justify-between", children: [
|
|
202961
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
202962
|
-
selection.length > 0 && (taskState == null ? void 0 : taskState.status) !== "in-progress" ? `${selection.length}个组件选中` : "",
|
|
202963
|
-
taskState == null ? void 0 : taskState.infoMessage,
|
|
202964
|
-
(taskState == null ? void 0 : taskState.status) === "in-progress" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
202965
|
-
Button$2,
|
|
202966
|
-
{
|
|
202967
|
-
variant: "light",
|
|
202968
|
-
size: "sm",
|
|
202969
|
-
isIconOnly: true,
|
|
202970
|
-
onPress: () => {
|
|
202971
|
-
task == null ? void 0 : task.stop();
|
|
202972
|
-
},
|
|
202973
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(TaskStopIcon, { className: "size-9 text-primary" })
|
|
202974
|
-
}
|
|
202975
|
-
)
|
|
202976
|
-
] }),
|
|
203255
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-default-500 flex items-center gap-2" }),
|
|
202977
203256
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
|
|
202978
203257
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button$2, { variant: "light", onPress: onClose, children: "关闭" }),
|
|
202979
203258
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -202982,7 +203261,7 @@ function ImportComponentModal({
|
|
|
202982
203261
|
variant: "solid",
|
|
202983
203262
|
color: "primary",
|
|
202984
203263
|
onPress: handleImport,
|
|
202985
|
-
isLoading:
|
|
203264
|
+
isLoading: loading,
|
|
202986
203265
|
children: "转入"
|
|
202987
203266
|
}
|
|
202988
203267
|
)
|
|
@@ -203018,7 +203297,6 @@ function ComponentsRootNode(props) {
|
|
|
203018
203297
|
const website = useWebsite();
|
|
203019
203298
|
const handleNewCagegory = useNewRow();
|
|
203020
203299
|
const components = useFrontComponents();
|
|
203021
|
-
const { taskState } = useComponentsImportTask();
|
|
203022
203300
|
const comsNoCategory = useMemo(
|
|
203023
203301
|
() => components == null ? void 0 : components.filter((item) => {
|
|
203024
203302
|
var _a3;
|
|
@@ -203058,7 +203336,6 @@ function ComponentsRootNode(props) {
|
|
|
203058
203336
|
},
|
|
203059
203337
|
[setEditingPage, components, setEditingComponent, onSelectContent]
|
|
203060
203338
|
);
|
|
203061
|
-
const importting = (taskState == null ? void 0 : taskState.status) === "in-progress";
|
|
203062
203339
|
if (!themeId) {
|
|
203063
203340
|
return null;
|
|
203064
203341
|
}
|
|
@@ -203067,7 +203344,7 @@ function ComponentsRootNode(props) {
|
|
|
203067
203344
|
GroupNode,
|
|
203068
203345
|
{
|
|
203069
203346
|
title: "自定义组件",
|
|
203070
|
-
fiexdAction: open
|
|
203347
|
+
fiexdAction: open,
|
|
203071
203348
|
icon: null,
|
|
203072
203349
|
classNames: {
|
|
203073
203350
|
title: "text-sm font-semibold"
|
|
@@ -203080,7 +203357,6 @@ function ComponentsRootNode(props) {
|
|
|
203080
203357
|
size: "sm",
|
|
203081
203358
|
variant: "light",
|
|
203082
203359
|
isIconOnly: true,
|
|
203083
|
-
isLoading: importting,
|
|
203084
203360
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
203085
203361
|
Icon,
|
|
203086
203362
|
{
|
|
@@ -203511,11 +203787,20 @@ function WebsiteStudioInner(props) {
|
|
|
203511
203787
|
const { aiUrl, deployUrl } = props;
|
|
203512
203788
|
const website = useWebsite();
|
|
203513
203789
|
const langId = ((_a3 = useCurrentLang()) == null ? void 0 : _a3.id) || ((_b3 = website == null ? void 0 : website.baseLang) == null ? void 0 : _b3.id);
|
|
203790
|
+
const token = useEntifyToken();
|
|
203514
203791
|
const { data: theme, isLoading: themeLoading } = useOneTheme(
|
|
203515
203792
|
newThemeQueryOptions(website == null ? void 0 : website.id, langId)
|
|
203516
203793
|
);
|
|
203517
203794
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(StudioRoot, { theme, deployUrl, children: [
|
|
203518
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(EditorScope, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
203795
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(EditorScope, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
203796
|
+
AiAgentRoot,
|
|
203797
|
+
{
|
|
203798
|
+
endpoint: aiUrl,
|
|
203799
|
+
globalProvider: WEBSITE_DESIGN_PROMPT,
|
|
203800
|
+
token,
|
|
203801
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(WebsiteDesigner, { themeLoading, deployUrl })
|
|
203802
|
+
}
|
|
203803
|
+
) }),
|
|
203519
203804
|
/* @__PURE__ */ jsxRuntimeExports.jsx(GlobalLoading, { loading: themeLoading })
|
|
203520
203805
|
] });
|
|
203521
203806
|
}
|
|
@@ -204389,8 +204674,17 @@ const ThemeStudio = (props) => {
|
|
|
204389
204674
|
themeId,
|
|
204390
204675
|
newThemeByIdQueryOptions()
|
|
204391
204676
|
);
|
|
204677
|
+
const token = useEntifyToken();
|
|
204392
204678
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(StudioRoot, { theme, deployUrl: deployURL, children: [
|
|
204393
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(EditorScope, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
204679
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(EditorScope, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
204680
|
+
AiAgentRoot,
|
|
204681
|
+
{
|
|
204682
|
+
endpoint: aiUrl,
|
|
204683
|
+
globalProvider: WEBSITE_DESIGN_PROMPT,
|
|
204684
|
+
token,
|
|
204685
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeDesigner, {})
|
|
204686
|
+
}
|
|
204687
|
+
) }),
|
|
204394
204688
|
/* @__PURE__ */ jsxRuntimeExports.jsx(GlobalLoading, { loading: themeLoading })
|
|
204395
204689
|
] });
|
|
204396
204690
|
};
|
|
@@ -204408,4 +204702,4 @@ export {
|
|
|
204408
204702
|
typescriptDefaults as t,
|
|
204409
204703
|
useCustomizedMaterials as u
|
|
204410
204704
|
};
|
|
204411
|
-
//# sourceMappingURL=index-
|
|
204705
|
+
//# sourceMappingURL=index-a0e7f111.js.map
|