Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
confucius
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
罗超
confucius
Commits
60522ff0
Commit
60522ff0
authored
Aug 24, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
f226bb3e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
15 deletions
+34
-15
common.js
src/api/common/common.js
+34
-15
No files found.
src/api/common/common.js
View file @
60522ff0
...
...
@@ -19,6 +19,18 @@ export function getFontConfig() {
};
}
/**
* 配置相关
*/
export
function
CommonConfig
()
{
return
{
FileConfig
:
{
FileUrl
:
'http://192.168.20.214:8130'
,
//本地服务器文件预览地址
UploadUrl
:
"http://192.168.20.214:8120"
,
//本地上传文件地址
}
}
}
/**
* 上传文件
...
...
@@ -48,12 +60,12 @@ export function UploadSelfFile(path, file, callback, configObj) {
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
);
break
;
//上传文件到阿里云
//上传文件到阿里云
case
2
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToALi
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
);
break
;
//上传文件到自己文件服务器
//上传文件到自己文件服务器
case
3
:
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
,
configObj
);
break
;
...
...
@@ -67,8 +79,9 @@ export function UploadViittoFile(path, file, callback) {
uploadLoadding
.
show
({
message
:
'正在上传文件,请稍后...'
})
let
viewFileUrl
=
'http://192.168.20.214:8130'
;
let
vtUploadUrl
=
"http://192.168.20.214:8120"
;
let
fileConfig
=
CommonConfig
()
let
viewFileUrl
=
fileConfig
.
FileConfig
.
FileUrl
;
let
vtUploadUrl
=
fileConfig
.
FileConfig
.
UploadUrl
;
let
locationName
=
window
.
location
.
hostname
;
if
(
locationName
.
indexOf
(
'testerp.oytour'
)
!==
-
1
)
{
vtUploadUrl
=
"http://upload.oytour.com"
;
...
...
@@ -216,6 +229,12 @@ export function UploadLocalSystem(configObj, fileObj, successCall) {
* 上传文件到本地文件系统
*/
export
function
UploadFileToSystem
(
uploadConfig
,
fileFullPath
,
fileObj
,
uploadLoadding
,
successCall
,
configObj
)
{
let
fileConfig
=
CommonConfig
();
let
locationName
=
window
.
location
.
hostname
;
if
(
locationName
.
indexOf
(
'localhost'
)
!==
-
1
)
{
uploadConfig
.
UploadDomain
=
fileConfig
.
FileConfig
.
UploadUrl
;
uploadConfig
.
CustomDomain
=
fileConfig
.
FileConfig
.
FileUrl
;
}
let
url
=
uploadConfig
.
UploadDomain
+
"/Upload?filePath="
+
fileFullPath
;
if
(
configObj
)
{
//是否转换图片
...
...
@@ -269,7 +288,7 @@ export function UploadFileToALi(uploadConfig, fileFullPath, fileObj, uploadLoadd
bucket
:
uploadConfig
.
Bucket
})
var
result
=
oss
.
multipartUpload
(
fileFullPath
,
fileObj
,
{
progress
:
function
*
(
p
)
{
}
progress
:
function
*
(
p
)
{}
}).
then
(
res
=>
{
uploadLoadding
.
hide
();
var
uploadResult
=
{
...
...
@@ -298,7 +317,7 @@ export function UploadFileToTencent(uploadConfig, fileFullPath, fileObj, uploadL
Key
:
fileFullPath
,
//文件名
StorageClass
:
'STANDARD'
,
Body
:
fileObj
,
// 上传文件对象
onProgress
:
function
(
progressData
)
{
}
onProgress
:
function
(
progressData
)
{}
},
function
(
err
,
data
)
{
uploadLoadding
.
hide
();
if
(
data
&&
data
.
statusCode
==
200
)
{
...
...
@@ -394,15 +413,15 @@ export function EduDownLoad(cmd, msg, fileName, callBack) {
/**
* 上传文件 企微写死阿里云
*/
export
function
wechatUploadSelfFile
(
path
,
file
,
callback
,
configObj
)
{
export
function
wechatUploadSelfFile
(
path
,
file
,
callback
,
configObj
)
{
//用户登录缓存
//配置写死的 腾讯云
var
uploadConfig
=
{
Region
:
"ap-chengdu"
,
SecretId
:
"AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd"
,
SecretKey
:
"PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob"
,
var
uploadConfig
=
{
Region
:
"ap-chengdu"
,
SecretId
:
"AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd"
,
SecretKey
:
"PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob"
,
Bucket
:
"viitto-1301420277"
};
};
//获取文件扩展名
var
index
=
file
.
name
.
lastIndexOf
(
"."
);
var
suffix
=
file
.
name
.
substr
(
index
);
...
...
@@ -414,7 +433,7 @@ export function EduDownLoad(cmd, msg, fileName, callBack) {
message
:
'正在上传文件,请稍后...'
})
if
(
uploadConfig
)
{
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
);
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
);
}
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment