暂存
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
// #ifdef H5
|
||||
import '@/lib/encryption/sm4.min.js'
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
import { sm4 } from 'sm-crypto';
|
||||
// #endif
|
||||
|
||||
|
||||
import useUserStore from "../stores/useUserStore";
|
||||
import {
|
||||
createRequestWithCache,
|
||||
@@ -601,7 +609,6 @@ export function sm4Decrypt(key, value, mode = "hex") {
|
||||
cipherType: mode === 'hex' ? 'hex' : 'base64',
|
||||
padding: 'pkcs#5'
|
||||
});
|
||||
|
||||
return decrypted
|
||||
|
||||
} catch (e) {
|
||||
@@ -641,6 +648,10 @@ export function isY9MachineType() {
|
||||
const ua = navigator.userAgent;
|
||||
const isY9Machine = /Y9-ZYYH/i.test(ua); // 匹配机器型号
|
||||
return isY9Machine;
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 一体机环境判断
|
||||
@@ -648,10 +659,16 @@ export function isAsdMachineType() {
|
||||
// const ua = navigator.userAgent;
|
||||
// const isY9Machine = /asd_hanweb/i.test(ua); // 匹配机器型号
|
||||
// return isY9Machine;
|
||||
try {
|
||||
return !!lightAppJssdk.user
|
||||
} catch (error) {
|
||||
false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const $api = {
|
||||
msg,
|
||||
prePage,
|
||||
|
||||
@@ -3,42 +3,35 @@
|
||||
<view v-if="loading" class="loading">
|
||||
<view class="semicircle-loader"></view>
|
||||
</view>
|
||||
<view class="container" id="pixi-box" ref="pixiContainerRef"></view>
|
||||
<!-- 通信组件 -->
|
||||
<view style="display: none" :random="random" :change:random="appModule.initPixi" :tagsConfig="tagsConfig" :change:tagsConfig="appModule.setTags" />
|
||||
<view v-else class="container" id="pixi-box" ref="pixiContainerRef"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
<script setup>
|
||||
import { onMounted, onUnmounted, ref, nextTick, watch } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
tags: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
default: [],
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: () => false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
tags: {
|
||||
handler(val) {
|
||||
if (val && val.length) {
|
||||
this.tagsConfig.map((tag, index) => {
|
||||
tag.name = val[index]?.job_name;
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.random++;
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
data: () => ({
|
||||
random: 0,
|
||||
tagsConfig: [
|
||||
});
|
||||
const emit = defineEmits(['tag-click']);
|
||||
|
||||
// DOM Ref
|
||||
const pixiContainerRef = ref(null);
|
||||
|
||||
// PIXI 变量
|
||||
let app = null;
|
||||
let tagsContainer = null;
|
||||
let activeTagInstances = [];
|
||||
|
||||
// 配置数据
|
||||
const tagsConfig = ref([
|
||||
{ bgColor: 0x0069fe, fontColor: 0xffffff, size: 16, opacity: 1.0, angle: 0, radius: 0 },
|
||||
{
|
||||
bgColor: 0x87e2ec,
|
||||
@@ -87,6 +80,7 @@ export default {
|
||||
radius: 100,
|
||||
tailRotation: -(3 * Math.PI) / 4.5,
|
||||
},
|
||||
|
||||
{
|
||||
bgColor: 0xff9400,
|
||||
fontColor: 0xffffff,
|
||||
@@ -124,57 +118,55 @@ export default {
|
||||
radius: 120,
|
||||
tailRotation: Math.PI / 3,
|
||||
},
|
||||
],
|
||||
}),
|
||||
methods: {
|
||||
tagClick(tagData) {
|
||||
this.$emit("tag-click", tagData);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
]);
|
||||
|
||||
<script module="appModule" lang="renderjs">
|
||||
watch(
|
||||
() => props.tags,
|
||||
(val) => {
|
||||
if (val && val.length) {
|
||||
tagsConfig.value.map((tag, index) => {
|
||||
// console.log(val[index])
|
||||
tag.name = val[index]?.job_name;
|
||||
});
|
||||
setTimeout(() => {
|
||||
initPixi();
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
window.addEventListener('resize', handleResize);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize);
|
||||
if (app) {
|
||||
app.destroy(true, { children: true, texture: true, baseTexture: true });
|
||||
app = null;
|
||||
}
|
||||
});
|
||||
|
||||
const getContainerDOM = () => {
|
||||
const refVal = pixiContainerRef.value;
|
||||
if (!refVal) return document.getElementById('pixi-box');
|
||||
if (refVal.$el) return refVal.$el;
|
||||
return refVal;
|
||||
};
|
||||
|
||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
app:null,
|
||||
finallyTags:[],
|
||||
tagsContainer:null,
|
||||
activeTagInstances:[],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.app) {
|
||||
this.app.destroy(true, { children: true, texture: true, baseTexture: true });
|
||||
this.app = null;
|
||||
}
|
||||
window.removeEventListener("resize", this.handleResize);
|
||||
},
|
||||
methods:{
|
||||
setTags(tags){
|
||||
this.finallyTags = [...tags]
|
||||
console.log(this.finallyTags,'+++++')
|
||||
},
|
||||
getContainerDOM(){
|
||||
return document.getElementById('pixi-box');
|
||||
},
|
||||
initPixi(random){
|
||||
if(!random > 0) return
|
||||
const container = this.getContainerDOM();
|
||||
const initPixi = () => {
|
||||
const container = getContainerDOM();
|
||||
if (!container) return;
|
||||
|
||||
const width = container.clientWidth || 300;
|
||||
const height = container.clientHeight || 300;
|
||||
|
||||
if (this.app) return;
|
||||
if (app) return;
|
||||
|
||||
this.app = new PIXI.Application({
|
||||
app = new PIXI.Application({
|
||||
width: width,
|
||||
height: height,
|
||||
backgroundAlpha: 0,
|
||||
@@ -183,45 +175,31 @@ export default {
|
||||
resolution: window.devicePixelRatio || 1,
|
||||
autoDensity: true,
|
||||
});
|
||||
this.app.view.style.touchAction = 'auto';
|
||||
app.view.style.touchAction = 'auto';
|
||||
|
||||
container.appendChild(this.app.view);
|
||||
container.appendChild(app.view);
|
||||
|
||||
this.tagsContainer = new PIXI.Container();
|
||||
this.app.stage.addChild(this.tagsContainer);
|
||||
tagsContainer = new PIXI.Container();
|
||||
app.stage.addChild(tagsContainer);
|
||||
|
||||
this.renderScene(width, height);
|
||||
},
|
||||
renderScene(width, height);
|
||||
};
|
||||
|
||||
renderScene(sw, sh){
|
||||
const renderScene = (sw, sh) => {
|
||||
let ratio = window.innerWidth / 400;
|
||||
if (ratio < 1) ratio = 1;
|
||||
tagsContainer.removeChildren();
|
||||
activeTagInstances = [];
|
||||
|
||||
// 先清理旧的标签事件监听器
|
||||
if (this.activeTagInstances && this.activeTagInstances.length > 0) {
|
||||
this.activeTagInstances.forEach(tag => {
|
||||
if (tag) {
|
||||
tag.eventMode = 'none';
|
||||
tag.removeAllListeners();
|
||||
}
|
||||
});
|
||||
this.activeTagInstances = [];
|
||||
}
|
||||
// 确保容器清空
|
||||
if (this.tagsContainer) {
|
||||
this.tagsContainer.removeChildren();
|
||||
}
|
||||
|
||||
|
||||
this.finallyTags.forEach((data, index) => {
|
||||
tagsConfig.value.forEach((data, index) => {
|
||||
const scaledRadius = data.radius * ratio;
|
||||
|
||||
let x = sw / 2 + scaledRadius * Math.cos(data.angle);
|
||||
let y = sh / 2 + scaledRadius * Math.sin(data.angle);
|
||||
|
||||
const tag = this.createTag(data, index, ratio);
|
||||
const tag = createTag(data, index, ratio);
|
||||
|
||||
this.tagsContainer.addChild(tag);
|
||||
tagsContainer.addChild(tag);
|
||||
|
||||
const safeW = tag.width / 2 + 10;
|
||||
const safeH = tag.height / 2 + 10;
|
||||
@@ -246,7 +224,7 @@ export default {
|
||||
};
|
||||
|
||||
if (data.radius > 0) {
|
||||
const tail = this.createCometTail(
|
||||
const tail = createCometTail(
|
||||
data.tailColor || data.bgColor,
|
||||
data.tailRotation,
|
||||
tag.width,
|
||||
@@ -257,13 +235,13 @@ export default {
|
||||
tag.updateTail = () => tail.updateAnim();
|
||||
}
|
||||
|
||||
this.activeTagInstances.push(tag);
|
||||
activeTagInstances.push(tag);
|
||||
});
|
||||
|
||||
// 动画循环
|
||||
this.app.ticker.add(() => {
|
||||
const screenH = this.app.screen.height;
|
||||
this.activeTagInstances.forEach((tag) => {
|
||||
app.ticker.add(() => {
|
||||
const screenH = app.screen.height;
|
||||
activeTagInstances.forEach((tag) => {
|
||||
const meta = tag.userData;
|
||||
if (meta) {
|
||||
// 计算新的浮动位置
|
||||
@@ -280,17 +258,15 @@ export default {
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
createTag(tagData, index, ratio){
|
||||
const createTag = (tagData, index, ratio) => {
|
||||
if (ratio > 1) ratio = ratio * 0.9;
|
||||
const tagGroup = new PIXI.Container();
|
||||
tagGroup.cursor = 'pointer';
|
||||
tagGroup.eventMode = 'static';
|
||||
tagGroup.cursor = 'pointer';
|
||||
|
||||
tagGroup.on('pointertap', () =>{
|
||||
this.$ownerInstance.callMethod('tagClick', tagData);
|
||||
});
|
||||
tagGroup.on('pointertap', () => emit('tag-click', tagData));
|
||||
|
||||
const text = new PIXI.Text(tagData.name, {
|
||||
fontFamily: ['PingFang SC', 'Microsoft YaHei', 'Arial'],
|
||||
@@ -317,9 +293,9 @@ export default {
|
||||
tagGroup.addChild(text);
|
||||
|
||||
return tagGroup;
|
||||
},
|
||||
};
|
||||
|
||||
createCometTail(bgColor, tailRotation, parentWidth, parentHeight, ratio){
|
||||
const createCometTail = (bgColor, tailRotation, parentWidth, parentHeight, ratio) => {
|
||||
if (ratio > 1) ratio = ratio;
|
||||
const tailGroup = new PIXI.Container();
|
||||
const graphics = new PIXI.Graphics();
|
||||
@@ -369,18 +345,15 @@ export default {
|
||||
};
|
||||
tailGroup.updateAnim();
|
||||
return tailGroup;
|
||||
},
|
||||
};
|
||||
|
||||
handleResize(){
|
||||
const container = this.getContainerDOM();
|
||||
if (!this.app || !container) return;
|
||||
this.app.destroy(true, { children: true, texture: true, baseTexture: true });
|
||||
this.app = null;
|
||||
this.initPixi(1);
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
const handleResize = () => {
|
||||
const container = getContainerDOM();
|
||||
if (!app || !container) return;
|
||||
app.destroy(true, { children: true, texture: true, baseTexture: true });
|
||||
app = null;
|
||||
initPixi();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -22,6 +22,9 @@ const useLocationStore = defineStore("location", () => {
|
||||
const count = ref(0)
|
||||
|
||||
function getLocation() { // 获取经纬度两个平台
|
||||
// #ifndef H5
|
||||
const lightAppJssdk = {}
|
||||
// #endif
|
||||
return new Promise((resole, reject) => {
|
||||
try {
|
||||
if (lightAppJssdk.map) {
|
||||
|
||||
@@ -52,6 +52,7 @@ class ScreenDetectionManager {
|
||||
|
||||
// 检测折叠屏
|
||||
checkVisualViewport() {
|
||||
try {
|
||||
if (window.visualViewport?.segments?.length > 1) {
|
||||
return {
|
||||
foldable: true,
|
||||
@@ -63,6 +64,13 @@ class ScreenDetectionManager {
|
||||
count: 1
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
foldable: false,
|
||||
count: 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 动态加载 CSS
|
||||
|
||||
17
utils/db.js
17
utils/db.js
@@ -1,4 +1,5 @@
|
||||
import IndexedDBHelper from '@/common/IndexedDBHelper.js'
|
||||
import UniStorageHelper from '@/common/UniStorageHelper.js'
|
||||
import useChatGroupDBStore from '@/stores/userChatGroupStore'
|
||||
import config from '@/config'
|
||||
|
||||
@@ -66,7 +67,14 @@ class BaseStore {
|
||||
}
|
||||
|
||||
initDB() {
|
||||
// #ifdef H5
|
||||
this.db = new IndexedDBHelper(this.dbName, config.DBversion);
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
this.db = new UniStorageHelper(this.dbName, config.DBversion);
|
||||
// #endif
|
||||
|
||||
return this.db.openDB([{
|
||||
name: 'record',
|
||||
keyPath: "id",
|
||||
@@ -103,8 +111,15 @@ class BaseStore {
|
||||
}
|
||||
|
||||
async clearDB() {
|
||||
// 修正拼写错误并优化 Promise 写法
|
||||
|
||||
|
||||
// #ifdef H5
|
||||
return new IndexedDBHelper().deleteDB(this.dbName);
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
return new UniStorageHelper().deleteDB(this.dbName);
|
||||
// #endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user