Skip to content

Commit

Permalink
Merge pull request #110 from little3201/develop
Browse files Browse the repository at this point in the history
修改评论提交按钮的类型:submit -> button
  • Loading branch information
little3201 authored Sep 23, 2021
2 parents 63227fb + d430b8d commit fe75955
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 58 deletions.
2 changes: 1 addition & 1 deletion components/global/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<button
@click="onSubmit"
aria-label="send_comment"
type="submit"
type="button"
class="text-white uppercase text-xs font-bold bg-gray-500 py-3 w-full outline-none"
>Submit Comment</button>
</form>
Expand Down
2 changes: 1 addition & 1 deletion components/global/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default defineComponent({
const onSubmit = async () => {
datas.value = []
let result = $axios.$get(SERVER_URL.posts.concat("/search?keyword=", keyword.value));
let result = $axios.$get(SERVER_URL.posts.concat("/search"), { params: { keyword: keyword.value } });
datas.value.push(result)
};
Expand Down
36 changes: 6 additions & 30 deletions components/sections/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
<div class="grid grid-flow-row grid-cols-1 lg:grid-cols-3">
<div class="lg:col-span-2">
<TopPosts :datas="topDatas" />
<ul
class="
flex
justify-between
items-center
text-center
border border-black
"
>
<ul class="flex justify-between items-center text-center border border-black">
<li
class="w-1/3 hover:bg-black hover:text-white"
:class="{ 'bg-black text-white': order == 'likes' }"
Expand All @@ -21,9 +13,7 @@
type="button"
@click="retrieve(), (order = 'likes')"
class="w-full h-10 text-xs font-bold uppercase focus:outline-none"
>
Most Liked
</button>
>Most Liked</button>
</li>
<li
class="w-1/3 hover:bg-black hover:text-white"
Expand All @@ -34,9 +24,7 @@
type="button"
@click="retrieve(), (order = 'viewed')"
class="w-full h-10 text-xs font-bold uppercase focus:outline-none"
>
Most Viewed
</button>
>Most Viewed</button>
</li>
<li
class="w-1/3 hover:bg-black hover:text-white"
Expand All @@ -47,18 +35,11 @@
aria-label="popular"
@click="retrieve(), (order = 'comment')"
class="w-full h-10 text-xs font-bold uppercase focus:outline-none"
>
Most Comments
</button>
>Most Comments</button>
</li>
</ul>
<ListItem :datas="datas" />
<Pagation
:page="page"
:size="size"
:total="total"
@retrieve="retrieve"
/>
<Pagation :page="page" :size="size" :total="total" @retrieve="retrieve" />
</div>
<LazySideBar />
</div>
Expand Down Expand Up @@ -103,12 +84,7 @@ export default defineComponent({
const retrieve = async (num: number) => {
page.value = num ? num : 0;
props.listDatas = await $axios.$get(
SERVER_URL.posts.concat(
"?page=" + page.value,
"&size=" + size.value,
"&order=",
order.value
)
SERVER_URL.posts, { params: { page: page.value, size: size.value, order: order.value } }
);
};
Expand Down
35 changes: 12 additions & 23 deletions pages/posts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
<div class="container mx-auto px-2 md:px-12 lg:px-16 xl:px-20">
<ul class="flex text-xs border border-black overflow-x-scroll">
<li
class=" hover:bg-black hover:text-white"
class="hover:bg-black hover:text-white"
:class="{ 'bg-black text-white': '' == category }"
>
<button
aria-label="posts_all"
type="button"
@click="retrieve(0, '')"
class="w-32 h-10 font-bold uppercase focus:outline-none"
>
All
</button>
>All</button>
</li>
<li
class="hover:bg-black hover:text-white"
Expand Down Expand Up @@ -40,7 +38,8 @@ import {
useFetch,
useContext,
ref,
useMeta
useMeta,
useRoute
} from "@nuxtjs/composition-api";
import { SERVER_URL } from "~/api/request";
Expand All @@ -50,10 +49,11 @@ export default defineComponent({
head: {},
setup() {
const { $axios, params } = useContext();
const { $axios } = useContext();
const route = useRoute();
// cotegory code
const category = ref(params.value.category);
const category = ref(route.value.params.category || '');
const categories = ref([]);
const datas = ref([]);
Expand All @@ -67,12 +67,7 @@ export default defineComponent({
[categories.value, datas.value, total.value] = await Promise.all([
$axios.$get(SERVER_URL.category),
$axios.$get(
SERVER_URL.posts.concat(
"?page=" + page.value,
"&size=" + size.value,
"&category=" + category.value
)
),
SERVER_URL.posts, { params: { page: page.value, size: size.value, category: category.value } }),
$axios.$get(SERVER_URL.posts.concat("/count")),
]);
});
Expand All @@ -95,20 +90,14 @@ export default defineComponent({
],
}));
const retrieve = (num: number, code: string) => {
const retrieve = async (num: number, code: string) => {
page.value = num;
if (code) {
category.value = code;
}
$axios
.get(
SERVER_URL.posts.concat(
"?page=" + page.value,
"&size=" + size.value,
"&category=" + category.value
)
)
.then((res) => (datas.value = res.data));
[datas.value, total.value] = await Promise.all([$axios
.$get(SERVER_URL.posts, { params: { page: page.value, size: size.value, category: category.value } }),
$axios.$get(SERVER_URL.posts.concat("/count"))])
};
return {
Expand Down
4 changes: 1 addition & 3 deletions pages/resource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export default defineComponent({
const { $axios } = useContext();
useFetch(async () => {
datas.value = await $axios.$get(SERVER_URL.resource, {
params: { page: 0, size: 12 },
});
datas.value = await $axios.$get(SERVER_URL.resource, { params: { page: 0, size: 12 }, });
});
useMeta(() => ({
Expand Down

0 comments on commit fe75955

Please sign in to comment.