Browse Source
feat(env): 添加百度统计开关配置项 在 .env、.env.production 和 .env.static 文件中新增 `VITE_APP_BAIDU_ENABLE` 配置项, 用于控制是否启用百度统计功能,默认设置为 false。 feat(package): 替换构建脚本中的 tsx 命令为 esno 将 build 相关命令中的 `tsx` 替换为 `pnpm exec esno`,以统一执行方式并提高兼容性。 fix(drawer): 优化 detail 模式下的容器挂载逻辑 当内容区容器不存在或高度为 0 时,回退到 body 容器并避免添加 __detail 类, 防止因 absolute 定位导致抽屉不可见的问题。 feat(icon): 改进图标缺失时的展示样式 引入 `.iconify-missing` 样式类,在图标加载失败时显示带问号的圆形占位符, 提升用户体验与界面可读性。 feat(router): 新增模型创建页面路由 添加 `/model/create` 路由及其子路由,支持从模型列表跳转至新建模型页面, 隐藏菜单和面包屑导航。 feat(tongji): 增强百度统计初始化逻辑 增加对 `VITE_APP_BAIDU_ENABLE` 环境变量的支持,并确保 script 标签不会重复插入, 增强百度统计的安全性和可控性。 refactor(model): 移除 CreateModel 抽屉组件引用 移除 ModelCard 中对 CreateModel 抽屉组件的依赖,改为通过路由跳转实现创建功能, 简化组件结构并降低耦合度。 ```pull/85/head
10 changed files with 286 additions and 34 deletions
@ -1,23 +1,35 @@ |
|||
import { router } from '@/router' |
|||
|
|||
// 用于 router push
|
|||
window._hmt = window._hmt || [] |
|||
// HM_ID
|
|||
declare global { |
|||
interface Window { |
|||
_hmt?: any[] |
|||
} |
|||
} |
|||
|
|||
// HM_ID(构建时注入)
|
|||
const HM_ID = import.meta.env.VITE_APP_BAIDU_CODE |
|||
;(function () { |
|||
// 有值的时候,才开启
|
|||
if (!HM_ID) |
|||
return |
|||
|
|||
const hm = document.createElement('script') |
|||
hm.src = `https://hm.baidu.com/hm.js?${HM_ID}` |
|||
const s = document.getElementsByTagName('script')[0] |
|||
s.parentNode.insertBefore(hm, s) |
|||
})() |
|||
|
|||
router.afterEach((to) => { |
|||
if (!HM_ID) |
|||
return |
|||
|
|||
_hmt.push(['_trackPageview', to.fullPath]) |
|||
}) |
|||
|
|||
// 统计开关:默认关闭,离线/内网部署建议保持关闭
|
|||
const BAIDU_TONGJI_ENABLED = import.meta.env.VITE_APP_BAIDU_ENABLE === 'true' |
|||
|
|||
const shouldEnable = BAIDU_TONGJI_ENABLED && !!HM_ID |
|||
|
|||
if (shouldEnable) { |
|||
window._hmt = window._hmt || [] |
|||
|
|||
;(function () { |
|||
const existing = document.querySelector<HTMLScriptElement>(`script[data-hm-id="${HM_ID}"]`) |
|||
if (existing) |
|||
return |
|||
|
|||
const hm = document.createElement('script') |
|||
hm.setAttribute('data-hm-id', HM_ID) |
|||
hm.src = `https://hm.baidu.com/hm.js?${HM_ID}` |
|||
const s = document.getElementsByTagName('script')[0] |
|||
s?.parentNode?.insertBefore(hm, s) |
|||
})() |
|||
|
|||
router.afterEach((to) => { |
|||
window._hmt?.push(['_trackPageview', to.fullPath]) |
|||
}) |
|||
} |
|||
|
|||
@ -0,0 +1,177 @@ |
|||
<script lang="ts" setup> |
|||
import { computed, reactive, ref, toRefs } from 'vue' |
|||
import { useRoute, useRouter } from 'vue-router' |
|||
import { Alert, Button, Card, Space, Steps } from 'ant-design-vue' |
|||
import Step1 from '@/views/model/list/step/Step1.vue' |
|||
import Step2 from '@/views/model/list/step/Step2.vue' |
|||
import Step3 from '@/views/model/list/step/Step3.vue' |
|||
import Step4 from '@/views/model/list/step/Step4.vue' |
|||
import { PageWrapper } from '@/components/Page' |
|||
|
|||
defineOptions({ name: 'ModelCreatePage' }) |
|||
|
|||
const route = useRoute() |
|||
const router = useRouter() |
|||
|
|||
const systemId = computed(() => { |
|||
const v = route.query.systemId |
|||
return v === undefined || v === null || v === '' ? undefined : Number(v) |
|||
}) |
|||
|
|||
const unitId = computed(() => { |
|||
const v = route.query.unitId |
|||
return v === undefined || v === null || v === '' ? undefined : Number(v) |
|||
}) |
|||
|
|||
const current = ref(0) |
|||
const step1Data = ref<any>(null) |
|||
const step2Data = ref<any>(null) |
|||
const step3Data = ref<any>(null) |
|||
|
|||
const state = reactive({ |
|||
initStep2: false, |
|||
initStep3: false, |
|||
initStep4: false, |
|||
initStep5: false, |
|||
}) |
|||
const { initStep2, initStep3, initStep4, initStep5 } = toRefs(state) |
|||
|
|||
const canShowContextWarning = computed(() => { |
|||
return systemId.value === undefined || unitId.value === undefined |
|||
}) |
|||
|
|||
function handleStep1Next(step1Values: any) { |
|||
current.value++ |
|||
step1Data.value = step1Values |
|||
state.initStep2 = true |
|||
} |
|||
|
|||
function handleStepPrev() { |
|||
current.value-- |
|||
} |
|||
|
|||
function handleStep2Next(step2Values: any) { |
|||
current.value++ |
|||
step2Data.value = step2Values |
|||
step2Values.systemId = systemId.value |
|||
step2Values.unitId = unitId.value |
|||
state.initStep3 = true |
|||
} |
|||
|
|||
function handleStep3Next(step3Values: any) { |
|||
current.value++ |
|||
step3Data.value = step3Values |
|||
state.initStep4 = true |
|||
} |
|||
|
|||
function handleStep4Next(step4Values: any) { |
|||
current.value++ |
|||
state.initStep5 = true |
|||
} |
|||
|
|||
function handleRedo() { |
|||
current.value = 0 |
|||
state.initStep2 = false |
|||
state.initStep3 = false |
|||
state.initStep4 = false |
|||
state.initStep5 = false |
|||
} |
|||
|
|||
function goBack() { |
|||
router.push('/model/list') |
|||
} |
|||
</script> |
|||
|
|||
<template> |
|||
<PageWrapper title="新建模型" content-background content-class="p-4"> |
|||
<div class="model-create"> |
|||
<div class="model-create__top"> |
|||
<Space> |
|||
<Button @click="goBack"> |
|||
返回模型列表 |
|||
</Button> |
|||
<Button v-if="current > 0" @click="handleRedo"> |
|||
重新开始 |
|||
</Button> |
|||
</Space> |
|||
</div> |
|||
|
|||
<Alert |
|||
v-if="canShowContextWarning" |
|||
class="model-create__hint" |
|||
type="warning" |
|||
show-icon |
|||
message="提示:当前未携带系统/机组信息" |
|||
description="你仍然可以完成建模;但如果需要绑定到具体机组,请从模型列表页选择系统/机组后再进入“新建模型”。" |
|||
/> |
|||
|
|||
<div class="model-create__steps"> |
|||
<a-steps :current="current"> |
|||
<a-step title="填写基本信息" /> |
|||
<a-step title="算法参数配置" /> |
|||
<a-step title="数据源选取" /> |
|||
<a-step title="完成" /> |
|||
</a-steps> |
|||
</div> |
|||
|
|||
<Card class="model-create__content" :bordered="false"> |
|||
<Step1 v-show="current === 0" @next="handleStep1Next" /> |
|||
<Step2 |
|||
v-show="current === 1" |
|||
v-if="initStep2" |
|||
:before-data="step1Data" |
|||
@prev="handleStepPrev" |
|||
@next="handleStep2Next" |
|||
/> |
|||
<Step3 |
|||
v-show="current === 2" |
|||
v-if="initStep3" |
|||
:before-data="step2Data" |
|||
:system-id="systemId" |
|||
:unit-id="unitId" |
|||
@prev="handleStepPrev" |
|||
@next="handleStep3Next" |
|||
/> |
|||
<Step4 |
|||
v-show="current === 3" |
|||
v-if="initStep4" |
|||
:model-id="step3Data" |
|||
@redo="handleRedo" |
|||
/> |
|||
</Card> |
|||
</div> |
|||
</PageWrapper> |
|||
</template> |
|||
|
|||
<style lang="less" scoped> |
|||
.model-create { |
|||
max-width: 1200px; |
|||
margin: 0 auto; |
|||
|
|||
&__top { |
|||
display: flex; |
|||
justify-content: space-between; |
|||
margin-bottom: 12px; |
|||
} |
|||
|
|||
&__hint { |
|||
margin-bottom: 12px; |
|||
} |
|||
|
|||
&__steps { |
|||
position: sticky; |
|||
top: 0; |
|||
z-index: 3; |
|||
padding: 12px 16px; |
|||
margin-bottom: 16px; |
|||
background: var(--component-background); |
|||
border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06)); |
|||
border-radius: 8px; |
|||
} |
|||
|
|||
&__content { |
|||
border-radius: 10px; |
|||
box-shadow: 0 8px 24px rgb(15 23 42 / 6%); |
|||
} |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue