更新readme

master
barney 2 years ago
parent f2d3b6632b
commit d3886ae21d
  1. 10
      README.md
  2. 11
      frontend/src/components/ArticleList.vue
  3. 11
      frontend/src/components/BlogHeader.vue
  4. 37
      frontend/src/components/CommentView.vue
  5. 2
      frontend/src/router/index.js
  6. 4
      frontend/src/store/index.js
  7. 4
      frontend/src/utils/authorization.js
  8. 18
      frontend/src/views/ArticleCreate.vue
  9. 6
      frontend/src/views/ArticleDetailView.vue
  10. 17
      frontend/src/views/ArticleEdit.vue
  11. 4
      frontend/src/views/LoginView.vue

@ -2,20 +2,20 @@
#### 1、博客首页展示
![image-20221003002818644](C:\Users\15270\AppData\Roaming\Typora\typora-user-images\image-20221003002818644.png)
![博客首页](https://cdn.jsdelivr.net/gh/JokerZhang66/images@master//img/image-20221003002818644.png)
#### 2.发布文章界面
![image-20221003002550725](C:\Users\15270\AppData\Roaming\Typora\typora-user-images\image-20221003002550725.png)
![](https://cdn.jsdelivr.net/gh/JokerZhang66/images@master//img/image-20221003002550725.png)
#### 3.登录、注册界面
![image-20221003002956157](C:\Users\15270\AppData\Roaming\Typora\typora-user-images\image-20221003002956157.png)
![](https://cdn.jsdelivr.net/gh/JokerZhang66/images@master//img/image-20221003002956157.png)
#### 4.用户管理界面
![image-20221003002845601](C:\Users\15270\AppData\Roaming\Typora\typora-user-images\image-20221003002845601.png)
![](https://cdn.jsdelivr.net/gh/JokerZhang66/images@master//img/image-20221003002845601.png)
#### 5.更新文章界面
![image-20221003003047933](C:\Users\15270\AppData\Roaming\Typora\typora-user-images\image-20221003003047933.png)
![](https://cdn.jsdelivr.net/gh/JokerZhang66/images@master//img/image-20221003003047933.png)

@ -17,11 +17,7 @@
{{ article.category.title }}
</span>
<span
v-for="tag in article.tags"
v-bind:key="tag"
class="tag"
>
<span v-for="tag in article.tags" v-bind:key="tag" class="tag">
{{ tag }}
</span>
<!-- 路由链接:to的两个参数分别是: 路由名称和传入的id -->
@ -200,7 +196,6 @@ export default {
</script>
<style scoped>
#articles {
padding: 0.4rem;
}
@ -210,17 +205,15 @@ export default {
border-radius: 10px;
box-shadow: darkslategrey 0 0 12px;
user-select: none;
}
.image-container {
width: 100%;
display: grid;
place-items: center;
}
.article-info {
width:90%;
width: 90%;
border-radius: 10px;
background-color: lightgray;
display: grid;

@ -90,14 +90,14 @@ export default {
});
onMounted(() => {
authorization().then(
(data) => {[haslogin.value, username.value] = data}
);
authorization().then((data) => {
[haslogin.value, username.value] = data;
});
});
const refresh = () => {
username.value = localStorage.getItem("username_blog");
}
};
return {
username,
@ -106,7 +106,7 @@ export default {
homePage,
quit,
};
}
},
};
</script>
@ -155,7 +155,6 @@ export default {
background-color: lightblue;
z-index: 10;
}
</style>
<style scoped>

@ -52,23 +52,23 @@
</template>
<script>
import $ from 'jquery';
import authorization from '@/utils/authorization'
import { ref, watchEffect } from 'vue';
import $ from "jquery";
import authorization from "@/utils/authorization";
import { ref, watchEffect } from "vue";
export default {
name: "CommentView",
props: {
article: {
required: true,
}
},
},
setup(props) {
//
let comments = ref([]);
//
let message = ref('');
let placeholder = ref('说点啥吧...');
let message = ref("");
let placeholder = ref("说点啥吧...");
//
let parentId = ref(null);
//
@ -76,25 +76,25 @@ export default {
authorization().then((response) => {
if (response[0]) {
$.ajax({
url: 'http://127.0.0.1:6789/api/comment/',
type: 'POST',
url: "http://127.0.0.1:6789/api/comment/",
type: "POST",
data: {
content: message.value,
article_id: props.article.id,
parent_id: parentId.value,
},
headers: {
authorization: "Bearer " + localStorage.getItem('access_blog')
authorization:
"Bearer " + localStorage.getItem("access_blog"),
},
success(resp) {
//
comments.value.unshift(resp);
message.value = '';
message.value = "";
window.alert("留言成功");
}
})
}else {
},
});
} else {
window.alert("请登录后再评论!");
}
});
@ -102,16 +102,17 @@ export default {
const replyTo = (comment) => {
parentId.value = comment.id;
placeholder.value = '对' + comment.author.username + '说';
placeholder.value = "对" + comment.author.username + "说";
};
const formatted_time = (iso_date_string) => {
const date = new Date(iso_date_string);
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
return date.toLocaleDateString() + " " + date.toLocaleTimeString();
};
watchEffect(() => {
comments.value = props.article !== null ? props.article.comments : [];
comments.value =
props.article !== null ? props.article.comments : [];
});
return {
@ -122,7 +123,7 @@ export default {
submit,
replyTo,
formatted_time,
}
};
},
};
</script>

@ -34,7 +34,7 @@ const routes = [
component: UserCenter,
},
{
path : "/article/create/",
path: "/article/create/",
name: "ArticleCreate",
component: ArticleCreate,
},

@ -9,9 +9,9 @@ export default createStore({
},
mutations: {
updateIsLogin(state,islogin) {
updateIsLogin(state, islogin) {
state.islogin = islogin;
},updateIsSuperUser(state, isSuperUser){
}, updateIsSuperUser(state, isSuperUser) {
state.isSuperUser = isSuperUser;
}
},

@ -28,7 +28,7 @@ const authorization = async () => {
refresh: refreshToken,
},
success(resp) {
const nextExpiredTime = new Date().getTime() + 24*3600*1000;
const nextExpiredTime = new Date().getTime() + 24 * 3600 * 1000;
storage.setItem("access_blog", resp.access);
storage.removeItem("refresh_blog"); // 移除刷新令牌
console.log(
@ -39,7 +39,7 @@ const authorization = async () => {
haslogin = true;
},
});
}catch(err){
} catch (err) {
storage.clear();
haslogin = false;
// console.log('authorization err');

@ -43,7 +43,7 @@
</div>
<div class="form-elem">
<div style="margin-bottom: 10px;">正文</div>
<div style="margin-bottom: 10px">正文</div>
<textarea
v-model="body"
placeholder="输入正文"
@ -66,7 +66,7 @@ import BlogFooter from "@/components/BlogFooter.vue";
import authorization from "@/utils/authorization";
import $ from "jquery";
import { onMounted } from "@vue/runtime-core";
import { useRouter } from 'vue-router';
import { useRouter } from "vue-router";
import { ref } from "vue";
export default {
name: "ArticleCreate",
@ -140,12 +140,12 @@ export default {
processData: false,
contentType: false,
headers: {
"Authorization":
Authorization:
"Bearer " + localStorage.getItem("access_blog"),
},
success(resp) {
avatarID.value = resp.id;
}
},
});
};
@ -183,8 +183,8 @@ export default {
url: "http://127.0.0.1:6789/api/article/",
type: "POST",
data: JSON.stringify(data),
contentType: 'application/json',
dataType: 'json',
contentType: "application/json",
dataType: "json",
headers: {
Authorization: "Bearer " + token,
},
@ -199,8 +199,7 @@ export default {
window.alert("令牌过期,请重新登录。");
}
});
}
};
return {
categories,
@ -213,8 +212,7 @@ export default {
chooseCategory,
onFileChange,
submit,
}
};
},
};
</script>

@ -56,7 +56,7 @@ export default {
type: "GET",
success(resp) {
article.value = resp;
}
},
});
});
@ -66,9 +66,9 @@ export default {
};
// vue3使computed
//
let isSuperUser = computed(()=> {
let isSuperUser = computed(() => {
return localStorage.getItem("is_superuser_blog") === "true";
})
});
return {
article,

@ -21,7 +21,12 @@
</button>
</span>
<div v-if="selectedCategory !== null" style="margin-top:5px; color:red;">:&nbsp;不选分类时可创建新分类!</div>
<div
v-if="selectedCategory !== null"
style="margin-top: 5px; color: red"
>
:&nbsp;不选分类时可创建新分类!
</div>
<div class="newCategory" v-if="selectedCategory === null">
<div>创建新分类:&nbsp;</div>
@ -172,7 +177,6 @@ export default {
//
.filter((x) => x.charAt(0) !== "");
//
if (
selectedCategory.value === null &&
@ -186,12 +190,13 @@ export default {
title: newCategory.value,
},
headers: {
Authorization: "Bearer " + localStorage.getItem("access_blog"),
Authorization:
"Bearer " +
localStorage.getItem("access_blog"),
},
success(resp) {
selectedCategory.value = resp;
},
});
}
@ -199,7 +204,6 @@ export default {
? selectedCategory.value.id
: null;
$.ajax({
url:
"http://127.0.0.1:6789/api/article/" +
@ -210,7 +214,8 @@ export default {
contentType: "application/json",
data: JSON.stringify(data),
headers: {
Authorization: "Bearer " + localStorage.getItem("access_blog"),
Authorization:
"Bearer " + localStorage.getItem("access_blog"),
},
success(resp) {
router.push({

@ -28,7 +28,7 @@
</div>
<div v-if="!haslogin">
<div class="error">{{error_msg}}</div>
<div class="error">{{ error_msg }}</div>
</div>
</form>
</div>
@ -101,7 +101,7 @@ export default {
error(resp) {
error_msg.value = resp.responseText;
haslogin.value = false;
}
},
});
};

Loading…
Cancel
Save