rebuild(stage-12): deliver private review workflows
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import { api } from "./client";
|
||||
|
||||
export type WatchItem = {
|
||||
identifier: string; code: string; name: string; sector: string | null; remark: string;
|
||||
pct_chg: number | null; return_5d: number | null; attention_score: number | null;
|
||||
};
|
||||
export type ReviewNote = {
|
||||
id: number; code: string; stock_name: string; trade_date: string;
|
||||
summary: string; content: string; plan: string; updated_at: string;
|
||||
};
|
||||
export type TradeEntry = {
|
||||
id: number; trade_date: string; code: string; name: string;
|
||||
action: "buy" | "sell" | "add" | "trim" | "watch"; action_label: string;
|
||||
price: number; quantity: number; position_pct: number | null;
|
||||
pnl_amount: number | null; pnl_pct: number | null;
|
||||
emotion: "calm" | "confident" | "hesitant" | "anxious" | "impulsive";
|
||||
emotion_label: string; tags: string[]; thesis: string; execution: string;
|
||||
};
|
||||
export type TradeSummary = {
|
||||
total: number; realized: number; win_rate: number | null;
|
||||
pnl_amount: number | null; average_position: number | null;
|
||||
};
|
||||
export type ReviewWorkspace = {
|
||||
trade_date: string; watchlist: WatchItem[]; daily: ReviewNote | null;
|
||||
history: ReviewNote[]; trades: TradeEntry[]; trade_summary: TradeSummary;
|
||||
};
|
||||
export type AlertItem = {
|
||||
id: number; kind: string; title: string; content: string; available_date: string;
|
||||
code: string; is_read: boolean; due: boolean; created_at: string;
|
||||
};
|
||||
export type AlertCenter = { items: AlertItem[]; unread_count: number; as_of: string };
|
||||
export type AssistantMessage = {
|
||||
id: number; role: "user" | "assistant"; content: string;
|
||||
context_date: string; status: "complete" | "stopped" | "error"; created_at: string;
|
||||
};
|
||||
export type AssistantEvent = {
|
||||
type: "delta" | "done" | "error"; content?: string; message?: string; partial?: boolean;
|
||||
};
|
||||
|
||||
export const reviewApi = {
|
||||
workspace(date: string): Promise<ReviewWorkspace> {
|
||||
return api.get(`/review?date=${encodeURIComponent(date)}`);
|
||||
},
|
||||
addWatch(identifier: string): Promise<{ identifier: string; name: string }> {
|
||||
return api.post("/review/watchlist", { identifier });
|
||||
},
|
||||
saveRemark(identifier: string, remark: string): Promise<{ message: string }> {
|
||||
return api.patch(`/review/watchlist/${encodeURIComponent(identifier)}/remark`, { remark });
|
||||
},
|
||||
removeWatch(identifier: string): Promise<{ message: string }> {
|
||||
return api.delete(`/review/watchlist/${encodeURIComponent(identifier)}`);
|
||||
},
|
||||
saveNote(note: Omit<ReviewNote, "id" | "updated_at">): Promise<{ id: number }> {
|
||||
return api.put("/review/notes", note);
|
||||
},
|
||||
stockNotes(code: string): Promise<ReviewNote[]> {
|
||||
return api.get(`/review/stock-notes/${encodeURIComponent(code)}`);
|
||||
},
|
||||
deleteNote(id: number): Promise<{ message: string }> {
|
||||
return api.delete(`/review/notes/${id}`);
|
||||
},
|
||||
saveTrade(trade: Omit<TradeEntry, "action_label" | "emotion_label">): Promise<{ id: number }> {
|
||||
return api.put("/review/trades", trade);
|
||||
},
|
||||
deleteTrade(id: number): Promise<{ message: string }> {
|
||||
return api.delete(`/review/trades/${id}`);
|
||||
},
|
||||
alerts(unread = false): Promise<AlertCenter> {
|
||||
return api.get(`/review/alerts?unread=${unread}`);
|
||||
},
|
||||
createAlert(value: { title: string; remind_date: string; code: string; content: string }): Promise<{ id: number }> {
|
||||
return api.post("/review/alerts", value);
|
||||
},
|
||||
markAlert(id: number): Promise<{ message: string }> {
|
||||
return api.patch(`/review/alerts/${id}/read`);
|
||||
},
|
||||
markAllAlerts(): Promise<{ updated: number }> {
|
||||
return api.patch("/review/alerts/read-all");
|
||||
},
|
||||
deleteAlert(id: number): Promise<{ message: string }> {
|
||||
return api.delete(`/review/alerts/${id}`);
|
||||
},
|
||||
assistantMessages(): Promise<AssistantMessage[]> {
|
||||
return api.get("/review/assistant/messages");
|
||||
},
|
||||
clearAssistant(): Promise<{ deleted: number }> {
|
||||
return api.delete("/review/assistant/messages");
|
||||
},
|
||||
chat(date: string, question: string, onEvent: (event: AssistantEvent) => void, signal?: AbortSignal): Promise<void> {
|
||||
return api.stream("/review/assistant/chat", { trade_date: date, question }, onEvent, signal);
|
||||
},
|
||||
};
|
||||
@@ -3,19 +3,26 @@ import ProfilePanel from "../account/ProfilePanel.vue";
|
||||
import MembershipPanel from "../account/MembershipPanel.vue";
|
||||
import PasswordPanel from "../account/PasswordPanel.vue";
|
||||
import SearchPanel from "../account/SearchPanel.vue";
|
||||
import AlertsPanel from "../../pages/review/AlertsPanel.vue";
|
||||
import AssistantPanel from "../../pages/review/AssistantPanel.vue";
|
||||
import { useUiStore } from "../stores/ui";
|
||||
import BaseDialog from "./BaseDialog.vue";
|
||||
|
||||
const ui = useUiStore();
|
||||
const titles = { profile: "个人资料", membership: "会员状态", password: "修改密码", search: "全局搜索" } as const;
|
||||
const titles = {
|
||||
profile: "个人资料", membership: "会员状态", password: "修改密码",
|
||||
search: "全局搜索", alerts: "提醒中心", assistant: "复盘助手",
|
||||
} as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BaseDialog v-if="ui.dialog" :title="titles[ui.dialog]" :wide="ui.dialog === 'membership' || ui.dialog === 'search'" @close="ui.closeDialog">
|
||||
<BaseDialog v-if="ui.dialog" :title="titles[ui.dialog]" :wide="['membership', 'search', 'alerts', 'assistant'].includes(ui.dialog)" @close="ui.closeDialog">
|
||||
<ProfilePanel v-if="ui.dialog === 'profile'" />
|
||||
<MembershipPanel v-else-if="ui.dialog === 'membership'" />
|
||||
<PasswordPanel v-else-if="ui.dialog === 'password'" />
|
||||
<SearchPanel v-else />
|
||||
<SearchPanel v-else-if="ui.dialog === 'search'" />
|
||||
<AlertsPanel v-else-if="ui.dialog === 'alerts'" />
|
||||
<AssistantPanel v-else />
|
||||
</BaseDialog>
|
||||
<BaseDialog v-else-if="ui.confirmation" :title="ui.confirmation.title" @close="ui.resolveConfirmation(false)">
|
||||
<div class="form-grid">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
export type DialogName = "profile" | "membership" | "password" | "search" | null;
|
||||
export type DialogName = "profile" | "membership" | "password" | "search" | "alerts" | "assistant" | null;
|
||||
export type Theme = "light" | "dark";
|
||||
export type Confirmation = { title: string; message: string; confirmLabel: string };
|
||||
|
||||
@@ -23,6 +23,7 @@ export const useUiStore = defineStore("ui", () => {
|
||||
const dialog = ref<DialogName>(null);
|
||||
const confirmation = ref<Confirmation | null>(null);
|
||||
const toast = ref("");
|
||||
const alertUnread = ref(0);
|
||||
let toastTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let confirmationResolve: ((value: boolean) => void) | undefined;
|
||||
|
||||
@@ -69,7 +70,7 @@ export const useUiStore = defineStore("ui", () => {
|
||||
}
|
||||
|
||||
return {
|
||||
theme, dialog, confirmation, toast, setTheme, toggleTheme, openDialog, closeDialog,
|
||||
theme, dialog, confirmation, toast, alertUnread, setTheme, toggleTheme, openDialog, closeDialog,
|
||||
askConfirmation, resolveConfirmation, showToast,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -246,6 +246,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1023px) {
|
||||
.review-main-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.trade-card, .daily-review-card { min-height: auto; }
|
||||
.review-watch-table { max-height: var(--s-320); }
|
||||
.trade-scroll { max-height: var(--s-320); }
|
||||
.trade-form-grid, .alert-create-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.review-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.review-summary > div:last-child { grid-column: 1 / -1; }
|
||||
.review-history-list article, .stock-note-history article { grid-template-columns: minmax(0, 1fr); }
|
||||
.review-history-list p, .review-history-list small,
|
||||
.stock-note-history p, .stock-note-history small { grid-column: 1; }
|
||||
.assistant-messages article { max-width: 94%; }
|
||||
}
|
||||
|
||||
@media (max-width: 1399px) {
|
||||
.auction-layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
|
||||
@@ -0,0 +1,397 @@
|
||||
.review-page {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: var(--layout-gap);
|
||||
}
|
||||
|
||||
.review-heading,
|
||||
.review-watch-card .card-header,
|
||||
.trade-card .card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.review-heading > div,
|
||||
.review-watch-card .card-header h2,
|
||||
.trade-card .card-header h2 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.review-watch-table {
|
||||
width: 100%;
|
||||
max-height: var(--s-260);
|
||||
}
|
||||
|
||||
.review-watch-card,
|
||||
.review-main-grid,
|
||||
.review-main-grid > *,
|
||||
.trade-scroll {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.review-watch-table th:first-child,
|
||||
.review-watch-table td:first-child {
|
||||
width: var(--s-44);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.review-watch-table th:nth-child(8),
|
||||
.review-watch-table td:nth-child(8) {
|
||||
min-width: var(--s-200);
|
||||
}
|
||||
|
||||
.watch-star {
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.review-remark {
|
||||
width: 100%;
|
||||
min-height: var(--s-30);
|
||||
padding: var(--s-4) var(--s-7);
|
||||
border: var(--s-1) solid var(--c-transparent);
|
||||
border-radius: var(--control-radius);
|
||||
color: var(--color-text);
|
||||
background: var(--color-surface-muted);
|
||||
font-size: var(--font-12);
|
||||
}
|
||||
|
||||
.review-remark:focus {
|
||||
border-color: var(--color-primary-border);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.review-main-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.2fr) minmax(var(--s-360), 0.8fr);
|
||||
gap: var(--layout-gap);
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.trade-card,
|
||||
.daily-review-card {
|
||||
min-height: var(--s-480);
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.review-card-action {
|
||||
margin-left: var(--s-8);
|
||||
}
|
||||
|
||||
.review-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: var(--s-1);
|
||||
border-bottom: var(--s-1) solid var(--color-divider);
|
||||
background: var(--color-divider);
|
||||
}
|
||||
|
||||
.review-summary > div {
|
||||
display: grid;
|
||||
gap: var(--s-2);
|
||||
padding: var(--s-8) var(--s-10);
|
||||
background: var(--color-surface-muted);
|
||||
}
|
||||
|
||||
.review-summary span {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-11);
|
||||
}
|
||||
|
||||
.review-summary strong {
|
||||
min-height: var(--s-18);
|
||||
font-size: var(--font-14);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.trade-scroll {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.trade-scroll .data-table {
|
||||
min-width: var(--s-dialog-wide);
|
||||
}
|
||||
|
||||
.daily-review-card {
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.daily-review-form {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(var(--s-96), 1fr) minmax(var(--s-80), 0.8fr) auto;
|
||||
gap: var(--s-10);
|
||||
padding: var(--s-14);
|
||||
}
|
||||
|
||||
.daily-review-form .field,
|
||||
.daily-review-form .textarea {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.daily-short {
|
||||
height: var(--s-64);
|
||||
}
|
||||
|
||||
.review-history-toggle {
|
||||
width: 100%;
|
||||
min-height: var(--s-44);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: var(--s-10) var(--s-14);
|
||||
color: var(--color-text);
|
||||
background: var(--c-transparent);
|
||||
font-size: var(--font-13);
|
||||
font-weight: var(--weight-600);
|
||||
}
|
||||
|
||||
.review-history-toggle span:last-child {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-11);
|
||||
font-weight: var(--weight-400);
|
||||
}
|
||||
|
||||
.review-history-list {
|
||||
max-height: var(--s-320);
|
||||
overflow: auto;
|
||||
border-top: var(--s-1) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.review-history-list article,
|
||||
.stock-note-history article {
|
||||
display: grid;
|
||||
grid-template-columns: var(--s-96) minmax(0, 1fr);
|
||||
gap: var(--s-6) var(--s-12);
|
||||
padding: var(--s-12) var(--s-14);
|
||||
border-bottom: var(--s-1) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.review-history-list time,
|
||||
.stock-note-history time {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-11);
|
||||
}
|
||||
|
||||
.review-history-list p,
|
||||
.review-history-list small,
|
||||
.stock-note-history p,
|
||||
.stock-note-history small {
|
||||
grid-column: 2;
|
||||
color: var(--color-text-secondary);
|
||||
line-height: var(--s-20);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.watch-search-results {
|
||||
display: grid;
|
||||
gap: var(--s-4);
|
||||
}
|
||||
|
||||
.watch-search-results button {
|
||||
min-height: var(--s-44);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--s-7) var(--s-10);
|
||||
border-radius: var(--control-radius);
|
||||
color: var(--color-text);
|
||||
background: var(--color-surface-muted);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.watch-search-results button:hover {
|
||||
background: var(--color-primary-soft);
|
||||
}
|
||||
|
||||
.watch-search-results button span:first-child {
|
||||
display: grid;
|
||||
gap: var(--s-2);
|
||||
}
|
||||
|
||||
.watch-search-results small {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.trade-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: var(--s-10);
|
||||
}
|
||||
|
||||
.trade-wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.alerts-panel,
|
||||
.assistant-panel {
|
||||
display: grid;
|
||||
gap: var(--s-12);
|
||||
}
|
||||
|
||||
.alerts-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.segmented {
|
||||
display: inline-flex;
|
||||
padding: var(--s-2);
|
||||
border-radius: var(--control-radius);
|
||||
background: var(--color-surface-muted);
|
||||
}
|
||||
|
||||
.segmented button,
|
||||
.assistant-prompts button {
|
||||
min-height: var(--s-30);
|
||||
padding: var(--s-4) var(--s-10);
|
||||
border-radius: var(--control-radius);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-12);
|
||||
}
|
||||
|
||||
.segmented button.active,
|
||||
.assistant-prompts button:hover {
|
||||
color: var(--color-primary);
|
||||
background: var(--color-surface-raised);
|
||||
}
|
||||
|
||||
.alert-create {
|
||||
display: grid;
|
||||
gap: var(--s-10);
|
||||
padding: var(--s-12);
|
||||
border: var(--s-1) solid var(--color-border);
|
||||
border-radius: var(--card-radius);
|
||||
background: var(--color-surface-muted);
|
||||
}
|
||||
|
||||
.alert-create-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.4fr) minmax(var(--s-160), 0.8fr) minmax(var(--s-120), 0.7fr);
|
||||
gap: var(--s-10);
|
||||
}
|
||||
|
||||
.alert-list {
|
||||
max-height: var(--s-320);
|
||||
overflow: auto;
|
||||
border: var(--s-1) solid var(--color-border);
|
||||
border-radius: var(--card-radius);
|
||||
}
|
||||
|
||||
.alert-list article {
|
||||
display: grid;
|
||||
gap: var(--s-6);
|
||||
padding: var(--s-12);
|
||||
border-bottom: var(--s-1) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.alert-list article.unread {
|
||||
background: var(--color-primary-soft);
|
||||
}
|
||||
|
||||
.alert-list article > div:first-child {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s-8);
|
||||
}
|
||||
|
||||
.alert-list p,
|
||||
.alert-list small {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.assistant-panel .notice {
|
||||
display: grid;
|
||||
gap: var(--s-2);
|
||||
}
|
||||
|
||||
.assistant-content {
|
||||
display: grid;
|
||||
grid-template-rows: minmax(var(--s-240), 1fr) auto auto;
|
||||
gap: var(--s-10);
|
||||
}
|
||||
|
||||
.assistant-messages {
|
||||
max-height: var(--s-400);
|
||||
overflow: auto;
|
||||
padding: var(--s-10);
|
||||
border: var(--s-1) solid var(--color-border);
|
||||
border-radius: var(--card-radius);
|
||||
background: var(--color-surface-muted);
|
||||
}
|
||||
|
||||
.assistant-messages article {
|
||||
max-width: 86%;
|
||||
display: grid;
|
||||
gap: var(--s-4);
|
||||
margin-bottom: var(--s-10);
|
||||
padding: var(--s-9) var(--s-12);
|
||||
border-radius: var(--card-radius);
|
||||
background: var(--color-surface-raised);
|
||||
}
|
||||
|
||||
.assistant-messages article.user {
|
||||
margin-left: auto;
|
||||
background: var(--color-primary-soft);
|
||||
}
|
||||
|
||||
.assistant-messages article span,
|
||||
.assistant-empty {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-11);
|
||||
}
|
||||
|
||||
.assistant-messages article p {
|
||||
line-height: var(--s-22);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.assistant-prompts,
|
||||
.assistant-compose > div {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--s-6);
|
||||
}
|
||||
|
||||
.assistant-compose {
|
||||
display: grid;
|
||||
gap: var(--s-8);
|
||||
}
|
||||
|
||||
.stock-notes-card {
|
||||
margin-top: var(--layout-gap);
|
||||
}
|
||||
|
||||
.stock-note-form {
|
||||
display: grid;
|
||||
gap: var(--s-10);
|
||||
padding: var(--s-14);
|
||||
}
|
||||
|
||||
.stock-note-history {
|
||||
max-height: var(--s-320);
|
||||
overflow: auto;
|
||||
border-top: var(--s-1) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.topbar-alert {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.alert-badge {
|
||||
position: absolute;
|
||||
top: calc(var(--s-6) * -1);
|
||||
right: calc(var(--s-8) * -1);
|
||||
min-width: var(--s-18);
|
||||
height: var(--s-18);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 0 var(--s-4);
|
||||
border-radius: var(--radius-round);
|
||||
color: var(--c-gray-050);
|
||||
background: var(--color-up);
|
||||
font-size: var(--font-10-5);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
Reference in New Issue
Block a user