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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,7 +15,15 @@
<view class="nearby-content"> <view class="nearby-content">
<swiper class="swiper" :current="state.current" @change="changeSwiperType"> <swiper class="swiper" :current="state.current" @change="changeSwiperType">
<swiper-item class="swiper-item" v-for="(_, index) in 4" :key="index"> <swiper-item class="swiper-item" v-for="(_, index) in 4" :key="index">
<!-- #ifndef MP-WEIXIN -->
<component :is="components[index]" :ref="(el) => handelComponentsRef(el, index)" /> <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-item>
</swiper> </swiper>
</view> </view>

View File

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