Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
x-training
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
x-training
Commits
f2c7272c
提交
f2c7272c
authored
12月 29, 2020
作者:
lihuihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改bug
上级
5451c8c7
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
193 行增加
和
2 行删除
+193
-2
base_api.js
src/api/base_api.js
+157
-0
upload.js
src/api/upload.js
+12
-0
MyUploadAdapter.js
src/components/ckeditor/MyUploadAdapter.js
+1
-1
index.vue
src/components/ckeditor/index.vue
+17
-0
main.js
src/main.js
+6
-1
没有找到文件。
src/api/base_api.js
0 → 100644
浏览文件 @
f2c7272c
import
axios
from
'axios'
import
_
from
'lodash'
import
qs
from
'qs'
import
{
MessageBox
,
Message
}
from
'element-ui'
export
default
class
API
{
constructor
(
config
)
{
/* 创建一个 自定义配置axios实例 */
// 让ajax携带cookie
axios
.
defaults
.
withCredentials
=
true
this
.
_axios
=
axios
.
create
({
timeout
:
config
.
timeout
||
60
*
1000
,
/* 表示服务器响应的数据类型,可以是 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream' */
responseType
:
config
.
resType
||
'json'
,
/* 将自动加在 `url` 前面,除非 `url` 是一个绝对 URL */
baseURL
:
config
.
apiBaseURL
||
''
,
/* 即将被发送的自定义请求头 */
headers
:
{
Accept
:
'*/*'
,
'Accept-Language'
:
''
,
'Content-Type'
:
'application/x-www-form-urlencoded'
}
})
}
/* 获取当前Vue创建实例 */
getVueInstance
()
{
return
window
.
G
.
$instance_vue
}
/* 重新封装 请求时的执行函数 */
_request
(
_config
=
{})
{
/* 具体执行请求成功后业务逻辑前,先执行该方法 */
const
beforeSuccess
=
_config
.
beforeSuccess
?
_config
.
beforeSuccess
:
this
.
_reqSuccess
/* 具体执行请求失败后业务逻辑前,先执行该方法 */
const
beforeFail
=
_config
.
beforeFail
?
_config
.
beforeFail
:
this
.
_reqFail
const
headers
=
{
// tenant: 'ciis',
// version: window.G.VERSION,
'Content-Type'
:
'application/x-www-form-urlencoded'
}
_config
.
headers
=
_
.
assignIn
(
headers
,
_config
.
headers
)
/* 判别 传输方式 */
if
(
_config
.
headers
[
'Content-Type'
]
===
'application/x-www-form-urlencoded'
)
{
_config
.
data
=
qs
.
stringify
(
_config
.
data
)
}
if
(
_config
.
headers
[
'Content-Type'
]
===
'multipart/form-data'
)
{
let
fr
=
new
FormData
()
// eslint-disable-line
const
_obj
=
_config
.
data
||
_config
.
params
for
(
const
key
in
_obj
)
{
fr
.
append
(
key
,
_obj
[
key
])
}
_config
.
data
=
fr
}
/* 创建并根据参数发起请求 */
return
this
.
_axios
(
_config
).
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
))
}
setConfirm
(
titleStr
,
btnStr
,
msgStr
)
{
return
MessageBox
.
confirm
(
msgStr
,
titleStr
,
{
confirmButtonText
:
btnStr
,
type
:
'warning'
,
showClose
:
false
,
closeOnPressEscape
:
false
,
closeOnClickModal
:
false
,
showCancelButton
:
false
})
}
goLoginIndex
(
_vIn
)
{
const
href
=
window
.
location
.
href
if
(
/
\/
login
\/
index/gi
.
test
(
href
))
{
_vIn
.
$router
.
go
(
0
)
}
else
{
// _vIn.$router.push({
// path: '/login/index?rd=' + encodeURIComponent(href.replace(/.*?\/\/.*?\//gi, '/'))
// })
window
.
location
.
href
=
`
${
webConf
.
others
.
loginUrl
}
?rd=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
}
}
/**
* 统一处理request success操作,在实现业务逻辑前进行统一处理。
* 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 返回数据
*/
_reqSuccess
(
res
)
{
const
{
data
}
=
res
/* 带 code 参数,新接口模型 */
if
(
data
.
code
!==
undefined
)
{
if
(
data
.
code
!==
0
&&
!
/getinfo$/gi
.
test
(
res
.
config
.
url
))
{
data
.
msg
&&
Message
({
type
:
'error'
,
message
:
data
.
msg
})
}
}
return
data
}
/**
* 统一处理request fail操作,在实现业务逻辑前进行统一处理。
* 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 如果未到达 response 阶段,则无res.response
*/
_reqFail
(
res
)
{
const
_vIn
=
this
.
getVueInstance
()
let
err
=
null
if
(
res
.
code
===
'ECONNABORTED'
)
{
err
=
new
Error
(
'网络超时,请稍后重试'
)
}
else
if
(
res
.
response
)
{
const
{
status
,
data
}
=
res
.
response
/* 不带 code 参数,老接口模型 */
if
(
data
)
{
if
(
status
===
403
&&
!
/getinfo$/gi
.
test
(
res
.
config
.
url
))
{
this
.
setConfirm
(
'提示'
,
'确定'
,
'登录状态已过期, 请重新登录。'
)
.
then
(()
=>
{
this
.
goLoginIndex
(
_vIn
)
})
.
catch
(()
=>
{
Message
({
type
:
'info'
,
message
:
'已取消,将不再记录任何数据操作,除非重新登录'
})
})
}
else
if
(
status
===
401
)
{
this
.
setConfirm
(
'提示'
,
'关闭'
,
data
.
message
).
then
(()
=>
{})
}
}
err
=
new
Error
(
data
.
message
||
JSON
.
stringify
(
data
))
err
.
code
=
data
.
code
}
else
{
err
=
new
Error
(
'msg:'
+
res
.
message
+
'stack:'
+
res
.
stack
)
err
.
code
=
500
}
/* 如果出错,创建错误对象,并抛出一个错误。 */
throw
err
}
/* 重新实现 get请求 */
get
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'GET'
,
params
:
data
},
config
))
}
/* 重新实现 post请求 */
post
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'POST'
,
data
:
data
},
config
))
}
/* 重新实现 put请求 */
put
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'PUT'
,
data
:
data
},
config
))
}
/* 重新实现 delete请求 */
delete
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'DELETE'
,
params
:
data
},
config
))
}
}
src/api/upload.js
0 → 100644
浏览文件 @
f2c7272c
import
BaseAPI
from
'@/api/base_api'
const
httpRequest
=
new
BaseAPI
(
webConf
)
/**
* 上传文件
*/
export
function
uploadFile
(
data
)
{
return
httpRequest
.
post
(
'/api/opera/v1/file/upload'
,
data
,
{
headers
:
{
'Content-Type'
:
'multipart/form-data'
}
})
}
src/components/ckeditor/MyUploadAdapter.js
浏览文件 @
f2c7272c
import
{
uploadFile
}
from
'@/api/
common
'
import
{
uploadFile
}
from
'@/api/
upload
'
export
default
class
MyUploadAdapter
{
export
default
class
MyUploadAdapter
{
constructor
(
loader
)
{
constructor
(
loader
)
{
...
...
src/components/ckeditor/index.vue
浏览文件 @
f2c7272c
...
@@ -49,6 +49,23 @@ export default {
...
@@ -49,6 +49,23 @@ export default {
</
script
>
</
script
>
<
style
>
<
style
>
.ck-toolbar
.ck-dropdown
:nth-child
(
15
)
{
display
:
none
!important
;
}
.ck-toolbar
.ck-button
:nth-child
(
4
)
{
display
:
none
!important
;
}
.ck-toolbar
.ck-button
:nth-child
(
6
)
{
display
:
none
!important
;
}
.ck-toolbar
.ck-button
:nth-child
(
7
)
{
display
:
none
!important
;
}
.ck-dropdown
{
}
.ck-file-dialog-button
{
display
:
none
;
}
.ck-content
{
.ck-content
{
min-height
:
300px
;
min-height
:
300px
;
max-height
:
500px
;
max-height
:
500px
;
...
...
src/main.js
浏览文件 @
f2c7272c
...
@@ -9,6 +9,11 @@ const before = new BeforeEnter()
...
@@ -9,6 +9,11 @@ const before = new BeforeEnter()
Vue
.
use
(
ElementUI
)
Vue
.
use
(
ElementUI
)
/* 设置全局变量 */
window
.
G
=
Vue
.
prototype
.
$GLOBAL
=
{
VERSION
:
'PC-1.0.0'
}
/* 导航守卫 */
/* 导航守卫 */
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
before
.
update
(
to
,
from
,
next
)
before
.
update
(
to
,
from
,
next
)
...
@@ -16,7 +21,7 @@ router.beforeEach((to, from, next) => {
...
@@ -16,7 +21,7 @@ router.beforeEach((to, from, next) => {
Vue
.
prototype
.
msgCenter
=
new
Vue
()
Vue
.
prototype
.
msgCenter
=
new
Vue
()
new
Vue
({
window
.
G
.
$instance_vue
=
new
Vue
({
store
,
store
,
router
,
router
,
render
:
h
=>
h
(
App
)
render
:
h
=>
h
(
App
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论