Merge remote-tracking branch 'origin/main'

This commit is contained in:
朱浩 2025-02-17 09:37:19 +08:00
commit b3b1dde262
6 changed files with 77 additions and 11 deletions

View File

@ -80,6 +80,7 @@ provide(injectKeySlideScale, scale)
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.slide-item {
position: absolute;

View File

@ -198,7 +198,7 @@ export default (isLoader?: boolean = true) => {
const touchInfo = ref<{ x: number; y: number; } | null>(null)
const touchStartListener = (e: TouchEvent) => {
e.preventDefault() // 阻止默认事件
// e.preventDefault() // 阻止默认事件
touchInfo.value = {
// x: e.changedTouches[0].pageX,
// y: e.changedTouches[0].pageY,
@ -208,6 +208,7 @@ export default (isLoader?: boolean = true) => {
}
const touchEndListener = (e: TouchEvent) => {
if (!touchInfo.value) return
// window.scrollTo(0, 0) // 滚动到顶部
const offsetX = Math.abs(touchInfo.value.x - e.changedTouches[0].clientX)
const offsetY = e.changedTouches[0].clientY - touchInfo.value.y
if ( Math.abs(offsetY) > offsetX && Math.abs(offsetY) > 50 ) {

View File

@ -23,7 +23,7 @@
</li>
<li v-if="computedregistertype!=4" :class="computedregistertype==1 || computedregistertype==2 ? '':'pointer-events'" @click="onUserTo('/joinSchool')">加入学校</li>
<li @click="onUserTo('/profile')">个人中心</li>
<li v-if="isStadium() !== true" @click="onUserTo('/schoolManagement')">学校管理</li>
<li v-if="isStadium() !== true && checkRole(['admin','headmaster'])" @click="onUserTo('/schoolManagement')">学校管理</li>
<li v-if="isStadium() !== true" @click="onUserTo('/class')">班级中心</li>
<li @click="logout">退出登录</li>
</ul>
@ -65,7 +65,7 @@ import pkc from "../../../../../package.json"
import defaultUserImg from '@/assets/images/img-avatar.png'
import { sessionStore } from '@/utils/store'
import {toLinkLeftWeb} from "@/utils/tool"
import { checkRole } from '@/utils/permission'
const { ipcRenderer } = window.electron || {}
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
@ -86,6 +86,7 @@ const defaultImg = ['/img/avatar-default.jpg','/images/img-avatar.png','/src/ass
//
const isStadium = () => {
console.log('isStadium',userStore.roles )
let user = userStore.user
let roles = user.roles
return roles.some(item => item.roleKey === 'stadium')

View File

@ -0,0 +1,51 @@
import useUserStore from '@/store/modules/user'
/**
* 字符权限校验
* @param {Array} value 校验值
* @returns {Boolean}
*/
export function checkPermi(value) {
if (value && value instanceof Array && value.length > 0) {
const permissions = useUserStore().permissions
const permissionDatas = value
const all_permission = "*:*:*";
const hasPermission = permissions.some(permission => {
return all_permission === permission || permissionDatas.includes(permission)
})
if (!hasPermission) {
return false
}
return true
} else {
console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
return false
}
}
/**
* 角色权限校验
* @param {Array} value 校验值
* @returns {Boolean}
*/
export function checkRole(value) {
if (value && value instanceof Array && value.length > 0) {
const roles = useUserStore().roles
const permissionRoles = value
const super_admin = "admin";
const hasRole = roles.some(role => {
return super_admin === role || permissionRoles.includes(role)
})
if (!hasRole) {
return false
}
return true
} else {
console.error(`need roles! Like checkRole="['admin','editor']"`)
return false
}
}

View File

@ -438,17 +438,23 @@ const toRousrceUrl = async (o) => {
if (!!o.src) { // src
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
const isBlobUrl = /^blob:/.test(o.src)
let onLineUrl = '' // 线
if (!!o.zipPath) onLineUrl = pptMedia[o.zipPath] || '' //
let onLineUrl = '', typeExt = '' // 线|
if (!!o.zipPath) {
onLineUrl = pptMedia[o.zipPath] || '' //
typeExt = o.zipPath.split('.').pop()
}
if (onLineUrl) o.src = onLineUrl // 线
else { //
if (isBase64) { //
const url = await getOnlineFileUrl(o.src)
if(!typeExt) typeExt = 'png'
const url = await getOnlineFileUrl(o.src, typeExt)
url &&(o.src = url)
url && o.zipPath && (pptMedia[o.zipPath] = url) //
} else if (isBlobUrl) { //
if(!typeExt) typeExt = o.type=='video'?'mp4':'mp3'
const res = await fetch(o.src)
const blob = await res.blob()
const url = await getOnlineFileUrl(blob, o.type=='video'?'mp4':'mp3')
const url = await getOnlineFileUrl(blob, typeExt)
URL.revokeObjectURL(o.src) //
url &&(o.src = url)
url && o.zipPath && (pptMedia[o.zipPath] = url) //

View File

@ -653,17 +653,23 @@ export default {
if (!!o.src) { // src
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
const isBlobUrl = /^blob:/.test(o.src)
let onLineUrl = '' // 线
if (!!o.zipPath) onLineUrl = this.pptMedia[o.zipPath] || '' //
let onLineUrl = '', typeExt = '' // 线|
if (!!o.zipPath) {
onLineUrl = this.pptMedia[o.zipPath] || '' //
typeExt = o.zipPath.split('.').pop()
}
if (onLineUrl) o.src = onLineUrl // 线
else { //
if (isBase64) { //
const url = await this.getOnlineFileUrl(o.src)
if(!typeExt) typeExt = 'png'
const url = await this.getOnlineFileUrl(o.src, typeExt)
url &&(o.src = url)
url && o.zipPath && (this.pptMedia[o.zipPath] = url) //
} else if (isBlobUrl) { //
if(!typeExt) typeExt = o.type=='video'?'mp4':'mp3'
const res = await fetch(o.src)
const blob = await res.blob()
const url = await this.getOnlineFileUrl(blob, o.type=='video'?'mp4':'mp3')
const url = await this.getOnlineFileUrl(blob, typeExt)
URL.revokeObjectURL(o.src) //
url &&(o.src = url)
url && o.zipPath && (this.pptMedia[o.zipPath] = url) //