完成支付宝分包
This commit is contained in:
parent
f44238d9bc
commit
bcb487daab
16
App.vue
16
App.vue
|
|
@ -4,7 +4,21 @@ export default {
|
|||
const startTime = Date.now()
|
||||
console.log('App Launch', options)
|
||||
|
||||
// 1. 同步初始化配置(必须完成)
|
||||
// 1. 获取并存储系统信息(只获取一次)
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
uni.setStorageSync('systemInfo', {
|
||||
platform: systemInfo.platform,
|
||||
system: systemInfo.system,
|
||||
osName: systemInfo.osName,
|
||||
osVersion: systemInfo.osVersion,
|
||||
statusBarHeight: systemInfo.statusBarHeight,
|
||||
windowWidth: systemInfo.windowWidth,
|
||||
windowHeight: systemInfo.windowHeight,
|
||||
isIOS: systemInfo.platform === 'ios',
|
||||
isAndroid: systemInfo.platform === 'android'
|
||||
})
|
||||
|
||||
// 2. 同步初始化配置(必须完成)
|
||||
this.initConfig(options)
|
||||
|
||||
// 启动完成
|
||||
|
|
|
|||
|
|
@ -83,10 +83,7 @@
|
|||
import {
|
||||
reactive,
|
||||
toRefs,
|
||||
ref,
|
||||
defineExpose,
|
||||
defineProps,
|
||||
defineEmits
|
||||
ref
|
||||
} from 'vue'
|
||||
import addBillJson from '@/static/json/add-bill.json'
|
||||
|
||||
|
|
|
|||
8
main.js
8
main.js
|
|
@ -20,15 +20,11 @@ export function createApp() {
|
|||
// 将store挂载到全局
|
||||
app.config.globalProperties.$store = store
|
||||
|
||||
// 获取系统信息并挂载到全局
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
// 从缓存读取系统信息(已在App.vue中获取)
|
||||
const systemInfo = uni.getStorageSync('systemInfo') || {}
|
||||
app.config.globalProperties.$platform = systemInfo.platform
|
||||
app.config.globalProperties.$systemInfo = systemInfo
|
||||
|
||||
// 获取系统信息
|
||||
const { getSystemInfo } = useStore()
|
||||
getSystemInfo()
|
||||
|
||||
return {
|
||||
app
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
"autoclose": true,
|
||||
"delay": 0
|
||||
},
|
||||
"optimization": {
|
||||
"subPackages": true
|
||||
},
|
||||
"runmode": "liberate", // 开启分包优化后,必须配置资源释放模式
|
||||
/* 模块配置 */
|
||||
"modules": {
|
||||
"Camera": {}
|
||||
|
|
|
|||
81
pages.json
81
pages.json
|
|
@ -7,9 +7,14 @@
|
|||
"navigationBarTitleText": "uni-app",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
"subPackages": [
|
||||
{
|
||||
"path": "pages/balance/index",
|
||||
"root": "pages/balance",
|
||||
"pages": [
|
||||
{
|
||||
"path": "index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额页面",
|
||||
"navigationStyle": "custom",
|
||||
|
|
@ -17,55 +22,77 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/bill/bill-list/bill-list",
|
||||
"path": "fast-entrance-management/fast-entrance-management",
|
||||
"style": {
|
||||
"navigationBarTitleText": "快速入口页面",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "pages/bill",
|
||||
"pages": [
|
||||
{
|
||||
"path": "bill-list/bill-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "账单列表页面",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/bill/add-bill/add-bill",
|
||||
"path": "add-bill/add-bill",
|
||||
"style": {
|
||||
"navigationBarTitleText": "新增账单",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/hot-icon/hot-icon",
|
||||
"path": "bill-detail/bill-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "账单详情页",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "pages/common",
|
||||
"pages": [
|
||||
{
|
||||
"path": "hot-icon/hot-icon",
|
||||
"style": {
|
||||
"navigationBarTitleText": "热门图标",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/balance/fast-entrance-management/fast-entrance-management",
|
||||
"style": {
|
||||
"navigationBarTitleText": "快速入口页面",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/bill/bill-detail/bill-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "账单详情页",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/index/alipay-annual-bill/alipay-annual-bill",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付宝年度账单",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/webview/webview",
|
||||
"path": "webview/webview",
|
||||
"style": {
|
||||
"navigationBarTitleText": "webView页面",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "alipay-annual-bill/alipay-annual-bill",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付宝年度账单",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"preloadRule": {
|
||||
"pages/index/index": {
|
||||
"network": "all",
|
||||
"packages": [
|
||||
"pages/balance",
|
||||
"pages/bill",
|
||||
"pages/common"
|
||||
]
|
||||
}
|
||||
},
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
|
|
|
|||
|
|
@ -70,8 +70,7 @@
|
|||
<view class="group-box">
|
||||
<image class="title-img" src="/static/image/index/monixiaobao.png"></image>
|
||||
<view class="menu-box">
|
||||
<view class="item-box" v-for="item in menuList" :key="item.name"
|
||||
@click="util.goPage(item.path)">
|
||||
<view class="item-box" v-for="item in menuList" :key="item.name" @click="clickMenu(item)">
|
||||
<view class="menu-item" :style="{ width: (windowWidth - 50) / 2 + 'px' }">
|
||||
<!-- <text class="menu-item-name">{{ item.name }}</text> -->
|
||||
<image class="name-img" :src="'/static/image/index/menu-name/' + item.icon + '.png'"
|
||||
|
|
@ -88,7 +87,7 @@
|
|||
<view class="activity-box">
|
||||
<image class="alipay-year-bill" :style="{ width: (windowWidth - 32) + 'px' }"
|
||||
src="/static/image/index/alipay-year-bill.png" mode="widthFix"
|
||||
@click="util.goPage(`/pages/index/alipay-annual-bill/alipay-annual-bill`)"></image>
|
||||
@click="util.goPage(`/pages/common/alipay-annual-bill/alipay-annual-bill`)"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
@ -103,7 +102,7 @@
|
|||
<script setup>
|
||||
import {
|
||||
util,
|
||||
deviceUtil
|
||||
uiUtil
|
||||
} from '@/utils/common.js'
|
||||
import {
|
||||
storage
|
||||
|
|
@ -285,6 +284,14 @@ const setUserData = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const clickMenu = (item) => {
|
||||
if (!item.path) {
|
||||
uiUtil.showError('开发中')
|
||||
} else {
|
||||
util.goPage(item.path)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击视频教程
|
||||
* @param item
|
||||
|
|
@ -685,10 +692,6 @@ const runMarqueeAnimation = (containerWidth, textWidth, myId) => {
|
|||
margin: 0 32rpx;
|
||||
}
|
||||
|
||||
.alipay-year-bill {
|
||||
/* width: 100%; */
|
||||
}
|
||||
|
||||
.footer-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,17 @@ import { storage } from '../utils/storage';
|
|||
|
||||
|
||||
|
||||
// 防抖函数
|
||||
const debounce = (fn, delay = 300) => {
|
||||
let timer = null
|
||||
return function (...args) {
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
fn.apply(this, args)
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
||||
// 定义应用的全局状态
|
||||
export const store = reactive({
|
||||
// 用户信息
|
||||
|
|
@ -15,11 +26,12 @@ export const store = reactive({
|
|||
notifications: true
|
||||
},
|
||||
|
||||
// 系统信息
|
||||
systemInfo: {
|
||||
// 系统信息(从缓存读取,避免重复调用)
|
||||
systemInfo: uni.getStorageSync('systemInfo') || {
|
||||
statusBarHeight: 0,
|
||||
windowHeight: 0,
|
||||
windowWidth: 0
|
||||
windowWidth: 0,
|
||||
platform: ''
|
||||
},
|
||||
|
||||
// 账单列表
|
||||
|
|
@ -71,8 +83,16 @@ export const useStore = () => {
|
|||
return store.billList
|
||||
}
|
||||
|
||||
// 数据持久化
|
||||
// 监听store变化,自动保存到本地存储
|
||||
// 手动保存账单列表(替代自动监听)
|
||||
const saveBillList = debounce(() => {
|
||||
storage.set('bill_list', store.billList)
|
||||
}, 500)
|
||||
|
||||
// 优化后的监听:使用防抖减少存储频率
|
||||
const debouncedSaveSettings = debounce((newValue) => {
|
||||
storage.set('settings', newValue)
|
||||
}, 500)
|
||||
|
||||
watch(
|
||||
() => store.userInfo,
|
||||
(newValue) => storage.set('userInfo', newValue),
|
||||
|
|
@ -81,28 +101,18 @@ export const useStore = () => {
|
|||
|
||||
watch(
|
||||
() => store.settings,
|
||||
(newValue) => storage.set('settings', newValue),
|
||||
(newValue) => debouncedSaveSettings(newValue),
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => store.billList,
|
||||
(newValue) => storage.set('bill_list', newValue),
|
||||
{ deep: true }
|
||||
);
|
||||
// 移除billList的自动监听,改为手动调用saveBillList
|
||||
|
||||
// 获取系统信息
|
||||
// 获取系统信息(从缓存读取)
|
||||
const getSystemInfo = () => {
|
||||
uni.getSystemInfo({
|
||||
success: (res) => {
|
||||
store.systemInfo.statusBarHeight = res.statusBarHeight || 0;
|
||||
store.systemInfo.windowHeight = res.windowHeight || 0;
|
||||
store.systemInfo.windowWidth = res.windowWidth || 0;
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取系统信息失败:', err);
|
||||
const cachedInfo = uni.getStorageSync('systemInfo')
|
||||
if (cachedInfo) {
|
||||
store.systemInfo = cachedInfo
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
@ -114,6 +124,7 @@ export const useStore = () => {
|
|||
updateBill,
|
||||
deleteBill,
|
||||
getBillList,
|
||||
saveBillList,
|
||||
getSystemInfo
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue