Skip to content

Commit

Permalink
feat: v4.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Aug 11, 2023
1 parent 9a7d754 commit 001edd0
Show file tree
Hide file tree
Showing 48 changed files with 80 additions and 48 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "surmon.me",
"version": "4.15.3",
"version": "4.16.0",
"description": "Surmon.me blog",
"author": "Surmon",
"license": "MIT",
Expand Down
Binary file added public/images/og-social-card.webp
Binary file not shown.
Binary file removed public/images/page-about/banner-mobile.jpg
Binary file not shown.
Binary file added public/images/page-about/banner-mobile.webp
Binary file not shown.
Binary file removed public/images/page-about/banner.jpg
Binary file not shown.
Binary file added public/images/page-about/banner.webp
Binary file not shown.
Binary file removed public/images/page-app/hot.png
Binary file not shown.
Binary file modified public/images/page-app/hot.webp
Binary file not shown.
Binary file modified public/images/page-feeelancer/banner-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/page-feeelancer/banner-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/page-feeelancer/banner-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/page-feeelancer/banner-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/page-feeelancer/banner.jpg
Binary file not shown.
Binary file modified public/images/page-merch/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/page-merch/banner.webp
Binary file not shown.
Binary file removed public/images/page-nft/banner.jpg
Binary file not shown.
Binary file removed public/images/page-nft/banner.webp
Binary file not shown.
Binary file removed public/images/qrcodes/douban.png
Binary file not shown.
Binary file added public/images/qrcodes/douban.webp
Binary file not shown.
Binary file removed public/images/qrcodes/instagram.png
Binary file not shown.
Binary file added public/images/qrcodes/instagram.webp
Binary file not shown.
Binary file removed public/images/qrcodes/wechat-channel.png
Binary file not shown.
Binary file added public/images/qrcodes/wechat-channel.webp
Binary file not shown.
Binary file removed public/images/qrcodes/wechat.jpg
Binary file not shown.
Binary file added public/images/qrcodes/wechat.webp
Binary file not shown.
Binary file removed public/images/qrcodes/youtube.png
Binary file not shown.
Binary file added public/images/qrcodes/youtube.webp
Binary file not shown.
Binary file removed public/images/third-party/alipay-qrcode.png
Binary file not shown.
Binary file added public/images/third-party/alipay-qrcode.webp
Binary file not shown.
Binary file removed public/images/third-party/btc-qrcode.png
Binary file not shown.
Binary file added public/images/third-party/btc-qrcode.webp
Binary file not shown.
Binary file removed public/images/third-party/eth-qrcode.png
Binary file not shown.
Binary file added public/images/third-party/eth-qrcode.webp
Binary file not shown.
Binary file removed public/images/third-party/paypal-qrcode.png
Binary file not shown.
Binary file added public/images/third-party/paypal-qrcode.webp
Binary file not shown.
Binary file removed public/images/third-party/wechat-pay-qrcode.jpg
Binary file not shown.
Binary file added public/images/third-party/wechat-pay-qrcode.webp
Binary file not shown.
Binary file added public/images/thumbnail/carrousel.webp
Binary file not shown.
19 changes: 0 additions & 19 deletions src/app/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export interface RenderError {
message: string
}

export enum ImageExt {
WebP = 'webp',
Jpg = 'jpeg'
}

export enum LayoutColumn {
Normal = 0,
Wide = 1, // 3 column
Expand Down Expand Up @@ -102,19 +97,6 @@ export const createGlobalState = (config: GlobalStateConfig) => {
}
}

// MARK: Using `jpg` format on mobile/WeChat/Safari
const imageExt = computed(() => {
const imageExtValue =
userAgent.isMobile && (userAgent.isWechat || userAgent.isSafari)
? (ImageExt.Jpg as ImageExt)
: (ImageExt.WebP as ImageExt)
return {
ext: imageExtValue,
isJpg: imageExtValue === ImageExt.Jpg,
isWebP: imageExtValue === ImageExt.WebP
}
})

// Global switchers
const switcher = reactive({
sponsor: false,
Expand Down Expand Up @@ -146,7 +128,6 @@ export const createGlobalState = (config: GlobalStateConfig) => {
setLayoutColumn,
// Device state
userAgent: readonly(userAgent),
imageExt,
// Global switchers
switcher: readonly(switcher),
toggleSwitcher
Expand Down
5 changes: 2 additions & 3 deletions src/components/flow/desktop/item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
article: Article
}>()
const { gState, cdnDomain } = useEnhancer()
const { cdnDomain } = useEnhancer()
const identity = useIdentityStore()
const isLiked = computed(() => identity.isLikedPage(props.article.id))
const isHybrid = computed(() => isHybridType(props.article.origin))
Expand All @@ -37,8 +37,7 @@
cdnDomain,
getImgProxyPath(url.replace(API_CONFIG.STATIC, ''), {
width: 350,
height: 238,
webp: gState.imageExt.value.isWebP
height: 238
})
)
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/flow/mobile/item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
article: Article
}>()
const { router, gState, cdnDomain } = useEnhancer()
const { router, cdnDomain } = useEnhancer()
const identityStore = useIdentityStore()
const isLiked = computed(() => identityStore.isLikedPage(props.article.id))
const isHybrid = computed(() => isHybridType(props.article.origin))
Expand All @@ -38,7 +38,6 @@
getImgProxyPath(url.replace(API_CONFIG.STATIC, ''), {
width: 700,
height: 247,
webp: gState.imageExt.value.isWebP,
watermark: `watermark:0.38:sowe:18:16:0.16`
})
)
Expand Down
10 changes: 5 additions & 5 deletions src/components/widget/sponsor/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ export const PROVIDERS = [
title: 'PayPal me',
link: VALUABLE_LINKS.PAYPAL,
logo: '/images/third-party/paypal-logo.svg',
qrcode: '/images/third-party/paypal-qrcode.png'
qrcode: '/images/third-party/paypal-qrcode.webp'
},
{
id: ProviderId.Alipay,
title: '支付宝',
text: '通过支付宝客户端扫码',
logo: '/images/third-party/alipay-logo.svg',
qrcode: '/images/third-party/alipay-qrcode.png'
qrcode: '/images/third-party/alipay-qrcode.webp'
},
{
id: ProviderId.WeChatPay,
title: '微信赞赏',
text: '通过微信客户端扫码',
logo: '/images/third-party/wechat-pay-logo.svg',
qrcode: '/images/third-party/wechat-pay-qrcode.jpg'
qrcode: '/images/third-party/wechat-pay-qrcode.webp'
},
{
id: ProviderId.BitCoin,
title: 'BTC',
address: IDENTITIES.BTC_ADDRESS,
logo: '/images/third-party/btc-logo.svg',
qrcode: '/images/third-party/btc-qrcode.png'
qrcode: '/images/third-party/btc-qrcode.webp'
},
{
id: ProviderId.Ethereum,
title: 'ETH',
address: IDENTITIES.ETH_ADDRESS,
logo: '/images/third-party/eth-logo.svg',
qrcode: '/images/third-party/eth-qrcode.png'
qrcode: '/images/third-party/eth-qrcode.webp'
}
]

Expand Down
42 changes: 36 additions & 6 deletions src/pages/about/desktop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@
}
const modalState = reactive({
wechat: false
wechat: false,
wechatChannel: false
})
const handleOpenWechat = () => {
modalState.wechat = true
handleGTagEvent('wechat_modal')
}
const handleOpenWechatChannel = () => {
modalState.wechatChannel = true
handleGTagEvent('wechat_channel_modal')
}
const handleSponsor = () => {
sponsor.fetch()
gState.toggleSwitcher('sponsor', true)
Expand Down Expand Up @@ -157,12 +163,11 @@
<i class="iconfont icon-instagram" />
<span class="text">Instagram</span>
</ulink>
</span>
<span class="mini">
<ulink class="item youtube" :href="VALUABLE_LINKS.YOUTUBE_CHANNEL">
<i class="iconfont icon-youtube" />
<span class="text">YouTube</span>
</ulink>
</span>
<span class="mini">
<ulink class="item telegram" :href="VALUABLE_LINKS.TELEGRAM">
<i class="iconfont icon-telegram" />
</ulink>
Expand All @@ -172,7 +177,7 @@
<popup v-model:visible="modalState.wechat" :scroll-close="false">
<div class="qrcode-modal wechat">
<div class="background"></div>
<uimage class="image" cdn src="/images/qrcodes/wechat.jpg" />
<uimage class="image" cdn src="/images/qrcodes/wechat.webp" />
<span class="text">
👋 &nbsp;
<i18n en="Friend me on WeChat" zh="扫码加微,解锁灵魂"></i18n>
Expand All @@ -181,6 +186,20 @@
</popup>
</client-only>
</button>
<button class="item wechat-channel" @click="handleOpenWechatChannel">
<i class="iconfont icon-wechat-channel" />
<client-only>
<popup v-model:visible="modalState.wechatChannel" :scroll-close="false">
<div class="qrcode-modal wechat-channel">
<div class="background"></div>
<uimage class="image" cdn src="/images/qrcodes/wechat-channel.webp" />
<span class="text">
<i18n en="Follow me on WeChat Channel" zh="扫一扫,关注我的微信视频号"></i18n>
</span>
</div>
</popup>
</client-only>
</button>
<ulink class="item linkedin" :href="VALUABLE_LINKS.LINKEDIN">
<i class="iconfont icon-linkedin" />
</ulink>
Expand Down Expand Up @@ -270,6 +289,9 @@
&.wechat {
--item-primary: #{$wechat-primary};
}
&.wechat-channel {
--item-primary: #{$wechat-channel-primary};
}
.background {
position: absolute;
Expand Down Expand Up @@ -409,6 +431,9 @@
border-radius: $sm-radius;
color: $white;
transition: all $transition-time-fast;
&:last-child {
margin: 0;
}
.iconfont {
font-size: $font-size-h4;
Expand All @@ -432,7 +457,6 @@
}
}
&.youtube {
margin: 0;
background-color: $youtube-primary;
&:hover {
background-color: mix($black, $youtube-primary, 8%);
Expand Down Expand Up @@ -475,6 +499,12 @@
&.wechat {
background-color: $wechat-primary;
}
&.wechat-channel {
background-color: $wechat-channel-primary;
}
&.youtube {
background-color: $youtube-primary;
}
&.telegram {
background-color: $telegram-primary;
}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/about/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<template>
<div class="about-page">
<page-banner :is-mobile="true" image="/images/page-about/banner-mobile.jpg" :image-position="70" cdn>
<page-banner :is-mobile="true" image="/images/page-about/banner-mobile.webp" :image-position="70" cdn>
<template #title>
<i18n :k="LanguageKey.PAGE_ABOUT" />
</template>
Expand Down Expand Up @@ -91,10 +91,10 @@
</div>
<div class="qrcodes">
<div class="item">
<uimage cdn class="image" src="/images/qrcodes/wechat.jpg" />
<uimage cdn class="image" src="/images/qrcodes/wechat.webp" />
</div>
<div class="item">
<uimage cdn class="image" src="/images/qrcodes/wechat-channel.png" />
<uimage cdn class="image" src="/images/qrcodes/wechat-channel.webp" />
</div>
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/article/related.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
count: 8
})
const { gState, cdnDomain } = useEnhancer()
const { cdnDomain } = useEnhancer()
const getThumbnailURL = (url?: string) => {
if (!url) {
return ''
Expand All @@ -31,8 +31,7 @@
cdnDomain,
getImgProxyPath(url.replace(API_CONFIG.STATIC, ''), {
width: 466,
height: 168,
webp: gState.imageExt.value.isWebP
height: 168
})
)
}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/index/carrousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
count: 9
})
const { gState, adConfig, cdnDomain, isDarkTheme } = useEnhancer()
const { adConfig, cdnDomain, isDarkTheme } = useEnhancer()
const getThumbnailURL = (url?: string) => {
if (!url) {
return getAssetURL(cdnDomain, '/images/thumbnail/carrousel.jpg')
Expand All @@ -40,7 +40,6 @@
getImgProxyPath(url.replace(API_CONFIG.STATIC, ''), {
width: 1190,
height: 420,
webp: gState.imageExt.value.isWebP,
watermark: `watermark:0.36:sowe:18:18:0.15`
})
)
Expand Down
6 changes: 2 additions & 4 deletions src/transforms/imgproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@

import { normalizePath } from '/@/transforms/url'

// AVIF/WebP: https://docs.imgproxy.net/configuration?id=avifwebp-support-detection
// format: https://docs.imgproxy.net/image_formats_support
// resize: https://docs.imgproxy.net/generating_the_url?id=resize
// watermark: https://docs.imgproxy.net/generating_the_url?id=watermark
const WebPFormat = `@webp`

export interface ImgProxyOptions {
width: number
height: number
watermark?: string
webp?: boolean
}

export const getImgProxyPath = (path: string, options: ImgProxyOptions) => {
const resize = `resize:fill:${options.width}:${options.height}:0`
const format = options.webp ? WebPFormat : ''
const watermark = options.watermark ? `/${options.watermark}` : ''
return `/${resize}${watermark}/plain${normalizePath(path)}${format}`
return `/${resize}${watermark}/plain${normalizePath(path)}`
}
27 changes: 27 additions & 0 deletions src/utils/webp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file WebP Checker
* @module util.webp
* @author Surmon <https://github.com/surmon-china>
* @link https://developers.google.com/speed/webp/faq?hl=zh-cn
*/

// check_webp_feature:
// 'feature' can be one of 'lossy', 'lossless', 'alpha' or 'animation'.
// 'callback(feature, result)' will be passed back the detection result (in an asynchronous way!)
export const checkWebPFeature = (feature: 'lossy' | 'lossless' | 'alpha' | 'animation', callback) => {
const kTestImages = {
lossy: `UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA`,
lossless: `UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==`,
alpha: `UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==`,
animation: `UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA`
}
const img = new Image()
img.onload = function () {
const result = img.width > 0 && img.height > 0
callback(feature, result)
}
img.onerror = function () {
callback(feature, false)
}
img.src = 'data:image/webp;base64,' + kTestImages[feature]
}

0 comments on commit 001edd0

Please sign in to comment.