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: repush profile #83

Merged
merged 24 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
12069ca
feat: lead Profile to the mainpage (#74)
Fantasy0214 Mar 17, 2024
7d2e391
Merge branch 'master' of github.com:03130214/lip
Fantasy0214 Mar 17, 2024
1a3512d
feat: repair the channels and todos
Fantasy0214 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
189 changes: 189 additions & 0 deletions src/routes/mainpage1.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<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,
currentnoticeid,
isJoinedTodo,
username,
originChannelID,
} 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 jumpnew(origin) {
originChannelID.set(origin);
push("/chantemplate");
}
async function jumptodo(title) {
const response_ = await pb.collection("notices").getFullList({
sort: "-created",
filter: `tittle="${title}"`,
});

currentnoticeid.set(response_[0].id);
const uEmail = $currentUserEmail;
const response = await pb.collection("todolist").getFullList({
sort: "-created",
filter: `useremail="${uEmail}"`,
});

for (const item of response) {
if (item.tittle == title) {
isJoinedTodo.set("find");
break;
} else {
isJoinedTodo.set("noFind");
}
}
push("/checknotice");
}
</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.slice(0, 6) as channel}
<!-- 限制显示到最多6个频道 -->
<button
class="channel-box"
on:click={() => jumpnew(channel.originid)}
>
{channel.channelname}
</button>
{/each}
</div>
</div>

<!-- 待办事项列表,显示最多2个 -->
<!-- 待办事项列表,显示最多2个 -->
<div class="todos h-2/5 p-2 mt-4">
<h2 class="text-2xl font-semibold mb-4 text-black">Todos</h2>
<div class="todo-list">
{#each todos.slice(0, 2) as todo}
<!-- 限制显示到最多2个待办事项 -->
<button class="todo-item" on:click={() => jumptodo(todo.tittle)}>
<div class="todo-title">{todo.tittle}</div>
<div class="todo-content">{todo.body}</div>
</button>
{/each}
</div>
</div>
</div>
</div>

<style>
.channels {
height: 55%;
}

.todos {
height: 45%;
overflow: hidden;
padding-top: 0;
}

/* 其余样式保持不变 */
.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; /* 将文字颜色设置为黑色 */
}

.todos {
overflow: hidden; /* 禁止滚动 */
}

.todo-list {
display: flex;
flex-direction: column;
}

.todo-item {
padding: 16px;
border-bottom: 1px solid #ccc; /* Add a bottom border for each todo */
margin-bottom: -1px; /* Overlap borders */
}

.todo-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 8px; /* Add some space between the title and content */
}

.todo-content {
font-size: 16px;
color: #333; /* Slightly lighter text for content */
}

/* 可能需要调整这些值来更好地匹配上传的图片 */
</style>
21 changes: 21 additions & 0 deletions src/routes/searchChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,32 @@
async function joinChannel(channelname, channelid) {
try {
const userEmail = $currentUserEmail;
// 获取当前日期
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1; // JavaScript的月份是从0开始的
const day = now.getDate();

// 以备选方式获取频道描述
const records = await pb
.collection("channels")
.getFullList({ filter: `channelName="${channelname}"` });
if (records.length === 0) {
throw new Error("未找到指定的频道。");
}
const channelDescription = records[0].channelDescription;

// 创建记录并包含年月日和频道描述
await pb.collection("users_channels").create({
useremail: userEmail,
channelname: channelname,
originid: channelid,
year: year,
month: month,
day: day,
channelDescription: channelDescription, // 存储频道描述
});

alert("已成功加入频道");
navigateToChannelDetail("main");
} catch (error) {
Expand Down
Loading