feat: 更新 @riwa/api-types 依赖至 0.0.89,优化交易对和图表组件
This commit is contained in:
@@ -68,6 +68,9 @@ const defaultOptions = {
|
||||
},
|
||||
} satisfies ChartingLibraryWidgetOptions;
|
||||
|
||||
export interface TradingViewChartExpose {
|
||||
}
|
||||
|
||||
export const TradingViewChart = defineComponent({
|
||||
name: "TradingViewChart",
|
||||
props: {
|
||||
@@ -141,6 +144,17 @@ export const TradingViewChart = defineComponent({
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 监听交易对变化,动态更新图表数据
|
||||
watch(() => props.symbol, (newSymbol) => {
|
||||
if (!widget.value || !newSymbol)
|
||||
return;
|
||||
widget.value.activeChart().setSymbol(newSymbol, () => {
|
||||
console.log(`[TradingView]: Symbol changed to ${newSymbol}`);
|
||||
});
|
||||
});
|
||||
|
||||
return () => h("div", { ref: el, class: "w-full", style: styles.value });
|
||||
},
|
||||
});
|
||||
|
||||
export type TradingViewInst = InstanceType<typeof TradingViewChart> & TradingViewChartExpose;
|
||||
|
||||
Reference in New Issue
Block a user