mirror of
				https://gitee.com/zoujingli/ThinkAdmin.git
				synced 2025-11-04 05:32:09 +08:00 
			
		
		
		
	修改图片选择器
This commit is contained in:
		
							parent
							
								
									3da4409270
								
							
						
					
					
						commit
						b04ca63a87
					
				@ -147,14 +147,14 @@ class Upload extends Controller
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function modal()
 | 
			
		||||
    public function image()
 | 
			
		||||
    {
 | 
			
		||||
        SystemFile::mQuery()->layTable(function () {
 | 
			
		||||
            $this->title = '文件选择器';
 | 
			
		||||
        }, function (QueryHelper $query) {
 | 
			
		||||
            $query->where(['status' => 2])->order('id desc');
 | 
			
		||||
            $query->like('name,hash')->dateBetween('create_at');
 | 
			
		||||
        });
 | 
			
		||||
        }, realpath(__DIR__ . '/../../view/api/image.html'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										36
									
								
								app/admin/view/api/image.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								app/admin/view/api/image.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
<div class="image-dialog" id="ImageDialog">
 | 
			
		||||
    <div class="image-dialog-head">
 | 
			
		||||
        <div class="pull-right">
 | 
			
		||||
            <a class="layui-btn layui-btn-sm">上传图片</a>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="image-dialog-body">
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<style>
 | 
			
		||||
    .image-dialog-head {
 | 
			
		||||
        clear: both;
 | 
			
		||||
        height: 30px;
 | 
			
		||||
        padding: 10px 15px;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .image-dialog-body {
 | 
			
		||||
        height: 500px;
 | 
			
		||||
        background: #efefef;
 | 
			
		||||
    }
 | 
			
		||||
</style>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
    require(['vue'], function (vue) {
 | 
			
		||||
        new vue({
 | 
			
		||||
            el: '#ImageDialog',
 | 
			
		||||
            data: {
 | 
			
		||||
                page: 1,
 | 
			
		||||
                items: []
 | 
			
		||||
            },
 | 
			
		||||
            methods: {}
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
@ -550,7 +550,7 @@ $(function () {
 | 
			
		||||
    $.fn.uploadOneImage = function () {
 | 
			
		||||
        return this.each(function () {
 | 
			
		||||
            if ($(this).data('inited')) return true; else $(this).data('inited', true);
 | 
			
		||||
            var $in = $(this), $bt = $('<a data-file class="uploadimage transition"><span class="layui-icon">ဆ</span><span class="layui-icon"></span></a>').data('input', this);
 | 
			
		||||
            var $in = $(this), $bt = $('<a data-file="image" class="uploadimage transition"><span class="layui-icon">ဆ</span><span class="layui-icon"></span></a>').data('input', this);
 | 
			
		||||
            $bt.attr('data-size', $in.data('size') || 0).attr('data-type', $in.data('type') || 'png,jpg,gif,jpeg').find('span').on('click', function (event) {
 | 
			
		||||
                event.stopPropagation();
 | 
			
		||||
                if ($(this).index() === 0) $bt.attr('style', ''), $in.val(''); else $in.val() && $.previewImage(encodeURI($in.val()));
 | 
			
		||||
@ -835,7 +835,10 @@ $(function () {
 | 
			
		||||
 | 
			
		||||
    /*! 注册 data-file 事件行为 */
 | 
			
		||||
    onEvent('click', '[data-file]', function () {
 | 
			
		||||
        if ($(this).data('inited') !== true) (function (that) {
 | 
			
		||||
        // 上传图片,支持单图或多图选择,分别是 images|images
 | 
			
		||||
        if (typeof this.dataset.file === 'string' && /^images?$/.test(this.dataset.file)) {
 | 
			
		||||
            $.form.modal(tapiRoot + '/api.upload/image', this.dataset, '图片管理器')
 | 
			
		||||
        } else if ($(this).data('inited') !== true) (function (that) {
 | 
			
		||||
            that.uploadFile(undefined, function () {
 | 
			
		||||
                that.trigger('upload.start');
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user