提交 935c0a60 编写于 作者: Skyeye云's avatar Skyeye云

用户自定义桌面背景图片

上级 f9342aee
......@@ -16,7 +16,7 @@ public class Constants {
* 过滤器过滤文件目录请求项
*/
public static final String[] FILTER_FILE_CATALOG_OPTION = { "/html",
"/css", "/js", "/assets", "/tpl" };
"/css", "/js", "/assets", "/tpl", "/images" };
/**
* 过滤器过滤文件后缀请求项
......
......@@ -14,4 +14,10 @@ public interface SysEveWinBgPicDao {
public Map<String, Object> querySysEveMationById(Map<String, Object> map) throws Exception;
public List<Map<String, Object>> querySysEveWinBgPicListToShow(Map<String, Object> map) throws Exception;
public int insertSysEveWinBgPicMationByCustom(Map<String, Object> map) throws Exception;
public List<Map<String, Object>> querySysEveWinBgPicCustomList(Map<String, Object> map) throws Exception;
}
......@@ -11,4 +11,10 @@ public interface SysEveWinBgPicService {
public void deleteSysEveWinBgPicMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void querySysEveWinBgPicListToShow(InputObject inputObject, OutputObject outputObject) throws Exception;
public void insertSysEveWinBgPicMationByCustom(InputObject inputObject, OutputObject outputObject) throws Exception;
public void querySysEveWinBgPicCustomList(InputObject inputObject, OutputObject outputObject) throws Exception;
}
......@@ -79,5 +79,67 @@ public class SysEveWinBgPicServiceImpl implements SysEveWinBgPicService{
ToolUtil.deleteFile(basePath);
sysEveWinBgPicDao.deleteSysEveWinBgPicMationById(map);
}
/**
*
* @Title: querySysEveWinBgPicList
* @Description: 获取win系统桌面图片列表供展示
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void querySysEveWinBgPicListToShow(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
List<Map<String, Object>> beans = sysEveWinBgPicDao.querySysEveWinBgPicListToShow(map);
if(beans != null && !beans.isEmpty()){
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
}
/**
*
* @Title: insertSysEveWinBgPicMationByCustom
* @Description: 添加win系统桌面图片信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void insertSysEveWinBgPicMationByCustom(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> user = inputObject.getLogParams();
map.put("id", ToolUtil.getSurFaceId());
map.put("createId", user.get("id"));
map.put("createTime", ToolUtil.getTimeAndToString());
sysEveWinBgPicDao.insertSysEveWinBgPicMationByCustom(map);
}
/**
*
* @Title: querySysEveWinBgPicCustomList
* @Description: 获取win系统桌面图片列表用户自定义
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void querySysEveWinBgPicCustomList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> user = inputObject.getLogParams();
map.put("createId", user.get("id"));
List<Map<String, Object>> beans = sysEveWinBgPicDao.querySysEveWinBgPicCustomList(map);
if(beans != null && !beans.isEmpty()){
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
}
}
......@@ -68,6 +68,9 @@ public class CommonServiceImpl implements CommonService{
case 3://系统桌面锁屏背景自定义图片上传
basePath = tPath + "\\assets\\winlockbgpic" ;
break;
case 4://系统桌面背景自定义图片上传用户自定义
basePath = tPath.substring(0, inputObject.getRequest().getSession().getServletContext().getRealPath("/").indexOf(Constants.PROJECT_WEB)) + "\\images\\upload\\winbgpic" ;
break;
default:
basePath = tPath.substring(0, inputObject.getRequest().getSession().getServletContext().getRealPath("/").indexOf(Constants.PROJECT_WEB));
break;
......@@ -82,9 +85,8 @@ public class CommonServiceImpl implements CommonService{
String fileExtName = fileName.substring(fileName.lastIndexOf(".") + 1);
if (file != null) {
File pack = new File(basePath);
if(!pack.isDirectory()){//目录不存在
pack.mkdir();//创建目录
}
if(!pack.isDirectory())//目录不存在
pack.mkdirs();//创建目录
// 自定义的文件名称
String newFileName = String.valueOf(System.currentTimeMillis()) + "." + fileExtName;
String path = basePath + "\\" + newFileName;
......@@ -99,6 +101,9 @@ public class CommonServiceImpl implements CommonService{
case 3://系统桌面锁屏背景自定义图片上传
newFileName = "/assets/winlockbgpic/" + newFileName ;
break;
case 4://系统桌面背景自定义图片上传用户自定义
newFileName = "/images/upload/winbgpic/" + newFileName ;
break;
default:
break;
}
......
......@@ -62,4 +62,52 @@ public class SysEveWinBgPicController {
sysEveWinBgPicService.deleteSysEveWinBgPicMationById(inputObject, outputObject);
}
/**
*
* @Title: querySysEveWinBgPicList
* @Description: 获取win系统桌面图片列表供展示
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysEveWinBgPicController/querySysEveWinBgPicListToShow")
@ResponseBody
public void querySysEveWinBgPicListToShow(InputObject inputObject, OutputObject outputObject) throws Exception{
sysEveWinBgPicService.querySysEveWinBgPicListToShow(inputObject, outputObject);
}
/**
*
* @Title: insertSysEveWinBgPicMationByCustom
* @Description: 添加win系统桌面图片信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysEveWinBgPicController/insertSysEveWinBgPicMationByCustom")
@ResponseBody
public void insertSysEveWinBgPicMationByCustom(InputObject inputObject, OutputObject outputObject) throws Exception{
sysEveWinBgPicService.insertSysEveWinBgPicMationByCustom(inputObject, outputObject);
}
/**
*
* @Title: querySysEveWinBgPicCustomList
* @Description: 获取win系统桌面图片列表用户自定义
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysEveWinBgPicController/querySysEveWinBgPicCustomList")
@ResponseBody
public void querySysEveWinBgPicCustomList(InputObject inputObject, OutputObject outputObject) throws Exception{
sysEveWinBgPicService.querySysEveWinBgPicCustomList(inputObject, outputObject);
}
}
......@@ -37,4 +37,33 @@
WHERE a.id = #{id}
</select>
<select id="querySysEveWinBgPicListToShow" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.pic_url picUrl
FROM
sys_eve_win_bg_pic a
WHERE a.pic_type = '1'
ORDER BY a.create_time DESC
</select>
<insert id="insertSysEveWinBgPicMationByCustom" parameterType="java.util.Map">
INSERT into sys_eve_win_bg_pic
(id, pic_url, pic_type, create_id, create_time)
VALUES
(#{id}, #{picUrl}, '2', #{createId}, #{createTime})
</insert>
<select id="querySysEveWinBgPicCustomList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.pic_url picUrl,
CONVERT(a.create_time, char) createTime
FROM
sys_eve_win_bg_pic a
WHERE a.pic_type = '2'
AND a.create_id = #{createId}
ORDER BY a.create_time DESC
</select>
</mapper>
\ No newline at end of file
......@@ -175,6 +175,13 @@
<url id="sysevewinbgpic003" path="/post/SysEveWinBgPicController/deleteSysEveWinBgPicMationById" val="删除win系统桌面图片信息" allUse="1">
<property id="rowId" name="id" ref="required" var="win系统桌面图片id"/>
</url>
<url id="sysevewinbgpic004" path="/post/SysEveWinBgPicController/querySysEveWinBgPicListToShow" val="获取win系统桌面图片列表供展示" allUse="1">
</url>
<url id="sysevewinbgpic005" path="/post/SysEveWinBgPicController/insertSysEveWinBgPicMationByCustom" val="用户自定义上传win系统桌面图片信息" allUse="1">
<property id="picUrl" name="picUrl" ref="required" var="图片路径"/>
</url>
<url id="sysevewinbgpic006" path="/post/SysEveWinBgPicController/querySysEveWinBgPicCustomList" val="获取win系统桌面图片列表用户自定义" allUse="1">
</url>
<url id="sysevewinlockbgpic001" path="/post/SysEveWinLockBgPicController/querySysEveWinLockBgPicList" val="获取win系统锁屏桌面图片列表" allUse="1">
<property id="limit" name="limit" ref="required,num" var="分页参数,每页多少条数据" />
......
IMAGE_SERVER_URL=http://192.168.116.20:8888/
IMAGES_PATH=D:/images/
......@@ -29,6 +29,7 @@
<context:component-scan base-package="com.skyeye.common.filter" />
<!-- 配置资源映射 -->
<mvc:resources location="file:///${IMAGES_PATH}" mapping="/images/**" />
<mvc:resources location="/assets/" mapping="/assets/**"></mvc:resources>
<mvc:resources location="/html/" mapping="/html/**"></mvc:resources>
<mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
......
......@@ -5,7 +5,7 @@
*/
var fileBasePath = getBaseRootPath();
var fileBasePath = getBaseRootPath();//上传文件展示路径
var reqBasePath = getBaseRootPath();
var basePath = "../../assets/lib/winui/";
var skyeyeVersion = "1.0.0-beta";
......
......@@ -2,10 +2,13 @@
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['table', 'jquery', 'winui', 'fileUpload'], function (exports) {
}).define(['table', 'jquery', 'winui', 'fileUpload', 'upload'], function (exports) {
winui.renderColor();
layui.use(['layer', 'form'], function (exports) {
var $ = layui.jquery, form = layui.form, unfinished = '暂未实现';
var $ = layui.jquery,
form = layui.form,
unfinished = '暂未实现',
upload = layui.upload;
$(function () {
winui.renderColor();
......@@ -25,38 +28,103 @@ layui.config({
$('.preview-start').addClass(startSize);
form.render();
//初始化背景图片
showGrid({
id: "background-choose",
url: reqBasePath + "sysevewinbgpic004",
params: {},
pagination: false,
template: getFileContent('tpl/systheme/bg-pic.tpl'),
ajaxSendLoadBefore: function(hdb){
hdb.registerHelper("compare1", function(v1, options){
return fileBasePath + v1;
});
},
options: {'click .bgPicItem':function(index, row){
//获取当前图片路径
var bgSrc = row.picUrl;
//改变预览背景
$('.background-preview').css('background-image', 'url(' + bgSrc + ')');
//改变父页面背景
winui.resetBg(bgSrc);
}
},
ajaxSendAfter:function(json){
initCustomBackGroundPic();
}
});
//预览锁屏界面
var Week = ['', '', '', '', '', '', ''];
var dateTime = new Date();
$('.lockscreen-preview-time').html('<p id="time">' + (dateTime.getHours() > 9 ? dateTime.getHours().toString() : '0' + dateTime.getHours()) + ':' + (dateTime.getMinutes() > 9 ? dateTime.getMinutes().toString() : '0' + dateTime.getMinutes()) + '</p><p id="date">' + (dateTime.getMonth() + 1) + '' + dateTime.getDate() + '日,星期' + Week[dateTime.getDay()] + '</p>');
});
//背景图片点击
$('.background-choose>img').on('click', function () {
//获取当前图片路径
var bgSrc = $(this).prop('src');
//改变预览背景
$('.background-preview').css('background-image', 'url(' + bgSrc + ')');
//改变父页面背景
winui.resetBg(bgSrc);
})
//自定义上传的桌面背景图片
function initCustomBackGroundPic(){
showGrid({
id: "cus-background-choose",
url: reqBasePath + "sysevewinbgpic006",
params: {},
pagination: false,
template: getFileContent('tpl/systheme/custom-bgpic-item.tpl'),
ajaxSendLoadBefore: function(hdb){
hdb.registerHelper("compare1", function(v1, options){
return fileBasePath + v1;
});
},
options: {'click .del':function(index, row){
layer.confirm('确认删除选中数据吗?', { icon: 3, title: '删除win系统桌面图片' }, function (index) {
layer.close(index);
AjaxPostUtil.request({url:reqBasePath + "sysevewinbgpic003", params:{rowId: row.id}, type:'json', callback:function(json){
if(json.returnCode == 0){
top.winui.window.msg("删除成功", {icon: 1,time: 2000});
refreshGrid("cus-background-choose", {params:{}});
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
}});
});
}, 'click .bgPicItem1':function(index, row){
//获取当前图片路径
var bgSrc = row.picUrl;
//改变预览背景
$('.background-preview').css('background-image', 'url(' + bgSrc + ')');
//改变父页面背景
winui.resetBg(bgSrc);
}
},
ajaxSendAfter:function(json){
}
});
}
//背景图片上传
$('.background-upload').on('click', function () {
var input = $(this).prev('input[type=file]');
input.trigger('click');
input.on('change', function () {
var src = $(this).val();
if (src) {
layer.msg('选择了路径【' + src + '】下的图片,返回一张性感的Girl给你')
//改变预览背景
$('.background-preview').css('background-image', 'url(images/sexy_girl.jpg)');
//改变父页面背景
winui.resetBg('images/sexy_girl.jpg');
$(this).val('').off('change');
}
})
});
var uploadInst = upload.render({
elem: '#addBean', // 绑定元素
url: reqBasePath + 'common003', // 上传接口
data: {type: 4},
done: function(json) {
// 上传完毕回调
if(json.returnCode == 0){
AjaxPostUtil.request({url:reqBasePath + "sysevewinbgpic005", params:{picUrl: json.bean.picUrl}, type:'json', callback:function(json){
if(json.returnCode == 0){
top.winui.window.msg("上传成功", {icon: 1,time: 2000});
refreshGrid("cus-background-choose", {params:{}});
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
}});
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
},
error: function(e) {
// 请求异常回调
console.log(e);
}
});
//锁屏界面点击
$('.lockscreen-choose>img').on('click', function () {
//获取当前图片路径
......
......@@ -262,6 +262,7 @@
<!--layui.js-->
<script src="../../assets/lib/layui/layui.js" type="text/javascript"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script>
layui.config({
base: '../../js/index/' //指定 index.js 路径
......
{{#each rows}}
<img src="{{#compare1 picUrl}}{{/compare1}}" class="bgPicItem" />
{{/each}}
\ No newline at end of file
{{#each rows}}
<div class="layui-col-xs2 pic-item">
<div class="layui-col-xs12 pic-item-div-top">
<img class="bgPicItem1" src="{{#compare1 picUrl}}{{/compare1}}"/>
</div>
<div class="layui-col-xs12 pic-item-div">
<div>
<a class="layui-btn layui-btn-danger layui-btn-xs del">删除</a>
</div>
</div>
</div>
{{/each}}
\ No newline at end of file
......@@ -47,10 +47,6 @@
<div style="width:14px;height:14px;margin-bottom:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;"></div>
</div>
<div class="preview-tilebox preview-tilebox-lg">
<div style="width:59px;height:59px;margin-right:1px;margin-bottom:1px;"></div>
......@@ -71,11 +67,6 @@
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:59px;height:29px;margin-bottom:1px;"></div>
</div>
</div>
<div class="preview-window">
......@@ -85,19 +76,13 @@
<div class="preview-taskbar"></div>
</div>
<h2>选择图片</h2>
<div class="background-choose">
<img src="../assets/images/bg_01.jpg" />
<img src="../assets/images/bg_02.jpg" />
<img src="../assets/images/bg_03.jpg" />
<img src="../assets/images/bg_04.jpg" />
<img src="../assets/images/bg_05.jpg" />
<div class="background-choose" id="background-choose" style="min-height: 90px;">
</div>
<!-- 上传图片 -->
<input type="file" name="file" class="layui-upload-file" style="display:none;">
<div class="background-upload">
浏览
<h2>自定义图片</h2>
<div class="background-choose" id="cus-background-choose" style="min-height: 130px;">
</div>
<div style="color:#ff6a00;margin-top:50px;">Tips:主题的相关设置存储于本地,下次打开可直接使用</div>
<!-- 上传图片 -->
<div class="background-upload" id="addBean">浏览</div>
</div>
<!-- 颜色设置 -->
<div class="winui-tab-item">
......@@ -128,10 +113,6 @@
<div style="width:14px;height:14px;margin-bottom:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;"></div>
</div>
<div class="preview-tilebox preview-tilebox-lg">
<div style="width:59px;height:59px;margin-right:1px;margin-bottom:1px;"></div>
......@@ -152,11 +133,6 @@
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:59px;height:29px;margin-bottom:1px;"></div>
</div>
</div>
<div class="preview-window">
......@@ -268,10 +244,6 @@
<div style="width:14px;height:14px;margin-bottom:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;"></div>
</div>
<div class="preview-tilebox preview-tilebox-lg">
<div style="width:59px;height:59px;margin-right:1px;margin-bottom:1px;"></div>
......@@ -292,11 +264,6 @@
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:14px;height:14px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:29px;height:29px;margin-bottom:1px;margin-right:1px;"></div>
<div style="width:59px;height:29px;margin-bottom:1px;"></div>
</div>
</div>
<div class="preview-window">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册