Skip to content

Commit 26bb049

Browse files
committed
feat: remove core-js polyfill
1 parent ea12407 commit 26bb049

File tree

5 files changed

+31
-30
lines changed

5 files changed

+31
-30
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"bezier-easing": "^2.1.0",
3131
"compression": "^1.7.4",
3232
"cookie-parser": "^1.4.6",
33-
"core-js": "^3.x",
3433
"dotenv": "^16.4.5",
3534
"emoji-233333": "^0.3.2",
3635
"express": "^4.20.x",

pnpm-lock.yaml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/flow/mobile/item.vue

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
11
<script lang="ts" setup>
22
import { computed } from 'vue'
33
import { LanguageKey } from '/@/language'
4+
import { UNDEFINED } from '/@/constants/value'
45
import { Article, ArticleLangI18n } from '/@/interfaces/article'
56
import { useEnhancer } from '/@/app/enhancer'
67
import { useIdentityStore } from '/@/stores/identity'
78
import { getArticleDetailRoute } from '/@/transforms/route'
89
import { getImgProxyPath, ImgProxyFormat } from '/@/transforms/imgproxy'
910
import { getImgProxyURL, getStaticPath, isOriginalStaticURL } from '/@/transforms/url'
1011
import { isOriginalType, isHybridType, isReprintType } from '/@/transforms/state'
11-
import { openNewWindow } from '/@/utils/opener'
1212
import { numberSplit } from '/@/transforms/text'
1313
1414
const props = defineProps<{
1515
article: Article
1616
}>()
1717
18-
const { router, cdnDomain, gState } = useEnhancer()
18+
const { cdnDomain, gState } = useEnhancer()
1919
const identityStore = useIdentityStore()
2020
const isLiked = computed(() => identityStore.isLikedPage(props.article.id))
2121
const isHybrid = computed(() => isHybridType(props.article.origin))
2222
const isReprint = computed(() => isReprintType(props.article.origin))
2323
const isOriginal = computed(() => isOriginalType(props.article.origin))
24-
25-
const handleClick = () => {
26-
if (gState.userAgent.isWechat) {
27-
router.push(getArticleDetailRoute(props.article.id))
28-
} else {
29-
openNewWindow(getArticleDetailRoute(props.article.id))
30-
}
31-
}
24+
const detailRoutePath = getArticleDetailRoute(props.article.id)
3225
3326
const getThumbnailURL = (url: string, format?: ImgProxyFormat) => {
3427
if (!isOriginalStaticURL(url)) {
3528
return url
3629
}
30+
3731
return getImgProxyURL(
3832
cdnDomain,
3933
getImgProxyPath(getStaticPath(url), {
@@ -48,7 +42,13 @@
4842
</script>
4943

5044
<template>
51-
<div class="article-item" @click="handleClick">
45+
<ulink
46+
class="article-item"
47+
:to="gState.userAgent.isWechat ? detailRoutePath : UNDEFINED"
48+
:href="!gState.userAgent.isWechat ? detailRoutePath : UNDEFINED"
49+
:blank="!gState.userAgent.isWechat"
50+
:external="false"
51+
>
5252
<div class="thumbnail">
5353
<span
5454
class="origin"
@@ -83,9 +83,7 @@
8383
<div class="content">
8484
<div class="body">
8585
<h4 class="title">
86-
<router-link class="link" :title="article.title" :to="getArticleDetailRoute(article.id)">
87-
{{ article.title }}
88-
</router-link>
86+
<span class="text" :title="article.title">{{ article.title }}</span>
8987
<span class="language">
9088
<i18n v-bind="ArticleLangI18n[article.lang]" />
9189
</span>
@@ -111,7 +109,7 @@
111109
</span>
112110
</div>
113111
</div>
114-
</div>
112+
</ulink>
115113
</template>
116114

117115
<style lang="scss" scoped>
@@ -198,8 +196,7 @@
198196
display: flex;
199197
justify-content: space-between;
200198
201-
.link {
202-
text-decoration: none;
199+
.text {
203200
max-width: calc(100% - 3em);
204201
@include text-overflow();
205202
}

src/csr.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
*/
66

77
// polyfills
8-
// e.g. loadmore / lozad component
9-
import 'intersection-observer'
10-
// for Android browsers. e.g. WeChat webview
11-
import 'core-js/modules/web.url.can-parse'
8+
import './polyfills'
129

1310
import * as Sentry from '@sentry/vue'
1411
import { computed, watch } from 'vue'

src/polyfills/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// For loadmore / lozad components
2+
import 'intersection-observer'
3+
4+
// For Android browsers. e.g. WeChat webview
5+
// MDN: https://developer.mozilla.org/en-US/docs/Web/API/URL/canParse_static
6+
// Fork from: https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/web.url.can-parse.js
7+
if (!URL.canParse) {
8+
URL.canParse = function (url: string, base?: string) {
9+
if (!url) throw new TypeError('Not enough arguments')
10+
try {
11+
return !!new URL(String(url), base ? String(base) : void 0)
12+
} catch (error) {
13+
return false
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)