From d7f1bf7d49a8383c939086c343bc56db3a8c0026 Mon Sep 17 00:00:00 2001
From: Miao_Spring <539943419@qq.com>
Date: Wed, 15 Jan 2025 07:39:03 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=A7=E7=BB=AD=E5=AE=8C=E6=88=90...?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/icons/create.vue | 3 +
components/user/postEditor.vue | 29 +++--
pages/user/main/post/edit-[id].vue | 146 ++++++++++++++++-----
pages/user/main/post/index.vue | 197 ++++++++++++++++++-----------
server/api/posts/getPostList.ts | 2 +-
server/api/posts/uploadPost.ts | 6 +-
style/el-miao-style.scss | 3 +
tsconfig.json | 6 +-
8 files changed, 270 insertions(+), 122 deletions(-)
create mode 100644 components/icons/create.vue
create mode 100644 style/el-miao-style.scss
diff --git a/components/icons/create.vue b/components/icons/create.vue
new file mode 100644
index 0000000..9ed0f31
--- /dev/null
+++ b/components/icons/create.vue
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/components/user/postEditor.vue b/components/user/postEditor.vue
index 830fc57..8253423 100644
--- a/components/user/postEditor.vue
+++ b/components/user/postEditor.vue
@@ -1,20 +1,29 @@
- editor以后再写
-
-
-
-
-
+
+
+
+
+ 标题
+
+
+
+
+
+
+
+
+
+ 摘要
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pages/user/main/post/index.vue b/pages/user/main/post/index.vue
index 52d61e6..7cbc54c 100644
--- a/pages/user/main/post/index.vue
+++ b/pages/user/main/post/index.vue
@@ -4,55 +4,68 @@
文章列表
-
- 上传文章
-
-
-
@@ -85,65 +98,99 @@ onMounted(async () => {
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 1rem;
- &-item {
- // height: 100px;
- border-radius: 5px;
- border: 1px solid #ccc;
+ &-create {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ cursor: pointer;
+
+ &-text {
+ letter-spacing: 2px;
+ transform: translateX(-2px);
+ user-select: none;
+ }
}
- .post-item {
- box-sizing: border-box;
- overflow: hidden;
- padding-bottom: 5px;
-
- // padding: 10px;
+ &-card {
&-header {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
-
- &-title {
- width: 100%;
- box-sizing: border-box;
- text-align: center;
- letter-spacing: 4px;
- text-decoration: none;
- font-size: large;
- background-color: #15aa87;
- color: #fff;
- padding: 3px 0 5px;
- // font-family: PT Serif, Serif;
- }
- }
-
- &-content {
- max-height: 45px;
- overflow: hidden;
- text-overflow: ellipsis;
- text-indent: 2em;
- color: #363636;
- }
-
- &-footer {
display: flex;
justify-content: space-between;
align-items: center;
- margin-top: 5px;
+ }
- &-info {
- padding: 0 5px;
-
- &>div {
- font-size: 10px;
- }
+ &-content {
+ &-tags {
+ display: flex;
+ height: 25px;
+ max-width: calc(100% - 0px);
+ user-select: none;
}
- &-btn {
- height: 25px;
- margin-right: 10px;
+ &-tag:not(:first-child) {
+ margin: 0 5px;
}
}
+
+ &-footer {
+ font-size: smaller;
+ color: #686868;
+ }
}
+
+ // .post-item {
+ // box-sizing: border-box;
+ // overflow: hidden;
+ // padding-bottom: 5px;
+
+ // // padding: 10px;
+ // &-header {
+ // display: flex;
+ // flex-direction: column;
+ // justify-content: space-between;
+
+ // &-title {
+ // width: 100%;
+ // box-sizing: border-box;
+ // text-align: center;
+ // letter-spacing: 4px;
+ // text-decoration: none;
+ // font-size: large;
+ // background-color: #15aa87;
+ // color: #fff;
+ // padding: 3px 0 5px;
+ // // font-family: PT Serif, Serif;
+ // }
+ // }
+
+ // &-content {
+ // max-height: 45px;
+ // overflow: hidden;
+ // text-overflow: ellipsis;
+ // text-indent: 2em;
+ // color: #363636;
+ // }
+
+ // &-footer {
+ // display: flex;
+ // justify-content: space-between;
+ // align-items: center;
+ // margin-top: 5px;
+
+ // &-info {
+ // padding: 0 5px;
+
+ // &>div {
+ // font-size: 10px;
+ // }
+ // }
+
+ // &-btn {
+ // height: 25px;
+ // margin-right: 10px;
+ // }
+ // }
+ // }
}
}
\ No newline at end of file
diff --git a/server/api/posts/getPostList.ts b/server/api/posts/getPostList.ts
index b22c79d..e302fae 100644
--- a/server/api/posts/getPostList.ts
+++ b/server/api/posts/getPostList.ts
@@ -30,6 +30,6 @@ export default defineEventHandler(async (event) => {
return {
code: 200,
- data: posts
+ data: posts.reverse()
};
});
\ No newline at end of file
diff --git a/server/api/posts/uploadPost.ts b/server/api/posts/uploadPost.ts
index 05077f5..47f8ea3 100644
--- a/server/api/posts/uploadPost.ts
+++ b/server/api/posts/uploadPost.ts
@@ -42,6 +42,7 @@ export default defineEventHandler(async (event) => {
const tags = tagsArray.slice(0, 15).concat(new Array(15 - tagsArray.length).fill(null));
try {
+ let id = -1
db.transaction(() => {
// 插入tags表
const tagResult = insertTagsStmt.run(...tags);
@@ -51,13 +52,16 @@ export default defineEventHandler(async (event) => {
const postResult = insertPostStmt.run(title, summary, type, url, date, tagId);
const postId = postResult.lastInsertRowid;
+ id = postId as number;
+
// 插入postContent表
insertContentStmt.run(postId, content);
})();
return {
code: 200,
- msg: '插入成功'
+ msg: '插入成功',
+ id
};
} catch (error) {
console.error('插入数据时出错:', error);
diff --git a/style/el-miao-style.scss b/style/el-miao-style.scss
new file mode 100644
index 0000000..1edd833
--- /dev/null
+++ b/style/el-miao-style.scss
@@ -0,0 +1,3 @@
+.miao-button {
+
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 2704d9a..f62873c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,8 +8,12 @@
"server/**/*",
"style/**/*",
"utils/**/*",
- ".nuxt/*.d.ts",
"types/**/*",
"plugins/**/*",
+ ".nuxt/imports.d.ts",
+ ".nuxt/nuxt.d.ts",
+ ],
+ "exclude": [
+ ".nuxt/components.d.ts",
]
}