Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
f189c30a
提交
f189c30a
authored
5月 16, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
论坛发布动态开发,错误图片资源升级为全局
上级
0cc4a930
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
113 行增加
和
14 行删除
+113
-14
errImg.js
assets/errImg.js
+0
-0
index.tsx
pages/forum/components/publishMessage/index.tsx
+103
-13
index.tsx
pages/forum/index.tsx
+10
-1
没有找到文件。
pages/forum/
assets/errImg.js
→
assets/errImg.js
浏览文件 @
f189c30a
File moved
pages/forum/components/publishMessage/index.tsx
浏览文件 @
f189c30a
import
{
Form
,
Input
,
Modal
}
from
"antd"
;
import
{
PlusOutlined
}
from
"@ant-design/icons"
;
import
{
Form
,
Input
,
Modal
,
Upload
}
from
"antd"
;
import
type
{
RcFile
,
UploadProps
}
from
"antd/es/upload"
;
import
type
{
UploadFile
}
from
"antd/es/upload/interface"
;
import
{
useState
}
from
"react"
;
const
getBase64
=
(
file
:
RcFile
):
Promise
<
string
>
=>
new
Promise
((
resolve
,
reject
)
=>
{
const
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
reader
.
onload
=
()
=>
resolve
(
reader
.
result
as
string
);
reader
.
onerror
=
(
error
)
=>
reject
(
error
);
});
type
Props
=
{
open
:
boolean
;
onOk
:
()
=>
{},
onCancel
:
()
=>
{}
onOk
?:
()
=>
void
;
onCancel
?:
()
=>
void
;
};
export
default
function
publishMessage
()
{
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
export
default
function
publishMessage
(
props
:
Props
)
{
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
showModal
=
()
=>
{
setIsModalOpen
(
true
);
};
const
handleOk
=
()
=>
{
setConfirmLoading
(
true
);
setTimeout
(()
=>
{
setIsModalOpen
(
false
);
handleCancel
(
);
setConfirmLoading
(
false
);
},
2000
);
};
const
handleCancel
=
()
=>
{
setIsModalOpen
(
false
);
props
.
onCancel
&&
props
.
onCancel
();
};
const
[
previewOpen
,
setPreviewOpen
]
=
useState
(
false
);
const
[
previewImage
,
setPreviewImage
]
=
useState
(
""
);
const
[
previewTitle
,
setPreviewTitle
]
=
useState
(
""
);
const
[
fileList
,
setFileList
]
=
useState
<
UploadFile
[]
>
([
{
uid
:
"-1"
,
name
:
"image.png"
,
status
:
"done"
,
url
:
"https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
,
},
{
uid
:
"-2"
,
name
:
"image.png"
,
status
:
"done"
,
url
:
"https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
,
},
{
uid
:
"-3"
,
name
:
"image.png"
,
status
:
"done"
,
url
:
"https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
,
},
{
uid
:
"-4"
,
name
:
"image.png"
,
status
:
"done"
,
url
:
"https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
,
},
{
uid
:
"-xxx"
,
percent
:
50
,
name
:
"image.png"
,
status
:
"uploading"
,
url
:
"https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
,
},
{
uid
:
"-5"
,
name
:
"image.png"
,
status
:
"error"
,
},
]);
const
handlePreviewCancel
=
()
=>
setPreviewOpen
(
false
);
const
handlePreview
=
async
(
file
:
UploadFile
)
=>
{
if
(
!
file
.
url
&&
!
file
.
preview
)
{
file
.
preview
=
await
getBase64
(
file
.
originFileObj
as
RcFile
);
}
setPreviewImage
(
file
.
url
||
(
file
.
preview
as
string
));
setPreviewOpen
(
true
);
setPreviewTitle
(
file
.
name
||
file
.
url
!
.
substring
(
file
.
url
!
.
lastIndexOf
(
"/"
)
+
1
)
);
};
const
handleChange
:
UploadProps
[
"onChange"
]
=
({
fileList
:
newFileList
})
=>
setFileList
(
newFileList
);
const
uploadButton
=
(
<
div
>
<
PlusOutlined
/>
<
div
style=
{
{
marginTop
:
8
}
}
>
Upload
</
div
>
</
div
>
);
return
(
<
Modal
title=
""
open=
{
isModalO
pen
}
open=
{
props
.
o
pen
}
onOk=
{
handleOk
}
onCancel=
{
handleCancel
}
width=
{
500
}
...
...
@@ -51,7 +123,25 @@ export default function publishMessage() {
style=
{
{
height
:
120
,
resize
:
"none"
}
}
></
Input
.
TextArea
>
</
Form
.
Item
>
<
Form
.
Item
></
Form
.
Item
>
<
Form
.
Item
>
<
Upload
action=
"https://www.mocky.io/v2/5cc8019d300000980a055e76"
listType=
"picture-card"
fileList=
{
fileList
}
onPreview=
{
handlePreview
}
onChange=
{
handleChange
}
>
{
fileList
.
length
>=
8
?
null
:
uploadButton
}
</
Upload
>
<
Modal
open=
{
previewOpen
}
title=
{
previewTitle
}
footer=
{
null
}
onCancel=
{
handlePreviewCancel
}
>
<
img
alt=
"example"
style=
{
{
width
:
"100%"
}
}
src=
{
previewImage
}
/>
</
Modal
>
</
Form
.
Item
>
</
Form
>
</
Modal
>
);
...
...
pages/forum/index.tsx
浏览文件 @
f189c30a
import
{
Button
,
Image
,
Space
,
Input
,
Modal
,
Form
}
from
"antd"
;
import
Layout
from
"~/components/layout"
;
import
styles
from
"./index.module.scss"
;
import
errImg
from
"
.
/assets/errImg"
;
import
errImg
from
"
~
/assets/errImg"
;
import
{
RightOutlined
}
from
"@ant-design/icons"
;
import
{
useState
}
from
"react"
;
import
PublishMessage
from
'./components/publishMessage'
export
default
function
forum
()
{
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
const
showModal
=
()
=>
{
setIsModalOpen
(
true
);
};
const
onPublishCancel
=
()
=>
{
setIsModalOpen
(
false
);
};
return
(
<
Layout
>
<
div
className=
{
styles
.
forum
}
>
...
...
@@ -157,6 +162,10 @@ export default function forum() {
</
div
>
</
Space
>
</
div
>
<
PublishMessage
open=
{
isModalOpen
}
onCancel=
{
onPublishCancel
}
></
PublishMessage
>
</
Layout
>
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论