feat: 添加交易视图功能,集成 lightweight-charts 库,优化数据展示

This commit is contained in:
2025-12-18 02:48:34 +07:00
parent 8bf6c06889
commit 5cf5052a51
9 changed files with 212 additions and 33 deletions

View File

@@ -45,7 +45,6 @@ const schema = toTypedSchema(yup.object({
}));
function handleSubmit(values: GenericObject) {
debugger;
emit("submit", values.editions);
}
</script>

View File

@@ -11,6 +11,43 @@ const [query] = useResetRef<AvailableSubscriptionBody>({
const { data, refresh } = safeClient(() => client.api.rwa.subscription.available_editions.get({
query: query.value,
}));
const tradingViewContainer = useTemplateRef<HTMLDivElement>("tradingViewContainer");
const tradingViewData = ref<any[]>([{ open: 10, high: 10.63, low: 9.49, close: 9.55, time: 1642427876 }, { open: 9.55, high: 10.30, low: 9.42, close: 9.94, time: 1642514276 }, { open: 9.94, high: 10.17, low: 9.92, close: 9.78, time: 1642600676 }, { open: 9.78, high: 10.59, low: 9.18, close: 9.51, time: 1642687076 }, { open: 9.51, high: 10.46, low: 9.10, close: 10.17, time: 1642773476 }, { open: 10.17, high: 10.96, low: 10.16, close: 10.47, time: 1642859876 }, { open: 10.47, high: 11.39, low: 10.40, close: 10.81, time: 1642946276 }, { open: 10.81, high: 11.60, low: 10.30, close: 10.75, time: 1643032676 }, { open: 10.75, high: 11.60, low: 10.49, close: 10.93, time: 1643119076 }, { open: 10.93, high: 11.53, low: 10.76, close: 10.96, time: 1643205476 }]);
setInterval(() => {
const lastData = tradingViewData.value[tradingViewData.value.length - 1];
const lastClose = lastData.close;
const lastTime = lastData.time;
const changePercent = (Math.random() - 0.5) * 0.04;
const open = lastClose;
const close = open * (1 + changePercent);
const volatility = Math.random() * 0.02;
const high = Math.max(open, close) * (1 + volatility);
const low = Math.min(open, close) * (1 - volatility);
const newTime = lastTime + 60;
const newData = {
open: Number(open.toFixed(2)),
high: Number(high.toFixed(2)),
low: Number(low.toFixed(2)),
close: Number(close.toFixed(2)),
time: newTime,
};
tradingViewData.value.push(newData);
if (tradingViewData.value.length > 50) {
tradingViewData.value.shift();
}
}, 1000);
const { resize } = useTradingView(tradingViewContainer, {
data: tradingViewData,
});
watch(query, () => {
refresh();
@@ -32,6 +69,7 @@ watch(query, () => {
<ui-tab-pane name="spot" title="Digital Products" class="py-5">
<Category v-model="query!.categoryId" />
<ion-content :scroll-y="true" />
<div ref="tradingViewContainer" class="w-full h-80" />
</ui-tab-pane>
<ui-tab-pane name="futures" title="Tokenized Products" class="py-5">
<div>Futures Market Content</div>