Skip to content

6411 Домнин.Н.М. Лаб.2 Вар.2#105

Open
exxxpm wants to merge 1 commit intoitsecd:mainfrom
exxxpm:main
Open

6411 Домнин.Н.М. Лаб.2 Вар.2#105
exxxpm wants to merge 1 commit intoitsecd:mainfrom
exxxpm:main

Conversation

@exxxpm
Copy link
Copy Markdown

@exxxpm exxxpm commented Apr 6, 2026

No description provided.

@AvtoBBus AvtoBBus self-requested a review April 9, 2026 14:06
Comment on lines +2 to +3
CLIENT_ORIGIN=http://localhost:5173
CLIENT_ORIGINS=http://localhost:5173,http://127.0.0.1:5173,http://localhost:4173,http://127.0.0.1:4173,http://localhost:4174,http://127.0.0.1:4174
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А может просто ['*']?

Comment on lines +3 to +18
function SunIcon() {
return (
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="4.2" />
<path d="M12 2.5v2.7M12 18.8v2.7M21.5 12h-2.7M5.2 12H2.5M18.7 5.3l-1.9 1.9M7.2 16.8l-1.9 1.9M18.7 18.7l-1.9-1.9M7.2 7.2 5.3 5.3" />
</svg>
);
}

function MoonIcon() {
return (
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M16.9 14.8A7.7 7.7 0 0 1 9.2 7.1c0-1.6.5-3.1 1.3-4.4A9 9 0 1 0 21.3 13c-1.3.8-2.8 1.3-4.4 1.3Z" />
</svg>
);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

svg можно вынести в отдельные svg-файлы

import { LoadingBlock } from "./LoadingBlock";
import { StationAutocomplete } from "./StationAutocomplete";

function RouteCard({ segment }) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это отдельная компонента

}

let isCancelled = false;
const timeoutId = window.setTimeout(async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обращаться к setTimeout через windows не обязательно

export function StationMap({ nearbyStations, selectedStation, pickedPoint, onMapPointPick }) {
const mapElementRef = useRef(null);
const mapInstanceRef = useRef(null);
const markersRef = useRef(new VectorSource());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хранить в отдельной переменной даже не слой, а его source не имеет смысла, потому что получить его вообще не трудно

const vectorLayer = mapRef.current?.getAllLayers().find(/* тут функция по которой вы ищете слой*/);
const source = vectorLayer?.getSource(); 

Возможно вы скажете, что это выглядит длиннее и будете правы, однако предположим, что слоёв у нас не 1, а как минимум 10 и получить данные из слоя может понадобиться в любом месте программы. Тогда мы в папочке utils создаём файлик, в котором у нас лежит функция с выше описанным кодом, к примеру вот так

function getSourceFromVectorLayerByName(mapObject, layerName) {
    if (!mapObject) return null;

    const vectorLayer = mapObject.getAllLayers().find(l => l.get('name') === layerName);
    if (!vectorLayer) return null;

    return vectorLayer.getSource(); 
}

И теперь вместо 10 переменных в компоненте с картой мы получаем 1 универсальную функцию, которую можно почти откуда угодно вызвать.

P.S. Если что, чтобы добавить поле name слою нужно сделать

const newLayer = new VectorLayer(/* ... */);
newLayer.set('name', 'my-layer');

import { EmptyState } from "./EmptyState";
import { LoadingBlock } from "./LoadingBlock";

function ScheduleCard({ entry }) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это тоже отдельный компонент

import { StationAutocomplete } from "./StationAutocomplete";
import { StationMap } from "./StationMap";

function FavoriteButton({ active, onClick }) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже отдельный компонент

Comment on lines +1 to +3
export function canUseStorage() {
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше вот так

import { todayDateValue } from "./utils/dates";
import { readStoredValue, writeStoredValue } from "./utils/storage";

const DEFAULT_THEME = "light";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже можно в конфиг

Comment on lines +21 to +23
function openSection(sectionId) {
window.location.hash = sectionId;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так есть якорные ссылки

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants