Skip to content

Commit

Permalink
eliminate warings (#49)
Browse files Browse the repository at this point in the history
* feat: add notices to a new collection

the new collection named todolist, and there are small changes about
how the pages look like.

* feat: add notices to a new collection

* style: update npm and run format

* style: run npm format again

* feat: link notices, todolists and channels

* feat: update todolist-link

* feat: update

* style: change a little style

* feat: eliminate warnings

---------

Co-authored-by: sheeplin <[email protected]>
Co-authored-by: My Go! <[email protected]>
  • Loading branch information
3 people authored Mar 9, 2024
1 parent 7d59c71 commit b65e397
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 198 deletions.
9 changes: 9 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import SearchChannel from "./routes/searchChannel.svelte";
import SendNotification from "./routes/sendNotification.svelte";
import Participants from "./routes/participants.svelte";
import SelectTags from "./routes/selectTags.svelte";
import Mychannel from "./routes/mychannel.svelte";
import Mynotice from "./routes/mynotice.svelte";
import Chantemplate from "./routes/chantemplate.svelte";
import Checknotice from "./routes/checknotice.svelte";

export default {
"/": DoorPage,
"/login": Login,
Expand All @@ -19,4 +24,8 @@ export default {
"/postnotice": SendNotification,
"/participants": Participants,
"/selectTags": SelectTags,
"/mychannel": Mychannel,
"/mynotice": Mynotice,
"/chantemplate": Chantemplate,
"/checknotice": Checknotice,
};
77 changes: 77 additions & 0 deletions src/routes/chantemplate.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!-- 频道模板 可发送通知 显示频道已有的通知-->
<script>
import PocketBase from "pocketbase";
import { PocketBase_URL } from "../utils/api/index";
import { currentchannelid, currentnoticeid } from "../store.js";
import { push } from "svelte-spa-router";
import { onMount } from "svelte";
const pb = new PocketBase(PocketBase_URL);
let records = [];
async function noticedisplay() {
try {
const channel = $currentchannelid;
const response = await pb.collection("notices").getFullList({
sort: "-created",
filter: `channelid="${channel}"`,
});
records = response;
} catch (error) {
alert("fail to find");
}
}
onMount(() => {
noticedisplay();
});
function send() {
push("/postnotice");
}
function check(id) {
currentnoticeid.set(id);
push("/checknotice");
}
</script>

<button on:click={send}>发送通知</button>

{#each records as record}
<div
class="record"
role="button"
tabindex="0"
on:click={() => check(record.id)}
on:keypress
>
<div class="title">{record.tittle}</div>
<div class="content">#{record.tag}</div>
<div class="author">from:{record.useremail}</div>
</div>
{/each}

<style>
.record {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #ffffff;
}
.title {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.content {
font-size: 16px;
}
.author {
font-size: 14px;
color: #666;
}
</style>
71 changes: 71 additions & 0 deletions src/routes/checkInformation.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!-- 查看当前用户创建的todolist 点击查看对应通知-->
<script>
import PocketBase from "pocketbase";
import { PocketBase_URL } from "../utils/api/index";
import { push } from "svelte-spa-router";
import Modal from "./Modal.svelte";
import { onMount } from "svelte";
import { currentUserEmail, currentnoticeid } from "../store.js";
const pb = new PocketBase(PocketBase_URL);
let records = [];
let showModal = false;
async function checkchan() {
try {
const userEmail = $currentUserEmail;
const response = await pb.collection("todolist").getFullList({
sort: "-created",
filter: `useremail="${userEmail}"`,
});
records = response;
} catch (error) {
alert("fail to find");
}
}
function jumpnew(id) {
currentnoticeid.set(id);
push("/checknotice");
}
function toggleModal() {
showModal = !showModal;
}
onMount(() => {
checkchan();
});
</script>

<button on:click={toggleModal}>查看todolist</button>

<Modal isOpen={showModal} close={toggleModal}>
<h2 style="color: black;">todolist</h2>
<div class="container">
{#each records as record}
<button class="button" on:click={() => jumpnew(record.noticeid)}
>#{record.tittle}</button
>
{/each}
</div>
</Modal>

<style>
.container {
max-width: 300px;
max-height: 200px; /* 设置列表的最大高度 */
overflow-y: auto; /* 超出部分显示滚动条 */
background: #f9f9f9; /* 背景色,可根据需要调整 */
border-radius: 5px; /* 边框圆角 */
padding: 10px; /* 内边距 */
}
.button {
width: 60%;
margin-top: 10px;
padding: 10px;
background-color: black;
border-radius: 4px;
}
.button:hover {
color: #ffffff;
opacity: 1;
background-color: #6a6d6e;
}
</style>
58 changes: 58 additions & 0 deletions src/routes/checknotice.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!-- 显示通知具体内容 -->
<script>
import { currentnoticeid } from "../store.js";
import PocketBase from "pocketbase";
import { PocketBase_URL } from "../utils/api/index";
import { onMount } from "svelte";
const pb = new PocketBase(PocketBase_URL);
let records = [];
async function noticedisplay() {
try {
const createid = $currentnoticeid;
const response = await pb.collection("notices").getFullList({
sort: "-created",
filter: `id="${createid}"`,
});
records = response;
} catch (error) {
alert("fail to find");
}
}
onMount(() => {
noticedisplay();
});
</script>

{#each records as record}
<div class="record">
<div class="tittle">{record.tittle}</div>
<div class="meta">
{record.year}.{record.month}.{record.day}/#{record.tag}/from:{record.useremail}
</div>
<div>{record.body}</div>
</div>
{/each}

<style>
.record {
border: 1px solid #ccc;
padding: 15px;
margin: 10px 0;
background-color: #f9f9f9;
}
.tittle {
font-size: 24px;
font-weight: bold;
margin-bottom: 8px;
color: #333;
}
.meta {
font-size: 12px;
color: #666;
margin-bottom: 12px;
}
</style>
1 change: 0 additions & 1 deletion src/routes/login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const pb = new PocketBase(PocketBase_URL);
let usereamil = "";
let password = "";
let username = "";
async function handleLogin() {
try {
Expand Down
Loading

0 comments on commit b65e397

Please sign in to comment.