Добавил гостевой режим, единые shine-ссылки и пометку о нестабильности мнений

This commit is contained in:
AidarKC
2026-05-20 16:14:59 +03:00
parent aa35d87885
commit 21413268f3
46 changed files with 1125 additions and 310 deletions
+73 -77
View File
@@ -1,3 +1,5 @@
import { parseShineRootSegment } from './services/shine-routes.js';
const ROOT_PAGES = ['messages-list', 'channels-list', 'network-view', 'notifications-view', 'profile-view'];
export const PRE_AUTH_PAGES = [
@@ -20,9 +22,7 @@ export function getRoute() {
.replace(/^index\.html$/i, '')
.replace(/^index\.html\//i, '')
.replace(/\/+$/, '');
if (!raw) {
return { pageId: '', params: {} };
}
if (!raw) return { pageId: '', params: {} };
const segments = raw.split('/').filter(Boolean);
const pageId = segments[0] || '';
@@ -36,6 +36,73 @@ export function getRoute() {
}
};
const shineLogin = parseShineRootSegment(pageId);
if (shineLogin) {
const section = decodePart(segments[1] || '').toLowerCase();
if (!section) {
return { pageId: 'user', params: { login: shineLogin, fromPage: 'messages-list', section: 'profile' } };
}
if (section === 'links') {
return { pageId: 'network-view', params: { mode: 'keep-history', login: shineLogin } };
}
if (section === 'channels') {
const sub = decodePart(segments[2] || '').toLowerCase();
if (sub === 'owned') {
return {
pageId: 'channels-list',
params: { mode: 'my', login: shineLogin, scope: 'owned' },
};
}
if (sub === 'following') {
return {
pageId: 'channels-list',
params: { mode: 'feed', login: shineLogin, scope: 'following' },
};
}
return {
pageId: 'channels-list',
params: { mode: 'feed', login: shineLogin, scope: 'all' },
};
}
if (section === 'msg') {
return {
pageId: 'channel-thread-view',
params: {
messageBlockchainName: decodePart(segments[2]),
messageBlockNumber: segments[3] || '',
messageBlockHash: '',
channelOwnerBlockchainName: '',
channelRootBlockNumber: '',
channelRootBlockHash: '',
},
};
}
if (section === 'channel') {
const ownerBlockchainName = decodePart(segments[2] || '');
const channelName = decodePart(segments[3] || '');
const messageBlockNumber = segments[4] || '';
if (ownerBlockchainName && channelName && messageBlockNumber) {
return {
pageId: 'channel-thread-view',
params: {
ownerBlockchainName,
channelName,
messageBlockNumber,
messageBlockHash: '',
messageBlockchainName: '',
channelOwnerBlockchainName: ownerBlockchainName,
channelRootBlockNumber: '',
channelRootBlockHash: '',
},
};
}
return {
pageId: 'channel-view',
params: { ownerBlockchainName, channelName, channelId: '' },
};
}
}
if (pageId === 'chat-view') {
return { pageId, params: { chatId: dynamicId ? decodeURIComponent(dynamicId) : '' } };
}
@@ -55,41 +122,6 @@ export function getRoute() {
return { pageId, params: { channelId: dynamicId || '' } };
}
if (pageId === 'channel') {
// Короткий формат:
// /channel/{ownerBlockchainName}/{channelName}
// /channel/{ownerBlockchainName}/{channelName}/{messageBlockNumber}
const ownerBlockchainName = decodePart(segments[1] || '');
const channelName = decodePart(segments[2] || '');
const messageBlockNumber = segments[3] || '';
if (ownerBlockchainName && channelName && messageBlockNumber) {
return {
pageId: 'channel-thread-view',
params: {
ownerBlockchainName,
channelName,
messageBlockNumber,
messageBlockHash: '',
// поддержка старого контракта страницы треда
messageBlockchainName: '',
channelOwnerBlockchainName: ownerBlockchainName,
channelRootBlockNumber: '',
channelRootBlockHash: '',
},
};
}
return {
pageId: 'channel-view',
params: {
ownerBlockchainName,
channelName,
channelId: '',
},
};
}
if (pageId === 'channel-thread-view') {
return {
pageId,
@@ -104,50 +136,16 @@ export function getRoute() {
};
}
if (pageId === 'm') {
return {
pageId: 'channel-thread-view',
params: {
messageBlockchainName: decodePart(segments[1]),
messageBlockNumber: segments[2] || '',
messageBlockHash: '',
channelOwnerBlockchainName: '',
channelRootBlockNumber: '',
channelRootBlockHash: '',
},
};
}
if (pageId === 'device-session-view') {
return { pageId, params: { sessionId: dynamicId ? decodeURIComponent(dynamicId) : '' } };
}
if (pageId === 'user') {
return {
pageId,
params: {
login: dynamicId ? decodeURIComponent(dynamicId) : '',
fromPage: segments[2] ? decodeURIComponent(segments[2]) : 'messages-list',
},
};
}
if (pageId === 'network-view') {
return {
pageId,
params: {
mode: segments[1] ? decodePart(segments[1]) : '',
},
};
return { pageId, params: { mode: segments[1] ? decodePart(segments[1]) : '' } };
}
if (pageId === 'channels-list') {
return {
pageId,
params: {
mode: segments[1] ? decodePart(segments[1]) : '',
},
};
return { pageId, params: { mode: segments[1] ? decodePart(segments[1]) : '' } };
}
return { pageId, params: {} };
@@ -185,9 +183,7 @@ export function resolveToolbarActive(pageId) {
pageId === 'language-view' ||
pageId === 'app-log-view' ||
pageId === 'pwa-diagnostics-view'
) {
return 'profile-view';
}
) return 'profile-view';
if (pageId === 'chat-view' || pageId === 'contact-search-view') return 'messages-list';
if (pageId === 'channel-view' || pageId === 'channel-thread-view' || pageId === 'add-channel-view' || pageId === 'add-personal-public-chat-view') return 'channels-list';
if (pageId === 'user') return 'messages-list';