diff --git a/珞珈岛-项目相关文件/luojia-island/service/.idea/.name b/珞珈岛-项目相关文件/luojia-island/service/.idea/.name new file mode 100644 index 0000000..6b2ac43 --- /dev/null +++ b/珞珈岛-项目相关文件/luojia-island/service/.idea/.name @@ -0,0 +1 @@ +LuojiaChannelApplication.java \ No newline at end of file diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/resources/application-local.yaml b/珞珈岛-项目相关文件/luojia-island/service/src/main/resources/application-local.yaml index 5b750ca..9430e6d 100644 --- a/珞珈岛-项目相关文件/luojia-island/service/src/main/resources/application-local.yaml +++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/resources/application-local.yaml @@ -2,11 +2,11 @@ lj: db: host: localhost - password: lzt&264610 + password: 1243969857 redis: host: localhost port: 6379 - password: 123456 + password: 1243969857 rabbitmq: host: localhost port: 5672 diff --git a/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/postlist.js b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/postlist.js index af303ac..4fceb46 100644 --- a/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/postlist.js +++ b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/postlist.js @@ -1,5 +1,5 @@ import {defineStore} from 'pinia'; -import axios from 'axios'; +//import axios from 'axios'; import request from '@/utils/request'; export const usePostListStore = defineStore('postList', { diff --git a/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/userpost.js b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/userpost.js new file mode 100644 index 0000000..9db88e8 --- /dev/null +++ b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/stores/userpost.js @@ -0,0 +1,78 @@ +import {defineStore} from 'pinia'; +//import axios from 'axios'; +import request from '@/utils/request'; + +export const usePostListStore = defineStore('postList', { + state: () => ({ + posts: [], // 帖子列表 + total: 0, // 帖子总数 + page: 1, // 当前页码 + pageSize: 10, // 每页帖子数 + lastVal: Date.now(), // 用于滚动分页的时间戳 + offset: 0, // 偏移量 + loading: false, // 加载状态 + finished: false, // 是否加载完全部 + }), + actions: { + setPosts(posts) { + this.posts = posts; + }, + setTotal(total) { + this.total = total; + }, + setPage(page) { + this.page = page; + }, + setPageSize(pageSize) { + this.pageSize = pageSize; + }, + addPost(post) { + this.posts.push(post); + this.total += 1; // 更新总数 + }, + removePost(postId) { + this.posts = this.posts.filter(post => post.id !== postId); + this.total -= 1; // 更新总数 + }, + async getList({ lastVal = this.lastVal, offset = this.offset, size = this.pageSize } = {}) { + if (this.loading || this.finished) return; + this.loading = true; + try { + const res = await request.post('/post/user', { lastVal, offset, size }); + if (res.code === 200) { + const { records, lastVal: newLastVal, offset: newOffset, size: newSize } = res.data; + if (records.length > 0) { + // 字段映射 + const mappedRecords = records.map(post => ({ + id: post.id, + avatar: post.userAvatar || post.image || require('@/assets/default-avatar/boy_1.png'), + title: post.title, + summary: post.content ? post.content.slice(0, 40) + (post.content.length > 40 ? '...' : '') : '', + likes: post.likeCount, + comments: post.commentCount, + favorites: post.favoriteCount, + category: post.category || '全部', + createTime: post.createTime, + userName: post.userName, + })); + this.posts = [...this.posts, ...mappedRecords]; + this.lastVal = newLastVal; + this.offset = newOffset; + this.pageSize = newSize; + } + if (records.length < size) { + this.finished = true; // 没有更多数据 + } + } + } finally { + this.loading = false; + } + }, + resetList() { + this.posts = []; + this.lastVal = Date.now(); + this.offset = 0; + this.finished = false; + } + }, +}); \ No newline at end of file diff --git a/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/PostPublish.vue b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/PostPublish.vue new file mode 100644 index 0000000..4b3a73c --- /dev/null +++ b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/PostPublish.vue @@ -0,0 +1,255 @@ + + + + + \ No newline at end of file diff --git a/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/UserPage.vue b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/UserPage.vue index fa7105b..a193679 100644 --- a/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/UserPage.vue +++ b/珞珈岛-项目相关文件/luojia-island/vue-frontend/src/views/UserPage.vue @@ -55,93 +55,99 @@ + +
加载中...
+
{{ error }}
+
+ +
+ {{ post.title }} +
+
-