-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Решение 2х задач по 2му занятию #2
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
import { defineComponent, createApp } from 'vue' | ||
|
||
const App = defineComponent({ | ||
name: 'App', | ||
|
||
setup() { | ||
const getDateLocal = new Date().toLocaleDateString(navigator.language, { dateStyle: 'long' }); | ||
|
||
return { | ||
getDateLocal | ||
} | ||
}, | ||
|
||
template: `<div>Сегодня {{ getDateLocal }}</div>` | ||
}); | ||
|
||
const app = createApp(App); | ||
app.mount('#app'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,91 @@ | ||
import { defineComponent } from 'vue' | ||
import { getWeatherData, WeatherConditionIcons } from './weather.service.ts' | ||
import {defineComponent} from 'vue' | ||
import {getWeatherData, WeatherConditionIcons} from './weather.service.ts' | ||
|
||
function getIconByConditionId(id) { | ||
return WeatherConditionIcons[parseInt(id)] || ''; | ||
} | ||
|
||
function timeToSeconds(time) { | ||
return time.split(':')[0]*60 + time.split(':')[1]*1; | ||
} | ||
|
||
function isDayNow(currientTime, sunriseTime, sunsetTime) { | ||
return timeToSeconds(sunriseTime) < timeToSeconds(currientTime) && timeToSeconds(currientTime) < timeToSeconds(sunsetTime); | ||
} | ||
|
||
Comment on lines
+8
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Строки в формате |
||
function kelvinToCelsius(tempK) { | ||
return (tempK - 273.15).toFixed(1); | ||
} | ||
|
||
function pressureConvert(pressure) { | ||
return Math.round(pressure * 0.75 ); | ||
} | ||
|
||
export default defineComponent({ | ||
name: 'WeatherApp', | ||
|
||
template: ` | ||
<div> | ||
<h1 class="title">Погода в Средиземье</h1> | ||
|
||
<ul class="weather-list unstyled-list"> | ||
<li class="weather-card weather-card--night"> | ||
<div class="weather-alert"> | ||
<span class="weather-alert__icon">⚠️</span> | ||
<span class="weather-alert__description">Королевская метеослужба короля Арагорна II: Предвещается наступление сильного шторма.</span> | ||
</div> | ||
<div> | ||
<h2 class="weather-card__name"> | ||
Гондор | ||
</h2> | ||
<div class="weather-card__time"> | ||
07:17 | ||
</div> | ||
</div> | ||
<div class="weather-conditions"> | ||
<div class="weather-conditions__icon" title="thunderstorm with heavy rain">⛈️</div> | ||
<div class="weather-conditions__temp">15.0 °C</div> | ||
</div> | ||
<div class="weather-details"> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Давление, мм рт. ст.</div> | ||
<div class="weather-details__item-value">754</div> | ||
</div> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Влажность, %</div> | ||
<div class="weather-details__item-value">90</div> | ||
</div> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Облачность, %</div> | ||
<div class="weather-details__item-value">100</div> | ||
</div> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Ветер, м/с</div> | ||
<div class="weather-details__item-value">10.5</div> | ||
</div> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
`, | ||
name: 'WeatherApp', | ||
|
||
setup() { | ||
const weatherData = getWeatherData(); | ||
|
||
return { | ||
weatherData, | ||
isDayNow, | ||
getIconByConditionId, | ||
kelvinToCelsius, | ||
pressureConvert | ||
} | ||
}, | ||
|
||
template: ` | ||
<div> | ||
<h1 class="title">Погода в Средиземье</h1> | ||
|
||
<ul class="weather-list unstyled-list"> | ||
<li | ||
v-for="(weatherItem, index) in weatherData" | ||
:key="index" | ||
class="weather-card" | ||
:class="{'weather-card--night': !isDayNow(weatherItem.current.dt, weatherItem.current.sunrise, weatherItem.current.sunset)}" | ||
> | ||
<div v-if="weatherItem.alert" class="weather-alert"> | ||
<span class="weather-alert__icon">⚠️</span> | ||
<span class="weather-alert__description">{{ weatherItem.alert.sender_name }}: | ||
{{ weatherItem.alert.description }}</span> | ||
</div> | ||
<div> | ||
<h2 class="weather-card__name"> | ||
{{ weatherItem.geographic_name }} | ||
</h2> | ||
<div class="weather-card__time"> | ||
{{ weatherItem.current.dt }} | ||
</div> | ||
</div> | ||
<div class="weather-conditions"> | ||
<div class="weather-conditions__icon" :title="weatherItem.current.weather.description"> | ||
{{ getIconByConditionId(weatherItem.current.weather.id) }} | ||
</div> | ||
<div class="weather-conditions__temp">{{ kelvinToCelsius(weatherItem.current.temp) }} °C</div> | ||
</div> | ||
<div class="weather-details"> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Давление, мм рт. ст.</div> | ||
<div class="weather-details__item-value">{{ pressureConvert(weatherItem.current.pressure) }}</div> | ||
</div> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Влажность, %</div> | ||
<div class="weather-details__item-value">{{ weatherItem.current.humidity }}</div> | ||
</div> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Облачность, %</div> | ||
<div class="weather-details__item-value">{{ weatherItem.current.clouds }}</div> | ||
</div> | ||
<div class="weather-details__item"> | ||
<div class="weather-details__item-label">Ветер, м/с</div> | ||
<div class="weather-details__item-value">{{ weatherItem.current.wind_speed }}</div> | ||
</div> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
`, | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vue сам приводит
undefined
к пустой строке при выводе