Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lead Profile to the mainpage #74

Merged
merged 22 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
51d8643
add a new page to search channels
Fantasy0214 Jan 24, 2024
6d10cb5
Merge branch 'frog-software:master' into master
Fantasy0214 Jan 25, 2024
85454de
Updated createchannel
Fantasy0214 Jan 27, 2024
db5584e
feat: refine createchannel
Fantasy0214 Jan 28, 2024
5a98c48
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Jan 28, 2024
0a855c0
feat: refine createchannel
Fantasy0214 Jan 28, 2024
01a00b2
feat: update searchChannel
Fantasy0214 Jan 29, 2024
2e39104
refactor: refactor createChannel
Fantasy0214 Jan 29, 2024
eae880d
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 7, 2024
d7d72ee
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 9, 2024
6357ab5
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 10, 2024
e2510d1
feat: add useremail for a channel
Fantasy0214 Mar 10, 2024
cfeacc2
feat: can choose the channels your created
Fantasy0214 Mar 10, 2024
802cc5a
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 10, 2024
a01263a
refactor: Refactor the code
Fantasy0214 Mar 10, 2024
e0b3893
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 11, 2024
8e36d92
feat: Added channel deletion and modification
Fantasy0214 Mar 11, 2024
e6cc6e7
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 14, 2024
97d74fe
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 16, 2024
ddb3a59
feat: lead Profile to the mainpage
Fantasy0214 Mar 16, 2024
7b838b7
feat: lead Profile to the mainpage
Fantasy0214 Mar 16, 2024
bbc8478
Merge branch 'master' into master
Clear1oveE Mar 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
>{$username}</a
>
</li>
<li><a class="justify-between" href="/#/profile">Profile</a></li>
<li><a href="/#/main1">Profile</a></li>
<li><a href="/#/myChannels">Mychannels</a></li>
<li><a href="/#/login">Logout</a></li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Login from "./routes/login.svelte";
import MainPage from "./routes/mainpage.svelte";
import MainPage1 from "./routes/mainpage1.svelte";
import DoorPage from "./routes/doorPage.svelte";
import Register from "./routes/register.svelte";
import CreateChannel from "./routes/createChannel.svelte";
Expand All @@ -20,6 +21,7 @@ export default {
"/": DoorPage,
"/login": Login,
"/main": MainPage,
"/main1": MainPage1,
"/register": Register,
"/createChannel": CreateChannel,
"/checkInformation": CheckInformation,
Expand Down
135 changes: 135 additions & 0 deletions src/routes/mainpage1.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<script>
import { push } from "svelte-spa-router";
import PocketBase from "pocketbase";
import { PocketBase_URL } from "../utils/api/index";
import { onMount } from "svelte";
import Navbar from "../components/Navbar.svelte";
import { currentUserEmail, username } from "../store.js";

const pb = new PocketBase(PocketBase_URL);
let channels = []; // 存储频道数据
let todos = []; // 存储待办事项数据

// 假设有异步函数来获取当前用户的频道和待办事项
async function fetchChannels() {
try {
const userEmail = $currentUserEmail;
const response = await pb.collection("users_channels").getFullList({
sort: "-created",
filter: `useremail="${userEmail}"`,
});
channels = response;
} catch (error) {
alert("fail to find");
}
}

async function fetchTodos() {
try {
const userEmail = $currentUserEmail;
const response = await pb.collection("todolist").getFullList({
sort: "-created",
filter: `useremail="${userEmail}"`,
});
todos = response;
} catch (error) {
alert("fail to find");
}
}

onMount(async () => {
await fetchChannels();
await fetchTodos();
});

function logout() {
// 登出逻辑,这里简单地跳转到登录页面
push("/login");
}

function navigateToChannelDetail(channelId) {
push(`/channel-detail/${channelId}`);
}

function navigateToTodoDetail(todoId) {
push(`/todo-detail/${todoId}`);
}
</script>

<Navbar />

<div class="flex h-screen">
<!-- 左侧用户信息 -->
<div
class="flex flex-col w-2/5 items-center space-y-10 py-10"
style="padding-top: 90px;"
>
<img
src="userPicture.jpeg"
alt="User Profile"
style="width: 300px; height: 300px; object-fit: cover;"
class="rounded-full"
/>
<p class="text-4xl text-black">{$username}</p>
<button class="btn" on:click={logout}>登出</button>
</div>

<!-- 右侧内容区 -->
<div class="w-3/5 p-4">
<!-- 频道列表 -->
<div class="channels h-3/5 overflow-y-auto p-2">
<h2 class="text-2xl font-semibold mb-4 text-black">Channels</h2>
<div class="grid grid-cols-2 gap-4">
{#each channels as channel}
<button
class="channel-box"
on:click={() => navigateToChannelDetail(channel.channelname)}
>
{channel.channelname}
</button>
{/each}
</div>
</div>

<!-- 待办事项列表 -->
<div class="todos h-2/5 overflow-y-auto p-2 mt-4">
<h2 class="text-2xl font-semibold mb-4 text-black">Todos</h2>
<div class="grid grid-cols-2 gap-4">
{#each todos as todo}
<button
class="todo-box"
on:click={() => navigateToTodoDetail(todo.tittle)}
>
{todo.tittle}
</button>
{/each}
</div>
</div>
</div>
</div>

<style>
.channel-box {
border: 1px solid #ccc;
padding: 8px 16px;
margin-bottom: 8px;
border-radius: 8px;
background-color: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
text-align: center;
height: 100px; /* 或者根据内容调整 */
color: black; /* 将文字颜色设置为黑色 */
}

.todo-box {
border: 1px solid #ddd;
padding: 8px 16px;
margin-bottom: 8px;
border-radius: 8px;
background-color: #f9f9f9;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
text-align: center;
height: 100px; /* 或者根据内容调整 */
color: black; /* 将文字颜色设置为黑色 */
}
</style>
Loading