Skip to content

Commit c34c509

Browse files
committed
bugifx
1 parent f210de0 commit c34c509

File tree

10 files changed

+26
-111
lines changed

10 files changed

+26
-111
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# MEMENTO SvelteKit Electron TypeScript
22
Template to create a desktop app with SvelteKit, Electron and TypeScript (with electron-updater, electron-reload and electron-builder)
33

4-
**This project is still under development: the `todos` section doesn't work!**
5-
64
## Get Started
75

86
This is a project template for [Svelte](https://svelte.dev) and [Electron](https://www.electronjs.org/) apps. It lives at https://github.com/el3um4s/memento-sveltekit-electron-typescript.

electron/configureDev.ts

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class ConfigureDev {
4343
_build_Dist() { exec("npm run svelte:build"); }
4444
_watch_Dist() { require("electron-reload")(path.join(__dirname, "www")); }
4545
_serve_Dist() {
46-
// this.loadURL = serve({ directory: pathOnDisk, scheme: "html" });
4746
this.loadURL = serve({ directory: "dist/www" });
4847
}
4948

electron/mainWindow.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Main {
3434

3535
app.on('ready', () => {
3636

37-
let loading = new BrowserWindow({show: false, frame: false})
37+
let loading = new BrowserWindow({show: false, frame: false, width: 300, height:300, transparent:true})
3838

3939
loading.once('show', async () => {
4040
this.window = await this.createWindow();

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Memento: how to use Svelte with Electron and TypeScript",
55
"author": "Samuele de Tomasi <[email protected]>",
66
"license": "MIT",
7-
"version": "0.0.3",
7+
"version": "0.0.4",
88
"main": "dist/index.js",
99
"scripts": {
1010
"nodemon": "nodemon",

svelte/src/lib/form.ts

-69
This file was deleted.

svelte/src/routes/todos/index.svelte

+6-33
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
<!-- <script context="module" lang="ts">
2-
import { enhance } from '$lib/form';
3-
// import type { Load } from '@sveltejs/kit';
4-
5-
// see https://kit.svelte.dev/docs#loading
6-
// export const load: Load = async () => {
7-
// globalThis.api.fileSystem.send('readFile', 'todos.json');
8-
// let todos = [];
9-
// await globalThis.api.fileSystem.receive('getFile', (data) => {
10-
// console.log('globalThis.api.fileSystem.receive');
11-
// console.log(data);
12-
// todos = data;
13-
// });
14-
// console.log('TODO DATA LOAD');
15-
// console.log(todos);
16-
// return {
17-
// props: { todos }
18-
// };
19-
// };
20-
</script> -->
211
<script lang="ts">
22-
import { slide } from 'svelte/transition';
23-
import { scale } from 'svelte/transition';
2+
import { slide, fade } from 'svelte/transition';
243
import { flip } from 'svelte/animate';
254
265
type Todo = {
@@ -30,9 +9,9 @@
309
done: boolean;
3110
};
3211
12+
const fileName = 'todos.json';
3313
export let todos: Todo[] = [];
3414
let todo: string;
35-
const fileName = 'todos.json';
3615
3716
globalThis.api.fileSystem.send('readFile', fileName);
3817
globalThis.api.fileSystem.receive('getFile', (data) => {
@@ -53,7 +32,7 @@
5332
}
5433
}
5534
56-
function toggleDone(uid) {
35+
function toggleDone(uid: string) {
5736
todos = todos.map((t) => {
5837
if (t.uid === uid) {
5938
return { ...t, done: !t.done };
@@ -64,12 +43,12 @@
6443
saveTodos();
6544
}
6645
67-
function deleteTodo(uid) {
46+
function deleteTodo(uid: string) {
6847
todos = todos.filter((t) => t.uid !== uid);
6948
saveTodos();
7049
}
7150
72-
function updateTodo(uid, text) {
51+
function updateTodo(uid: string, text: string) {
7352
todos = todos.map((t) => {
7453
if (t.uid === uid) {
7554
return { ...t, text };
@@ -99,14 +78,8 @@
9978
<form class="new" on:submit|preventDefault={saveNewTodo}>
10079
<input name="text" aria-label="Add todo" placeholder="+ tap to add a todo" bind:value={todo} />
10180
</form>
102-
10381
{#each todos as todo (todo.uid)}
104-
<div
105-
class="todo"
106-
class:done={todo.done}
107-
transition:scale|local={{ start: 0.7 }}
108-
animate:flip={{ duration: 200 }}
109-
>
82+
<div class="todo" class:done={todo.done} transition:slide animate:flip={{ duration: 400 }}>
11083
<form on:submit|preventDefault on:click={() => toggleDone(todo.uid)}>
11184
<input type="hidden" name="done" value={todo.done ? '' : 'true'} />
11285
<button class="toggle" aria-label="Mark todo as {todo.done ? 'not done' : 'done'}" />

svelte/static/loading.html

+16-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
loading
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Loading</title>
8+
</head>
9+
<body>
10+
<div style="width:100%; text-align: center;">
11+
<div style="width: 256px; height: 256px; border-radius: 100%; background-color: rgb(240,240,240);">
12+
<img width="256px" src="loading.png"/>
13+
</div>
14+
</div>
15+
</body>
16+
</html>

svelte/static/loading.png

13.7 KB
Loading

svelte/static/todos.json

-1
This file was deleted.

0 commit comments

Comments
 (0)