Files
tuanwei-uniapp/src/components/common-hero/common-hero.vue
T
ticket-02 agent 81a093120c build(cli): 迁移到 uni-app 官方 Vite CLI 骨架(src/ 布局)
按地图口径把 HBuilderX 工程改成官方 #vite(JS 版)CLI 工程:

- 业务代码 git mv 进 src/(176 个 rename,逐文件字节比对零内容改动):
  App.vue / main.js / manifest.json / pages.json / uni.scss /
  pages/ / packageMine/ / components/ / utils/ / static/ /
  uni_modules/ / uni.promisify.adaptor.js
- 新增官方骨架:package.json(@dcloudio/* 同版本 pin
  3.0.0-5020620260917001,vite 精确 5.2.8,vue ^3.4.21;只留 h5 与
  mp-weixin 脚本)、vite.config.js、shims-uni.d.ts;补 sass devDependency
  以支持既有 lang="scss"
- index.html 沿用本仓文件,入口改为 /src/main.js
- manifest.json 删除 app-plus / quickapp / mp-alipay / mp-baidu /
  mp-toutiao 五个死平台段,只留 mp-weixin
- .gitignore 加 dist/
- pnpm-workspace.yaml 新增 allowBuilds 白名单:pnpm 12 起
  onlyBuiltDependencies 已被移除,且 strictDepBuilds 默认 true 会把
  「未复核构建脚本」判成非零退出。白名单只列传递依赖
  esbuild / @parcel/watcher / core-js / core-js-pure。
  未使用 shamefully-hoist 或 node-linker=hoisted。

验收:pnpm build:mp-weixin 退出码 0,产物 app.json 的
pages / subPackages / tabBar / window 与改造前基线逐项一致;
project.config.json 落产物且 appid = wxf7ee9cd5801bf7a6。
2026-10-15 15:17:32 +08:00

196 lines
4.0 KiB
Vue

<template>
<view class="hero-section" :style="heroStyle">
<!-- <view class="hero-bg hero-bg-left"></view>-->
<!-- <view class="hero-bg hero-bg-right"></view>-->
<view class="navbar" :style="navbarStyle">
<view class="navbar-inner">
<view class="navbar-left" v-if="showBack">
<view class="nav-back-btn" @tap="handleBack">
<uv-icon name="arrow-left" color="#101214" size="22"></uv-icon>
</view>
</view>
<view class="navbar-title">{{ title }}</view>
<view class="navbar-right-placeholder"></view>
</view>
</view>
<view class="navbar-spacer" :style="{ height: navbarHeight + 'px' }"></view>
<slot></slot>
</view>
</template>
<script>
const TAB_BAR_PATHS = ['/pages/index/index', '/pages/assistant/index', '/pages/mine/index']
export default {
name: 'CommonHero',
props: {
title: {
type: String,
default: ''
},
useImageBg: {
type: Boolean,
default: false
},
backgroundImage: {
type: String,
default: '/static/indexBg.jpg'
},
reduceTop: {
type: Number,
default: 0
}
},
data() {
return {
statusBarHeight: 0,
currentRoute: ''
}
},
computed: {
showBack() {
return TAB_BAR_PATHS.indexOf(this.currentRoute) === -1
},
navbarHeight() {
return this.statusBarHeight + uni.upx2px(88) - uni.upx2px(this.reduceTop)
},
navbarStyle() {
return {
paddingTop: `${this.statusBarHeight}px`
}
},
heroStyle() {
if (this.useImageBg) {
return {
backgroundImage: `url('${this.backgroundImage}')`,
backgroundSize: 'cover',
backgroundPosition: 'center top',
backgroundRepeat: 'no-repeat'
}
}
return {
background: 'linear-gradient(180deg, #f7fbff 0%, #d9f0ff 44%, #f4fbff 100%)'
}
}
},
mounted() {
const { statusBarHeight = 0 } = uni.getSystemInfoSync()
this.statusBarHeight = statusBarHeight
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const route = currentPage && currentPage.route ? currentPage.route : ''
this.currentRoute = route ? `/${route}` : ''
},
methods: {
handleBack() {
const pages = getCurrentPages()
if (pages.length > 1) {
uni.navigateBack({
delta: 1
})
return
}
uni.switchTab({
url: '/pages/index/index'
})
}
}
}
</script>
<style lang="scss" scoped>
.hero-section {
position: relative;
//padding: 0 0 30rpx;
overflow: hidden;
backgroud: url('@/static/indexBg.jpg');
}
.hero-bg {
position: absolute;
border-radius: 50%;
filter: blur(8rpx);
opacity: 0.9;
backgroud: url('@/static/indexBg.jpg');
}
.hero-bg-left {
top: 84rpx;
left: -30rpx;
width: 300rpx;
height: 200rpx;
background: radial-gradient(circle, rgba(197, 237, 255, 0.95) 0%, rgba(197, 237, 255, 0) 72%);
}
.hero-bg-right {
top: 46rpx;
right: -40rpx;
width: 360rpx;
height: 260rpx;
background: radial-gradient(circle, rgba(184, 231, 255, 0.92) 0%, rgba(184, 231, 255, 0) 72%);
}
.navbar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
padding-left: 28rpx;
padding-right: 20rpx;
background: rgba(255, 255, 255, 0.72);
backdrop-filter: blur(18rpx);
-webkit-backdrop-filter: blur(18rpx);
box-shadow: 0 10rpx 28rpx rgba(65, 105, 135, 0.08);
}
.navbar-inner {
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.navbar-left {
width: 72rpx;
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
}
.nav-back-btn {
width: 72rpx;
height: 72rpx;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.72);
box-shadow: 0 8rpx 18rpx rgba(115, 164, 196, 0.14);
display: flex;
align-items: center;
justify-content: center;
}
.navbar-title {
flex: 1;
font-size: 28rpx;
font-weight: 700;
color: #101214;
letter-spacing: 2rpx;
text-align: center;
}
.navbar-spacer {
width: 100%;
}
.navbar-right-placeholder {
width: 72rpx;
height: 72rpx;
flex-shrink: 0;
opacity: 0;
}
</style>