This commit is contained in:
zdg 2024-12-20 09:44:02 +08:00
commit e5667fac2d
5 changed files with 172 additions and 37 deletions

View File

@ -1,26 +1,35 @@
<template> <template>
<draggable handle=".header-btn" :draggable="false" item-key="backgroundColor" v-model="gridPicList" class="grid-pic-wrap" :style="getGrid"> <div style="position: relative;height: 100%;width: 100%;">
<template #item="{ element, index }"> <draggable handle=".header-btn" :draggable="false" item-key="backgroundColor" v-model="gridPicList" class="grid-pic-wrap" :style="getGrid">
<div class="grid-pic-item" :key="element.backgroundColor" :style="getWH(element,index)"> <template #item="{ element, index }">
<div class="delete-btn" @click="gridPicList.splice(index,1)">X</div> <div class="grid-pic-item" :key="element.backgroundColor" :style="getWH(element,index)">
<div class="header-btn"></div> <div class="delete-btn" @click="gridPicList.splice(index,1)">X</div>
<ViewerItem :gridPicList="gridPicList" :index="index" :images="[element.src]"></ViewerItem> <div class="header-btn"></div>
</div> <ViewerItem :gridPicList="gridPicList" :index="index" :images="element"></ViewerItem>
</template> </div>
</draggable> </template>
<el-input style="position:fixed;bottom: 20px;right: 80px;width: 1000px" v-model="inputValue" type="text" /> </draggable>
<el-button class="add-btn" @click="addPic"> <el-input style="position:fixed;bottom: 20px;right: 180px;width: 1000px" v-model="inputValue" type="text" />
添加 <el-button class="add-btn" @click="addPic">
</el-button> 添加
</el-button>
<el-button style="position:fixed;bottom: 20px;right: 80px;" @click="startPencil">
画笔
</el-button>
<div class="modal-mode">
<canvas id="canvas_pic_001" style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;"></canvas>
</div>
</div>
</template> </template>
<script setup> <script setup>
import {ref, computed} from 'vue' import {ref, computed, onMounted} from 'vue'
import Draggable from 'vuedraggable' import Draggable from 'vuedraggable'
import ViewerItem from "./viewer-item.vue"; import ViewerItem from "./viewer-item.vue";
import Fabric from 'fabric';
const gridPicList = ref([]) const gridPicList = ref([])
const inputValue = ref('') const inputValue = ref('')
const isShow = ref(false)
// //
const getWH = (item,index)=>{ const getWH = (item,index)=>{
return { return {
@ -29,6 +38,14 @@
} }
} }
const picList = [
'https://prev.ysaix.com:7868/src/assets/images/homecard4.jpg',
'https://prev.ysaix.com:7868/src/assets/images/homecard3.jpg',
'https://prev.ysaix.com:7868/src/assets/images/homecard2.jpg',
'https://prev.ysaix.com:7868/src/assets/images/homecard1.jpg',
'https://prev.ysaix.com:7868/profile/avatar/2024/06/26/blob_20240626135106A001.png',
'https://prev.ysaix.com:7868/assets/app_download.b3fb227b.png'
]
// grid // grid
const getGrid = computed(() => { const getGrid = computed(() => {
switch (gridPicList.value.length) { switch (gridPicList.value.length) {
@ -106,12 +123,20 @@
if (gridPicList.value.length >= 9) { if (gridPicList.value.length >= 9) {
return return
} }
let src = inputValue.value||picList[gridPicList.value.length]
if (!src) {
return;
}
gridPicList.value.push({ gridPicList.value.push({
src: inputValue.value, src: src,
backgroundColor: getRandomColor() backgroundColor: getRandomColor()
}) })
inputValue.value = '' inputValue.value = ''
} }
//
const startPencil = () => {
isShow.value = !isShow.value
}
// //
function getRandomColor() { function getRandomColor() {
let r = Math.floor(Math.random() * 256).toString(16); let r = Math.floor(Math.random() * 256).toString(16);
@ -123,13 +148,38 @@
b = b.length === 1? '0' + b : b; b = b.length === 1? '0' + b : b;
return `#${r}${g}${b}`; return `#${r}${g}${b}`;
} }
//
const initPend = () => {
let canvas = new Fabric.fabric.Canvas('canvas_pic_001',{
interactive: false,
selection: true,
backgroundColor: "rgba(15,15,15,0)"
})
canvas.defaultCursor = 'default'
canvas.setHeight(300)
canvas.setWidth(400)
canvas.isDrawingMode = true;
canvas.freeDrawingBrush = new Fabric.fabric.PencilBrush(canvas)
canvas.freeDrawingBrush.width = 1//
canvas.freeDrawingBrush.color = "red"//
}
onMounted(() => {
initPend()
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.modal-mode{
width: 100%;
height: 100%;
position: absolute;
z-index: 1001;
background-color: rgba(0, 0, 0, 0.2);
}
.grid-pic-wrap{ .grid-pic-wrap{
width: 100%; width: 100%;
height: 100%; height: 100%;
display: grid; display: grid;
position: absolute;
overflow: hidden; overflow: hidden;
.grid-pic-item{ .grid-pic-item{
//animation: fadeIn 0.5s ease-in-out forwards; //animation: fadeIn 0.5s ease-in-out forwards;

View File

@ -1,13 +1,19 @@
<template> <template>
<viewer :ref="collectRef('viewerRef'+index)" :options="optins" :images="images" class="images clearfix"> <div class="viewer-item-wrap" :id="'viewer_id'+index">
<template #default="scope"> <Viewer @move="move" @moved="moved" @inited="inited" @zoomed="zoomed" :ref="collectRef('viewerRef'+index)" :options="optins" :images="[images.src]" class="images clearfix">
<img v-for="src in scope.images" :key="index" :src="src" style="display: none"> <template #default="scope">
</template> <div class="viewer-img-box">
</viewer> <img v-for="src in scope.images" :key="index" :src="src" style="display: none">
</div>
</template>
</Viewer>
</div>
</template> </template>
<script setup> <script setup>
import {ref, watch, nextTick} from "vue"; import {ref, watch, nextTick, onMounted} from "vue";
import { component as Viewer } from 'v-viewer'
import Fabric from 'fabric';
import 'viewerjs/dist/viewer.css'
const props = defineProps({ const props = defineProps({
images: { images: {
type: Object, type: Object,
@ -22,7 +28,54 @@ const props = defineProps({
default: () => [] default: () => []
} }
}) })
let $viewer = null;
const refs = ref([]); const refs = ref([]);
//
const inited = (viewer) => {
$viewer = viewer
}
//
const zoomed = (e) => {
setImgStyle()
// console.log('zoomed', e)
}
//
const moved = (e) => {
setImgStyle()
// console.log('moved',e)
}
const move = (e) => {
// console.log('move', e)
}
const appendCanvasToShow = () => {
initImgStyle()
}
const setImgStyle = () => {
let item = window.document.getElementById('viewer_id'+props.index)
let canvas = item.querySelectorAll('.viewer-canvas')[0]
let img = canvas.querySelectorAll('img')[0]
let imgStyle = img.getAttribute('style')
imgStyle = imgStyle.replace('relative', 'absolute') + 'z-index: 1002';
img.style = imgStyle;
let canvasNew = canvas.querySelectorAll('canvas')[0]
canvasNew.style = imgStyle;
}
const initImgStyle = () => {
let item = window.document.getElementById('viewer_id'+props.index)
let canvas = item.querySelectorAll('.viewer-canvas')[0]
let img = canvas.querySelectorAll('img')[0];
let imgStyle = img.getAttribute('style')
imgStyle = imgStyle.replace('relative', 'absolute') + 'z-index: 1002';
img.style = imgStyle;
const canvasNew = document.createElement('canvas');
canvasNew.style = imgStyle;
canvasNew.id = 'canvas_pic_'+props.index
canvas.appendChild(canvasNew);
initPend()
}
const collectRef = (key) => { const collectRef = (key) => {
return (el) => { return (el) => {
@ -30,30 +83,65 @@ const collectRef = (key) => {
}; };
}; };
//viewer //viewer
const optins = { const optins = ref({
"inline": true, "inline": true,
"button": false, "button": false,
"navbar": false, "navbar": false,
"title": false, "title": false,
"toolbar": false, "toolbar": false,
"tooltip": true, "tooltip": true,
"movable": true,
"zoomable": true, "zoomable": true,
"rotatable": true, "rotatable": true,
"movable": false,
"scalable": true, "scalable": true,
"transition": true, "transition": true,
"fullscreen": true, "fullscreen": true,
"keyboard": true "keyboard": true
} })
const initViewers = () => { const initViewers = () => {
refs.value['viewerRef'+props.index]?.rebuildViewer() refs.value['viewerRef'+props.index]?.rebuildViewer()
setTimeout(()=>{
initImgStyle()
},300)
} }
//
const initPend = () => {
let canvas = new Fabric.fabric.Canvas('canvas_pic_'+props.index,{
interactive: false,
selection: true,
backgroundColor: "rgba(15,15,15,0)"
})
canvas.defaultCursor = 'default'
canvas.setHeight(300)
canvas.setWidth(400)
canvas.isDrawingMode = true;
canvas.freeDrawingBrush = new Fabric.fabric.PencilBrush(canvas)
canvas.freeDrawingBrush.width = 1//
canvas.freeDrawingBrush.color = "red"//
}
watch(props.gridPicList, (newValue, oldValue) => { watch(props.gridPicList, (newValue, oldValue) => {
nextTick(()=>{ nextTick(()=>{
initViewers() initViewers()
}) })
}); });
/*
watch(props.images, (newValue, oldValue) => {
// optins.value.movable = newValue.dragable
initPend()
});
*/
onMounted(()=>{
setTimeout(()=>{
appendCanvasToShow()
}, 300)
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.viewer-item-wrap{
width: 100%;
height: 100%;
}
</style> </style>

View File

@ -57,9 +57,9 @@ import { ref, watch , reactive, onMounted, onBeforeMount, computed} from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { sessionStore } from '@/utils/store'
import pkc from "../../../../../package.json" import pkc from "../../../../../package.json"
import defaultUserImg from '@/assets/images/img-avatar.png' import defaultUserImg from '@/assets/images/img-avatar.png'
import { sessionStore } from '@/utils/store'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
@ -183,7 +183,7 @@ watch(
const logout = () => { const logout = () => {
if(!!sessionstore.get('curr.classcourse'))return ElMessage.warning('当前正在上课,请先结束上课') if(!!sessionStore.get('curr.classcourse'))return ElMessage.warning('当前正在上课,请先结束上课')
ElMessageBox.confirm('确认退出系统吗?', '提示', { ElMessageBox.confirm('确认退出系统吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -212,7 +212,7 @@ onMounted(() => {
</script> </script>
<style lang="scss"> <style lang="scss">
.el-popover.popoverStyle{ .el-popover.popoverStyle{
min-width:120px; min-width:120px;
padding: 0; padding: 0;
} }

View File

@ -17,8 +17,7 @@ import log from 'electron-log/renderer' // 渲染进程日志-文件记录
import customComponent from '@/components/common' // 自定义组件 import customComponent from '@/components/common' // 自定义组件
import plugins from './plugins' // plugins插件 import plugins from './plugins' // plugins插件
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import VueViewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印到日志文件 if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印到日志文件
Object.assign(console, log.functions) // 渲染进程日志-控制台替换 Object.assign(console, log.functions) // 渲染进程日志-控制台替换
} }
@ -42,7 +41,6 @@ import Directive from '@/AixPPTist/src/plugins/directive'
app.use(router) app.use(router)
.use(store) .use(store)
.use(VueViewer)
.use(ElementPlus, { locale: zhLocale }) .use(ElementPlus, { locale: zhLocale })
.use(customComponent) // 自定义组件 .use(customComponent) // 自定义组件
.use(plugins) .use(plugins)

View File

@ -10,7 +10,7 @@
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="createAIPPT">新建文枢课件</el-dropdown-item> <el-dropdown-item @click="createAIPPT">新建文枢课件</el-dropdown-item>
<el-dropdown-item @click="aiTOPPT">AI一键生成</el-dropdown-item> <el-dropdown-item @click="aiTOPPT">AI一键生成</el-dropdown-item>
<el-dropdown-item @click="openGridPic">打开宫格</el-dropdown-item> <!-- <el-dropdown-item @click="openGridPic">打开宫格</el-dropdown-item>-->
<el-dropdown-item @click="openFilePicker">导入PPT</el-dropdown-item> <el-dropdown-item @click="openFilePicker">导入PPT</el-dropdown-item>
<input type="file" ref="fileInput" style="display: none;" @change="handleFileChange" accept="application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation"> <input type="file" ref="fileInput" style="display: none;" @change="handleFileChange" accept="application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation">
</el-dropdown-menu> </el-dropdown-menu>
@ -297,7 +297,7 @@ export default {
}, },
currentKJFileList() { currentKJFileList() {
// return this.currentFileList.filter((item) => item.fileFlag === 'apt' || item.fileFlag === '') // return this.currentFileList.filter((item) => item.fileFlag === 'apt' || item.fileFlag === '')
return this.currentFileList.filter((item) => ['apt','aippt','课件'].includes(item.fileFlag)) return this.currentFileList.filter((item) => ['aippt'].includes(item.fileFlag))
}, },
currentSCFileList() { currentSCFileList() {
// return this.currentFileList.filter((item) => item.fileFlag !== 'apt' && item.fileFlag !== '') // return this.currentFileList.filter((item) => item.fileFlag !== 'apt' && item.fileFlag !== '')
@ -923,7 +923,6 @@ export default {
return getSmarttalkPage({ return getSmarttalkPage({
...this.uploadData, ...this.uploadData,
orderByColumn: 'createTime', orderByColumn: 'createTime',
fileFlag: 'aippt',
isAsc: 'desc', isAsc: 'desc',
pageSize: 500 pageSize: 500
}) })