Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
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
viitto
pptist
Commits
241573f3
Commit
241573f3
authored
May 29, 2024
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传修改
parent
a1d56094
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
17 deletions
+15
-17
aliyun.ts
src/utils/upload/aliyun.ts
+11
-12
Setting.vue
src/views/UserCenter/Setting.vue
+4
-5
No files found.
src/utils/upload/aliyun.ts
View file @
241573f3
import
{
domainManager
}
from
"../domainManager"
;
class
AliyunUpload
{
static
UploadAsync
=
async
(
file
:
any
,
name
:
string
)
=>
{
static
UploadAsync
=
async
(
file
:
any
,
name
:
string
)
=>
{
try
{
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
const
response
=
await
fetch
(
`
${
domainManager
().
UploadUrl
}
/Upload/UploadToALiOSS?filePath=
${
encodeURIComponent
(
name
)}
`
,
{
method
:
'POST'
,
body
:
formData
,
method
:
'POST'
,
body
:
formData
,
});
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
let
result
=
await
response
.
text
()
let
datas
=
JSON
.
parse
(
result
)
return
'https://im.oytour.com'
+
datas
.
FilePath
return
'https://im.oytour.com'
+
datas
.
FilePath
}
return
''
}
catch
(
error
)
{
return
''
}
}
static
UploadAvatar
=
async
(
file
:
any
,
name
:
string
)
=>
{
console
.
log
(
name
,
'----name'
)
static
UploadAvatar
=
async
(
file
:
any
,
filepath
:
string
)
=>
{
try
{
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
const
response
=
await
fetch
(
`
${
domainManager
().
UploadUrl
}
/Upload?filePath=
${
encodeURIComponent
(
name
)}
`
,
{
method
:
'POST'
,
body
:
formData
,
const
response
=
await
fetch
(
`
${
domainManager
().
UploadUrl
}
/Upload?filePath=
${
encodeURIComponent
(
filepath
)}
`
,
{
method
:
'POST'
,
body
:
formData
,
});
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
let
result
=
await
response
.
text
()
let
datas
=
JSON
.
parse
(
result
)
return
'https://im.oytour.com'
+
datas
.
FilePath
return
`
${
domainManager
().
ViittoFileUrl
}
`
+
datas
.
FilePath
}
return
''
}
catch
(
error
)
{
...
...
src/views/UserCenter/Setting.vue
View file @
241573f3
...
...
@@ -189,12 +189,11 @@ const handleAvatarSuccess=async (res:any)=>{
const
beforeAvatarUpload
=
async
(
res
:
any
)
=>
{
dialogType
.
value
=
3
loadingImg
.
value
=
true
let
timestamp
=
new
Date
().
getTime
()
let
url
=
await
AliyunUpload
.
UploadAvatar
(
res
,
`
${
res
.
name
.
split
(
'.'
)[
0
]}${
timestamp
}
`
)
console
.
log
(
"beforeAvatarUpload_res"
,
userInfo
.
value
.
photo
);
let
filePath
=
"/Upload/User/"
;
let
url
=
await
AliyunUpload
.
UploadAvatar
(
res
,
filePath
);
if
(
url
!=
''
)
{
console
.
log
(
url
,
';--------------url'
)
// userInfo.value.photo =url
userInfo
.
value
.
photo
=
url
// await bindHandler()
}
}
...
...
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