Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
asadahimeka committed May 19, 2023
2 parents 2c12ccb + 6cff29f commit 6fa67ff
Show file tree
Hide file tree
Showing 35 changed files with 272 additions and 121 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixiv-viewer",
"version": "1.8.12",
"version": "1.8.15",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
9 changes: 6 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
<link rel="stylesheet" href="https://cdn.staticfile.org/Swiper/5.4.5/css/swiper.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/lxgw-wenkai-webfont/1.6.0/style.css">
<script src="<%= BASE_URL %>static/js/flexible.min.js"></script>
<% if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_UMAMI_SRC) { %>
<script async defer src="<%= process.env.VUE_APP_UMAMI_SRC %>" data-website-id="<%= process.env.VUE_APP_UMAMI_ID %>"></script>
<% } %>
</head>

<body>
Expand All @@ -50,6 +47,12 @@
<% } %>
<% } %>
<!-- built files will be auto injected -->
<% if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_CF_BEACON) { %>
<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "<%= process.env.VUE_APP_CF_BEACON %>"}'></script>
<% } %>
<% if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_UMAMI_SRC) { %>
<script async defer src="<%= process.env.VUE_APP_UMAMI_SRC %>" data-website-id="<%= process.env.VUE_APP_UMAMI_ID %>"></script>
<% } %>
</body>

</html>
43 changes: 42 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ html,body
display none
.Home
padding-top 1.1rem
padding-top 1.2rem
.com_sel_tabs
position fixed
z-index 1
Expand All @@ -61,4 +61,45 @@ html,body
top 0.3rem
margin-bottom 0
padding 0
@media screen and (min-width: 1280px)
.Home,
.search .tags,
.search .result-list,
.rank-list,
.users .user-tabs .van-tab__pane,
.user-illusts,
#app .related,
#app .Spotlights,
#app .Discovery,
#app .HomeRecommIllust
padding-left 5vw
padding-right 5vw
#app
.nav-container
left unset
right 0
bottom 42px
width 1.2rem
height auto
transform: translateX(100%);
&.showNav
transform: translateX(0);
.nav-bar
flex-direction: column
justify-content: center
align-items: center
padding-top 15px
border-top-left-radius: 0.21333rem;
border-top-right-radius: 0;
border-bottom-left-radius: 0.21333rem;
li
width 100%
margin-bottom 25px
&.nav_to_top
display list-item
.icon
font-size 0.72rem
span
display none
</style>
23 changes: 13 additions & 10 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { get } from './http'
import { LocalStorage, SessionStorage } from '@/utils/storage'
import { getCache, setCache } from '@/utils/siteCache'
import { i18n } from '@/i18n'
import { filterCensoredIllusts } from '@/utils/filter'

const isSupportWebP = (() => {
const elem = document.createElement('canvas')
Expand Down Expand Up @@ -539,7 +540,7 @@ const api = {
}
}

return { status: 0, data: relatedList }
return { status: 0, data: filterCensoredIllusts(relatedList) }
},

async getPopularPreviewNovel(word) {
Expand Down Expand Up @@ -907,7 +908,7 @@ const api = {
}
}

return { status: 0, data: rankList }
return { status: 0, data: filterCensoredIllusts(rankList) }
},

async getWebRankList(mode = 'daily', page = 1, date = dayjs().subtract(2, 'days').format('YYYYMMDD'), content) {
Expand Down Expand Up @@ -936,7 +937,7 @@ const api = {
}
}

return { status: 0, data: rankList }
return { status: 0, data: filterCensoredIllusts(rankList) }
},

async getDiscoveryArtworks(mode = 'all', limit = 60) {
Expand All @@ -959,7 +960,7 @@ const api = {
}
}

return { status: 0, data: list }
return { status: 0, data: filterCensoredIllusts(list) }
},

async getDiscoveryList(mode = 'safe', max = 18, nocache = false) {
Expand All @@ -980,7 +981,7 @@ const api = {
}
}

return { status: 0, data: list }
return { status: 0, data: filterCensoredIllusts(list) }
},

/**
Expand Down Expand Up @@ -1017,7 +1018,7 @@ const api = {
}
}

return { status: 0, data: rankList }
return { status: 0, data: filterCensoredIllusts(rankList) }
},

async getNovelRankList(mode = 'day', page = 1, date = dayjs().subtract(2, 'days').format('YYYY-MM-DD')) {
Expand Down Expand Up @@ -1083,11 +1084,11 @@ const api = {
}
}

return { status: 0, data: searchList }
return { status: 0, data: filterCensoredIllusts(searchList) }
},

async searchNovel(word, page = 1) {
const cacheKey = `searchList_novel_${window.btoa(encodeURI(word))}_${page}`
const cacheKey = `searchList_novel_${word}_${page}`
let searchList = SessionStorage.get(cacheKey)

if (!searchList) {
Expand Down Expand Up @@ -1227,7 +1228,8 @@ const api = {
}
} else {
ugoira = {
zip: imgProxy(res.ugoira_metadata.zip_urls.medium),
// zip: imgProxy(res.ugoira_metadata.zip_urls.medium),
zip: imgProxy(res.ugoira_metadata.zip_urls.medium.replace('_ugoira600x600', '_ugoira1920x1080')),
frames: res.ugoira_metadata.frames,
}
}
Expand Down Expand Up @@ -1298,7 +1300,7 @@ const api = {
}
}

return { status: 0, data: memberArtwork }
return { status: 0, data: filterCensoredIllusts(memberArtwork) }
},

async getMemberNovel(id, page = 1) {
Expand Down Expand Up @@ -1366,6 +1368,7 @@ const api = {
}
}

memberFavorite.illusts = filterCensoredIllusts(memberFavorite.illusts)
return { status: 0, data: memberFavorite }
},

Expand Down
16 changes: 9 additions & 7 deletions src/assets/style/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ html, body
color #fff

.user-wrap,
.illust-wrap
.user-illusts
height auto

.sup_tags .van-tag
Expand All @@ -240,8 +240,6 @@ html, body
border 1px solid #aaa
border-radius: 0.26667rem;

.nav-container
height 1rem
.nav-container .nav-bar
box-shadow 0 0 0.26667rem #555
background rgba(0,0,0,0.8)
Expand All @@ -252,6 +250,8 @@ html, body
color #fff
.icon
display none
span
display inline-block

.com_sel_tab,
.rank .nav a
Expand Down Expand Up @@ -280,8 +280,8 @@ html, body

.search .search-bar-wrap .search-bar,
.search .search-bar-wrap .van-search__content,
.rank .top,
.com_sel_tabs
.search .com_sel_tabs,
.rank .top
background rgba(0,0,0,0.8)
.search-dropdown
background #16161a
Expand All @@ -292,8 +292,10 @@ html, body
.van-cell
background-color: transparent !important

.rank .top .calendar .date
color #fff
.rank .top
left 0
.calendar .date
color #fff

.image-card .meta::before
height 100%
Expand Down
2 changes: 1 addition & 1 deletion src/components/ImageLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
},
computed: {
isMasonry() {
if (this.layout == 'Grid') return true
if (['Masonry', 'Grid'].includes(this.layout)) return true
if (this.layout == 'Justified') return false
return ['Masonry', 'Grid'].includes(this.wfType)
},
Expand Down
12 changes: 11 additions & 1 deletion src/components/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<Icon class="icon" name="setting" index="Setting" :current-index="$route.name" />
<span>{{ $t('nav.setting') }}</span>
</li>
<li v-if="notMobile" class="nav_to_top" @click="scrollToTop()">
<Icon class="icon" name="to_top" />
<span>Top</span>
</li>
</ul>
</div>
</template>
Expand Down Expand Up @@ -87,9 +91,12 @@ export default {
this.notMobile && removeEventListener('scroll', this.scrollFn)
},
methods: {
scrollToTop() {
document.documentElement.scrollTo({ top: 0, behavior: 'smooth' })
},
navigateTo(name, params) {
if (this.$route.name.startsWith(name)) {
document.documentElement.scrollTo({ top: 0, behavior: 'smooth' })
this.scrollToTop()
} else {
this.$router.push({ name, params })
}
Expand All @@ -99,6 +106,9 @@ export default {
</script>
<style lang="stylus" scoped>
.nav_to_top
display none
.nav-container {
position: fixed;
bottom: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/icons/svg/discovery.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/svg/to_top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Vue.use(Vuex)
const settings = LocalStorage.get('PIXIV_SETTING', {
r18: false,
r18g: false,
showAi: false,
ai: false,
})

// if (!document.cookie.includes('nsfw=1')) {
// if (settings.r18) settings.r18 = false
// if (settings.r18g) settings.r18g = false
// }

const blockTags = LocalStorage.get('PXV_B_TAGS', '').split(',').filter(Boolean)
const blockUids = LocalStorage.get('PXV_B_UIDS', '').split(',').filter(Boolean)
export const blockTags = LocalStorage.get('PXV_B_TAGS', '').split(',').filter(Boolean)
export const blockUids = LocalStorage.get('PXV_B_UIDS', '').split(',').filter(Boolean)

export default new Vuex.Store({
state: {
Expand All @@ -42,18 +42,18 @@ export default new Vuex.Store({
}
if (artwork.x_restrict == 1) {
if (artwork.illust_ai_type == 2) {
return !state.SETTING.r18 || !state.SETTING.showAi
return !state.SETTING.r18 || !state.SETTING.ai
}
return !state.SETTING.r18
}
if (artwork.x_restrict == 2) {
if (artwork.illust_ai_type == 2) {
return !state.SETTING.r18g || !state.SETTING.showAi
return !state.SETTING.r18g || !state.SETTING.ai
}
return !state.SETTING.r18g
}
if (artwork.illust_ai_type == 2) {
return !state.SETTING.showAi
return !state.SETTING.ai
}
return false
},
Expand Down
38 changes: 38 additions & 0 deletions src/utils/filter.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
import store, { blockTags, blockUids } from '@/store'

const re1 = /||TIPS|manga|BL/
const re2 = /R-?18|||||loli||BL|/

const blockedUserIds = [24517, 423251, 16776564]
export function filterHomeIllust(e) {
if (e.type == 'manga') return false
if (e.images.length != 1) return false
if (e.illust_ai_type == 2) return false
if (blockedUserIds.includes(+e.author.id)) return false
return !re1.test(JSON.stringify(e.tags))
}

export function filterRecommIllust(e) {
if (e.illust_ai_type == 2) return false
return !re2.test(JSON.stringify(e.tags))
}

export function filterHomeNovel(e) {
if (e.illust_ai_type == 2) return false
return !re2.test(JSON.stringify(e.tags))
}

export function filterCensoredIllust(artwork) {
if (blockUids.length && blockUids.includes(`${artwork?.author?.id}`)) {
return false
}
if (blockTags.length) {
const tags = JSON.stringify(artwork?.tags || [])
if (blockTags.some(e => tags.includes(e))) {
return false
}
}

if (artwork.x_restrict == 1) {
if (artwork.illust_ai_type == 2) {
return store.state.SETTING.r18 && store.state.SETTING.ai
}
return store.state.SETTING.r18
}
if (artwork.x_restrict == 2) {
if (artwork.illust_ai_type == 2) {
return store.state.SETTING.r18g && store.state.SETTING.ai
}
return store.state.SETTING.r18g
}
if (artwork.illust_ai_type == 2) {
return store.state.SETTING.ai
}
return true
}

export function filterCensoredIllusts(list = []) {
return list.filter(filterCensoredIllust)
}
2 changes: 1 addition & 1 deletion src/views/Artwork/components/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default {
axios
.get(zipUrl, {
responseType: 'blob',
timeout: 1000 * 30,
timeout: 1000 * 60,
onDownloadProgress: progress => {
this.progress = progress.loaded / progress.total
},
Expand Down
Loading

0 comments on commit 6fa67ff

Please sign in to comment.