refactor: 补充提交
This commit is contained in:
parent
1359640db7
commit
dd02e978ca
@ -19,7 +19,7 @@ const props = withDefaults(defineProps<LayTimelineProps>(), {
|
||||
const timeLineClass = computed(() => [
|
||||
"layui-timeline",
|
||||
props.direction === "horizontal" ? "layui-timeline-horizontal" : "",
|
||||
])
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -7,7 +7,16 @@ export default {
|
||||
import "./index.less";
|
||||
import { Recordable } from "../../types";
|
||||
import { layer } from "@layui/layer-vue";
|
||||
import { computed, ComputedRef, getCurrentInstance, nextTick, ref, toRaw, useSlots, withDefaults } from "vue";
|
||||
import {
|
||||
computed,
|
||||
ComputedRef,
|
||||
getCurrentInstance,
|
||||
nextTick,
|
||||
ref,
|
||||
toRaw,
|
||||
useSlots,
|
||||
withDefaults,
|
||||
} from "vue";
|
||||
import { templateRef } from "@vueuse/core";
|
||||
import { LayLayer } from "@layui/layer-vue";
|
||||
import Cropper from "cropperjs";
|
||||
@ -15,7 +24,7 @@ import Cropper from "cropperjs";
|
||||
//https://www.layuiweb.com/doc/modules/upload.html#options
|
||||
export interface LayerButton {
|
||||
text: string;
|
||||
callback:Function
|
||||
callback: Function;
|
||||
}
|
||||
export interface LayerModal {
|
||||
title?: string;
|
||||
@ -30,7 +39,7 @@ export interface LayerModal{
|
||||
zIndex?: number;
|
||||
type?: "component" | "iframe";
|
||||
closeBtn?: boolean;
|
||||
area:string[],
|
||||
area: string[];
|
||||
btn?: LayerButton[];
|
||||
btnAlign?: "l" | "r" | "c";
|
||||
anim?: boolean;
|
||||
@ -38,7 +47,7 @@ export interface LayerModal{
|
||||
}
|
||||
export interface cutOptions {
|
||||
layerOption: LayerModal;
|
||||
copperOption?:typeof Cropper
|
||||
copperOption?: typeof Cropper;
|
||||
}
|
||||
|
||||
export interface LayUploadProps {
|
||||
@ -54,7 +63,7 @@ export interface LayUploadProps {
|
||||
disabled?: boolean;
|
||||
cut?: boolean;
|
||||
cutOptions: cutOptions;
|
||||
};
|
||||
}
|
||||
|
||||
const getCutDownResult = () => {
|
||||
if (_cropper) {
|
||||
@ -75,7 +84,7 @@ const closeCutDownModal =()=>{
|
||||
let currentTimeStamp = new Date().valueOf();
|
||||
emit("cutcancel", Object.assign({ currentTimeStamp }));
|
||||
nextTick(() => clearAllCutEffect());
|
||||
}
|
||||
};
|
||||
const clearAllCutEffect = () => {
|
||||
activeUploadFiles.value = [];
|
||||
activeUploadFilesImgs.value = [];
|
||||
@ -90,13 +99,13 @@ let defaultCutLayerOption:LayerModal = {
|
||||
offset: [],
|
||||
btn: [
|
||||
{ text: "导出", callback: getCutDownResult },
|
||||
{ text:"取消" ,callback:closeCutDownModal }
|
||||
{ text: "取消", callback: closeCutDownModal },
|
||||
],
|
||||
area: ["640px", "640px"],
|
||||
content: "11",
|
||||
shade: true,
|
||||
shadeClose: true,
|
||||
type:"component"
|
||||
type: "component",
|
||||
};
|
||||
const props = withDefaults(defineProps<LayUploadProps>(), {
|
||||
acceptMime: "images",
|
||||
@ -107,13 +116,20 @@ const props = withDefaults(defineProps<LayUploadProps>(), {
|
||||
drag: false,
|
||||
disabled: false,
|
||||
cut: false,
|
||||
cutOptions:void 0
|
||||
cutOptions: void 0,
|
||||
});
|
||||
|
||||
const slot = useSlots();
|
||||
const slots = slot.default && slot.default();
|
||||
const context = getCurrentInstance();
|
||||
const emit = defineEmits(["choose", "before", "done", "error","cutdone","cutcancel"]);
|
||||
const emit = defineEmits([
|
||||
"choose",
|
||||
"before",
|
||||
"done",
|
||||
"error",
|
||||
"cutdone",
|
||||
"cutcancel",
|
||||
]);
|
||||
|
||||
// 内部变量
|
||||
const isDragEnter = ref(false);
|
||||
@ -125,7 +141,9 @@ const orgFileInput = templateRef<HTMLElement>("orgFileInput");
|
||||
let _cropper: any = null;
|
||||
let computedCutLayerOption: ComputedRef<LayerModal>;
|
||||
if (props.cutOptions && props.cutOptions.layerOption) {
|
||||
computedCutLayerOption = computed(()=>Object.assign(defaultCutLayerOption,props.cutOptions.layerOption));
|
||||
computedCutLayerOption = computed(() =>
|
||||
Object.assign(defaultCutLayerOption, props.cutOptions.layerOption)
|
||||
);
|
||||
} else {
|
||||
computedCutLayerOption = computed(() => defaultCutLayerOption);
|
||||
}
|
||||
@ -182,7 +200,7 @@ interface localUploadOption {
|
||||
[propMame: string]: any;
|
||||
}
|
||||
const dataURLtoFile = (dataurl: string) => {
|
||||
let arr:any[] = dataurl.split(',');
|
||||
let arr: any[] = dataurl.split(",");
|
||||
let mime: string = "";
|
||||
if (arr.length > 0) {
|
||||
mime = arr[0].match(/:(.*?);/)[1];
|
||||
@ -302,7 +320,9 @@ const getUploadChange = (e: any) => {
|
||||
}, 400);
|
||||
} else {
|
||||
if (arm2) {
|
||||
console.warn("layui-vue:当前版本暂不支持单次多文件剪裁,尝试设置 multiple 为false,通过@done获取返回文件对象");
|
||||
console.warn(
|
||||
"layui-vue:当前版本暂不支持单次多文件剪裁,尝试设置 multiple 为false,通过@done获取返回文件对象"
|
||||
);
|
||||
}
|
||||
commonUploadTransaction(_files);
|
||||
}
|
||||
@ -311,7 +331,7 @@ const commonUploadTransaction=(_files:any[])=>{
|
||||
if (props.url) {
|
||||
localUploadTransaction({
|
||||
url: props.url,
|
||||
files: _files
|
||||
files: _files,
|
||||
});
|
||||
} else {
|
||||
emit("done", _files);
|
||||
@ -329,9 +349,7 @@ const clickOrgInput = () => {
|
||||
//console.log(currentTimeStamp);
|
||||
emit("choose", currentTimeStamp);
|
||||
};
|
||||
const cutTransaction =()=>{
|
||||
|
||||
};
|
||||
const cutTransaction = () => {};
|
||||
//内部方法 -> end
|
||||
</script>
|
||||
<template>
|
||||
@ -358,7 +376,13 @@ const cutTransaction =()=>{
|
||||
<div
|
||||
v-else
|
||||
class="layui-upload-drag"
|
||||
:class="disabled?'layui-upload-drag-disable':isDragEnter ? 'layui-upload-drag-draging' : ''"
|
||||
:class="
|
||||
disabled
|
||||
? 'layui-upload-drag-disable'
|
||||
: isDragEnter
|
||||
? 'layui-upload-drag-draging'
|
||||
: ''
|
||||
"
|
||||
@click.stop="chooseFile"
|
||||
>
|
||||
<i class="layui-icon"></i>
|
||||
@ -381,11 +405,20 @@ const cutTransaction =()=>{
|
||||
:anim="computedCutLayerOption.anim"
|
||||
:isOutAnim="computedCutLayerOption.isOutAnim"
|
||||
:btn="computedCutLayerOption.btn"
|
||||
v-model="innerCutVisible" @close="clearAllCutEffect">
|
||||
<div class="copper-container" v-for="(base64str,index) in activeUploadFilesImgs" :key="`file${index}`">
|
||||
<img :src="base64str" :id="`_lay_upload_img${index}`" class="_lay_upload_img">
|
||||
v-model="innerCutVisible"
|
||||
@close="clearAllCutEffect"
|
||||
>
|
||||
<div
|
||||
class="copper-container"
|
||||
v-for="(base64str, index) in activeUploadFilesImgs"
|
||||
:key="`file${index}`"
|
||||
>
|
||||
<img
|
||||
:src="base64str"
|
||||
:id="`_lay_upload_img${index}`"
|
||||
class="_lay_upload_img"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</lay-layer>
|
||||
<div class="layui-upload-list">
|
||||
<slot name="preview"></slot>
|
||||
|
@ -60,10 +60,10 @@ const changeTheme = (theme: string) => {
|
||||
disableStyleSheetsProxy: false,
|
||||
}
|
||||
);
|
||||
localStorage.setItem('layui-vue-theme-dark','true')
|
||||
localStorage.setItem("layui-vue-theme-dark", "true");
|
||||
} else {
|
||||
disableDarkMode();
|
||||
localStorage.setItem('layui-vue-theme-dark','false')
|
||||
localStorage.setItem("layui-vue-theme-dark", "false");
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user