Skip to content

Commit

Permalink
fix: geo location city is null
Browse files Browse the repository at this point in the history
  • Loading branch information
mixj93 committed Feb 22, 2021
1 parent 18a0e55 commit 93be00e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

### 下载插件

下载[最新版本](https://github.com/mixj93/uebersicht-weather-widget/releases/latest)的插件压缩包,解压缩下载的文件并把 `weather.jsx` 放到 Übersicht 的插件文件夹中。
查看[最新版本](https://github.com/mixj93/uebersicht-weather-widget/releases/latest),下载插件文件 `weather.jsx`,并放到 Übersicht 的插件文件夹中。

### 配置插件

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Just downloading from [Übersicht's website](http://tracesof.net/uebersicht/).

### Download Widget

Download the widget zip file check out [the latest release](https://github.com/mixj93/uebersicht-weather-widget/releases/latest), unzip the file and put `Weather.jsx` into Übersicht widgets folder.
Check out [the latest release](https://github.com/mixj93/uebersicht-weather-widget/releases/latest), download the widget file `Weather.jsx` and put into Übersicht widgets folder.

### Configure Widget

Expand Down
13 changes: 11 additions & 2 deletions Weather.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,16 @@ const ICON = {
export const command = (dispatch) => {
geolocation.getCurrentPosition(
(geo) => {
const city = geo.address.city
console.log('🚀 ~ command ~ geo', geo)
const { country, state, city } = geo.address
let address
if (city !== '(null)') {
address = city
} else if (state !== '(null)') {
address = state
} else {
address = country
}
const lat = geo.position.coords.latitude
const lon = geo.position.coords.longitude
const proxy = 'http://127.0.0.1:41417'
Expand All @@ -121,7 +130,7 @@ export const command = (dispatch) => {
return dispatch({
type: 'FETCH_SUCCEDED',
data: data,
city: city
city: address
})
})
},
Expand Down
Binary file removed Weather.jsx.zip
Binary file not shown.

0 comments on commit 93be00e

Please sign in to comment.