@ydesign/react-editor 0.1.2 → 0.1.3
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/README.md +20 -119
- package/dist/canvas/workspace.d.ts +1 -1
- package/dist/chunk-3PMUQSBH.js +1 -0
- package/dist/chunk-3UOBPTKL.js +151 -0
- package/dist/{chunk-RBRSKAZL.js → chunk-AMEXYVS6.js} +1 -1
- package/dist/chunk-C4XMVZO4.js +1 -0
- package/dist/chunk-OV7AL42Z.js +1 -0
- package/dist/{chunk-WFMCGQ5V.js → chunk-Q7N7SBSC.js} +1 -1
- package/dist/{chunk-QALZ5CAJ.js → chunk-SEZLO2OE.js} +15 -15
- package/dist/{chunk-63A6RW6Y.js → chunk-VIU27HHW.js} +1 -1
- package/dist/config.d.ts +2 -221
- package/dist/config.js +1 -1
- package/dist/model/store.d.ts +1 -1
- package/dist/model/store.js +1 -1
- package/dist/project.d.ts +11 -1
- package/dist/project.js +1 -1
- package/dist/side-panel/index.d.ts +1 -1
- package/dist/side-panel/index.js +1 -1
- package/dist/side-panel/side-panel.d.ts +1 -1
- package/dist/side-panel/side-panel.js +1 -1
- package/dist/{store-DfmY1m2j.d.ts → store-CgxwnT-h.d.ts} +3 -0
- package/dist/toolbar/download-button.d.ts +1 -1
- package/dist/toolbar/download-button.js +1 -1
- package/dist/toolbar/toolbar.d.ts +1 -1
- package/dist/toolbar/toolbar.js +3 -3
- package/dist/toolbar/zoom-buttons.d.ts +1 -1
- package/dist/topbar/create-design.d.ts +1 -1
- package/dist/topbar/create-design.js +1 -1
- package/dist/topbar/topbar.d.ts +1 -1
- package/dist/topbar/topbar.js +2 -2
- package/dist/utils/l10n.d.ts +228 -0
- package/dist/utils/l10n.js +1 -0
- package/package.json +2 -2
- package/dist/chunk-2AZQIJ4K.js +0 -1
- package/dist/chunk-6XGFXDKJ.js +0 -151
- package/dist/chunk-EUTDQZKU.js +0 -1
- package/dist/chunk-KERQXVBL.js +0 -1
package/dist/topbar/topbar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as x}from"../chunk-3UOBPTKL.js";import{c as u}from"../chunk-OV7AL42Z.js";import"../chunk-C4XMVZO4.js";import"../chunk-YBC2DYJX.js";import"../chunk-EWOU5F3O.js";import{b as g}from"../chunk-5C2MNUBC.js";import"../chunk-3PMUQSBH.js";import{a as h}from"../chunk-AMEXYVS6.js";import{c as n}from"../chunk-Q7N7SBSC.js";import"../chunk-O2XFH626.js";import d from"styled-components";import{observer as C}from"mobx-react-lite";import{Dropdown as T,Button as S,Modal as L}from"antd";import{Menu as N,Plus as P,Languages as z,Check as b}from"lucide-react";import{useState as I}from"react";import{observer as B}from"mobx-react-lite";import{Fragment as K,jsx as a,jsxs as M}from"react/jsx-runtime";var{confirm:D}=L,v=B(({store:o,project:t})=>{let[l,i]=I(!1),s=[{label:n("topbar.newDesign"),key:"new_design",icon:a(P,{size:16})},{label:n("topbar.language"),key:"language",icon:a("div",{style:{height:22,display:"flex",alignItems:"center"},children:a(z,{size:16})}),children:[{key:"en",label:"English",onClick:()=>{t.setLanguage("en")},extra:t.language==="en"?a(b,{size:16}):null},{key:"zh",label:"\u4E2D\u6587",onClick:()=>{t.setLanguage("zh")},extra:t.language==="zh"?a(b,{size:16}):null}]}];return M(K,{children:[a(T,{menu:{items:s,onClick:({key:r})=>{r==="new_design"&&i(!0)}},trigger:["click"],styles:{root:{width:188}},children:a(S,{type:"text",children:a(N,{size:16})})}),a(x,{visible:l,onClose:()=>i(!1),onConfirm:r=>{D({title:"\u521B\u5EFA\u8BBE\u8BA1\u540E\uFF0C\u5C06\u65B0\u5EFA\u753B\u5E03\uFF0C\u5F53\u524D\u6D77\u62A5\u5185\u5BB9\u53EF\u5728\u4F5C\u56FE\u8BB0\u5F55\u4E2D\u67E5\u770B\u3002",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",onOk(){console.log("OK"),console.log("size ---> ",r);let c=JSON.stringify({bg:{backgroundColor:r.bgColor}}),y=new URLSearchParams({create:"",createEmptyPoster:"true",createInfo:c,height:String(r.height),unit:r.unit,width:String(r.width)});console.log("params \u7684\u53C2\u6570 ---> ",y.toString()),console.log("\u9700\u8981\u8DF3\u8F6C\u7684\u7F16\u8F91\u5668\u5730\u5740",t.urls.editorUrl),window.open(`${t.urls.editorUrl}?${y.toString()}`,"_blank")}})},store:o,project:t})]})});import{Input as O,Tooltip as R,Button as U,theme as _,Divider as E}from"antd";import{CloudUpload as m,Loader as F,Check as $}from"lucide-react";var w="https://pub-d7c4dca6f69c4b329766184b707dc826.r2.dev/images/2026-03-20/90d9e12a-edaa-447b-9ac2-6fdd7ec6397c/97900353-048f-4792-91bd-bdcd2d751d3b/e03bc692-c918-4fd5-bb0b-d3d93eb012a3.png";import{jsx as e,jsxs as f}from"react/jsx-runtime";var j=d("div")`
|
|
2
2
|
white-space: nowrap;
|
|
3
3
|
height: 55px;
|
|
4
4
|
padding: 0 15px;
|
|
@@ -25,4 +25,4 @@ import{a as u}from"../chunk-6XGFXDKJ.js";import{c as f}from"../chunk-2AZQIJ4K.js
|
|
|
25
25
|
display: flex;
|
|
26
26
|
align-items: center;
|
|
27
27
|
height: 55px;
|
|
28
|
-
`,
|
|
28
|
+
`,k={loading:{icon:e(m,{size:16,style:{display:"flex"}}),textKey:"topbar.statusLoading"},save:{icon:e(m,{size:16,style:{display:"flex"}}),textKey:"topbar.statusSave"},saved:{icon:e($,{size:16,style:{display:"flex",color:"#52c41a"}}),textKey:"topbar.statusSaved",color:"#52c41a"},"has-changes":{icon:e(m,{size:16,style:{display:"flex",color:"#faad14"}}),textKey:"topbar.statusHasChanges",color:"#faad14"},saving:{icon:e(F,{size:16,style:{display:"flex"}}),textKey:"topbar.statusSaving"}},J=C(({project:o})=>{let t=k[o.status]||k.saved;return e(R,{title:n(t.textKey),children:e(U,{type:"text",style:{marginLeft:14,color:t.color},icon:t.icon,onClick:()=>{(o.status==="save"||o.status==="saved")&&o.save()},children:n(t.textKey)})})}),ge=C(({store:o,logo:t,logoUrl:l})=>{let i=u(),{token:s}=_.useToken(),p=t===void 0?e("img",{src:w,className:"h-[28px]"}):typeof t=="string"?e("img",{src:t,className:"h-[28px]"}):t,r=l?e("a",{href:l,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center"},children:p}):e("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>window.history.back(),children:p});return e(j,{className:"topbar",style:{backgroundColor:s.colorBgContainer,color:s.colorText,borderBottom:`1px solid ${s.colorBorder}`},children:f(A,{children:[f(G,{children:[e("div",{style:{display:"flex",alignItems:"center"},children:r}),e(E,{orientation:"vertical",style:{height:"1.3em",borderColor:"#ebe6e7",marginLeft:15}}),e(v,{store:o,project:i}),e("div",{style:{paddingLeft:10,maxWidth:200},children:e(O,{value:i.name,placeholder:n("topbar.editableTextPlaceholder"),onChange:c=>i.name=c.target.value})}),f("div",{style:{paddingLeft:16,fontSize:14},className:"text-gray-600",children:[g({px:o.width,unit:o.unit,dpi:o.dpi,precious:0})," x"," ",g({px:o.height,unit:o.unit,dpi:o.dpi,precious:0})," ",o.unit]}),e(J,{project:i})]}),e(H,{children:e(h,{store:o})})]})})});export{ge as Topbar};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设置/更新翻译
|
|
3
|
+
* @param {object} newTranslations - 新的翻译对象
|
|
4
|
+
* @param {object} options - 配置选项
|
|
5
|
+
* @param {boolean} options.validate - 是否验证翻译完整性
|
|
6
|
+
*/
|
|
7
|
+
declare const setTranslations: (newTranslations: any, { validate }?: {
|
|
8
|
+
validate?: boolean | undefined;
|
|
9
|
+
}) => void;
|
|
10
|
+
/**
|
|
11
|
+
* 获取所有翻译(返回普通 JS 对象)
|
|
12
|
+
* @returns {object}
|
|
13
|
+
*/
|
|
14
|
+
declare const getTranslations: () => {
|
|
15
|
+
toolbar: {
|
|
16
|
+
undo: string;
|
|
17
|
+
redo: string;
|
|
18
|
+
duration: string;
|
|
19
|
+
opacity: string;
|
|
20
|
+
effects: string;
|
|
21
|
+
blur: string;
|
|
22
|
+
textBackground: string;
|
|
23
|
+
backgroundCornerRadius: string;
|
|
24
|
+
backgroundOpacity: string;
|
|
25
|
+
backgroundPadding: string;
|
|
26
|
+
backgroundColor: string;
|
|
27
|
+
brightness: string;
|
|
28
|
+
filters: string;
|
|
29
|
+
sepia: string;
|
|
30
|
+
grayscale: string;
|
|
31
|
+
contrast: string;
|
|
32
|
+
saturation: string;
|
|
33
|
+
vibrance: string;
|
|
34
|
+
hueRotation: string;
|
|
35
|
+
noise: string;
|
|
36
|
+
pixelate: string;
|
|
37
|
+
textStroke: string;
|
|
38
|
+
shadow: string;
|
|
39
|
+
border: string;
|
|
40
|
+
cornerRadius: string;
|
|
41
|
+
textleft: string;
|
|
42
|
+
textcenter: string;
|
|
43
|
+
textright: string;
|
|
44
|
+
textjustify: string;
|
|
45
|
+
textBold: string;
|
|
46
|
+
textItalic: string;
|
|
47
|
+
textUnderline: string;
|
|
48
|
+
textStrikethrough: string;
|
|
49
|
+
splitByGrapheme: string;
|
|
50
|
+
position: string;
|
|
51
|
+
layering: string;
|
|
52
|
+
toForward: string;
|
|
53
|
+
up: string;
|
|
54
|
+
down: string;
|
|
55
|
+
toBottom: string;
|
|
56
|
+
alignLeft: string;
|
|
57
|
+
alignCenter: string;
|
|
58
|
+
alignRight: string;
|
|
59
|
+
alignTop: string;
|
|
60
|
+
alignMiddle: string;
|
|
61
|
+
alignBottom: string;
|
|
62
|
+
flip: string;
|
|
63
|
+
flipHorizontally: string;
|
|
64
|
+
flipVertically: string;
|
|
65
|
+
fitToBackground: string;
|
|
66
|
+
removeBackground: string;
|
|
67
|
+
removeBackgroundTitle: string;
|
|
68
|
+
cancelRemoveBackground: string;
|
|
69
|
+
confirmRemoveBackground: string;
|
|
70
|
+
eraserPen: string;
|
|
71
|
+
eraserPenTitle: string;
|
|
72
|
+
cancelEraserPen: string;
|
|
73
|
+
confirmEraserPen: string;
|
|
74
|
+
crop: string;
|
|
75
|
+
cropDone: string;
|
|
76
|
+
cropCancel: string;
|
|
77
|
+
clip: string;
|
|
78
|
+
removeClip: string;
|
|
79
|
+
removeMask: string;
|
|
80
|
+
transparency: string;
|
|
81
|
+
lockedDescription: string;
|
|
82
|
+
unlockedDescription: string;
|
|
83
|
+
removeElements: string;
|
|
84
|
+
duplicateElements: string;
|
|
85
|
+
download: string;
|
|
86
|
+
saveAsImage: string;
|
|
87
|
+
saveAsPDF: string;
|
|
88
|
+
lineHeight: string;
|
|
89
|
+
letterSpacing: string;
|
|
90
|
+
offsetX: string;
|
|
91
|
+
offsetY: string;
|
|
92
|
+
color: string;
|
|
93
|
+
selectable: string;
|
|
94
|
+
draggable: string;
|
|
95
|
+
removable: string;
|
|
96
|
+
resizable: string;
|
|
97
|
+
contentEditable: string;
|
|
98
|
+
styleEditable: string;
|
|
99
|
+
alwaysOnTop: string;
|
|
100
|
+
showInExport: string;
|
|
101
|
+
ungroupElements: string;
|
|
102
|
+
groupElements: string;
|
|
103
|
+
lineSize: string;
|
|
104
|
+
fade: string;
|
|
105
|
+
move: string;
|
|
106
|
+
zoom: string;
|
|
107
|
+
rotate: string;
|
|
108
|
+
none: string;
|
|
109
|
+
bounce: string;
|
|
110
|
+
blink: string;
|
|
111
|
+
strength: string;
|
|
112
|
+
spaceEvenly: string;
|
|
113
|
+
horizontalDistribution: string;
|
|
114
|
+
verticalDistribution: string;
|
|
115
|
+
strokeWidth: string;
|
|
116
|
+
strokeSettings: string;
|
|
117
|
+
colorPicker: {
|
|
118
|
+
solid: string;
|
|
119
|
+
linear: string;
|
|
120
|
+
angle: string;
|
|
121
|
+
};
|
|
122
|
+
aiText: {
|
|
123
|
+
aiWrite: string;
|
|
124
|
+
rewrite: string;
|
|
125
|
+
shorten: string;
|
|
126
|
+
continue: string;
|
|
127
|
+
proofread: string;
|
|
128
|
+
tones: string;
|
|
129
|
+
friendly: string;
|
|
130
|
+
professional: string;
|
|
131
|
+
humorous: string;
|
|
132
|
+
formal: string;
|
|
133
|
+
customPrompt: string;
|
|
134
|
+
generatedResult: string;
|
|
135
|
+
cancel: string;
|
|
136
|
+
generate: string;
|
|
137
|
+
back: string;
|
|
138
|
+
tryAgain: string;
|
|
139
|
+
insert: string;
|
|
140
|
+
promptPlaceholder: string;
|
|
141
|
+
};
|
|
142
|
+
addImage: string;
|
|
143
|
+
addText: string;
|
|
144
|
+
fileType: string;
|
|
145
|
+
quality: string;
|
|
146
|
+
multiplier: string;
|
|
147
|
+
size: string;
|
|
148
|
+
};
|
|
149
|
+
workspace: {
|
|
150
|
+
noPages: string;
|
|
151
|
+
addPage: string;
|
|
152
|
+
removePage: string;
|
|
153
|
+
duplicatePage: string;
|
|
154
|
+
moveUp: string;
|
|
155
|
+
moveDown: string;
|
|
156
|
+
};
|
|
157
|
+
scale: {
|
|
158
|
+
reset: string;
|
|
159
|
+
};
|
|
160
|
+
error: {
|
|
161
|
+
removeBackground: string;
|
|
162
|
+
};
|
|
163
|
+
sidePanel: {
|
|
164
|
+
templates: string;
|
|
165
|
+
searchTemplatesWithSameSize: string;
|
|
166
|
+
searchPlaceholder: string;
|
|
167
|
+
otherFormats: string;
|
|
168
|
+
noResults: string;
|
|
169
|
+
error: string;
|
|
170
|
+
text: string;
|
|
171
|
+
uploadFont: string;
|
|
172
|
+
myFonts: string;
|
|
173
|
+
photos: string;
|
|
174
|
+
videos: string;
|
|
175
|
+
animations: string;
|
|
176
|
+
effects: string;
|
|
177
|
+
elements: string;
|
|
178
|
+
shapes: string;
|
|
179
|
+
lines: string;
|
|
180
|
+
upload: string;
|
|
181
|
+
uploadImage: string;
|
|
182
|
+
uploadTip: string;
|
|
183
|
+
background: string;
|
|
184
|
+
resize: string;
|
|
185
|
+
layers: string;
|
|
186
|
+
layerTypes: {
|
|
187
|
+
image: string;
|
|
188
|
+
text: string;
|
|
189
|
+
svg: string;
|
|
190
|
+
line: string;
|
|
191
|
+
figure: string;
|
|
192
|
+
group: string;
|
|
193
|
+
};
|
|
194
|
+
layersTip: string;
|
|
195
|
+
noLayers: string;
|
|
196
|
+
namePlaceholder: string;
|
|
197
|
+
useMagicResize: string;
|
|
198
|
+
clipImage: string;
|
|
199
|
+
width: string;
|
|
200
|
+
height: string;
|
|
201
|
+
magicResizeDescription: string;
|
|
202
|
+
headerText: string;
|
|
203
|
+
createHeader: string;
|
|
204
|
+
subHeaderText: string;
|
|
205
|
+
createSubHeader: string;
|
|
206
|
+
bodyText: string;
|
|
207
|
+
createBody: string;
|
|
208
|
+
units: string;
|
|
209
|
+
};
|
|
210
|
+
topbar: {
|
|
211
|
+
newDesign: string;
|
|
212
|
+
language: string;
|
|
213
|
+
editableTextPlaceholder: string;
|
|
214
|
+
statusLoading: string;
|
|
215
|
+
statusSave: string;
|
|
216
|
+
statusSaved: string;
|
|
217
|
+
statusHasChanges: string;
|
|
218
|
+
statusSaving: string;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* 获取翻译文本
|
|
223
|
+
* @param {string} key - 翻译键,如 'toolbar.opacity'
|
|
224
|
+
* @returns {string} 翻译文本,如果不存在则返回格式化后的键名
|
|
225
|
+
*/
|
|
226
|
+
declare const translate: (key: string) => string;
|
|
227
|
+
|
|
228
|
+
export { getTranslations, setTranslations, translate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"../chunk-Q7N7SBSC.js";import"../chunk-O2XFH626.js";export{b as getTranslations,a as setTranslations,c as translate};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ydesign/react-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "设计编辑器UI组件库,基于react版本",
|
|
5
5
|
"main": "dist/app.js",
|
|
6
6
|
"module": "dist/app.js",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"tailwind-merge": "^3.3.1",
|
|
121
121
|
"tailwindcss": "^4.1.17",
|
|
122
122
|
"tw-animate-css": "^1.4.0",
|
|
123
|
-
"@ydesign/core": "^0.0
|
|
123
|
+
"@ydesign/core": "^0.1.0"
|
|
124
124
|
},
|
|
125
125
|
"browserslist": [
|
|
126
126
|
"> 0.5%",
|
package/dist/chunk-2AZQIJ4K.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as g}from"./chunk-KERQXVBL.js";import{b as m}from"./chunk-YBC2DYJX.js";import{c as l,d as p}from"./chunk-EUTDQZKU.js";import{a as s}from"./chunk-O2XFH626.js";import*as d from"mobx";import{createContext as f,useContext as y}from"react";import h from"axios";var i=h.create({timeout:6e4});i.interceptors.request.use(t=>{let e=g();return e.token&&(t.headers.Authorization=`Bearer ${e.token}`,t.headers["yitu-workspace-id"]=e.workspaceId),t},t=>Promise.reject(t));i.interceptors.response.use(t=>{let{data:e}=t,r=e?.statusCode??e?.status;if(r!=null){if(r>=200&&r<=201)return e;let n=e?.result?.message||e?.message||"An error occurred";return Promise.reject(new Error(n))}if(t.status>=200&&t.status<300&&e)return e;let o=new Error(e?.message||"An error occurred");return Promise.reject(o)},t=>{let e=t?.response?.data,r=e?.result?.message||e?.message||t.message||"An error occurred";return Promise.reject(new Error(r))});var c=i;var w=t=>{try{return localStorage.getItem(t)}catch{return null}},P=(t,e)=>{try{localStorage.setItem(t,e)}catch{}},u=class{constructor({store:e}){s(this,"saveTimeout",null);s(this,"isOne",!1);s(this,"store");s(this,"id","");s(this,"name","");s(this,"user",{});s(this,"skipSaving",!1);s(this,"cloudEnabled",!1);s(this,"status","loading");s(this,"language",w("ydesign-language")||navigator.language||"en");s(this,"designsLength",0);s(this,"urls",{editorUrl:"/design"});d.makeAutoObservable(this),this.store=e,e.on("change",()=>{if(!this.isOne){this.isOne=!0;return}this.requestSave()})}setLanguage(e){this.language=e,P("ydesign-language",e)}requestSave(){this.status="has-changes",!this.saveTimeout&&(this.saveTimeout=setTimeout(()=>{this.saveTimeout=null,this.save()},5e3))}async firstLoad(e){if(e)this.store.loadJSON(e);else{let r=new URL(window.location.href),o=new URLSearchParams(r.search),n=o.get("type")||"",a=o.get("id")||"";console.log("\u6765\u6E90 ---> ",n,a),this.loadById(a,n)}}async loadById(e,r){if(e){if(console.log("\u53BB\u8FDC\u7A0B\u83B7\u53D6\u6570\u636E"),r==="me"){let o=l(e),n=await c.post(o.url,o.data),{content:a}=n.result;console.log("\u4E2A\u4EBA\u8D44\u4EA7 ---> ",a),this.store.loadJSON(a);return}if(r==="record"){let o=p(e),n=await c.get(o.url),{content:a}=n.result;console.log("\u4F5C\u56FE\u8BB0\u5F55 ---> ",a),this.store.loadJSON(a);return}console.log("\u6CA1\u6709\u5339\u914D\u5230\u7684\u6765\u6E90")}else console.log("\u6CA1\u6709id\u65E0\u6CD5\u83B7\u53D6\u8FDC\u7A0B\u6570\u636E")}updateUrlWithProjectId(){if(!this.id||this.id==="local"){window.history.replaceState({},"","/");return}let e=new URL(window.location.href);new URLSearchParams(e.search).set("id",this.id),window.history.replaceState({},"",`/design/${this.id}`)}async save(){this.status="saving";let e=this.store.toJSON();console.log("storeJSON",e);try{await new Promise(r=>setTimeout(r,2e3))}catch(r){console.error("save error",r)}this.status="saved"}async getGlobalFont(e){return e?.length?(m(e),e):[]}},S=f(null),R=()=>{let t=y(S);if(!t)throw new Error("useProject must be used within a ProjectProvider");return t},T=t=>new u(t),N=T;export{c as a,S as b,R as c,T as d,N as e};
|
package/dist/chunk-6XGFXDKJ.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import{a as I,c as ne}from"./chunk-2AZQIJ4K.js";import{a as L}from"./chunk-EWOU5F3O.js";import{b as G,c as B}from"./chunk-5C2MNUBC.js";import{a as te,b as ie,e as oe}from"./chunk-EUTDQZKU.js";import{Modal as Be,Button as Ue,ColorPicker as Te,InputNumber as re,Select as Me,Tooltip as le,App as Re,theme as De}from"antd";import{Grid2X2 as Le,Star as We,ShoppingBag as $e,FileText as Ae,Presentation as Ee,Share2 as _e,Printer as Fe,ImagePlus as He,FolderPlus as i,LockKeyholeOpen as Ve,LockKeyhole as je}from"lucide-react";import{useRef as Oe,useState as u,useMemo as ce,useCallback as T}from"react";import A from"styled-components";import{App as ke,Modal as Se,Upload as se}from"antd";import{Inbox as Ce}from"lucide-react";import{useRef as Pe,useState as Ne}from"react";import{jsx as a,jsxs as U}from"react/jsx-runtime";var{Dragger:Ie}=se,ae=({visible:S,onClose:E})=>{let{message:b,modal:_}=ke.useApp(),[h,C]=Ne(!1),x=Pe(null),F=ne();return a(Se,{width:750,title:"\u4E0A\u4F20 PSD \u6587\u4EF6",open:S,onCancel:()=>{if(h){b.warning("\u6587\u4EF6\u6B63\u5728\u89E3\u6790\u4E2D\uFF0C\u8BF7\u7A0D\u5019...");return}E()},footer:null,mask:{closable:!h},styles:{body:{height:"calc(100% - 40px)",padding:"10px 0 0 0"},container:{height:500}},centered:!0,children:a("div",{style:{height:"100%"},children:U(Ie,{...{name:"file-psd",multiple:!1,accept:".psd",showUploadList:!1,beforeUpload(r){return r.name.toLowerCase().endsWith(".psd")?!0:(b.error("\u4EC5\u652F\u6301 .psd \u683C\u5F0F\u6587\u4EF6"),se.LIST_IGNORE)},customRequest(r){let{file:n,onSuccess:p,onError:s,onProgress:f}=r;C(!0),x.current=b.loading("PSD \u6587\u4EF6\u89E3\u6790\u4E2D\uFF0C\u8BF7\u7A0D\u5019...",0);let c=new FormData;c.append("file",n),I.post(ie().url,c,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress(d){d.total&&f&&f({percent:Math.round(d.loaded/d.total*100)})}}).then(d=>{p?.(d)}).catch(d=>{s?.(d)})},async onChange(r){let{status:n}=r.file;if(console.log("info",r),n==="done"){x.current?.(),x.current=null,C(!1),b.success(`${r.file.name} \u89E3\u6790\u6210\u529F`);let p=r.file.response;console.log("PSD \u89E3\u6790\u7ED3\u679C:",p.result);let{thumbnailUrl:s,content:f,name:c,width:d,height:m,filename:V,parseUrl:v}=p.result,M={sourceResourcesId:crypto.randomUUID(),content:f,width:d,height:m,parseUrl:v,thumbnailUrl:s,filename:V,name:c};console.log("postRecord ---> ",M);let y=oe(M);console.log("postData",y);try{let w=await I.post(y.url,y.data);console.log("res ---> ",w.result);let j=w.result,P=`${F.urls.editorUrl}?id=${j.id}&type=record`;console.log("editUrl",P);let z=window.open(P,"_blank");(!z||z.closed)&&_.info({title:"\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u7A97\u53E3",width:480,content:U("div",{style:{padding:"16px 0"},children:[a("p",{style:{marginBottom:8,color:"#666"},children:"\u4F60\u9700\u8981\u6388\u6743\u672C\u7AD9\u5728\u6D4F\u89C8\u5668\u6253\u5F00\u591A\u4E2A\u7A97\u53E3\u3002"}),U("div",{style:{marginBottom:12},children:[a("p",{children:a("b",{children:"\u7B2C1\u6B65"})}),a("p",{children:"\u70B9\u51FB\u6D4F\u89C8\u5668\u53F3\u4FA7\u9876\u90E8\u5F39\u51FA\u7684\u963B\u6B62\u7A0B\u5E8F\u56FE\u6807\u3002"})]}),U("div",{style:{marginBottom:12},children:[a("p",{children:a("b",{children:"\u7B2C2\u6B65"})}),a("p",{children:"\u70B9\u51FB\u59CB\u7EC8\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u5F0F\u7A97\u53E3\u548C\u8FDB\u884C\u91CD\u5B9A\u5411\u3002"})]}),U("div",{style:{marginBottom:12},children:[a("p",{children:a("b",{children:"\u7B2C3\u6B65"})}),a("p",{children:"\u70B9\u51FB\u5B8C\u6210\u6309\u94AE\uFF0C\u5373\u53EF\u6B63\u5E38\u4F7F\u7528\u529F\u80FD\u5566~"})]})]}),okText:"\u6211\u77E5\u9053\u5566"})}catch(w){console.error(w)}}else if(n==="error"){x.current?.(),x.current=null,C(!1);let p=r.file.error?.message||"\u89E3\u6790\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";b.error(p)}}},disabled:h,children:[a("p",{className:"flex items-center justify-center",children:a(Ce,{size:60})}),a("p",{className:"ant-upload-text",children:h?"\u89E3\u6790\u4E2D...":"\u62D6\u62FD\u6587\u4EF6\u5230\u6B64\u5904\u4E0A\u4F20\u6216\u70B9\u51FB\u4E0A\u4F20"}),a("p",{className:"ant-upload-hint",children:a("a",{href:"https://www.yuque.com/meitumcp/vvtts5/gfv8e5",target:"_blank",onClick:r=>{r.stopPropagation()},children:"PSD\u6587\u4EF6\u5BFC\u5165\u89C4\u8303"})})]})})})};import{Fragment as Ze,jsx as e,jsxs as l}from"react/jsx-runtime";var Xe=[{key:"all",label:"\u5168\u90E8",icon:Le},{key:"common",label:"\u5E38\u7528\u5C3A\u5BF8",icon:We},{key:"ecommerce",label:"\u7535\u5546\u7269\u6599",icon:$e},{key:"office",label:"\u884C\u653F\u529E\u516C",icon:Ae},{key:"presentation",label:"\u6F14\u793A\u6587\u7A3F",icon:Ee},{key:"social",label:"\u793E\u4EA4\u5A92\u4F53",icon:_e},{key:"print",label:"\u5370\u5237\u7269\u6599",icon:Fe}],de=[{key:"common",label:"\u5E38\u7528\u5C3A\u5BF8",sizes:[{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"1440x1440px",width:1440,height:1440,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"800x800px",width:800,height:800,unit:"px"},{icon:e(i,{size:24}),name:"\u624B\u673A\u6D77\u62A5",desc:"1242x2208px",width:1242,height:2208,unit:"px"},{icon:e(i,{size:24}),name:"\u5C0F\u7EA2\u4E66\u5C01\u9762",desc:"1242x1656px",width:1242,height:1656,unit:"px"},{icon:e(i,{size:24}),name:"\u7AD6\u7248\u89C6\u9891\u5C01\u9762",desc:"1080x1920px",width:1080,height:1920,unit:"px"},{icon:e(i,{size:24}),name:"PPT\uFF0816:9\uFF09",desc:"1920x1080px",width:1920,height:1080,unit:"px"}]},{key:"ecommerce",label:"\u7535\u5546\u7269\u6599",sizes:[{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"1440x1440px",width:1440,height:1440,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"800x800px",width:800,height:800,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF083:4\uFF09",desc:"1440x1920px",width:1440,height:1920,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF083:4\uFF09",desc:"750x1000px",width:750,height:1e3,unit:"px"},{icon:e(i,{size:24}),name:"\u76F4\u64AD\u95F4\u80CC\u666F",desc:"1242x2690px",width:1242,height:2690,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u8BE6\u60C5\u9875",desc:"750x1000px",width:750,height:1e3,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u7AD6\u7248\u6D77\u62A5",desc:"1200x1920px",width:1200,height:1920,unit:"px"}]},{key:"office",label:"\u884C\u653F\u529E\u516C",sizes:[{icon:e(i,{size:24}),name:"\u7B80\u5386",desc:"2480x3507px",width:2480,height:3507,unit:"px"},{icon:e(i,{size:24}),name:"\u5DE5\u724C\u5DE5\u4F5C\u8BC1",desc:"709x1087px",width:709,height:1087,unit:"px"},{icon:e(i,{size:24}),name:"\u5956\u72B6\u8BC1\u4E66",desc:"3437x2550px",width:3437,height:2550,unit:"px"}]},{key:"presentation",label:"\u6F14\u793A\u6587\u7A3F",sizes:[{icon:e(i,{size:24}),name:"PPT\uFF0816:9\uFF09",desc:"1920x1080px",width:1920,height:1080,unit:"px"},{icon:e(i,{size:24}),name:"PPT\uFF084:3\uFF09",desc:"1024x768px",width:1024,height:768,unit:"px"}]},{key:"social",label:"\u793E\u4EA4\u5A92\u4F53",sizes:[{icon:e(i,{size:24}),name:"\u624B\u673A\u6D77\u62A5",desc:"1242x2208px",width:1242,height:2208,unit:"px"},{icon:e(i,{size:24}),name:"\u624B\u673A\u5168\u5C4F\u6D77\u62A5",desc:"1242x2688px",width:1242,height:2688,unit:"px"},{icon:e(i,{size:24}),name:"\u7AD6\u7248\u89C6\u9891\u5C01\u9762",desc:"1080x1920px",width:1080,height:1920,unit:"px"},{icon:e(i,{size:24}),name:"\u6A2A\u7248\u89C6\u9891\u5C01\u9762",desc:"1920x1080px",width:1920,height:1080,unit:"px"},{icon:e(i,{size:24}),name:"\u5C0F\u7EA2\u4E66\u5C01\u9762",desc:"1242x1656px",width:1242,height:1656,unit:"px"},{icon:e(i,{size:24}),name:"\u6296\u97F3\u56FE\u6587\u5E26\u8D27",desc:"1242x1656px",width:1242,height:1656,unit:"px"},{icon:e(i,{size:24}),name:"\u516C\u4F17\u53F7\u9996\u56FE",desc:"900x383px",width:900,height:383,unit:"px"},{icon:e(i,{size:24}),name:"\u516C\u4F17\u53F7\u6B21\u56FE",desc:"900x800px",width:900,height:800,unit:"px"},{icon:e(i,{size:24}),name:"\u957F\u56FE\u6D77\u62A5",desc:"800x2000px",width:800,height:2e3,unit:"px"}]},{key:"print",label:"\u5370\u5237\u7269\u6599",sizes:[{icon:e(i,{size:24}),name:"\u4E00\u5BF8\u8BC1\u4EF6\u7167",desc:"23x35mm",width:25,height:35,unit:"mm"},{icon:e(i,{size:24}),name:"\u4E8C\u5BF8\u8BC1\u4EF6\u7167",desc:"35x53mm",width:35,height:53,unit:"mm"},{icon:e(i,{size:24}),name:"1.8\u7C73\u5C55\u67B6",desc:"80x180cm",width:80,height:180,unit:"cm"},{icon:e(i,{size:24}),name:"2m\u6613\u62C9\u5B9D",desc:"80x200cm",width:80,height:200,unit:"cm"},{icon:e(i,{size:24}),name:"\u540D\u7247",desc:"96x60mm",width:96,height:60,unit:"mm"},{icon:e(i,{size:24}),name:"\u4F18\u60E0\u5238",desc:"186x66mm",width:186,height:66,unit:"mm"},{icon:e(i,{size:24}),name:"\u4F20\u5355",desc:"216x291cm",width:216,height:291,unit:"cm"}]}],pe=A.div`
|
|
2
|
-
padding: 16px 24px;
|
|
3
|
-
height: 60px;
|
|
4
|
-
flex: 1;
|
|
5
|
-
display: flex;
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
align-items: center;
|
|
8
|
-
border-radius: 8px;
|
|
9
|
-
border: 1px dashed #d0d2d6;
|
|
10
|
-
&:hover {
|
|
11
|
-
background-color: rgba(0, 31, 92, 0.06);
|
|
12
|
-
}
|
|
13
|
-
span {
|
|
14
|
-
margin-left: 8px;
|
|
15
|
-
}
|
|
16
|
-
`,qe=A.div`
|
|
17
|
-
flex: 1;
|
|
18
|
-
margin-left: 14px;
|
|
19
|
-
height: 100%;
|
|
20
|
-
|
|
21
|
-
.createrContentInner {
|
|
22
|
-
margin-bottom: 16px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.scrollbars div:first-child {
|
|
26
|
-
scroll-behavior: smooth;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.Widget.categorySection[data-is-folded='false'] .categoryFoldBtn,
|
|
30
|
-
.Widget.categorySection[data-is-multi-row='false'] .categoryFoldBtn {
|
|
31
|
-
display: none;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.Widget.categorySection[data-is-folded='true'] ul {
|
|
35
|
-
height: 97px;
|
|
36
|
-
overflow: hidden;
|
|
37
|
-
}
|
|
38
|
-
`,Ge=A.div`
|
|
39
|
-
width: 100%;
|
|
40
|
-
height: 100%;
|
|
41
|
-
position: relative;
|
|
42
|
-
padding-top: 16px;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
align-items: center;
|
|
48
|
-
|
|
49
|
-
border-radius: 8px;
|
|
50
|
-
background-color: rgba(0, 0, 0, 0.05);
|
|
51
|
-
|
|
52
|
-
.canvasSizeName {
|
|
53
|
-
color: #616366;
|
|
54
|
-
font-size: 12px;
|
|
55
|
-
font-weight: 600;
|
|
56
|
-
line-height: 16px;
|
|
57
|
-
margin-top: 8px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.canvasSizeSize {
|
|
61
|
-
height: 14px;
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
width: 100%;
|
|
64
|
-
margin-top: 4px;
|
|
65
|
-
|
|
66
|
-
span {
|
|
67
|
-
color: #abadb2;
|
|
68
|
-
display: block;
|
|
69
|
-
font-size: 20px;
|
|
70
|
-
font-weight: 400;
|
|
71
|
-
height: 200%;
|
|
72
|
-
line-height: 26px;
|
|
73
|
-
text-align: center;
|
|
74
|
-
-webkit-transform: scale(0.5);
|
|
75
|
-
transform: scale(0.5);
|
|
76
|
-
-webkit-transform-origin: top left;
|
|
77
|
-
transform-origin: top left;
|
|
78
|
-
width: 200%;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.canvasSizeMask {
|
|
83
|
-
background: rgba(0, 0, 0, 0.25);
|
|
84
|
-
display: none;
|
|
85
|
-
height: 100%;
|
|
86
|
-
left: 0;
|
|
87
|
-
position: absolute;
|
|
88
|
-
top: 0;
|
|
89
|
-
width: 100%;
|
|
90
|
-
}
|
|
91
|
-
.canvasSizeMask,
|
|
92
|
-
.canvasSizeMask button {
|
|
93
|
-
justify-content: center;
|
|
94
|
-
align-items: center;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.canvasSizeMask button {
|
|
98
|
-
background-color: #fff;
|
|
99
|
-
width: 66px;
|
|
100
|
-
height: 26px;
|
|
101
|
-
display: flex;
|
|
102
|
-
padding: 0 8px;
|
|
103
|
-
outline: none;
|
|
104
|
-
line-height: 16px;
|
|
105
|
-
font-size: 12px;
|
|
106
|
-
cursor: pointer;
|
|
107
|
-
color: #1c1d1f;
|
|
108
|
-
border-radius: 6px;
|
|
109
|
-
}
|
|
110
|
-
.canvasSizeMask button:active {
|
|
111
|
-
background-color: #f2f2f2;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&:hover .canvasSizeMask {
|
|
115
|
-
display: flex;
|
|
116
|
-
}
|
|
117
|
-
`,Ke=A.div`
|
|
118
|
-
display: flex;
|
|
119
|
-
margin-top: 20px;
|
|
120
|
-
flex-wrap: wrap;
|
|
121
|
-
align-items: center;
|
|
122
|
-
position: relative;
|
|
123
|
-
|
|
124
|
-
.sizeWarning {
|
|
125
|
-
width: 100%;
|
|
126
|
-
margin-bottom: 8px;
|
|
127
|
-
padding: 4px 8px;
|
|
128
|
-
font-size: 12px;
|
|
129
|
-
color: #ff4d4f;
|
|
130
|
-
background-color: #fff2f0;
|
|
131
|
-
border: 1px solid #ffccc7;
|
|
132
|
-
border-radius: 4px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.Widget.sizeInpueBox {
|
|
136
|
-
display: flex;
|
|
137
|
-
align-items: center;
|
|
138
|
-
|
|
139
|
-
flex: 1;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.Widget.sizeInpueBox .sizeInput {
|
|
143
|
-
flex: 1;
|
|
144
|
-
}
|
|
145
|
-
.Widget.sizeInpueBox .linkIcon {
|
|
146
|
-
padding: 8px;
|
|
147
|
-
background-color: #001f5c0f;
|
|
148
|
-
border-radius: 8px;
|
|
149
|
-
margin: 0 4px;
|
|
150
|
-
}
|
|
151
|
-
`,k=72,W=130,$=8e3,gt=({project:S,visible:E,onClose:b,onConfirm:_})=>{let{message:h,modal:C}=Re.useApp(),[x,F]=u("all"),H=Oe(null),{token:r}=De.useToken(),[n,p]=u(null),[s,f]=u(null),[c,d]=u("px"),[m,V]=u(!1),[v,M]=u(1),[y,w]=u("#ffffff"),[j,P]=u(!1),z=ce(()=>n?B({unitVal:n,dpi:k,unit:c}):0,[n,c]),O=ce(()=>s?B({unitVal:s,dpi:k,unit:c}):0,[s,c]),X=n!=null&&s!=null&&n>0&&s>0,R=X&&(z>$||O>$),D=X&&(z<W||O<W),q=!X||R||D,K=R?`\u8D85\u51FA\u753B\u5E03\u5C3A\u5BF8\u9650\u5236\uFF1A${$} * ${$} px`:D?`\u4F4E\u4E8E\u753B\u5E03\u5C3A\u5BF8\u9650\u5236\uFF1A${W} * ${W} px`:"",me=T(t=>{p(t),m&&t&&t>0&&f(Math.round(t/v))},[m,v]),he=T(t=>{f(t),m&&t&&t>0&&p(Math.round(t*v))},[m,v]),ge=T(()=>{!m&&n&&s&&n>0&&s>0&&M(n/s),V(t=>!t)},[m,n,s]),ue=T(t=>{if(n){let o=B({unitVal:n,dpi:k,unit:c});p(Math.round(G({px:o,dpi:k,unit:t,precious:0})))}if(s){let o=B({unitVal:s,dpi:k,unit:c});f(Math.round(G({px:o,dpi:k,unit:t,precious:0})))}d(t)},[n,s,c]),xe=T(()=>{if(q)return;let t=JSON.stringify({bg:{backgroundColor:y}}),o=new URLSearchParams({create:"",createEmptyPoster:"true",createInfo:t,height:String(s),unit:c,width:String(n)});console.log("params \u7684\u53C2\u6570 ---> ",o.toString()),console.log("project ",S.urls.editorUrl),window.open(`${S.urls.editorUrl}?${o.toString()}`,"_blank")},[q,y,O,z,c]),fe=t=>{F(t);let o=H.current;if(!o)return;let g=o.querySelector(`[data-category-id="${t}"]`);g&&o.scrollTo({top:g.offsetTop,behavior:"smooth"})},[ye,be]=u(()=>{let t={};return de.forEach(o=>{t[o.key]=o.sizes.length>6}),t});return l(Ze,{children:[l(Be,{title:"\u521B\u5EFA\u8BBE\u8BA1",open:E,onCancel:b,footer:null,width:880,mask:{closable:!1},styles:{body:{display:"flex",flex:1,padding:"20px 0",height:"100%"},container:{height:550}},children:[e("div",{className:"createrSideBar",style:{width:140,"--sidebar-active-bg":r.colorPrimaryBg,"--sidebar-hover-bg":r.colorPrimaryBgHover},children:Xe.map(t=>l("div",{"data-active":t.key===x,className:L("createrSideBarItem","flex h-[40px] px-2 mb-2 cursor-pointer rounded-md items-center hover:bg-[var(--sidebar-hover-bg)]",{"bg-[var(--sidebar-active-bg)] hover:bg-[var(--sidebar-active-bg)]":t.key===x}),onClick:()=>fe(t.key),children:[e(t.icon,{size:16,className:"ml-2"}),e("span",{className:"ml-2",children:t.label})]},t.key))}),e(qe,{children:e("div",{className:"scrollbars",style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e("div",{ref:H,style:{position:"absolute",inset:0,overflow:"scroll"},children:l("div",{className:"createrContentInner",children:[e("div",{"data-category-id":"all"}),l("div",{className:"openBtns flex",children:[l(pe,{onClick:()=>{let t=document.createElement("input");t.type="file",t.accept="image/*",t.onchange=async()=>{let o=t.files?.[0];if(o)try{h.loading("\u6B63\u5728\u4E0A\u4F20...",0);let g=te(),N=new FormData;N.append("file",o);let Z=await I.post(g.url,N,{headers:{"Content-Type":"multipart/form-data"}});console.log("res",Z);let{url:J,width:Q,height:Y}=Z.result;console.log("url",J,Q,Y);let ve=encodeURIComponent(encodeURIComponent(J)),we=new URLSearchParams({createEmptyPoster:"true",width:String(Q),height:String(Y),unit:"px"});h.destroy();let ze=`${S.urls.editorUrl}/?${we.toString()}&open=${ve}`,ee=window.open(ze,"_blank");(!ee||ee.closed)&&C.info({title:"\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u7A97\u53E3",width:480,content:l("div",{style:{padding:"16px 0"},children:[e("p",{style:{marginBottom:8,color:"#666"},children:"\u4F60\u9700\u8981\u6388\u6743\u672C\u7AD9\u5728\u6D4F\u89C8\u5668\u6253\u5F00\u591A\u4E2A\u7A97\u53E3\u3002"}),l("div",{style:{marginBottom:12},children:[e("p",{children:e("b",{children:"\u7B2C1\u6B65"})}),e("p",{children:"\u70B9\u51FB\u6D4F\u89C8\u5668\u53F3\u4FA7\u9876\u90E8\u5F39\u51FA\u7684\u963B\u6B62\u7A0B\u5E8F\u56FE\u6807\u3002"})]}),l("div",{style:{marginBottom:12},children:[e("p",{children:e("b",{children:"\u7B2C2\u6B65"})}),e("p",{children:"\u70B9\u51FB\u59CB\u7EC8\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u5F0F\u7A97\u53E3\u548C\u8FDB\u884C\u91CD\u5B9A\u5411\u3002"})]}),l("div",{style:{marginBottom:12},children:[e("p",{children:e("b",{children:"\u7B2C3\u6B65"})}),e("p",{children:"\u70B9\u51FB\u5B8C\u6210\u6309\u94AE\uFF0C\u5373\u53EF\u6B63\u5E38\u4F7F\u7528\u529F\u80FD\u5566~"})]})]}),okText:"\u6211\u77E5\u9053\u5566"})}catch(g){h.destroy();let N=g?.message||"\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";h.error(N),console.error("\u4E0A\u4F20\u5931\u8D25:",N,g)}},t.click()},children:[e(He,{style:{color:r.colorPrimary}}),e("span",{children:"\u6253\u5F00\u56FE\u7247"})]}),e(le,{title:"\u4EC5\u652F\u6301psd\u683C\u5F0F\u6587\u4EF6",children:l(pe,{style:{marginLeft:12},onClick:()=>{P(!0),console.log("\u70B9\u51FB")},children:[e(i,{style:{color:r.colorPrimary}}),e("span",{children:"\u6253\u5F00PSD"})]})})]}),de.map(t=>l("div",{className:L("Widget categorySection","mt-6"),"data-category-id":t.key,"data-is-folded":ye[t.key]??!1,"data-is-multi-row":t.sizes.length>6,children:[l("div",{className:L("categoryHeader","flex items-center justify-between"),children:[e("div",{className:"categoryTitle text-sm font-semibold",children:t.label}),e("div",{className:"categoryFoldBtn flex items-center cursor-pointer",onClick:()=>be(o=>({...o,[t.key]:!1})),children:e("span",{className:"text-[#616366]",children:"\u67E5\u770B\u66F4\u591A"})})]}),t.key==="common"&&l(Ke,{children:[K&&e("div",{className:"sizeWarning",children:K}),l("div",{className:"Widget sizeInpueBox",children:[e("div",{className:"sizeInput",children:e(re,{prefix:"\u5BBD",value:n,min:0,precision:0,status:R||D?"error":void 0,onChange:me,styles:{actions:{opacity:1,width:24}},style:{width:"100%"}})}),e(le,{title:m?"\u89E3\u9501\u6BD4\u4F8B":"\u9501\u5B9A\u6BD4\u4F8B",children:e("div",{className:"linkIcon",style:{cursor:"pointer"},onClick:ge,children:m?e(je,{size:16}):e(Ve,{size:16})})}),e("div",{className:"sizeInput",children:e(re,{prefix:"\u9AD8",value:s,min:0,precision:0,status:R||D?"error":void 0,onChange:he,styles:{actions:{opacity:1,width:24}},style:{width:"100%"}})}),e("div",{className:"sizeUnitSelect",style:{width:98,marginLeft:12},children:e(Me,{value:c,style:{width:98},onChange:ue,options:[{label:"px \u50CF\u7D20",value:"px"},{label:"cm \u5398\u7C73",value:"cm"},{label:"mm \u6BEB\u7C73",value:"mm"}]})})]}),e("div",{className:"widgets-color-picker",style:{width:98,marginLeft:12},children:e(Te,{mode:"single",format:"hex",value:y,onChange:o=>w(o.toHexString()),styles:{root:{width:98},body:{width:92}}})}),e(Ue,{type:"primary",disabled:q,style:{width:98,marginLeft:12},onClick:xe,children:"\u521B\u5EFA"})]}),e("ul",{className:"flex mt-4 flex-wrap gap-3",children:t.sizes.map((o,g)=>e("li",{style:{width:"calc((100% - 60px) / 6)",height:97},children:l(Ge,{children:[o.icon,e("div",{className:"canvasSizeName",children:o.name}),e("div",{className:"canvasSizeSize",children:e("span",{children:o.desc})}),e("div",{className:"canvasSizeMask",onClick:()=>{_({...o,bgColor:y})},children:e("button",{type:"button",children:"\u521B\u5EFA"})})]})},g))})]},t.key))]})})})})]}),e(ae,{visible:j,onClose:()=>P(!1)})]})};export{gt as a};
|
package/dist/chunk-EUTDQZKU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s="http://219.151.185.37:9003",a=`${s}/api`,e=()=>s+"/api",r={fontList:()=>({url:`${e()}/fonts`}),templateList:()=>({url:`${e()}/templates/list`}),templateDetail:t=>({url:`${e()}/templates/detail/${t}`}),uploadImage:()=>({url:`${e()}/images/upload`}),psdParse:()=>({url:`${e()}/psd/parser`}),createRecord:t=>({method:"POST",url:`${e()}/record`,data:t}),recordDetail:t=>({url:`${e()}/record/${t}`}),resourcesDetail:t=>({method:"POST",url:`${e()}/resources/detail`,data:{type:"template",id:t}})};var n=()=>r.uploadImage(),l=()=>r.psdParse(),p=t=>r.resourcesDetail(t),i=t=>r.recordDetail(t),c=t=>r.createRecord(t),u=(t,o)=>{r[t]=o};export{n as a,l as b,p as c,i as d,c as e,u as f};
|
package/dist/chunk-KERQXVBL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as l,c as g,d as m,e as p}from"./chunk-YBC2DYJX.js";import{types as a,cast as b,flow as f,destroy as h,getSnapshot as E,onSnapshot as x}from"mobx-state-tree";async function u(e,t){let o=document.createElement("a"),i=URL.createObjectURL(e);o.href=i,o.download=t,document.body.appendChild(o),o.click(),setTimeout(function(){document.body.removeChild(o),window.URL.revokeObjectURL(i)},0)}import{observable as j,toJS as S}from"mobx";import{isEqual as F}from"es-toolkit/compat";var s=(e,t)=>{if(e?.objects)for(let o of e.objects){if(t(o)===!0)break;s(o,t)}},k=a.model("Font",{fontFamily:a.string,name:a.optional(a.string,""),url:a.optional(a.string,""),img:a.optional(a.string,""),styles:a.frozen()}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{fontFamily:e.fontFamily||e.name})),O=a.model("Store",{name:"yitu-design",token:"",workspaceId:"",width:1080,height:1080,scale:1,scaleToFit:1,unit:"px",dpi:72,bleed:0,bleedVisible:!1,rulesVisible:!1,openedSidePanel:"",selectedElementsIds:a.array(a.string),backgroundColor:a.optional(a.union(a.string,a.frozen()),"#fff"),fonts:a.array(k),editor:a.frozen(null),custom:a.frozen(),objects:a.array(a.frozen()),_key:"",_updateTrigger:0,_updateFontSize:0}).views(e=>({get selectedElements(){let t=e._updateTrigger;return console.log("_trigger\u90FD\u53D8\u5316\u662F\u89E6\u53D1\u805A\u7126\u5143\u7D20\u7684\u5237\u65B0 ---> ",t),e.selectedElementsIds.map(o=>e.editor?.objectsHandler.findOneById(o))}})).views(e=>({get selectedShapes(){let t=[];return s({objects:e.selectedElements},o=>{o?.type!=="group"&&t.push(o)}),t},find(t){let o,i=e.editor?.customCanvas.canvas.getObjects();if(i)return s({objects:i},r=>{if(!o&&t(r))return o=r,!0}),o},getElementById(t){return e.editor?.objectsHandler.findOneById(t)}})).actions(e=>({_setEditor(t){e.editor=t},_triggerUpdate(){e._updateTrigger=e._updateTrigger+1},_fontSizeUpdate(){e._updateFontSize=e._updateFontSize+1},_syncBackgroundColor(t){e.backgroundColor=t}})).actions(e=>({setBackgroundColor(t,o){e.backgroundColor=t,e.editor?.workareaHandler.setWorkareaBgColor(t,o)},set(t,o){e.editor?.objectsHandler.update(t,o?.id)},setUnit({unit:t,dpi:o}){e.unit=t||e.unit,e.dpi=o||e.dpi},setObjects(t){e.objects=t},selectElements(t){e.selectedElementsIds=b(t)},openSidePanel(t){e.openedSidePanel!==t&&(e.openedSidePanel=t)},deleteElements(t){t.forEach(o=>{e.editor?.objectsHandler.remove(o)})},setScale(t){e.scale=t},clone(){e.editor?.objectsHandler.clone()},addElement(t,o){return console.log("\u6DFB\u52A0json\u6570\u636E",t),e.editor?.objectsHandler.addJson(t,o)},setSize({width:t,height:o}){e.width=t,e.height=o,e.editor?.workareaHandler.setSize({width:t,height:o})},setupEditorListeners(){e.editor&&(e.editor.on("object:modified",()=>{e._triggerUpdate()}),e.editor.on("textbox:modified",()=>{e._fontSizeUpdate()}),e.editor.on("history:changed",t=>{t?.backgroundColor!==void 0&&e._syncBackgroundColor(t.backgroundColor)}))}})).actions(e=>({_forEachElementUp(t,o){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),r=t.map(n=>({id:n,index:i.findIndex(d=>d.id===n)}));r.sort((n,d)=>d.index-n.index);for(let{index:n}of r){if(n==-1)continue;let d=n<i.length-1&&i[n+1],c=t.indexOf(d?.id)>=0;n===i.length-1||c||o(n)}},_forEachElementDown(t,o){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),r=t.map(n=>({id:n,index:i.findIndex(d=>d.id===n)}));r.sort((n,d)=>d.index-n.index);for(let{index:n}of r){if(n==-1)continue;let d=n>0&&i[n-1],c=t.indexOf(d?.id)>=0;n===0||c||o(n)}return!1}})).actions(e=>({canMoveElementsUp(t){let o=!1;return e._forEachElementUp(t,()=>{o=!0}),o},moveElementsUp(t){if(!e.editor)return;let o=e.editor.layerHandler.getEffectiveLayers();[...t].map(r=>({id:r,index:o.findIndex(n=>n.id===r)})).filter(r=>r.index!==-1).sort((r,n)=>n.index-r.index).map(r=>r.id).forEach(r=>{e.editor?.layerHandler.bringForward(r)}),e._triggerUpdate()},canMoveElementsTop(t){return this.canMoveElementsUp(t)},moveElementsTop(t){e.editor&&(t.forEach(o=>{e.editor?.layerHandler.bringToFront(o)}),e._triggerUpdate())},canMoveElementsDown(t){let o=!1;return e._forEachElementDown(t,()=>{o=!0}),o},moveElementsDown(t){if(!e.editor)return;let o=e.editor.layerHandler.getEffectiveLayers();[...t].map(r=>({id:r,index:o.findIndex(n=>n.id===r)})).filter(r=>r.index!==-1).sort((r,n)=>r.index-n.index).map(r=>r.id).forEach(r=>{e.editor?.layerHandler.sendBackwards(r)}),e._triggerUpdate()},canMoveElementsBottom(t){return this.canMoveElementsDown(t)},moveElementsBottom(t){e.editor&&(t.forEach(o=>{e.editor?.layerHandler.sendToBack(o)}),e._triggerUpdate())},setElementZIndex(){}})).actions(e=>({async toDataURL(t){return e.editor?.rendererHandler.toDataURL(t)},async toBlob(t){return e.editor?.rendererHandler.toBlob(t)},async saveAsImage(t){if(!e.editor)return;let{fileName:o,...i}=t||{multiplier:1},r=await e.editor.rendererHandler.toBlob(i);r&&u(r,o||"yitu."+i.format)},toJSON(){return e.editor?.rendererHandler.toJSON()},toObject(){return e.editor?.rendererHandler.toObject()},loadJSON:f(function*(t){if(!e.editor)return;let o=yield e.editor.sceneHandler.importFromJSON(t);o&&(e.width=o.width,e.height=o.height,e.backgroundColor=o.fill)}),clear(){}})).actions(e=>({removeFont(t){e.fonts.filter(o=>o.fontFamily===t).forEach(o=>{h(o)})},addFont(t){this.removeFont(t.fontFamily),e.fonts.push(t),this.loadFont(t.fontFamily)},async loadFont(t){let o=e.fonts.find(n=>n.fontFamily===t)||l.find(n=>n.fontFamily===t),r=[{fontStyle:"normal",fontWeight:"normal"},{fontStyle:"normal",fontWeight:"bold"}];return o?(o.styles&&(r=o.styles.map(n=>({fontStyle:n.fontStyle||"normal",fontWeight:n.fontWeight||"normal"}))),m(o)):p(t),Promise.all(r.map(n=>g(t,n.fontStyle,n.fontWeight)))}})).actions(e=>({on(t,o){if(t==="change"){let i=E(e.objects);return x(e.objects,r=>{let n=r;F(i,n)||(i=n,o(n))})}}})),y=j({token:"",workspaceId:""}),T=()=>S(y);function w({key:e,token:t,workspaceId:o}){return y={token:t??"",workspaceId:o??""},O.create({_key:e,token:t??"",workspaceId:o??""})}var z=w;export{s as a,k as b,O as c,T as d,w as e,z as f};
|