You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+59-50Lines changed: 59 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,8 @@
1
1
2
+
2
3
# ReactronBase
3
4
4
-
ReactronBase is a boilerplate for building desktop applications using Electron and Vite. This template sets up a development environment with TypeScript, Tailwind CSS, and Electron, providing essential configurations for building and packaging your application.
5
+
ReactronBase is a boilerplate for building desktop applications using Electron and Vite. This template sets up a development environment with TypeScript, Tailwind CSS, and Electron, providing essential configurations for building and packaging your application. It is designed to accelerate development by offering a streamlined setup, rapid build processes, and powerful tooling for both the main and renderer processes.
5
6
6
7
## 📁 Project Structure
7
8
@@ -111,10 +112,10 @@ npm run rebuild-sql
111
112
112
113
## 🛠️ Development Tools
113
114
114
-
-**Vite**: Fast build tool and development server for the renderer process.
115
-
-**Electron**: Framework for building cross-platform desktop applications with web technologies.
116
-
-**TypeScript**: Adds static types to JavaScript for improved developer experience.
117
-
-**Tailwind CSS**: Utility-first CSS framework for building modern UIs.
115
+
-**Vite**: Fast build tool and development server for the renderer process, providing a modern and efficient development experience.
116
+
-**Electron**: Framework for building cross-platform desktop applications with web technologies, enabling seamless integration between web and native functionalities.
117
+
-**TypeScript**: Adds static types to JavaScript for improved developer experience and robust code quality.
118
+
-**Tailwind CSS**: Utility-first CSS framework for building modern UIs, allowing rapid design and customization.
118
119
119
120
## 💡 Tips and Tricks
120
121
@@ -141,9 +142,36 @@ npm run rebuild-sql
141
142
142
143
## 🎨 Customizing the Application
143
144
144
-
-**Styles**: Modify `src/renderer/styles.css` to adjust the appearance of your application.
145
+
-**Styles**: Modify `src/renderer/styles.css` to adjust the appearance of your application. Utilize Tailwind CSS for utility-first styling.
145
146
-**Configuration**: Update `electron-windows-store-config.json` for custom Windows Store packaging settings.
146
147
148
+
## 📦 Creating Components and Pages
149
+
150
+
### Creating Components
151
+
152
+
To create a new component, run:
153
+
154
+
```bash
155
+
npm run create:component <component-name>
156
+
```
157
+
158
+
Replace `<component-name>` with the desired name for your component. This command will:
159
+
- Generate a new component file in `src/renderer/components/`.
160
+
- Create a corresponding SCSS file for styling.
161
+
162
+
### Creating Pages
163
+
164
+
To create a new page, run:
165
+
166
+
```bash
167
+
npm run create:page <page-name>
168
+
```
169
+
170
+
Replace `<page-name>` with the desired name for your page. This command will:
171
+
- Create a new folder in `src/renderer/pages/` with the page name.
172
+
- Generate a TypeScript file and SCSS file for the page.
173
+
- Automatically update your routing configuration to include the new page.
174
+
147
175
## ❓ FAQ
148
176
149
177
**Q: What is ReactronBase?**
@@ -175,62 +203,43 @@ To seed your database with initial data, create a seeding script. You can add th
db.run('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
189
212
190
-
console.log('Database seeded successfully.');
191
-
awaitdb.close();
192
-
}
213
+
const stmt =db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
214
+
stmt.run('John Doe', 'john@example.com');
215
+
stmt.finalize();
216
+
});
193
217
194
-
seedDatabase().catch((error) =>console.error('Failed to seed database:', error));
218
+
db.close();
195
219
```
196
220
197
-
Run the seeding script as part of your application setup or manually execute it.
221
+
Run the seeding script:
198
222
199
-
### Resetting the Database
223
+
```bash
224
+
npx ts-node src/main/seed.ts
225
+
```
200
226
201
-
To reset your database, you can delete the existing `db/dev.db` file and let your application recreate it. This can be done manually or through a script.
227
+
### Resetting the Database
202
228
203
-
Example reset script (`reset-db.ts`):
229
+
To reset your database, you can drop existing tables and re-run the seeding script. Modify your seeding script to include table dropping commands:
204
230
205
231
```typescript
206
-
import { unlink } from'fs';
207
-
import { open } from'sqlite';
208
-
importsqlite3from'sqlite3';
209
-
210
-
asyncfunction resetDatabase() {
211
-
try {
212
-
// Delete the existing database file
213
-
unlink('db/dev.db', async (err) => {
214
-
if (err) throwerr;
215
-
216
-
// Recreate the database and initialize schema
217
-
const db =awaitopen({
218
-
filename: 'db/dev.db',
219
-
driver: sqlite3.Database,
220
-
});
221
-
222
-
// Initialize schema
223
-
awaitdb.run('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
224
-
225
-
console.log('Database reset and schema initialized.');
226
-
awaitdb.close();
227
-
});
228
-
} catch (error) {
229
-
console.error('Failed to reset database:', error);
230
-
}
231
-
}
232
+
db.serialize(() => {
233
+
db.run('DROP TABLE IF EXISTS users');
234
+
db.run('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
0 commit comments