rebuild(audit): complete entity detail and market preview
This commit is contained in:
@@ -56,6 +56,33 @@ export type ChartSeries = {
|
||||
points: ChartPoint[];
|
||||
};
|
||||
|
||||
export type EntityMetric = { key: string; label: string; value: number | null; unit: string };
|
||||
export type EntityDetail = {
|
||||
entity: MarketEntity;
|
||||
trade_date: string;
|
||||
observed_at: string;
|
||||
price: number;
|
||||
previous_close: number | null;
|
||||
change: number | null;
|
||||
metrics: EntityMetric[];
|
||||
money_flow: {
|
||||
available: boolean;
|
||||
net_million: number | null;
|
||||
large_million: number | null;
|
||||
net_5d_million: number | null;
|
||||
flow_to_circ_mv_5d: number | null;
|
||||
} | null;
|
||||
event: {
|
||||
status: string;
|
||||
reason: string;
|
||||
streak: number | null;
|
||||
first_time: string | null;
|
||||
last_time: string | null;
|
||||
open_times: number | null;
|
||||
seal_amount: number | null;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type MarketWorkspaceData = {
|
||||
trade_date: string | null;
|
||||
observed_at?: string;
|
||||
@@ -125,6 +152,11 @@ export const marketApi = {
|
||||
const identifier = encodeURIComponent(entity.identifier);
|
||||
return api.get<ChartSeries>(`/market/entities/${type}/${identifier}/charts/${interval}`);
|
||||
},
|
||||
detail(entity: MarketEntity, date: string): Promise<EntityDetail> {
|
||||
const type = encodeURIComponent(entity.entity_type);
|
||||
const identifier = encodeURIComponent(entity.identifier);
|
||||
return api.get<EntityDetail>(`/market/entities/${type}/${identifier}/detail?date=${encodeURIComponent(date)}`);
|
||||
},
|
||||
workspace(key: string, date: string): Promise<MarketWorkspaceData> {
|
||||
return api.get<MarketWorkspaceData>(
|
||||
`/market/workspaces/${encodeURIComponent(key)}?date=${encodeURIComponent(date)}`,
|
||||
|
||||
@@ -67,6 +67,7 @@ export type ScreenerWorkspace = {
|
||||
};
|
||||
export type StrategyTrack = {
|
||||
id: number;
|
||||
identifier: string;
|
||||
code: string;
|
||||
name: string;
|
||||
sector: string;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import MarketEntityLink from "../market/MarketEntityLink.vue";
|
||||
|
||||
type TableColumn = {
|
||||
key: string;
|
||||
label: string;
|
||||
@@ -9,12 +11,13 @@ type TableColumn = {
|
||||
format?: (value: unknown, row: Record<string, unknown>) => string;
|
||||
};
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
columns: TableColumn[];
|
||||
rows: Record<string, unknown>[];
|
||||
sortKey: string;
|
||||
sortDirection: "asc" | "desc";
|
||||
}>();
|
||||
entityType?: "stock" | "sector" | "theme" | "index";
|
||||
}>(), { entityType: "stock" });
|
||||
const emit = defineEmits<{ sort: [key: string] }>();
|
||||
|
||||
function ariaSort(key: string, sortable?: boolean): "ascending" | "descending" | "none" | undefined {
|
||||
@@ -42,7 +45,12 @@ function ariaSort(key: string, sortable?: boolean): "ascending" | "descending" |
|
||||
<tr v-for="(row, index) in rows" :key="String(row.identifier ?? index)">
|
||||
<td class="index-column numeric">{{ index + 1 }}</td>
|
||||
<td v-for="column in columns" :key="column.key" :data-label="column.label" :class="{ numeric: column.numeric, 'wide-column': column.wide, 'code-column': column.code, up: column.key.includes('change') && Number(row[column.key]) > 0, down: column.key.includes('change') && Number(row[column.key]) < 0 }">
|
||||
{{ column.format ? column.format(row[column.key], row) : (row[column.key] ?? "") }}
|
||||
<MarketEntityLink
|
||||
v-if="column.code && row.identifier && row.code && row.name"
|
||||
:entity="{ entity_type: entityType, identifier: String(row.identifier), code: String(row.code), name: String(row.name), sector: row.sector ? String(row.sector) : null }"
|
||||
:label="String(column.format ? column.format(row[column.key], row) : row[column.key])"
|
||||
/>
|
||||
<template v-else>{{ column.format ? column.format(row[column.key], row) : (row[column.key] ?? "") }}</template>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import type { MarketEntity } from "../api/market";
|
||||
import MarketPreviewPanel from "./MarketPreviewPanel.vue";
|
||||
|
||||
const props = defineProps<{ entity: MarketEntity; label?: string }>();
|
||||
const router = useRouter();
|
||||
const anchor = ref<HTMLElement | null>(null);
|
||||
const visible = ref(false);
|
||||
const position = ref({ left: 0, top: 0 });
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const text = computed(() => props.label ?? props.entity.code);
|
||||
|
||||
function show(): void {
|
||||
if (matchMedia("(hover: none)").matches) return;
|
||||
if (timer) clearTimeout(timer);
|
||||
const rect = anchor.value?.getBoundingClientRect();
|
||||
if (!rect) return;
|
||||
const width = Math.min(480, window.innerWidth - 32);
|
||||
const height = 360;
|
||||
position.value = {
|
||||
left: Math.max(16, Math.min(rect.left, window.innerWidth - width - 16)),
|
||||
top: rect.bottom + height + 12 <= window.innerHeight
|
||||
? rect.bottom + 8
|
||||
: Math.max(8, rect.top - height - 8),
|
||||
};
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
function scheduleClose(): void {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(() => { visible.value = false; }, 180);
|
||||
}
|
||||
|
||||
function openDetail(): void {
|
||||
visible.value = false;
|
||||
void router.push({
|
||||
name: "entity-detail",
|
||||
params: { entityType: props.entity.entity_type, identifier: props.entity.identifier },
|
||||
query: { code: props.entity.code, name: props.entity.name, sector: props.entity.sector ?? undefined },
|
||||
});
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => timer && clearTimeout(timer));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button ref="anchor" class="market-entity-link" type="button" @mouseenter="show" @mouseleave="scheduleClose" @focus="show" @blur="scheduleClose" @click="openDetail">{{ text }}</button>
|
||||
<Teleport to="body">
|
||||
<div v-if="visible" class="market-hover-popover" :style="{ left: `${position.left}px`, top: `${position.top}px` }" @mouseenter="show" @mouseleave="scheduleClose">
|
||||
<MarketPreviewPanel :entity="entity" />
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -124,3 +124,143 @@
|
||||
.entity-chart {
|
||||
min-height: var(--s-400);
|
||||
}
|
||||
|
||||
.market-entity-link {
|
||||
padding: 0;
|
||||
color: var(--color-primary);
|
||||
background: var(--c-transparent);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
.market-entity-link:hover {
|
||||
color: var(--color-primary-hover);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.market-hover-popover {
|
||||
position: fixed;
|
||||
z-index: var(--z-popover);
|
||||
width: min(var(--s-480), calc(100vw - var(--s-32)));
|
||||
height: var(--s-360);
|
||||
overflow: hidden;
|
||||
border: var(--s-1) solid var(--color-border);
|
||||
border-radius: var(--card-radius);
|
||||
background: var(--color-surface);
|
||||
box-shadow: var(--shadow-float);
|
||||
}
|
||||
|
||||
.market-hover-popover .market-preview {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.entity-detail-page {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: var(--layout-gap);
|
||||
}
|
||||
|
||||
.entity-detail-heading {
|
||||
align-items: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.entity-detail-heading > div:first-child {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s-8);
|
||||
}
|
||||
|
||||
.entity-detail-code {
|
||||
color: var(--color-text-faint);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.entity-detail-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--s-8);
|
||||
}
|
||||
|
||||
.entity-detail-price strong {
|
||||
font-size: var(--font-24);
|
||||
}
|
||||
|
||||
.entity-detail-price small {
|
||||
color: var(--color-text-faint);
|
||||
}
|
||||
|
||||
.entity-detail-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.entity-detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) var(--s-320);
|
||||
gap: var(--layout-gap);
|
||||
}
|
||||
|
||||
.entity-metrics-card,
|
||||
.entity-flow-card,
|
||||
.entity-event-card,
|
||||
.entity-members-card {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.entity-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--s-1);
|
||||
padding: var(--s-1);
|
||||
background: var(--color-divider);
|
||||
}
|
||||
|
||||
.entity-metrics > div {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: var(--s-4);
|
||||
padding: var(--s-10) var(--s-12);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
.entity-metrics dt,
|
||||
.entity-event-body dt {
|
||||
color: var(--color-text-faint);
|
||||
font-size: var(--font-11);
|
||||
}
|
||||
|
||||
.entity-metrics dd,
|
||||
.entity-event-body dd {
|
||||
margin: 0;
|
||||
font-weight: var(--weight-600);
|
||||
}
|
||||
|
||||
.entity-stock-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--layout-gap);
|
||||
}
|
||||
|
||||
.entity-event-body {
|
||||
display: grid;
|
||||
gap: var(--s-16);
|
||||
padding: var(--s-16);
|
||||
}
|
||||
|
||||
.entity-event-body > strong {
|
||||
line-height: var(--s-20);
|
||||
}
|
||||
|
||||
.entity-event-body dl {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: var(--s-8);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.entity-event-body dl > div {
|
||||
display: grid;
|
||||
gap: var(--s-4);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,31 @@
|
||||
padding: var(--s-12) var(--s-10);
|
||||
}
|
||||
|
||||
.entity-detail-heading,
|
||||
.entity-detail-heading > div:first-child,
|
||||
.entity-detail-price,
|
||||
.entity-detail-actions {
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.entity-detail-actions {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.entity-detail-grid,
|
||||
.entity-stock-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.entity-metrics {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.market-hover-popover {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile-context-bar {
|
||||
display: grid;
|
||||
gap: var(--s-10);
|
||||
|
||||
Reference in New Issue
Block a user