-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
7d59c71
commit b65e397
Showing
11 changed files
with
440 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.