Skip to content

Commit e601eb0

Browse files
committed
refactor: refactor the header of popup page
1 parent e357bfe commit e601eb0

File tree

12 files changed

+116
-147
lines changed

12 files changed

+116
-147
lines changed

src/i18n/message/popup/header-resource.json

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,47 @@
11
{
22
"en": {
3-
"rate": "Rate Us",
3+
"rating": "Submit rating",
44
"showSiteName": "Display site name",
55
"showTopN": "Display top {n}",
66
"donutChart": "Displayed as donut charts"
77
},
88
"zh_CN": {
9-
"rate": "评分",
109
"showSiteName": "显示网站名称",
1110
"showTopN": "显示前 {n} 名",
1211
"donutChart": "以圆环图显示"
1312
},
1413
"zh_TW": {
15-
"rate": "評分",
1614
"showSiteName": "顯示網站名稱",
1715
"showTopN": "顯示前{n}个"
1816
},
1917
"ja": {
20-
"rate": "評価する",
2118
"showSiteName": "サイト名を表示",
2219
"showTopN": "トップ {n} を表示"
2320
},
2421
"pt_PT": {
25-
"rate": "Avaliar",
2622
"showSiteName": "Mostrar nome do site",
2723
"donutChart": "Mostrado como gráfico estilo donut"
2824
},
29-
"uk": {
30-
"rate": "Оцінити"
31-
},
25+
"uk": {},
3226
"es": {
33-
"rate": "Calificar",
3427
"showSiteName": "Mostrar nombre del sitio",
3528
"showTopN": "Mostrar primeros {n}"
3629
},
3730
"de": {
38-
"rate": "Bewerten",
3931
"showSiteName": "Seitenname anzeigen",
4032
"showTopN": "Top {n} anzeigen"
4133
},
4234
"fr": {
43-
"rate": "Évaluez-nous",
4435
"showSiteName": "Afficher le nom du site",
4536
"showTopN": "Afficher les {n} premiers",
4637
"donutChart": "Affichés sous forme de graphiques en anneau"
4738
},
4839
"ru": {
49-
"rate": "Оценить",
5040
"showSiteName": "Отобразить имя сайта",
5141
"showTopN": "Отображать заголовок {n}"
5242
},
53-
"ar": {
54-
"rate": "قيمنا"
55-
},
43+
"ar": {},
5644
"tr": {
57-
"rate": "Bizi Değerlendirin",
5845
"showSiteName": "Site adını göster",
5946
"showTopN": "En iyi {n} göster",
6047
"donutChart": "Halka grafik olarak göster"

src/i18n/message/popup/header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import resource from './header-resource.json'
99

1010
export type HeaderMessage = {
11+
rating: string
1112
donutChart: string
12-
rate: string
1313
showSiteName: string
1414
showTopN: string
1515
}

src/pages/app/components/About/Description.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { css } from '@emotion/css'
33
import { MediaSize, useMediaSize } from "@hooks"
44
import { locale } from "@i18n"
55
import Flex from "@pages/components/Flex"
6-
import { CoffeeIcon } from '@pages/util/icon'
6+
import { Coffee, GitHub } from '@pages/util/icon'
77
import { saveFlag } from "@service/meta-service"
88
import packageInfo, { AUTHOR_EMAIL } from "@src/package"
99
import {
@@ -22,7 +22,7 @@ import {
2222
import { type ComponentSize, ElCard, ElDescriptions, ElDescriptionsItem, ElDivider, ElText, useNamespace } from "element-plus"
2323
import { computed, defineComponent, reactive } from "vue"
2424
import DescLink from "./DescLink"
25-
import { Chrome, Echarts, Edge, ElementPlus, Firefox, GitHub, Vue } from './Icon'
25+
import { Chrome, Echarts, Edge, ElementPlus, Firefox, Vue } from './Icon'
2626
import InstallationLink from "./InstallationLink"
2727

2828
const useStyle = () => {
@@ -155,7 +155,7 @@ const _default = defineComponent<{}>(() => {
155155
</ElDescriptionsItem>
156156
{locale !== 'zh_CN' && (
157157
<ElDescriptionsItem label='Buy me a coffee' labelAlign="right">
158-
<DescLink icon={CoffeeIcon} href={BUY_ME_A_COFFEE_PAGE}>{BUY_ME_A_COFFEE_PAGE}</DescLink>
158+
<DescLink icon={<Coffee />} href={BUY_ME_A_COFFEE_PAGE}>{BUY_ME_A_COFFEE_PAGE}</DescLink>
159159
</ElDescriptionsItem>
160160
)}
161161
</ElDescriptions>

src/pages/app/components/About/Icon.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ export const Firefox: FunctionalComponent<{}> = () => (
140140
</svg>
141141
)
142142

143-
export const GitHub: FunctionalComponent<{}> = () => (
144-
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
145-
<path d='M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z' />
146-
</svg>
147-
)
148-
149143
export const Vue: FunctionalComponent<{}> = () => (
150144
<svg viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'>
151145
<path d='M615.6 123.6h165.5L512 589.7 242.9 123.6H63.5L512 900.4l448.5-776.9z' fill='#41B883' />

src/pages/popup/components/Header/Coffee.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/pages/popup/components/Header/Github.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { createTab } from "@api/chrome/tab"
2+
import { Collection, MoreFilled } from '@element-plus/icons-vue'
3+
import { locale } from '@i18n'
4+
import Flex from '@pages/components/Flex'
5+
import { Coffee, GitHub, Heart } from '@pages/util/icon'
6+
import { getColor, type ColorVariant } from '@pages/util/style'
7+
import { t } from '@popup/locale'
8+
import { saveFlag } from "@service/meta-service"
9+
import { BUY_ME_A_COFFEE_PAGE, CHANGE_LOG_PAGE, DONATION_PAGE, REVIEW_PAGE, SOURCE_CODE_PAGE } from "@util/constant/url"
10+
import { ElDropdown, ElDropdownItem, ElDropdownMenu, ElIcon } from "element-plus"
11+
import { defineComponent, type StyleValue } from "vue"
12+
import { type JSX } from 'vue/jsx-runtime'
13+
14+
type Command = 'rate' | 'coffee' | 'donation' | 'github' | 'changelog'
15+
16+
type ItemLinkProps = {
17+
icon: JSX.Element
18+
text: string
19+
iconColor?: ColorVariant
20+
}
21+
const ItemLink = ({ icon, text, iconColor }: ItemLinkProps) => (
22+
<Flex gap={2} align='center'>
23+
<ElIcon color={iconColor ? getColor(iconColor) : undefined}>{icon}</ElIcon>
24+
{text}
25+
</Flex>
26+
)
27+
28+
const MoreInfo = defineComponent<{}>(() => {
29+
const handleCmd = async (cmd: Command) => {
30+
if (cmd === 'rate') {
31+
await saveFlag("rateOpen")
32+
createTab(REVIEW_PAGE)
33+
} else if (cmd === 'coffee') {
34+
createTab(BUY_ME_A_COFFEE_PAGE)
35+
} else if (cmd === 'github') {
36+
createTab(SOURCE_CODE_PAGE)
37+
} else if (cmd === 'changelog') {
38+
createTab(CHANGE_LOG_PAGE)
39+
} else if (cmd === 'donation') {
40+
createTab(DONATION_PAGE)
41+
}
42+
}
43+
44+
return () => (
45+
<ElDropdown
46+
size='small'
47+
trigger='click'
48+
onCommand={handleCmd}
49+
style={{ cursor: 'pointer' } satisfies StyleValue}
50+
v-slots={{
51+
default: () => <ElIcon><MoreFilled /></ElIcon>,
52+
dropdown: () => (
53+
<ElDropdownMenu>
54+
<ElDropdownItem command={'github' satisfies Command}>
55+
<ItemLink icon={<GitHub />} text={t(msg => msg.base.sourceCode)} />
56+
</ElDropdownItem>
57+
<ElDropdownItem command={'changelog' satisfies Command}>
58+
<ItemLink icon={<Collection />} text={t(msg => msg.base.changeLog)} />
59+
</ElDropdownItem>
60+
<ElDropdownItem command={'rate' satisfies Command} divided>
61+
<ItemLink icon={<Heart />} text={t(msg => msg.header.rating)} iconColor="danger" />
62+
</ElDropdownItem>
63+
{locale === 'zh_CN' ? (
64+
<ElDropdownItem command={'donation' satisfies Command}>
65+
<ItemLink icon={<Coffee />} text="请他喝杯咖啡~" iconColor="warning" />
66+
</ElDropdownItem>
67+
) : (
68+
<ElDropdownItem command={'coffee' satisfies Command}>
69+
<ItemLink icon={<Coffee />} text="Buy me a coffee" iconColor="warning" />
70+
</ElDropdownItem>
71+
)}
72+
</ElDropdownMenu >
73+
)
74+
}}>
75+
</ElDropdown >
76+
)
77+
})
78+
79+
export default MoreInfo

src/pages/popup/components/Header/RateUs.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/pages/popup/components/Header/index.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import { IS_ANDROID } from "@util/constant/environment"
77
import { getAppPageUrl } from "@util/constant/url"
88
import { ElLink } from "element-plus"
99
import { FunctionalComponent } from "vue"
10-
import Coffee from './Coffee'
1110
import DarkSwitch from "./DarkSwitch"
12-
import Github from "./Github"
1311
import Logo from "./Logo"
12+
import MoreInfo from './MoreInfo'
1413
import Option from "./Option"
15-
import RateUs from './RateUs'
1614

1715
const openAppPage = async () => {
1816
const appPageUrl = getAppPageUrl()
@@ -33,22 +31,16 @@ const openAppPage = async () => {
3331

3432
const Header: FunctionalComponent = () => (
3533
<Flex justify="space-between" padding='0 10px' color='text-primary'>
36-
<Flex gap={4}>
37-
<Logo />
38-
<Coffee />
39-
</Flex>
34+
<Logo />
4035
<Flex gap={10}>
41-
<Flex gap={10}>
42-
<RateUs />
43-
<ElLink underline="never" onClick={openAppPage} icon={View} style={{ gap: '3px' }}>
44-
{t(msg => msg.base.allFunction)}
45-
</ElLink>
46-
</Flex>
36+
<ElLink underline="never" onClick={openAppPage} icon={View} style={{ gap: '3px' }}>
37+
{t(msg => msg.base.allFunction)}
38+
</ElLink>
4739
<Flex align="center" gap={8} fontSize={30}>
4840
<LangSelect />
4941
<DarkSwitch />
5042
<Option />
51-
<Github />
43+
<MoreInfo />
5244
</Flex>
5345
</Flex>
5446
</Flex>

src/pages/util/icon.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
export const CoffeeIcon = (
1+
import { type FunctionalComponent } from 'vue'
2+
3+
export const Coffee: FunctionalComponent<{}> = () => (
24
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
35
<path d="M742.954667 682.666667H554.666667a42.666667 42.666667 0 0 1 0-85.333334h195.413333l14.208-170.666666H259.712l29.013333 348.416A85.333333 85.333333 0 0 0 373.76 853.333333h276.48a85.333333 85.333333 0 0 0 85.034667-78.250666l7.68-92.416z m67.2-341.333334H853.333333V256h-122.965333a119.850667 119.850667 0 0 1-107.178667-66.261333 34.517333 34.517333 0 0 0-30.890666-19.072h-160.597334a34.517333 34.517333 0 0 0-30.890666 19.072A119.850667 119.850667 0 0 1 293.632 256H170.666667v85.333333H810.154667z m39.765333 85.333334l-29.610667 355.498666A170.666667 170.666667 0 0 1 650.24 938.666667H373.76a170.666667 170.666667 0 0 1-170.069333-156.501334L174.08 426.666667H170.666667a85.333333 85.333333 0 0 1-85.333334-85.333334V256a85.333333 85.333333 0 0 1 85.333334-85.333333h122.965333a34.517333 34.517333 0 0 0 30.890667-19.072A119.850667 119.850667 0 0 1 431.701333 85.333333h160.597334c45.397333 0 86.912 25.642667 107.178666 66.261334a34.517333 34.517333 0 0 0 30.890667 19.072H853.333333a85.333333 85.333333 0 0 1 85.333334 85.333333v85.333333a85.333333 85.333333 0 0 1-85.333334 85.333334h-3.413333z"></path>
46
</svg>
7+
)
8+
9+
export const GitHub: FunctionalComponent<{}> = () => (
10+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
11+
<path d='M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z' />
12+
</svg>
13+
)
14+
15+
export const Heart: FunctionalComponent<{}> = () => (
16+
<svg viewBox="0 0 1024 1024">
17+
<path d="M1000 248Q976.992 192 933.984 148.992 849.984 64 732.992 64q-64 0-121.504 28T512 171.008q-42.016-51.008-99.488-79.008T291.008 64Q174.016 64 90.016 150.016 47.008 193.024 24 249.024-0.992 308.032 0 371.04q0.992 68.992 28.992 130.496t79.008 104.512q4.992 4 8.992 8 14.016 12 112.992 102.016 208 191.008 256.992 235.008 11.008 8.992 24.992 8.992t24.992-8.992q32.992-30.016 180.992-164.992 158.016-144 196-179.008 52-43.008 80.992-104.992t28.992-132q0-64-24-122.016z" />
18+
</svg >
519
)

0 commit comments

Comments
 (0)