Skip to content

Commit

Permalink
fix: 1.make.md冲突,不能使用ctrl+o打开文件 2.clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
JuckZ committed Sep 14, 2023
2 parents 309add3 + 13c649c commit fbca009
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/api/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class WeatherResponseForJournal {
this.temp = weather.tempMax;
this.text = weather.textDay;
const air = await getair(locationId, API_KEY);
this.desc = `${city} ${weather.textDay}, ${weather.tempMin}~${weather.tempMax}${air.category} ${
this.desc = `${city} ${weather.textDay}, ${weather.tempMin}~${weather.tempMax}${air?.category} ${
this.windydesc
}${weather.moonPhase.replace(/[\u4e00-\u9fa5]/g, '')}`;
this.icon = weather.iconDay;
Expand Down Expand Up @@ -266,7 +266,6 @@ async function getWWeather(city: string) {

export async function getWeatherDaily(latitude: number, longitude: number): Promise<WeatherResponse | null> {
try {
// now or 3d
const url = `https://devapi.qweather.com/v7/weather/3d?location=${longitude},${latitude}&key=${API_KEY}`;
console.log(url);

Expand Down Expand Up @@ -333,17 +332,17 @@ export async function getCurrentLocation(): Promise<{
* @param apiKey API Key
* @returns
*/
async function getair(locationId, apiKey): Promise<AirResponse | -1> {
async function getair(locationId, apiKey) {
const weatherUrl = `https://devapi.qweather.com/v7/air/now?location=${locationId}&key=${apiKey}`;
const wUrl = new URL(weatherUrl);
const res = await request({
url: wUrl.href,
method: 'GET',
});

const data = JSON.parse(res) as { code: string; now: AirResponse };
const data = JSON.parse(res) as AirResponse;
if (data.code != '200') {
return -1;
return null;
}
const air = data.now;
return air;
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
getRoot(old) {
return function () {
const top = old.call(this);
return top.getRoot === this.getRoot ? top : top.getRoot();
top.getRoot === this.getRoot ? top : top.getRoot();
// bugfix make.md冲突,不能使用ctrl+o打开文件 #bug
return top;
};
},
onResize(old) {
Expand Down

0 comments on commit fbca009

Please sign in to comment.