Skip to content

Commit

Permalink
Merge pull request #419 from hibiya-itchief/hihihib-#386-調整
Browse files Browse the repository at this point in the history
#386 調整 (ブックマーク)
  • Loading branch information
hibiyahibiyahibiya authored Oct 4, 2023
2 parents 24987fe + c12e6f8 commit 4173e80
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pages/groups/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ type Data = {
sort_displayname: string
query_cache: any
search_result_number: number
storage_bookmarks: (string | null)[]
display_bookmarks: boolean
selectedTag: Tag | undefined
}
Expand All @@ -255,6 +256,7 @@ export default Vue.extend({
search_result_number: 0,
search_query: '',
sort_displayname: 'デフォルト順',
storage_bookmarks: [],
display_bookmarks: false,
query_cache: undefined,
}
Expand All @@ -281,7 +283,10 @@ export default Vue.extend({
// クエリパラメータを見て検索バー内の文字列を再現など
if (typeof this.$route.query.q === 'string') {
this.search_query = this.$route.query.q
this.PushQuery(null, undefined, null, null, null)
// 検索中はタグ選択ができないため、created時もtを削除
if (this.$route.query.t !== undefined) {
this.PushQuery(null, undefined, null, null, null)
}
this.SearchGroups()
}
if (
Expand Down Expand Up @@ -318,10 +323,14 @@ export default Vue.extend({
}
},
mounted() {
for (let i = 0; i < localStorage.length; i++) {
this.storage_bookmarks.push(localStorage.key(i))
}
this.nowloading = false
},
methods: {
// それぞれ、Qは検索バーの内容、Tはタグ、Bはブックマーク、Sはソート(並び替え)、Rは昇順/降順の切り替え(ReverseのR)
PushQuery(Q: any, T: any, B: any, S: any, R: any) {
Q = Q === null ? this.$route.query.q : Q
T = T === null ? this.$route.query.t : T
Expand All @@ -330,6 +339,7 @@ export default Vue.extend({
R = R === null ? this.$route.query.r : R
this.$router.push({ query: { q: Q, t: T, b: B, s: S, r: R } }) // nullは「現在のクエリを維持」と同義
},
SortGroups(sort: 'id' | 'groupname' | 'title') {
if (sort === 'groupname') {
this.sort_displayname = '団体名順'
Expand Down Expand Up @@ -435,13 +445,13 @@ export default Vue.extend({
FilterBookmarks(id: string) {
// お気に入りならtrue
if (this.nowloading === true) return false
for (let i = 0; i < localStorage.length; i++) {
if ('seiryofes.groups.favorite.' + id === localStorage.key(i)) {
return true
}
if (this.nowloading === true) {
return false
} else {
return this.storage_bookmarks.includes(
'seiryofes.groups.favorite.' + id
)
}
return false
},
HashColor(text: string) {
Expand Down

0 comments on commit 4173e80

Please sign in to comment.