Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f09b8b

Browse files
integrate iconscout with jsonLottie comp
1 parent5e249b2 commit7f09b8b

File tree

5 files changed

+85
-251
lines changed

5 files changed

+85
-251
lines changed

‎client/packages/lowcoder/src/api/iconscoutApi.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export type ResponseType = {
1717
};
1818

1919
constapiUrl="https://api.iconscout.com";
20-
constclientID="";//"91870410585071";
21-
constclientSecret="";// "GV5aCWpwdLWTxVXFBjMKSoyDPUyjzXLR";
20+
constclientID="";
21+
constclientSecret="";
2222
constcurrentPage=1;
2323
constcurrentQuery='';
2424
constcurrentData=[];
@@ -75,6 +75,11 @@ class IconscoutApi extends Api {
7575
});
7676
returnresponse?.data.response.download;
7777
}
78+
79+
staticasyncdownloadJSON(url:string):Promise<any>{
80+
constresponse=awaitaxios.get(url)
81+
returnresponse?.data;
82+
}
7883
}
7984

8085
exportdefaultIconscoutApi;

‎client/packages/lowcoder/src/comps/comps/imageComp.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const ContainerImg = (props: RecordConstructorToView<typeof childrenMap>) => {
157157
<AntImage
158158
src={
159159
props.sourceMode==='advanced'
160-
?(props.srcIconScoutasReactElement)?.props.value
160+
?props.srcIconScout?.value
161161
:props.src.value
162162
}
163163
referrerPolicy="same-origin"
@@ -200,7 +200,7 @@ let ImageBasicComp = new UICompBuilder(childrenMap, (props) => {
200200
{children.sourceMode.getView()==='standard'&&children.src.propertyView({
201201
label:trans("image.src"),
202202
})}
203-
{children.sourceMode.getView()==='advanced'&&children.srcIconScout.propertyView({
203+
{children.sourceMode.getView()==='advanced'&&children.srcIconScout.propertyView({
204204
label:trans("image.src"),
205205
})}
206206
</Section>

‎client/packages/lowcoder/src/comps/comps/jsonComp/jsonLottieComp.tsx‎

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
22
import{
33
ArrayOrJSONObjectControl,
44
NumberControl,
5+
StringControl,
56
}from"comps/controls/codeControl";
67
import{dropdownControl}from"comps/controls/dropdownControl";
78
import{BoolControl}from"comps/controls/boolControl";
89
import{styleControl}from"comps/controls/styleControl";
910
import{AnimationStyle,LottieStyle}from"comps/controls/styleControlConstants";
1011
import{trans}from"i18n";
1112
import{Section,sectionNames}from"lowcoder-design";
12-
import{useContext,lazy}from"react";
13+
import{useContext,lazy,useEffect}from"react";
1314
import{UICompBuilder,withDefault}from"../../generators";
1415
import{
1516
NameConfig,
@@ -19,6 +20,9 @@ import {
1920
import{defaultLottie}from"./jsonConstants";
2021
import{EditorContext}from"comps/editorState";
2122
import{IconScoutAssetType,IconscoutControl}from"@lowcoder-ee/comps/controls/iconscoutControl";
23+
import{isEmpty}from"lodash";
24+
importIconscoutApifrom"@lowcoder-ee/api/iconscoutApi";
25+
import{changeValueAction,multiChangeAction}from"lowcoder-core";
2226

2327
constPlayer=lazy(
2428
()=>import('@lottiefiles/react-lottie-player')
@@ -98,7 +102,8 @@ let JsonLottieTmpComp = (function () {
98102
JSON.stringify(defaultLottie,null,2)
99103
),
100104
srcIconScout:IconscoutControl(IconScoutAssetType.LOTTIE),
101-
valueIconScout:ArrayOrJSONObjectControl,
105+
uuidIconScout:StringControl,
106+
valueIconScout:withDefault(ArrayOrJSONObjectControl,JSON.stringify({})),
102107
speed:dropdownControl(speedOptions,"1"),
103108
width:withDefault(NumberControl,100),
104109
height:withDefault(NumberControl,100),
@@ -108,11 +113,38 @@ let JsonLottieTmpComp = (function () {
108113
loop:dropdownControl(loopOptions,"single"),
109114
keepLastFrame:BoolControl.DEFAULT_TRUE,
110115
};
111-
returnnewUICompBuilder(childrenMap,(props)=>{
112-
console.log(props.srcIconScout);
116+
returnnewUICompBuilder(childrenMap,(props,dispatch)=>{
117+
118+
constdownloadAsset=async(uuid:string)=>{
119+
try{
120+
constresult=awaitIconscoutApi.download(uuid,{
121+
format:'ai',
122+
});
123+
if(result&&result.download_url){
124+
constjson=awaitIconscoutApi.downloadJSON(result.download_url);
125+
dispatch(
126+
multiChangeAction({
127+
uuidIconScout:changeValueAction(uuid,true),
128+
valueIconScout:changeValueAction(JSON.stringify(json,null,2),true)
129+
})
130+
)
131+
}
132+
}catch(error){
133+
console.error(error);
134+
}
135+
136+
}
137+
useEffect(()=>{
138+
if(props.srcIconScout?.uuid&&props.srcIconScout?.uuid!==props.uuidIconScout){
139+
// get asset download link
140+
downloadAsset(props.srcIconScout?.uuid);
141+
}
142+
},[props.srcIconScout]);
143+
113144
return(
114145
<div
115146
style={{
147+
height:'100%',
116148
padding:`${props.container.margin}`,
117149
animation:props.animationStyle.animation,
118150
animationDelay:props.animationStyle.animationDelay,
@@ -139,7 +171,11 @@ let JsonLottieTmpComp = (function () {
139171
hover={props.animationStart==="on hover"&&true}
140172
loop={props.loop==="single" ?false :true}
141173
speed={Number(props.speed)}
142-
src={props.value}
174+
src={
175+
props.sourceMode==='advanced'
176+
?(isEmpty(props.valueIconScout) ?'' :props.valueIconScout)
177+
:props.value
178+
}
143179
style={{
144180
height:"100%",
145181
width:"100%",

‎client/packages/lowcoder/src/comps/comps/meetingComp/controlButton.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ let ButtonTmpComp = (function () {
296296
<IconScoutWrapper
297297
$style={{ ...props.style,size:props.iconSize}}
298298
>
299-
{props.prefixIconScout}
299+
<imgsrc={props.prefixIconScout.value}/>
300300
</IconScoutWrapper>
301301
)}
302302
</Button100>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp