Skip to content

Commit

Permalink
add MyChannels (#76)
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

* style: channel and notice style

* feat: useremail is added automatically

* ci: format-check

* css: pass the lint

* style: recover the background color

* feat : update the saveChange

* feat: update the title of login and doorpage

* feat: update the format of saveChanges

* feat: update the checknotice

* feat: uodate checknotice format

* feat: fix notice

* feat: add myChannels

---------

Co-authored-by: 独 后藤 <[email protected]>
Co-authored-by: sheeplin <[email protected]>
Co-authored-by: 後藤ひとり <[email protected]>
  • Loading branch information
4 people authored Mar 17, 2024
1 parent f552963 commit 767cdd3
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 67 deletions.
147 changes: 81 additions & 66 deletions src/components/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,95 @@
}
</script>

<div class="navbar bg-base-100 rounded-3xl shadow-xl topnavbar">
<div class="flex-none">
<div class="drawer">
<input
id="my-drawer"
type="checkbox"
bind:checked={isOpen}
class="drawer-toggle"
/>
<div class="drawer-content">
<!-- Page content here -->
<button on:click={toggleDrawer} class="btn btn-square btn-ghost">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="inline-block w-5 h-5 stroke-current"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
></path></svg
>
</button>
</div>
<div class="drawer-side">
<label for="my-drawer" aria-label="close sidebar" class="drawer-overlay"
></label>
<ul class="menu p-4 w-80 min-h-full bg-base-200 text-base-content">
<!-- Sidebar content here -->
<li><a href="/#">Sidebar Item 1</a></li>
<li><a href="/#">Sidebar Item 2</a></li>
</ul>
<div class="navbar">
<div class="navbar bg-base-100 rounded-3xl shadow-xl topnavbar">
<div class="flex-none">
<div class="drawer">
<input
id="my-drawer"
type="checkbox"
bind:checked={isOpen}
class="drawer-toggle"
/>
<div class="drawer-content">
<!-- Page content here -->
<button on:click={toggleDrawer} class="btn btn-square btn-ghost">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="inline-block w-5 h-5 stroke-current"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
></path></svg
>
</button>
</div>
<div class="drawer-side">
<label
for="my-drawer"
aria-label="close sidebar"
class="drawer-overlay"
></label>
<ul class="menu p-4 w-80 min-h-full bg-base-200 text-base-content">
<!-- Sidebar content here -->
<li><a href="/#">Sidebar Item 1</a></li>
<li><a href="/#">Sidebar Item 2</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="flex-1">
<a href="/#/login" class="btn btn-ghost text-xl logo">lips</a>
</div>
<div class="flex-none">
<div class="dropdown dropdown-end">
<div
class="mt-3 z-[1] card card-compact dropdown-content w-52 bg-base-100 shadow"
>
<div class="card-body">
<span class="font-bold text-lg">8 Items</span>
<span class="text-info">Subtotal: $999</span>
<div class="card-actions">
<button class="btn btn-primary btn-block">View cart</button>
<div class="flex-1">
<a href="/#/infoPage" class="btn btn-ghost text-xl logo">lips</a>
</div>
<div class="flex-none">
<div class="dropdown dropdown-end">
<div
class="mt-3 z-[1] card card-compact dropdown-content w-52 bg-base-100 shadow"
>
<div class="card-body">
<span class="font-bold text-lg">8 Items</span>
<span class="text-info">Subtotal: $999</span>
<div class="card-actions">
<button class="btn btn-primary btn-block">View cart</button>
</div>
</div>
</div>
</div>
</div>
<div class="dropdown dropdown-end">
<div tabindex="0" role="button" class="btn btn-ghost btn-circle avatar">
<div class="w-10 rounded-full">
<img alt="Tailwind CSS Navbar component" src="userPicture.jpeg" />
<div class="dropdown dropdown-end">
<div tabindex="0" role="button" class="btn btn-ghost btn-circle avatar">
<div class="w-10 rounded-full">
<img alt="Tailwind CSS Navbar component" src="userPicture.jpeg" />
<!-- <img alt="Tailwind CSS Navbar component" src="selectTagsPicture.jpg" /> -->
</div>
</div>
<ul
class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"
>
<li>
<a class="justify-between btn-disabled text-black" href="/"
>{$username}</a
>
</li>
<li><a class="justify-between" href="/#/profile">Profile</a></li>
<li><a href="/#/myChannels">Mychannels</a></li>
<li><a href="/#/login">Logout</a></li>
</ul>
</div>
<ul
class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"
>
<li>
<a class="justify-between btn-disabled text-black" href="/"
>{$username}</a
>
</li>
<li><a class="justify-between" href="/#/profile">Profile</a></li>
<li><a href="/#/setting">Settings</a></li>
<li><a href="/#/login">Logout</a></li>
</ul>
</div>
</div>
</div>

<div class="navbar"></div>
<style>
.navbar {
position: fixed; /* 或 absolute,根据需要选择 */
top: 0;
left: 0;
width: 100%;
z-index: 1000; /* 确保这个值足够高,以覆盖其他元素 */
/* 其他样式,如背景色等 */
}
</style>
2 changes: 2 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import UpdateChannel from "./routes/updateChannel.svelte";
import Jumptag from "./routes/jumptag.svelte";
import InfoPage from "./routes/infoPage.svelte";
import Updatenotice from "./routes/updatenotice.svelte";
import Mychannels from "./routes/myChannels.svelte";
export default {
"/": DoorPage,
"/login": Login,
Expand All @@ -33,4 +34,5 @@ export default {
"/jumptag": Jumptag,
"/infoPage": InfoPage,
"/updatenotice": Updatenotice,
"/myChannels": Mychannels,
};
18 changes: 17 additions & 1 deletion src/routes/infoPage.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script>
import PocketBase from "pocketbase";
import { PocketBase_URL } from "../utils/api/index";
import { currentUserEmail, originChannelID } from "../store.js";
import { currentUserEmail, originChannelID, username } from "../store.js";
import { push } from "svelte-spa-router";
import { onMount } from "svelte";
import Navbar from "../components/Navbar.svelte";
const pb = new PocketBase(PocketBase_URL);
let isFind = false;
Expand All @@ -26,6 +27,18 @@
alert("fail to find");
}
}
async function checkUser() {
try {
const userEmail = $currentUserEmail;
const response_ = await pb.collection("users").getFullList({
sort: "-created",
filter: `email="${userEmail}"`,
});
username.set(response_[0].username);
} catch (error) {
alert("fail to find");
}
}
function jumpnew(origin) {
//currentchannelid.set(id);
originChannelID.set(origin);
Expand All @@ -34,9 +47,12 @@
onMount(() => {
checkIsJoined();
checkUser();
});
</script>

<Navbar />

<div class="container">
<div class="left">
<div class="top">
Expand Down
66 changes: 66 additions & 0 deletions src/routes/myChannels.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<script>
import PocketBase from "pocketbase";
import { PocketBase_URL } from "../utils/api/index";
import { onMount } from "svelte";
import Navbar from "../components/Navbar.svelte";
import { push } from "svelte-spa-router";
import { currentUserEmail, username, originChannelID } from "../store.js";
const pb = new PocketBase(PocketBase_URL);
let src = "userPicture.jpeg";
let channels = [];
async function getChannels() {
const useremail = $currentUserEmail;
const response_ = await pb.collection("users_channels").getFullList({
sort: "-created",
filter: `useremail="${useremail}"`,
});
channels = response_;
}
function jumpnew(origin) {
originChannelID.set(origin);
push("/chantemplate");
}
onMount(() => {
getChannels();
});
</script>

<Navbar />
<body>
<div class="flex flex-col w-2/5 items-center h-dvh space-y-10 py-10">
<img {src} alt="user" class="button-img" />
<p class="text-7xl text-black">{$username}</p>
</div>

<div class="channel-container fixed right-0 top-0 w-3/5">
{#each channels as channel}
<div class="channel bg-transparent border-b border-gray-400">
<button class="text-5xl" on:click={() => jumpnew(channel.originid)}
>{channel.channelname}</button
>
</div>
{/each}
</div>
</body>

<style>
.button-img {
width: 360px; /* 设置图像的宽度 */
height: 360px; /* 设置图像的高度为与宽度相同的值,以确保图像是正方形的 */
border-radius: 50%; /* 这将使图像的边角变圆,形成圆形 */
object-fit: cover; /* 确保图像在调整大小时保持其宽高比 */
}
.channel-container {
position: fixed; /* 或absolute,根据需求和上下文确定 */
top: 15vh; /* 从视口顶部向下20%的位置开始 */
right: 0;
width: 60%; /* 占据屏幕宽度的60% */
height: 80vh; /* 占视口高度的80% */
overflow-y: auto; /* 内容超出时显示滚动条 */
}
.channel {
height: 25%; /* 每个频道占容器高度的20% */
}
</style>

0 comments on commit 767cdd3

Please sign in to comment.