flat: 兼容

This commit is contained in:
史典卓
2025-05-13 11:42:17 +08:00
parent fd74b7d4df
commit 5333254c58
8 changed files with 68 additions and 23 deletions

12
App.vue
View File

@@ -7,11 +7,11 @@ const { $api, navTo, appendScriptTagElement } = inject('globalFunction');
onLaunch((options) => {
useDictStore().getDictData();
uni.onTabBarMidButtonTap(() => {
uni.navigateTo({
url: '/pages/chat/chat',
});
});
// uni.onTabBarMidButtonTap(() => {
// uni.navigateTo({
// url: '/pages/chat/chat',
// });
// });
let token = uni.getStorageSync('token') || ''; // 同步获取 缓存信息
if (token) {
@@ -28,6 +28,7 @@ onLaunch((options) => {
});
onMounted(() => {
// #ifndef MP-WEIXIN
if (process.env.NODE_ENV === 'development') {
appendScriptTagElement('./static/js/jweixin-1.4.0.js').then(() => {
console.log('✅ 微信 JSSDK 加载完成');
@@ -37,6 +38,7 @@ onMounted(() => {
console.log('✅ 微信 JSSDK 加载完成');
});
}
// #endif
});
onShow(() => {

View File

@@ -164,10 +164,17 @@ pre code {
white-space: pre-wrap; /* 保证换行处理 */
}
/* #ifndef MP-WEIXIN */
pre code:empty,
pre code:not(:has(*)):not(:has(text)) {
display: none;
}
/* #endif */
/* #ifdef MP-WEIXIN */
pre code:empty {
display: none;
}
/* #endif */
.code-container {
position: relative;

View File

@@ -7,6 +7,7 @@ import SelectPopup from './selectPopup.vue';
export default {
install(app) {
const popupApp = createApp(SelectPopup);
// #ifdef H5
const popupInstance = popupApp.mount(document.createElement('div'));
document.body.appendChild(popupInstance.$el);
@@ -14,7 +15,11 @@ export default {
const openPopup = (config) => {
popupInstance.open(config);
};
// #endif
// #ifndef H5
const openPopup = (config) => {};
// #endif
// 提供给所有组件使用
app.provide('openSelectPopup', openPopup);
}

View File

@@ -4,8 +4,9 @@
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "青岛智慧就业平台",
// #ifdef H5
"navigationStyle": "custom"
// #endif
}
},
{

View File

@@ -1,6 +1,11 @@
<template>
<view class="chat-container">
<!-- #ifdef MP-WEIXIN -->
<view class="chat-background">
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view class="chat-background" v-fade:600="!messages.length">
<!-- #endif -->
<image class="backlogo" src="/static/icon/backAI.png"></image>
<view class="back-rowTitle">欢迎使用青岛AI智能求职</view>
<view class="back-rowText">
@@ -20,7 +25,12 @@
</view>
</view>
<scroll-view class="chat-list scrollView" :scroll-top="scrollTop" :scroll-y="true" scroll-with-animation>
<!-- #ifdef MP-WEIXIN -->
<view class="chat-list list-content">
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view class="chat-list list-content" v-fade:600="messages.length >= 1">
<!-- #endif -->
<view
v-for="(msg, index) in messages"
:key="index"

View File

@@ -17,7 +17,13 @@
<view class="container-main">
<swiper class="swiper" :current="state.current" @change="changeSwiperType">
<swiper-item class="swiper-item" v-for="(_, index) in 2" :key="index">
<!-- #ifndef MP-WEIXIN -->
<component :is="components[index]" :ref="(el) => handelComponentsRef(el, index)" />
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<ReadComponent v-show="currentIndex === 0" :ref="(el) => handelComponentsRef(el, index)" />
<UnreadComponent v-show="currentIndex === 1" :ref="(el) => handelComponentsRef(el, index)" />
<!-- #endif -->
</swiper-item>
</swiper>
</view>
@@ -28,11 +34,11 @@
<script setup>
import { reactive, inject, watch, ref, onMounted } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import readComponent from './read.vue';
import unreadComponent from './unread.vue';
import ReadComponent from './read.vue';
import UnreadComponent from './unread.vue';
const loadedMap = reactive([false, false]);
const swiperRefs = [ref(null), ref(null)];
const components = [readComponent, unreadComponent];
const components = [ReadComponent, UnreadComponent];
const state = reactive({
current: 0,

View File

@@ -15,7 +15,15 @@
<view class="nearby-content">
<swiper class="swiper" :current="state.current" @change="changeSwiperType">
<swiper-item class="swiper-item" v-for="(_, index) in 4" :key="index">
<!-- #ifndef MP-WEIXIN -->
<component :is="components[index]" :ref="(el) => handelComponentsRef(el, index)" />
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<oneComponent v-show="currentIndex === 0" :ref="(el) => handelComponentsRef(el, index)" />
<twoComponent v-show="currentIndex === 1" :ref="(el) => handelComponentsRef(el, index)" />
<threeComponent v-show="currentIndex === 2" :ref="(el) => handelComponentsRef(el, index)" />
<fourComponent v-show="currentIndex === 3" :ref="(el) => handelComponentsRef(el, index)" />
<!-- #endif -->
</swiper-item>
</swiper>
</view>

View File

@@ -1,8 +1,7 @@
{
"description": "项目配置文件。",
"packOptions": {
"ignore": [],
"include": []
"ignore": []
},
"setting": {
"urlCheck": false,
@@ -10,21 +9,28 @@
"postcss": true,
"minified": true,
"newFeature": true,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": true
"bigPackageSizeSupport": true
},
"compileType": "miniprogram",
"libVersion": "3.6.3",
"libVersion": "",
"appid": "touristappid",
"projectname": "qingdao-employment-service",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"current": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}