205 lines
5.5 KiB
JavaScript
205 lines
5.5 KiB
JavaScript
import { writeFileSync, readFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
const root = 'e:/Gitea/ai_trade_assistance'
|
|
|
|
function w(rel, content) {
|
|
writeFileSync(join(root, rel), content, 'utf8')
|
|
console.log('ok', rel)
|
|
}
|
|
|
|
const S = {
|
|
fenshi: '\u5206\u65f6',
|
|
wuri: '\u4e94\u65e5',
|
|
riK: '\u65e5K',
|
|
zhouK: '\u5468K',
|
|
yueK: '\u6708K',
|
|
junjia: '\u5747\u4ef7',
|
|
cjl: '\u6210\u4ea4\u91cf',
|
|
xindu: '\u7f6e\u4fe1\u5ea6',
|
|
yijian: '\u4e00\u952e\u83b7\u53d6\u5efa\u8bae',
|
|
shouqi: '\u6536\u8d77',
|
|
zhankai: '\u5c55\u5f00',
|
|
hint: '\u57fa\u4e8e\u884c\u60c5\u3001\u76d8\u53e3\u3001\u65b0\u95fb\u4e0e\u6301\u4ed3\u7684\u7efc\u5408\u5206\u6790\uff08\u5f53\u524d\u4e3a Mock\uff09',
|
|
warn: '\u8bf7\u5148\u5728\u8bbe\u7f6e\u4e2d\u914d\u7f6e DeepSeek API Key\uff08\u672c\u9636\u6bb5\u4ecd\u8fd4\u56de Mock \u5efa\u8bae\uff09',
|
|
qita: '\u5176\u4ed6',
|
|
shuliang: '\u6570\u91cf',
|
|
zengjian: '\u589e\u51cf',
|
|
zhanbi: '\u5360\u6bd4',
|
|
}
|
|
|
|
// Patch ChartPanel: replace garbled labels in existing file structure by rewriting full file from template pieces
|
|
const chartPath = join(root, 'src/components/quote/ChartPanel.vue')
|
|
let chart = readFileSync(chartPath, 'utf8')
|
|
chart = chart
|
|
.replace(/label="\?+"/g, (m, offset, str) => m) // noop marker
|
|
.replace(/<el-tab-pane label="[^"]*" name="intraday"/, `<el-tab-pane label="${S.fenshi}" name="intraday"`)
|
|
.replace(/<el-tab-pane label="[^"]*" name="five"/, `<el-tab-pane label="${S.wuri}" name="five"`)
|
|
.replace(/<el-tab-pane label="[^"]*" name="day"/, `<el-tab-pane label="${S.riK}" name="day"`)
|
|
.replace(/<el-tab-pane label="[^"]*" name="week"/, `<el-tab-pane label="${S.zhouK}" name="week"`)
|
|
.replace(/<el-tab-pane label="[^"]*" name="month"/, `<el-tab-pane label="${S.yueK}" name="month"`)
|
|
.replace(/data: \['[^\]]*'\]/, `data: ['${S.fenshi}', '${S.junjia}']`)
|
|
.replace(/name: '[^']*',\s*\n\s*type: 'line',\s*\n\s*data: prices/, `name: '${S.fenshi}',\n type: 'line',\n data: prices`)
|
|
.replace(/name: '[^']*',\s*\n\s*type: 'line',\s*\n\s*data: avgs/, `name: '${S.junjia}',\n type: 'line',\n data: avgs`)
|
|
.replace(/name: '[^']*',\s*\n\s*type: 'bar',\s*\n\s*data: vols/, `name: '${S.cjl}',\n type: 'bar',\n data: vols`)
|
|
writeFileSync(chartPath, chart, 'utf8')
|
|
console.log('ok ChartPanel.vue')
|
|
|
|
w(
|
|
'src/components/ai/AiAdviceDrawer.vue',
|
|
`<template>
|
|
<div class="ai-drawer" :class="{ open: expanded }">
|
|
<div class="bar">
|
|
<div class="summary">
|
|
<span class="badge" :class="data.direction">AI</span>
|
|
<strong>{{ data.action }}</strong>
|
|
<span class="text">{{ data.summary }}</span>
|
|
<span class="meta">${S.xindu} {{ data.confidence }}% \u00b7 {{ data.updatedAt }}</span>
|
|
</div>
|
|
<div class="btns">
|
|
<el-button size="small" :loading="loading" @click="onRefresh">${S.yijian}</el-button>
|
|
<el-button size="small" text type="primary" @click="expanded = !expanded">
|
|
{{ expanded ? '${S.shouqi}' : '${S.zhankai}' }}
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
<div v-show="expanded" class="body">
|
|
<div class="hint">${S.hint}</div>
|
|
<ul>
|
|
<li v-for="(r, i) in data.reasons" :key="i">{{ r }}</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { ElMessage } from 'element-plus'
|
|
import type { AiAdvice } from '../../types'
|
|
import { useSettingsStore } from '../../stores/settings'
|
|
|
|
withDefaults(
|
|
defineProps<{
|
|
data: AiAdvice
|
|
loading?: boolean
|
|
}>(),
|
|
{ loading: false },
|
|
)
|
|
|
|
const emit = defineEmits<{
|
|
refresh: []
|
|
}>()
|
|
const settings = useSettingsStore()
|
|
const expanded = ref(false)
|
|
|
|
function onRefresh() {
|
|
if (!settings.apiKey) {
|
|
ElMessage.warning('${S.warn}')
|
|
}
|
|
emit('refresh')
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.ai-drawer {
|
|
max-width: 1440px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.bar {
|
|
min-height: var(--ai-bar-height);
|
|
padding: 8px 16px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.summary {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
flex: 1;
|
|
min-width: 0;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 28px;
|
|
height: 28px;
|
|
border-radius: 6px;
|
|
background: linear-gradient(135deg, #1677ff, #69b1ff);
|
|
color: #fff;
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.text {
|
|
color: var(--text-primary);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.meta {
|
|
color: var(--text-secondary);
|
|
flex-shrink: 0;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.btns {
|
|
display: flex;
|
|
gap: 4px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.body {
|
|
padding: 0 16px 14px 54px;
|
|
border-top: 1px dashed var(--border);
|
|
}
|
|
|
|
.hint {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
margin: 10px 0 6px;
|
|
}
|
|
|
|
ul {
|
|
margin: 0;
|
|
padding-left: 18px;
|
|
font-size: 13px;
|
|
line-height: 1.7;
|
|
color: #3d4450;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.bar {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.meta {
|
|
display: none;
|
|
}
|
|
}
|
|
</style>
|
|
`,
|
|
)
|
|
|
|
// Fix PositionDonut Chinese in tooltip/legend if garbled
|
|
const donutPath = join(root, 'src/components/position/PositionDonut.vue')
|
|
let donut = readFileSync(donutPath, 'utf8')
|
|
donut = donut
|
|
.replace(/data\.push\(\{ name: '[^']*', value: otherQty \}\)/, `data.push({ name: '${S.qita}', value: otherQty })`)
|
|
.replace(
|
|
/return `\$\{param\.name\}<br\/>[^`]+`/,
|
|
`return \`\${param.name}<br/>${S.shuliang}: \${param.value}<br/>${S.zengjian}: \${sign}\${change}<br/>${S.zhanbi}: \${param.percent}%\``,
|
|
)
|
|
writeFileSync(donutPath, donut, 'utf8')
|
|
console.log('ok PositionDonut.vue')
|
|
|
|
console.log('batch2 done')
|