From 95113b312970a2079382395e61f7c0fdfbba6651 Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Sun, 13 Nov 2022 00:32:01 +0900 Subject: [PATCH 01/20] =?UTF-8?q?[change]=20Ctrl+Enter=E3=81=A7=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E6=8A=95=E7=A8=BF=E3=81=8C=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/comments/CommentsField.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/components/comments/CommentsField.vue b/components/comments/CommentsField.vue index 8aa0fe2..e6cd014 100644 --- a/components/comments/CommentsField.vue +++ b/components/comments/CommentsField.vue @@ -19,6 +19,7 @@ placeholder="コメント" maxlength="500" @focus="focusCommentForm = true" + v-on:keydown.ctrl.enter="click" />
Date: Sun, 13 Nov 2022 01:06:03 +0900 Subject: [PATCH 02/20] =?UTF-8?q?[change]=20=E4=B8=8B=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=B8=E3=81=AE=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=AF=E3=81=AE=E3=83=9D=E3=82=B8=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Header.vue | 2 +- pages/users/_id.vue | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/Header.vue b/components/Header.vue index 7612638..6950584 100644 --- a/components/Header.vue +++ b/components/Header.vue @@ -209,7 +209,7 @@ export default class Header extends Vue { toDraftPage() { workFilterStore.setOnPageName('menu') workFilterStore.setFilterVisibility('draft') - this.$router.push(`/users/${this.getUserId}`) + this.$router.push(`/users/${this.getUserId}#user_work`) } clickLogin() { diff --git a/pages/users/_id.vue b/pages/users/_id.vue index b4a33a1..b18c2cb 100644 --- a/pages/users/_id.vue +++ b/pages/users/_id.vue @@ -5,6 +5,7 @@ :include-draft="getUser.id === $route.params.id" @search="searchWorks" @clear="clear" + id="user_work" />
From 8b0893583f770b89c67f3bddba7f3b3f5a36c37a Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Sun, 13 Nov 2022 01:18:50 +0900 Subject: [PATCH 03/20] =?UTF-8?q?[change]=20=E4=BD=9C=E5=93=81=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=88=E3=83=AB=E3=81=AE=E6=96=87=E5=AD=97=E6=95=B0?= =?UTF-8?q?=E5=88=B6=E9=99=90=E3=81=A8=E3=83=91=E3=83=B3=E3=82=AF=E3=82=BA?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/works/WorksCard.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/works/WorksCard.vue b/components/works/WorksCard.vue index 732555d..5405428 100644 --- a/components/works/WorksCard.vue +++ b/components/works/WorksCard.vue @@ -51,7 +51,7 @@
- {{ workData.title }} + {{ getTitle }}
limitTitle + ? this.workData.title.substr(0, limitTitle) + '...' + : this.workData.title + return title + } + dateFormatter(date: string): string { // const nowDate: Date = new Date() // const postDate: Date = new Date(date) From fed73d31cec9fa71862e4f639a8dcc96f0c0e6bc Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Sun, 13 Nov 2022 17:06:43 +0900 Subject: [PATCH 04/20] =?UTF-8?q?[change]=20auth=20middleware=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/auth.ts | 6 +++--- store/auth.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/middleware/auth.ts b/middleware/auth.ts index 57d0a58..42e515b 100644 --- a/middleware/auth.ts +++ b/middleware/auth.ts @@ -1,19 +1,19 @@ import { Middleware } from '@nuxt/types' import { authStore } from '~/store' -const auth: Middleware = ({ route }) => { +const auth: Middleware = async ({ route }) => { const refreshToken = localStorage.getItem('refresh_token') if ( authStore.getAccessToken && !authStore.nowLogin && !route.query.access_token ) { - authStore.fetchUser() + await authStore.fetchUser() } if (!refreshToken || authStore.nowLogin || route.query.access_token) { return } - authStore.authAgain() + await authStore.authAgain() } export default auth diff --git a/store/auth.ts b/store/auth.ts index 3ca29a3..ef61707 100644 --- a/store/auth.ts +++ b/store/auth.ts @@ -69,8 +69,8 @@ export default class Auth extends VuexModule { @Action public fetchUser(accessToken?: string): Promise { const token = accessToken || this.accessToken - return new Promise((resolve, reject) => { - axios + return new Promise(async (resolve, reject) => { + await axios .get('/users/@me', { headers: { Authorization: `Bearer ${token}` @@ -98,8 +98,8 @@ export default class Auth extends VuexModule { @Action private getAccessTokenByRefreshToken(refreshToken?: string): Promise { const token = refreshToken || String(localStorage.getItem('refresh_token')) - return new Promise((resolve, reject) => { - axios + return new Promise(async (resolve, reject) => { + await axios .post('/auth/token', { refresh_token: token }) From 0a7739ca4ab68e6bdebd8c8be4f4697cebee84dc Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Mon, 21 Nov 2022 22:17:52 +0900 Subject: [PATCH 05/20] =?UTF-8?q?[change]=20docker=E3=81=AE=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 - docker-compose.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1fd1d6d..88c93bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,5 @@ RUN apk update && \ apk add git COPY package*.json ./ -RUN yarn install COPY . ./ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 59c0a40..f07570b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,4 @@ services: - .env environment: - CHOKIDAR_USEPOLLING=true - command: sh -c "yarn run generate:host && yarn run start:host" + command: sh -c "yarn install && yarn run generate:host && yarn run start:host" From cfdfd65377298038a0c476ed7e0128e36693ca55 Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Mon, 21 Nov 2022 22:28:03 +0900 Subject: [PATCH 06/20] =?UTF-8?q?[fix]=20=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index 1093b3b..9ec404a 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -145,7 +145,9 @@ export default class Index extends Vue { this.query += `visibility=${this.getFilterVisibility}` } this.query += this.query === '' ? '?' : '&' - this.query += `oldest_work_id=${this.works[0].id}` + this.query += `newest_work_id=${this.works[this.works.length - 1].id}` + this.query += this.query === '' ? '?' : '&' + this.query += `limit=${this.limit}` const resWorks = await AxiosClient.client( 'GET', `/works${this.query}`, @@ -183,6 +185,8 @@ export default class Index extends Vue { this.query += this.query === '' ? '?' : '&' this.query += `visibility=${this.getFilterVisibility}` } + this.query += this.query === '' ? '?' : '&' + this.query += `limit=${this.limit}` const resWorks = await AxiosClient.client( 'GET', `/works${this.query}`, From 5f807187786495e5e6b4d4444d18b0ce79695eb6 Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Tue, 22 Nov 2022 01:07:04 +0900 Subject: [PATCH 07/20] =?UTF-8?q?[change]=20=E3=82=AF=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=81=AE=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E5=87=A6=E7=90=86=E3=82=92=E5=85=B1=E9=80=9A=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.vue | 80 +++++++++++++++++++-------------------------- pages/users/_id.vue | 38 ++++++++------------- utils/query.ts | 79 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 71 deletions(-) create mode 100644 utils/query.ts diff --git a/pages/index.vue b/pages/index.vue index 9ec404a..73f1b6f 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -32,6 +32,7 @@ import Loading from '@/components/commons/Loading.vue' import { Work } from '@/types' import { authStore, tagSelectorStore, workFilterStore } from '@/store' import { AxiosClient } from '@/utils/axios' +import { Query } from '@/utils/query' @Component({ components: { @@ -45,24 +46,21 @@ import { AxiosClient } from '@/utils/axios' tagSelectorStore.initSelectedTags() workFilterStore.setOnPageName('top') } - let query: string = '' + const query = new Query() if ( workFilterStore.getUseConditionsWhenAsyncData && workFilterStore.getOnPageName === 'top' ) { - if (tagSelectorStore.getSelectedTags.length !== 0) { - query = '?tags=' - tagSelectorStore.getSelectedTags.map((tag) => { - query += `${tag.id},` - }) - query = query.slice(0, -1) - } - if (workFilterStore.getFilterVisibility !== '') { - query += query === '' ? '?' : '&' - query += `visibility=${workFilterStore.getFilterVisibility}` - } + query.create( + tagSelectorStore.getSelectedTags, + workFilterStore.getFilterVisibility + ) } - const resWorks = await AxiosClient.client('GET', `/works${query}`, true) + const resWorks = await AxiosClient.client( + 'GET', + `/works${query.getQuery()}`, + true + ) if (resWorks.status !== 200) { alert('作品一覧の取得に失敗しました') } @@ -72,7 +70,7 @@ import { AxiosClient } from '@/utils/axios' }) export default class Index extends Vue { works: Array = [] - query: string = '' + query: Query = new Query() processing: boolean = false scrollY: number = 0 isWorksEmpty: boolean = false @@ -131,26 +129,20 @@ export default class Index extends Vue { async getNextContent() { if (this.getNowLogin) { - this.query = '' + this.query.init() workFilterStore.setSearched(true) - if (this.getSelectedTags.length !== 0) { - this.query = '?tags=' - this.getSelectedTags.map((tag) => { - this.query += `${tag.id},` - }) - this.query = this.query.slice(0, -1) - } - if (this.getFilterVisibility !== '') { - this.query += this.query === '' ? '?' : '&' - this.query += `visibility=${this.getFilterVisibility}` - } - this.query += this.query === '' ? '?' : '&' - this.query += `newest_work_id=${this.works[this.works.length - 1].id}` - this.query += this.query === '' ? '?' : '&' - this.query += `limit=${this.limit}` + this.query.create( + this.getSelectedTags, + this.getFilterVisibility, + this.works[this.works.length - 1].id, + undefined, + undefined, + undefined, + this.limit + ) const resWorks = await AxiosClient.client( 'GET', - `/works${this.query}`, + `/works${this.query.getQuery()}`, true ) if (resWorks.status !== 200) { @@ -171,25 +163,21 @@ export default class Index extends Vue { async searchWorks() { this.isWorksEmpty = false - this.query = '' + this.query.init() workFilterStore.setSearched(true) this.processing = true - if (this.getSelectedTags.length !== 0) { - this.query = '?tags=' - this.getSelectedTags.map((tag) => { - this.query += `${tag.id},` - }) - this.query = this.query.slice(0, -1) - } - if (this.getFilterVisibility !== '') { - this.query += this.query === '' ? '?' : '&' - this.query += `visibility=${this.getFilterVisibility}` - } - this.query += this.query === '' ? '?' : '&' - this.query += `limit=${this.limit}` + this.query.create( + this.getSelectedTags, + this.getFilterVisibility, + undefined, + undefined, + undefined, + undefined, + this.limit + ) const resWorks = await AxiosClient.client( 'GET', - `/works${this.query}`, + `/works${this.query.getQuery()}`, this.getNowLogin ? true : false ) if (resWorks.status !== 200) { diff --git a/pages/users/_id.vue b/pages/users/_id.vue index b18c2cb..d52c419 100644 --- a/pages/users/_id.vue +++ b/pages/users/_id.vue @@ -25,6 +25,7 @@ import Loading from '@/components/commons/Loading.vue' import { User, Work } from '@/types' import { authStore, tagSelectorStore, workFilterStore } from '~/store' import { AxiosClient } from '@/utils/axios' +import { Query } from '@/utils/query' @Component({ components: { @@ -44,18 +45,11 @@ import { AxiosClient } from '@/utils/axios' let User let resUser let resWorks - let query: string = '' - if (tagSelectorStore.getSelectedTags.length !== 0) { - query = '?tags=' - } - tagSelectorStore.getSelectedTags.map((tag) => { - query += `${tag.id},` - }) - query = query.slice(0, -1) - query += query === '' ? '?' : '&' - if (workFilterStore.getFilterVisibility !== '') { - query += `visibility=${workFilterStore.getFilterVisibility}` - } + const query: Query = new Query() + query.create( + tagSelectorStore.getSelectedTags, + workFilterStore.getFilterVisibility + ) if (authStore.getUser.id === '' && authStore.getAccessToken !== '') { User = await AxiosClient.client('GET', '/users/@me', true) } @@ -66,7 +60,7 @@ import { AxiosClient } from '@/utils/axios' resUser = await AxiosClient.client('GET', '/users/@me', true) resWorks = await AxiosClient.client( 'GET', - `/users/@me/works${query}`, + `/users/@me/works${query.getQuery()}`, true ) } else { @@ -77,7 +71,7 @@ import { AxiosClient } from '@/utils/axios' ) resWorks = await AxiosClient.client( 'GET', - `/users/${route.params.id}/works${query}`, + `/users/${route.params.id}/works${query.getQuery()}`, true ) } @@ -96,7 +90,7 @@ export default class Users extends Vue { userWorksCount: number = 6 userWorks: string[] = Array(this.userWorksCount) processing: boolean = false - query: string = '' + query: Query = new Query() get getUser() { return authStore.getUser @@ -123,25 +117,19 @@ export default class Users extends Vue { if (this.getNowLogin) { workFilterStore.setSearched(true) this.processing = true - this.query = '?tags=' - this.getSelectedTags.map((tag) => { - this.query += `${tag.id},` - }) - this.query = this.query.slice(0, -1) - if (this.getFilterVisibility !== '') { - this.query += `&visibility=${this.getFilterVisibility}` - } + this.query.init() + this.query.create(this.getSelectedTags, this.getFilterVisibility) let resWorks if (this.getUser.id === this.$route.params.id) { resWorks = await AxiosClient.client( 'GET', - `/users/@me/works${this.query}`, + `/users/@me/works${this.query.getQuery()}`, true ) } else { resWorks = await AxiosClient.client( 'GET', - `/users/${this.$route.params.id}/works${this.query}`, + `/users/${this.$route.params.id}/works${this.query.getQuery()}`, true ) } diff --git a/utils/query.ts b/utils/query.ts new file mode 100644 index 0000000..87171a3 --- /dev/null +++ b/utils/query.ts @@ -0,0 +1,79 @@ +import { GetTag } from '@/types' + +export class Query { + private query: string + + constructor() { + this.query = '' + } + + private addQuestionOrAnd() { + this.query += this.query ? '&' : '?' + } + + public create( + tags?: GetTag[], + visibility?: string, + newest_work_id?: string, + oldest_work_id?: string, + newest_comment_id?: string, + oldest_comment_id?: string, + limit?: number, + smallest_tag_id?: string, + biggest_tag_id?: string, + w?: string + ) { + if (tags) { + this.addQuestionOrAnd() + this.query += 'tags=' + tags.map((tag) => { + this.query += `${tag.id},` + }) + this.query = this.query.slice(0, -1) + } + if (visibility) { + this.addQuestionOrAnd() + this.query += `visibility=${visibility}` + } + if (newest_work_id) { + this.addQuestionOrAnd() + this.query += `newest_work_id=${newest_work_id}` + } + if (oldest_work_id) { + this.addQuestionOrAnd() + this.query += `oldest_work_id=${oldest_work_id}` + } + if (newest_comment_id) { + this.addQuestionOrAnd() + this.query += `newest_comment_id=${newest_comment_id}` + } + if (oldest_comment_id) { + this.addQuestionOrAnd() + this.query += `oldest_comment_id=${oldest_comment_id}` + } + if (limit) { + this.addQuestionOrAnd() + this.query += `limit=${limit}` + } + if (smallest_tag_id) { + this.addQuestionOrAnd() + this.query += `smallest_tag_id=${smallest_tag_id}` + } + if (biggest_tag_id) { + this.addQuestionOrAnd() + this.query += `biggest_tag_id=${biggest_tag_id}` + } + if (w) { + this.addQuestionOrAnd() + this.query += `w=${w}` + } + } + + public init() { + this.query = '' + } + + public getQuery() { + return this.query + } +} From 39b3d52ae1a8a6e8a387296235a3f1cbf03d6f6b Mon Sep 17 00:00:00 2001 From: Simo-C3 Date: Tue, 22 Nov 2022 01:07:35 +0900 Subject: [PATCH 08/20] =?UTF-8?q?[change]=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E6=A9=9F=E8=83=BD=E3=81=AE=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/comments/CommentsField.vue | 1 + components/comments/CommentsList.vue | 8 +--- components/comments/CommentsListItem.vue | 54 ++++++++++++++++++------ pages/works/_id/index.vue | 19 ++++----- types/common.d.ts | 6 +++ 5 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 types/common.d.ts diff --git a/components/comments/CommentsField.vue b/components/comments/CommentsField.vue index e6cd014..1eb9097 100644 --- a/components/comments/CommentsField.vue +++ b/components/comments/CommentsField.vue @@ -20,6 +20,7 @@ maxlength="500" @focus="focusCommentForm = true" v-on:keydown.ctrl.enter="click" + v-on:keydown.meta.enter="click" />
- + /> -->