Skip to content

Commit e52b2d0

Browse files
committed
适配主题
1 parent a7b2e31 commit e52b2d0

File tree

11 files changed

+92
-86
lines changed

11 files changed

+92
-86
lines changed

public/cn.widgetjs.widgets.hotspot.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,38 @@
156156
}
157157
]
158158
},
159+
{
160+
"name": "cn.widgetjs.widgets.hotspot.bilibili_rcmd",
161+
"title": {
162+
"zh-CN": "B站首页推荐"
163+
},
164+
"description": {
165+
"zh-CN": ""
166+
},
167+
"keywords": [
168+
"recommend"
169+
],
170+
"security": false,
171+
"permissions": [],
172+
"lang": "zh-CN",
173+
"width": 4,
174+
"height": 4,
175+
"maxWidth": 4,
176+
"webviewTag": false,
177+
"maxHeight": 4,
178+
"minWidth": 4,
179+
"minHeight": 4,
180+
"movable": true,
181+
"singleton": false,
182+
"resizable": true,
183+
"path": "/widget/bilibili_rcmd",
184+
"meta": {},
185+
"backgroundThrottling": true,
186+
"previewImage": "修改为组件预览图地址",
187+
"categories": [],
188+
"supportDeployMode": 17,
189+
"routes": []
190+
},
159191
{
160192
"name": "cn.widgetjs.widgets.hotspot.bilibili",
161193
"title": {
@@ -248,4 +280,4 @@
248280
}
249281
],
250282
"pages": []
251-
}
283+
}

public/widget.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,38 @@
156156
}
157157
]
158158
},
159+
{
160+
"name": "cn.widgetjs.widgets.hotspot.bilibili_rcmd",
161+
"title": {
162+
"zh-CN": "B站首页推荐"
163+
},
164+
"description": {
165+
"zh-CN": ""
166+
},
167+
"keywords": [
168+
"recommend"
169+
],
170+
"security": false,
171+
"permissions": [],
172+
"lang": "zh-CN",
173+
"width": 4,
174+
"height": 4,
175+
"maxWidth": 4,
176+
"webviewTag": false,
177+
"maxHeight": 4,
178+
"minWidth": 4,
179+
"minHeight": 4,
180+
"movable": true,
181+
"singleton": false,
182+
"resizable": true,
183+
"path": "/widget/bilibili_rcmd",
184+
"meta": {},
185+
"backgroundThrottling": true,
186+
"previewImage": "修改为组件预览图地址",
187+
"categories": [],
188+
"supportDeployMode": 17,
189+
"routes": []
190+
},
159191
{
160192
"name": "cn.widgetjs.widgets.hotspot.bilibili",
161193
"title": {
@@ -248,4 +280,4 @@
248280
}
249281
],
250282
"pages": []
251-
}
283+
}

src/widget.package.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { WidgetPackage } from '@widget-js/core'
22

33
const widgetPackage = new WidgetPackage({
44
remote: {
5+
hostname: 'widgetjs.cn',
56
entry: 'https://rtugeek.gitee.io/hotspot',
67
hash: true,
78
base: '/hotspot',

src/widgets/bilibili/BilibiliWidget.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async function getHotList() {
4040
<div class="bilibili-header">
4141
<img src="./images/bilibili_tv.png" style="margin-right: 8px" height="18" alt="">
4242
<div class="bilibili-title">
43-
bilibili热搜
43+
Bilibili热搜
4444
</div>
4545
</div>
4646
</template>
@@ -74,7 +74,7 @@ async function getHotList() {
7474
display: flex;
7575
flex-direction: row;
7676
align-items: center;
77-
color: #fff;
77+
color: var(--widget-color);
7878
font-size: 14px;
7979
font-weight: bold;
8080
10.3 KB
Loading
-1.5 KB
Loading

src/widgets/components/HotspotBox.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,29 @@ const { height } = useWindowSize()
1818
<slot name="header" />
1919
</div>
2020
<!-- 60是标题高度,24是组件上下空白的间距 -->
21-
<ElScrollbar :height="height - 60 - 24" :wrap-style="{ backgroundColor: bodyColor, borderRadius: '12px' }">
21+
<ElScrollbar :height="height - 60 - 24" :wrap-style="{ borderRadius: '12px' }">
2222
<div class="hotspot-content">
2323
<slot name="body" />
2424
</div>
2525
</ElScrollbar>
2626
</div>
2727
</template>
2828

29-
<style scoped lang="scss">
29+
<style lang="scss">
3030
.hotspot-box {
3131
width: var(--widget-inner-width);
3232
height: var(--widget-inner-height);
3333
position: absolute;
3434
display: flex;
3535
flex-direction: column;
3636
overflow: hidden;
37+
background-color: var(widget-background-color);
3738
font-family: OPPOSans-Bold, 'Microsoft Yahei', serif;
3839
padding: 16px 16px 16px 16px;
3940
41+
.hotspot-content{
42+
background: color-mix(in srgb, var(--widget-background-color), var(--widget-color) 10%);
43+
}
4044
.hotspot-header {
4145
position: relative;
4246
width: 100%;

src/widgets/components/HotspotItem.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const positionBackgroundColor = computed(() => {
6868
height: inherit;
6969
line-height: inherit;
7070
overflow: hidden;
71+
color: var(--widget-color);
7172
white-space: nowrap;
7273
text-overflow: ellipsis;
7374
cursor: pointer;

src/widgets/douyin/DouyinWidget.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function getHotList() {
4545
<template>
4646
<HotspotBox class="hotspot-box">
4747
<template #header>
48-
<div style="color: white" class="header">
48+
<div class="header">
4949
<svg
5050
t="1678001437744"
5151
class="logo"
@@ -103,7 +103,7 @@ async function getHotList() {
103103
.header {
104104
display: flex;
105105
align-content: center;
106-
106+
color: var(--widget-color);
107107
.logo {
108108
width: 18px;
109109
height: 18px;

src/widgets/douyin/DouyinWidgetView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import DouyinWidget from './DouyinWidget.vue'
44
</script>
55

66
<template>
7-
<WidgetWrapper shadow-color="#383a58">
7+
<WidgetWrapper>
88
<DouyinWidget />
99
</WidgetWrapper>
1010
</template>

src/widgets/zhihu/ZhihuWidget.vue

Lines changed: 13 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,17 @@
22
import axios from 'axios'
33
import type { Ref } from 'vue'
44
import { nextTick, onMounted, ref } from 'vue'
5-
import { slice } from 'lodash'
6-
import dayjs from 'dayjs'
75
import { useIntervalFn } from '@vueuse/core'
86
import type { ZhihuModel } from './model/ZhihuModel'
97
import { ZhihuConvert } from './model/ZhihuModel'
108
import HotspotItem from '@/widgets/components/HotspotItem.vue'
119
import HotspotBox from '@/widgets/components/HotspotBox.vue'
1210
13-
type NavType = 'hot' | 'news'
14-
15-
const activeNav: Ref<NavType> = ref('hot')
16-
1711
const hotList: Ref<ZhihuModel[]> = ref([])
18-
const newsList: Ref<ZhihuModel[]> = ref([])
19-
const viewList: Ref<ZhihuModel[]> = ref([])
2012
2113
onMounted(async () => {
2214
await nextTick()
2315
await getHotList()
24-
await getNews()
25-
const yesterday = dayjs().subtract(1, 'day').format('YYYYMMDD')
26-
getBeforeNews(yesterday)
27-
handleChangeNav(activeNav.value)
2816
})
2917
3018
function getUrl(url: string) {
@@ -37,68 +25,31 @@ const service = axios.create({
3725
timeout: 50000,
3826
})
3927
40-
const newsService = axios.create({
41-
baseURL: 'https://news-at.zhihu.com/',
42-
withCredentials: true,
43-
timeout: 50000,
44-
})
45-
4628
// 知乎热榜
4729
async function getHotList() {
48-
const res = await service.get('/api/v3/feed/topstory/hot-lists/total?limit=30&desktop=true')
30+
const res = await service.get(
31+
'/api/v3/feed/topstory/hot-lists/total?limit=30&desktop=true',
32+
)
4933
const result = ZhihuConvert.hot2Model(res.data.data)
5034
hotList.value = result
5135
}
5236
53-
// 知乎日报
54-
async function getNews() {
55-
const res = await newsService.get('/api/4/stories/latest')
56-
const result = ZhihuConvert.news2Model(res.data.top_stories)
57-
newsList.value = result
58-
}
59-
60-
// 知乎日报-往日
61-
async function getBeforeNews(dateStr: string) {
62-
const res = await newsService.get(`/api/4/stories/before/${dateStr}`)
63-
const result = ZhihuConvert.news2Model(res.data.stories)
64-
newsList.value = newsList.value.concat(result)
65-
}
66-
67-
function handleChangeNav(nav: NavType) {
68-
activeNav.value = nav
69-
if (nav == 'hot') {
70-
viewList.value = slice(Object.assign([], hotList.value), 0, 10)
71-
}
72-
if (nav == 'news') {
73-
viewList.value = slice(Object.assign([], newsList.value), 0, 10)
74-
}
75-
}
76-
7737
useIntervalFn(() => {
7838
getHotList()
79-
getNews()
8039
}, 20 * 60 * 1000)
8140
</script>
8241

8342
<template>
8443
<HotspotBox class="zhihu-box">
8544
<template #header>
8645
<div class="zhihu-header">
87-
<div class="zhihu-logo" />
88-
<div class="zhihu-top-nav">
89-
<span class="hot_text zhihu-nav-item" :class="{ active: activeNav == 'hot' }" @click="handleChangeNav('hot')">热榜</span>
90-
<span
91-
class="news_text zhihu-nav-item"
92-
:class="{ active: activeNav == 'news' }"
93-
@click="handleChangeNav('news')"
94-
>日报</span>
95-
</div>
46+
知乎热榜
9647
<div class="zhihu-liukanshan" />
9748
</div>
9849
</template>
9950
<template #body>
10051
<HotspotItem
101-
v-for="(item, index) in viewList"
52+
v-for="(item, index) in hotList"
10253
:key="index"
10354
:url="getUrl(item.url)"
10455
:title="item.title"
@@ -107,7 +58,9 @@ useIntervalFn(() => {
10758
<template #append>
10859
<div v-if="item.hot" class="zhihu-hot" @click="getUrl(item.url)">
10960
<span class="mgc_fire_fill" />
110-
<span class="zhihu-hot-count">{{ item.hot.replaceAll(' ', '') }}</span>
61+
<span class="zhihu-hot-count">{{
62+
item.hot.replaceAll(" ", "")
63+
}}</span>
11164
</div>
11265
</template>
11366
</HotspotItem>
@@ -120,7 +73,7 @@ useIntervalFn(() => {
12073
display: flex;
12174
flex-direction: column;
12275
overflow: hidden;
123-
font-family: OPPOSans-Bold, 'Microsoft Yahei', serif;
76+
font-family: OPPOSans-Bold, "Microsoft Yahei", serif;
12477
12578
// 顶部
12679
.zhihu-header {
@@ -133,48 +86,31 @@ useIntervalFn(() => {
13386
.zhihu-logo {
13487
width: 35px;
13588
height: 16px;
136-
background-image: url('@/widgets/zhihu/images/logo.svg');
89+
background-image: url("@/widgets/zhihu/images/logo.svg");
13790
background-size: cover;
13891
position: relative;
13992
margin-right: 8px;
14093
14194
&::after {
14295
position: absolute;
143-
content: '';
96+
content: "";
14497
width: 2px;
14598
height: 2px;
146-
background-color: #fff;
99+
background-color: var(--widget-color);
147100
border-radius: 2px;
148101
overflow: hidden;
149102
right: -8px;
150103
bottom: 8px;
151104
}
152105
}
153106
154-
.zhihu-top-nav {
155-
color: #fff;
156-
font-size: 14px;
157-
158-
.zhihu-nav-item {
159-
margin-left: 12px;
160-
cursor: pointer;
161-
}
162-
163-
.active {
164-
border-radius: 1px;
165-
width: 28px;
166-
height: 2px;
167-
border-bottom: 2px solid rgba(255, 244, 183, 1);
168-
}
169-
}
170-
171107
.zhihu-liukanshan {
172108
position: absolute;
173109
bottom: -10px;
174110
right: 20px;
175111
width: 36px;
176112
height: 36px;
177-
background-image: url('@/widgets/zhihu/images/liukanshan.png');
113+
background-image: url("@/widgets/zhihu/images/liukanshan.png");
178114
background-size: cover;
179115
}
180116
}

0 commit comments

Comments
 (0)