Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
54637ac0
提交
54637ac0
authored
6月 21, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
文件上传服务修改
上级
f8ad0292
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
53 行增加
和
31 行删除
+53
-31
getOneStopUploadUrl.js
one_stop_public/Base16/getOneStopUploadUrl.js
+5
-0
test.js
one_stop_public/Base16/test.js
+0
-0
ShowItem.js
one_stop_public/libs/PictureSignature/ShowItem.js
+40
-29
request.js
one_stop_public/utils/request.js
+2
-0
uploadFile.js
zyd_public/WangEditor/uploadFile.js
+6
-2
没有找到文件。
one_stop_public/Base16/getOneStopUploadUrl.js
0 → 100644
浏览文件 @
54637ac0
import
{
queryApiActionPath
}
from
'@/webPublic/one_stop_public/utils/queryConfig'
;
export
default
function
getOneStopUploadUrl
(){
return
queryApiActionPath
()
+
'/upload'
;
}
one_stop_public/Base16/test.js
0 → 100644
浏览文件 @
54637ac0
one_stop_public/libs/PictureSignature/ShowItem.js
浏览文件 @
54637ac0
import
React
from
"react"
;
import
{
queryApiActionPath
}
from
"@/webPublic/one_stop_public/utils/queryConfig"
;
import
{
getToken
}
from
"@/webPublic/one_stop_public/utils/token"
;
import
React
from
'react'
;
import
{
queryApiActionPath
}
from
'@/webPublic/one_stop_public/utils/queryConfig'
;
import
{
getToken
}
from
'@/webPublic/one_stop_public/utils/token'
;
import
{
isFromIframe
}
from
'@/webPublic/one_stop_public/utils/utils'
;
import
getOneStopUploadUrl
from
'@/webPublic/one_stop_public/Base16/getOneStopUploadUrl'
;
const
oneSetItemP
=
{
marginBottom
:
0
,
...
...
@@ -10,7 +11,13 @@ const oneSetItemP = {
let
startX
=
0
;
let
startY
=
0
;
const
ShowItem
=
({
basicUrl
,
type
,
x
,
y
,
...
otherInfo
})
=>
{
const
ShowItem
=
({
basicUrl
,
type
,
x
,
y
,
...
otherInfo
})
=>
{
switch
(
type
)
{
case
'image'
:
return
(
...
...
@@ -53,14 +60,14 @@ const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => {
export
const
dragEventList
=
(
setOtherProps
,
otherProps
)
=>
{
let
draggedRef
=
null
;
let
documentThis
=
isFromIframe
()
?
window
?.
parent
?.
document
:
document
;
documentThis
.
onmousedown
=
function
(
evt
)
{
startX
=
evt
.
offsetX
;
startY
=
evt
.
offsetY
;
}
documentThis
.
onmousedown
=
function
(
evt
)
{
startX
=
evt
.
offsetX
;
startY
=
evt
.
offsetY
;
}
;
documentThis
.
addEventListener
(
'dragstart'
,
function
(
event
)
{
function
(
event
)
{
// 保存拖动元素的引用(ref.)
draggedRef
=
event
.
target
;
event
.
target
.
style
.
opacity
=
0.2
;
...
...
@@ -91,13 +98,14 @@ export const dragEventList = (setOtherProps, otherProps) => {
// 阻止默认动作(如打开一些元素的链接)
event
.
preventDefault
();
// 将拖动的元素到所选择的放置目标节点中
let
infoClientRect
=
documentThis
.
getElementById
(
'dropZone'
).
getBoundingClientRect
();
let
infoClientRect
=
documentThis
.
getElementById
(
'dropZone'
)
.
getBoundingClientRect
();
// console.log(startX, typeof startX, startY);
// return ;
let
leftNew
=
Math
.
ceil
(
event
.
clientX
-
infoClientRect
.
left
)
-
startX
;
let
topNew
=
Math
.
ceil
(
event
.
clientY
-
infoClientRect
.
top
)
-
startY
;
// console.log(leftNew, topNew);
if
(
leftNew
<
0
||
leftNew
>
infoClientRect
.
width
||
topNew
<
0
||
topNew
>
infoClientRect
.
height
)
{
if
(
leftNew
<
0
||
leftNew
>
infoClientRect
.
width
||
topNew
<
0
||
topNew
>
infoClientRect
.
height
)
{
console
.
log
(
'拖拽到了图片区域外部,不能进行拖拽'
);
return
false
;
}
...
...
@@ -106,7 +114,7 @@ export const dragEventList = (setOtherProps, otherProps) => {
let
item
=
otherProps
.
signConfig
.
find
((
g
)
=>
{
return
g
.
key
===
key
;
});
if
(
!
item
)
{
if
(
!
item
)
{
return
false
;
}
item
.
x
=
leftNew
;
...
...
@@ -114,23 +122,25 @@ export const dragEventList = (setOtherProps, otherProps) => {
setOtherProps
({
...
otherProps
,
signConfig
:
otherProps
.
signConfig
,
})
})
;
draggedRef
.
style
.
left
=
leftNew
;
// `${left}px`;
draggedRef
.
style
.
top
=
topNew
;
// `${top}px`;
return
true
;
},
false
,
);
}
}
;
export
const
uploadFile
=
(
file
)
=>
{
let
url
=
queryApiActionPath
()
+
'/upload?token='
+
getToken
();
let
url
=
getOneStopUploadUrl
();
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
return
fetch
(
url
,
{
formData
.
append
(
'token'
,
getToken
());
return
fetch
(
url
,
{
method
:
'POST'
,
headers
:
{
Accept
:
'*/*'
,
Authorization
:
`bearer
${
getToken
()}
`
,
},
body
:
formData
,
})
...
...
@@ -139,23 +149,23 @@ export const uploadFile = (file) => {
})
.
then
((
res
)
=>
{
return
res
;
})
}
})
;
}
;
// 将图片宽度确定 高度按比例调整后返回一张新的图片
export
const
zipImage
=
(
path
,
fileName
,
limitWidth
=
1200
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
image
=
new
Image
();
//新建一个img标签(还没嵌入DOM节点)
let
imageUrl
=
queryApiActionPath
()
+
path
;
image
.
setAttribute
(
"crossOrigin"
,
'Anonymous'
);
let
imageUrl
=
queryApiActionPath
()
+
path
;
image
.
setAttribute
(
'crossOrigin'
,
'Anonymous'
);
image
.
src
=
imageUrl
;
image
.
onload
=
()
=>
{
const
canvas
=
document
.
createElement
(
'canvas'
);
const
context
=
canvas
.
getContext
(
'2d'
);
const
imageWidth
=
limitWidth
;
const
ratio
=
image
.
width
/
limitWidth
;
// 按宽度固定 压缩图片
if
(
ratio
===
1
||
isNaN
(
ratio
))
{
if
(
ratio
===
1
||
isNaN
(
ratio
))
{
resolve
(
path
);
return
true
;
}
...
...
@@ -179,13 +189,14 @@ export const zipImage = (path, fileName, limitWidth = 1200) => {
return
new
File
([
u8arr
],
filename
,
{
type
:
mime
});
};
let
file
=
dataURLtoFile
(
data
,
fileName
);
uploadFile
(
file
).
then
((
res
)
=>
{
if
(
res
){
resolve
(
res
);
}
else
{
resolve
(
path
);
}
});
uploadFile
(
file
)
.
then
((
res
)
=>
{
if
(
res
)
{
resolve
(
res
);
}
else
{
resolve
(
path
);
}
});
//压缩完成
};
});
...
...
@@ -194,4 +205,4 @@ export const zipImage = (path, fileName, limitWidth = 1200) => {
};
export
default
ShowItem
export
default
ShowItem
;
one_stop_public/utils/request.js
浏览文件 @
54637ac0
...
...
@@ -128,6 +128,8 @@ const loginUmiRequest = extend({
const
getUrl
=
url
=>
(
url
.
startsWith
(
'/'
)
?
url
:
'/'
+
url
);
export
const
request
=
(
url
,
data
,
options
=
{})
=>
{
return
giveBase16EnCode
(
data
,
url
)
.
then
((
newData
)
=>
{
if
(
typeof
newData
===
'object'
&&
newData
.
url
&&
newData
.
datas
){
...
...
zyd_public/WangEditor/uploadFile.js
浏览文件 @
54637ac0
import
request
from
'@/utils/request'
;
import
config
from
'@/config/config'
;
import
config
,
{
getUploadUrl
}
from
'@/config/config'
;
import
{
getToken
}
from
'@/utils/authority'
;
const
uploadUrl
=
config
.
uploadUrl
.
split
(
'?'
)[
0
]
;
const
uploadUrl
=
getUploadUrl
()
;
export
default
function
uploadFile
(
params
)
{
return
request
(
uploadUrl
,
{
method
:
'POST'
,
headers
:
{
Authorization
:
`bearer
${
getToken
()}
`
,
},
body
:
params
,
});
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论