From 466ca11cbb6ed16d6796c55716163c7705745702 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 2 Oct 2021 16:42:41 +0800 Subject: [PATCH] it work! --- public/index.html | 16 ++-- rollup.config.js | 5 +- src/App.svelte | 185 ++++++++++++++++++++++++++++++++++++++++----- src/Message.svelte | 93 +++++++++++++++++++++++ src/main.js | 7 +- 5 files changed, 270 insertions(+), 36 deletions(-) create mode 100644 src/Message.svelte diff --git a/public/index.html b/public/index.html index 5da7ed3..bb1bd72 100644 --- a/public/index.html +++ b/public/index.html @@ -1,16 +1,16 @@ - + - - + + - Svelte app + 落絮 - - - + + + - + diff --git a/rollup.config.js b/rollup.config.js index e8965ec..21cf736 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -18,8 +18,8 @@ function serve() { writeBundle() { if (server) return; server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { - stdio: ['ignore', 'inherit', 'inherit'], - shell: true + // stdio: ['ignore', 'inherit', 'inherit'], + // shell: true }); process.on('SIGTERM', toExit); @@ -71,6 +71,7 @@ export default { production && terser() ], watch: { + buildDelay: 500, clearScreen: false } }; diff --git a/src/App.svelte b/src/App.svelte index 10faec7..27950c1 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,30 +1,173 @@ + +
-

Hello {name}!

-

Visit the Svelte tutorial to learn how to build Svelte apps.

+ + + {#if error} +
{error}
+ {/if} + + {#if result} + {#each result.messages as message} + + {/each} + {/if} + {#if loading} +

正在加载...

+ {:else if result && result.has_more} +
+ {/if}
\ No newline at end of file + .error { + color: red; + text-align: center; + } + + #loading, #more { + display: flex; + justify-content: center; + } + #loading > * { + border: 1px #bfbfbf solid; + border-radius: 2em; + padding: 0.5em 1em; + } + diff --git a/src/Message.svelte b/src/Message.svelte new file mode 100644 index 0000000..b1d2342 --- /dev/null +++ b/src/Message.svelte @@ -0,0 +1,93 @@ + + +
+
+ {msg.from_name} 的头像 +
+
{msg.from_name}
+
{msg.text}
+ +
+
+
+ + diff --git a/src/main.js b/src/main.js index d6cacbb..2dce74c 100644 --- a/src/main.js +++ b/src/main.js @@ -1,10 +1,7 @@ import App from './App.svelte'; const app = new App({ - target: document.body, - props: { - name: 'world' - } + target: document.body }); -export default app; \ No newline at end of file +export default app;