Skip to content

Commit 95e2e9d

Browse files
author
ci-bot
committed
gen website AI
1 parent 72c84cf commit 95e2e9d

File tree

19 files changed

+964
-100
lines changed

19 files changed

+964
-100
lines changed

apps/quick-dapp/src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useReducer, useState } from 'react';
22
import { IntlProvider } from 'react-intl'
33
import CreateInstance from './components/CreateInstance';
44
import EditInstance from './components/EditInstance';
5+
import EditHtmlTemplate from './components/EditHtmlTemplate';
56
import DeployPanel from './components/DeployPanel';
67
import LoadingScreen from './components/LoadingScreen';
78
import { appInitialState, appReducer } from './reducers/state';
@@ -52,7 +53,11 @@ function App(): JSX.Element {
5253
}}
5354
>
5455
<IntlProvider locale={locale.code} messages={locale.messages}>
55-
{Object.keys(appState.instance.abi).length > 0 ? (
56+
{appState.instance.htmlTemplate ? (
57+
<div className="container-fluid pt-3">
58+
<EditHtmlTemplate />
59+
</div>
60+
) : Object.keys(appState.instance.abi).length > 0 ? (
5661
<div className="row m-0 pt-3">
5762
<EditInstance />
5863
<DeployPanel />

apps/quick-dapp/src/actions/index.ts

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,7 @@ export const deploy = async (payload: any, callback: any) => {
158158
}
159159
}
160160

161-
const { data } = await axios.get(
162-
// It's the json file contains all the static files paths of dapp-template.
163-
// It's generated through the build process automatically.
164-
`${window.origin}/plugins/remix-dapp/manifest.json`
165-
);
166-
167-
const paths = Object.keys(data);
168-
169-
const { logo, ...instance } = state.instance;
161+
const { logo, htmlTemplate, ...instance } = state.instance;
170162

171163
const instanceJson = JSON.stringify({
172164
...instance,
@@ -179,29 +171,35 @@ export const deploy = async (payload: any, callback: any) => {
179171
'dir/assets/instance.json': instanceJson,
180172
};
181173

182-
// console.log(
183-
// JSON.stringify({
184-
// ...instance,
185-
// shareTo: payload.shareTo,
186-
// })
187-
// );
188-
189-
for (let index = 0; index < paths.length; index++) {
190-
const path = paths[index];
191-
// download all the static files from the dapp-template domain.
192-
// here is the codebase of dapp-template: https://github.com/drafish/remix-dapp
193-
const resp = await axios.get(`${window.origin}/plugins/remix-dapp/${path}`);
194-
files[`dir/${path}`] = resp.data;
174+
// Use the HTML template provided by the user instead of downloading dapp-template
175+
if (htmlTemplate) {
176+
files['dir/index.html'] = htmlTemplate;
177+
} else {
178+
// Fallback to the old method if no HTML template is provided
179+
const { data } = await axios.get(
180+
`${window.origin}/plugins/remix-dapp/manifest.json`
181+
);
182+
183+
const paths = Object.keys(data);
184+
185+
for (let index = 0; index < paths.length; index++) {
186+
const path = paths[index];
187+
const resp = await axios.get(`${window.origin}/plugins/remix-dapp/${path}`);
188+
files[`dir/${path}`] = resp.data;
189+
}
190+
191+
if (files['dir/index.html']) {
192+
files['dir/index.html'] = files['dir/index.html'].replace(
193+
'assets/css/themes/remix-dark_tvx1s2.css',
194+
themeMap[instance.theme].url
195+
);
196+
}
195197
}
196198

197199
if (logo) {
198200
files['dir/assets/logo.png'] = logo
199201
}
200202
files['dir/CORS'] = '*'
201-
files['dir/index.html'] = files['dir/index.html'].replace(
202-
'assets/css/themes/remix-dark_tvx1s2.css',
203-
themeMap[instance.theme].url
204-
);
205203

206204
try {
207205
await surgeClient.publish({
@@ -287,8 +285,27 @@ export const initInstance = async ({
287285
methodIdentifiers,
288286
devdoc,
289287
solcVersion,
288+
htmlTemplate,
290289
...payload
291290
}: any) => {
291+
// If HTML template is provided, use simplified initialization
292+
if (htmlTemplate) {
293+
await dispatch({
294+
type: 'SET_INSTANCE',
295+
payload: {
296+
...payload,
297+
htmlTemplate,
298+
abi: {},
299+
items: {},
300+
containers: [],
301+
natSpec: { checked: false, methods: {} },
302+
solcVersion: solcVersion ? getVersion(solcVersion) : { version: '0.8.25', canReceive: true },
303+
},
304+
});
305+
return;
306+
}
307+
308+
// Original ABI-based initialization (kept for backward compatibility)
292309
const functionHashes: any = {};
293310
const natSpec: any = { checked: false, methods: {} };
294311
if (methodIdentifiers && devdoc) {
@@ -324,18 +341,20 @@ export const initInstance = async ({
324341

325342
const abi: any = {};
326343
const lowLevel: any = {}
327-
payload.abi.forEach((item: any) => {
328-
if (item.type === 'function') {
329-
item.id = encodeFunctionId(item);
330-
abi[item.id] = item;
331-
}
332-
if (item.type === 'fallback') {
333-
lowLevel.fallback = item;
334-
}
335-
if (item.type === 'receive') {
336-
lowLevel.receive = item;
337-
}
338-
});
344+
if (payload.abi) {
345+
payload.abi.forEach((item: any) => {
346+
if (item.type === 'function') {
347+
item.id = encodeFunctionId(item);
348+
abi[item.id] = item;
349+
}
350+
if (item.type === 'fallback') {
351+
lowLevel.fallback = item;
352+
}
353+
if (item.type === 'receive') {
354+
lowLevel.receive = item;
355+
}
356+
});
357+
}
339358
const ids = Object.keys(abi);
340359
const items =
341360
ids.length > 2
@@ -345,8 +364,6 @@ export const initInstance = async ({
345364
}
346365
: { A: ids };
347366

348-
// const logo = await axios.get('https://dev.remix-dapp.pages.dev/logo.png', { responseType: 'arraybuffer' })
349-
350367
await dispatch({
351368
type: 'SET_INSTANCE',
352369
payload: {
@@ -355,9 +372,8 @@ export const initInstance = async ({
355372
items,
356373
containers: Object.keys(items),
357374
natSpec,
358-
solcVersion: getVersion(solcVersion),
375+
solcVersion: solcVersion ? getVersion(solcVersion) : { version: '0.8.25', canReceive: true },
359376
...lowLevel,
360-
// logo: logo.data,
361377
},
362378
});
363379
};
@@ -394,6 +410,7 @@ export const emptyInstance = async () => {
394410
name: '',
395411
address: '',
396412
network: '',
413+
htmlTemplate: '',
397414
abi: {},
398415
items: {},
399416
containers: [],
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
.chat-box-container {
2+
display: flex;
3+
flex-direction: column;
4+
border: 1px solid var(--border);
5+
background: var(--body-bg);
6+
}
7+
8+
.chat-box-header {
9+
background: var(--secondary);
10+
color: var(--text);
11+
padding: 12px 16px;
12+
border-bottom: 1px solid var(--border);
13+
}
14+
15+
.chat-box-body {
16+
flex: 1;
17+
overflow-y: auto;
18+
padding: 16px;
19+
background: var(--body-bg);
20+
}
21+
22+
.messages-container {
23+
display: flex;
24+
flex-direction: column;
25+
gap: 12px;
26+
}
27+
28+
.message {
29+
display: flex;
30+
flex-direction: column;
31+
gap: 4px;
32+
animation: fadeIn 0.3s ease-in;
33+
}
34+
35+
@keyframes fadeIn {
36+
from {
37+
opacity: 0;
38+
transform: translateY(10px);
39+
}
40+
to {
41+
opacity: 1;
42+
transform: translateY(0);
43+
}
44+
}
45+
46+
.user-message {
47+
align-items: flex-end;
48+
}
49+
50+
.assistant-message {
51+
align-items: flex-start;
52+
}
53+
54+
.message-role {
55+
font-size: 12px;
56+
color: var(--text-muted);
57+
font-weight: 500;
58+
text-transform: uppercase;
59+
}
60+
61+
.message-content {
62+
max-width: 70%;
63+
padding: 10px 14px;
64+
border-radius: 8px;
65+
word-wrap: break-word;
66+
}
67+
68+
.user-message .message-content {
69+
background: var(--primary);
70+
color: white;
71+
border-bottom-right-radius: 4px;
72+
}
73+
74+
.assistant-message .message-content {
75+
background: var(--light);
76+
color: var(--text);
77+
border-bottom-left-radius: 4px;
78+
}
79+
80+
.typing-indicator {
81+
display: inline-block;
82+
animation: typing 1.4s infinite;
83+
}
84+
85+
@keyframes typing {
86+
0%, 60%, 100% {
87+
opacity: 0.3;
88+
}
89+
30% {
90+
opacity: 1;
91+
}
92+
}
93+
94+
.chat-box-footer {
95+
padding: 12px;
96+
border-top: 1px solid var(--border);
97+
background: var(--body-bg);
98+
}
99+
100+
.chat-input-group {
101+
display: flex;
102+
gap: 8px;
103+
}
104+
105+
.chat-input {
106+
flex: 1;
107+
resize: none;
108+
border: 1px solid var(--border);
109+
background: var(--body-bg);
110+
color: var(--text);
111+
}
112+
113+
.chat-input:focus {
114+
border-color: var(--primary);
115+
background: var(--body-bg);
116+
color: var(--text);
117+
}
118+
119+
.send-button {
120+
align-self: flex-end;
121+
min-width: 80px;
122+
}

0 commit comments

Comments
 (0)