Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
download-web
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
downloader
download-web
Commits
85482980
Commit
85482980
authored
Sep 01, 2025
by
焦子成
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d36acf7e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
114 additions
and
36 deletions
+114
-36
src/api/api.js
+33
-0
src/main.js
+2
-0
src/router/index.js
+14
-14
src/stores/auth.js
+20
-18
src/utils/request.js
+34
-0
src/views/Downloader.vue
+0
-0
src/views/Login.vue
+0
-0
src/views/Settings.vue
+3
-3
vite.config.js
+8
-1
No files found.
src/api/api.js
0 → 100644
View file @
85482980
var
apiHost
=
""
;
var
domain
=
""
;
let
env
=
process
.
env
.
NODE_ENV
||
""
;
if
(
env
==
"production"
)
{
apiHost
=
"https://taskh5.htangcloud.com"
;
}
else
if
(
env
==
"test"
)
{
apiHost
=
"https://testapp.rongketech.com"
;
}
else
{
apiHost
=
"http://39.107.245.36:8081"
;
domain
=
'/api'
}
console
.
log
(
`-----env[
${
env
}
]-----, apiHost[
${
apiHost
}
]`
);
const
config
=
{
apiHost
,
domain
,
login
:
`
${
domain
}
/user/login`
,
register
:
`
${
domain
}
/user/register`
,
uploadBatchList
:
`
${
domain
}
/uploadBatch/pageList`
,
uploadBatchQueryUpload
:
`
${
domain
}
/uploadBatch/queryUpload`
,
uploadBatchDelete
:
`
${
domain
}
/uploadBatch/delete`
,
uploadDetailList
:
`
${
domain
}
/uploadDetail/pageList`
,
uploadBatchFileUpload
:
`
${
domain
}
/uploadBatch/fileUpload`
,
uploadDetailTotalNum
:
`
${
domain
}
/uploadDetail/totalNum`
,
uploadDetailDeleteAll
:
`
${
domain
}
/uploadDetail/deleteAll`
,
uploadDetailDelete
:
`
${
domain
}
/uploadDetail/delete`
,
downLoadStatus
:
`
${
domain
}
/uploadDetail/downLoadStatus`
,
fileUploadDetail
:
`
${
domain
}
/uploadBatch/fileUploadDetail`
,
};
export
default
config
;
src/main.js
View file @
85482980
...
@@ -7,6 +7,7 @@ import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
...
@@ -7,6 +7,7 @@ import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import
App
from
'./App.vue'
import
App
from
'./App.vue'
import
router
from
'./router'
import
router
from
'./router'
import
'./style.css'
import
'./style.css'
import
axios
from
'axios'
const
app
=
createApp
(
App
)
const
app
=
createApp
(
App
)
const
pinia
=
createPinia
()
const
pinia
=
createPinia
()
...
@@ -16,5 +17,6 @@ app.use(router)
...
@@ -16,5 +17,6 @@ app.use(router)
app
.
use
(
ElementPlus
,
{
app
.
use
(
ElementPlus
,
{
locale
:
zhCn
,
locale
:
zhCn
,
})
})
// app.prototype.$http = axios
app
.
mount
(
'#app'
)
app
.
mount
(
'#app'
)
src/router/index.js
View file @
85482980
...
@@ -42,21 +42,21 @@ const router = createRouter({
...
@@ -42,21 +42,21 @@ const router = createRouter({
})
})
// 路由守卫
// 路由守卫
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
//
router.beforeEach((to, from, next) => {
const
authStore
=
useAuthStore
()
//
const authStore = useAuthStore()
// 初始化认证状态
//
// 初始化认证状态
if
(
!
authStore
.
isAuthenticated
)
{
//
if (!authStore.isAuthenticated) {
authStore
.
initialize
()
//
authStore.initialize()
}
//
}
if
(
to
.
meta
.
requiresAuth
&&
!
authStore
.
isAuthenticated
)
{
//
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
next
(
'/login'
)
//
next('/login')
}
else
if
(
to
.
path
===
'/login'
&&
authStore
.
isAuthenticated
)
{
//
} else if (to.path === '/login' && authStore.isAuthenticated) {
next
(
'/downloader'
)
//
next('/downloader')
}
else
{
//
} else {
next
()
//
next()
}
//
}
})
//
})
export
default
router
export
default
router
src/stores/auth.js
View file @
85482980
...
@@ -58,18 +58,18 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -58,18 +58,18 @@ export const useAuthStore = defineStore('auth', () => {
}
}
// 检查用户名是否已存在
// 检查用户名是否已存在
const
isUsernameExists
=
(
user
n
ame
)
=>
{
const
isUsernameExists
=
(
user
N
ame
)
=>
{
return
users
.
value
.
some
(
user
=>
user
.
user
name
===
usern
ame
)
return
users
.
value
.
some
(
user
=>
user
.
user
Name
===
userN
ame
)
}
}
// 用户注册
// 用户注册
const
register
=
async
(
user
n
ame
,
password
,
email
=
''
)
=>
{
const
register
=
async
(
user
N
ame
,
password
,
email
=
''
)
=>
{
// 验证用户名
// 验证用户名
if
(
!
user
name
||
usern
ame
.
trim
().
length
<
3
)
{
if
(
!
user
Name
||
userN
ame
.
trim
().
length
<
3
)
{
throw
new
Error
(
'用户名至少需要3个字符'
)
throw
new
Error
(
'用户名至少需要3个字符'
)
}
}
if
(
isUsernameExists
(
user
n
ame
))
{
if
(
isUsernameExists
(
user
N
ame
))
{
throw
new
Error
(
'用户名已存在'
)
throw
new
Error
(
'用户名已存在'
)
}
}
...
@@ -82,7 +82,7 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -82,7 +82,7 @@ export const useAuthStore = defineStore('auth', () => {
// 创建新用户
// 创建新用户
const
newUser
=
{
const
newUser
=
{
id
:
Date
.
now
().
toString
(),
id
:
Date
.
now
().
toString
(),
user
name
:
usern
ame
.
trim
(),
user
Name
:
userN
ame
.
trim
(),
password
:
btoa
(
password
),
// 简单的Base64编码(实际项目中应使用更安全的加密)
password
:
btoa
(
password
),
// 简单的Base64编码(实际项目中应使用更安全的加密)
email
:
email
.
trim
(),
email
:
email
.
trim
(),
createdAt
:
new
Date
().
toISOString
(),
createdAt
:
new
Date
().
toISOString
(),
...
@@ -102,9 +102,9 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -102,9 +102,9 @@ export const useAuthStore = defineStore('auth', () => {
}
}
// 用户登录
// 用户登录
const
login
=
async
(
user
n
ame
,
password
)
=>
{
const
login
=
async
(
user
N
ame
,
password
)
=>
{
try
{
try
{
console
.
log
(
'Auth store login 被调用,用户名:'
,
user
n
ame
)
console
.
log
(
'Auth store login 被调用,用户名:'
,
user
N
ame
)
// 确保用户数据已加载
// 确保用户数据已加载
if
(
users
.
value
.
length
===
0
)
{
if
(
users
.
value
.
length
===
0
)
{
...
@@ -112,17 +112,19 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -112,17 +112,19 @@ export const useAuthStore = defineStore('auth', () => {
loadUsersFromStorage
()
loadUsersFromStorage
()
}
}
console
.
log
(
'当前用户列表:'
,
users
.
value
.
map
(
u
=>
u
.
user
n
ame
))
console
.
log
(
'当前用户列表:'
,
users
.
value
.
map
(
u
=>
u
.
user
N
ame
))
// 查找用户
// 查找用户
const
user
=
users
.
value
.
find
(
u
=>
u
.
username
===
usern
ame
)
let
user
=
users
.
value
.
find
(
u
=>
u
.
userName
===
userN
ame
)
console
.
log
(
'--->查找用户:'
,
user
)
if
(
!
user
)
{
if
(
!
user
)
{
console
.
log
(
'未找到用户:'
,
username
)
console
.
log
(
'未找到用户:'
,
userName
)
throw
new
Error
(
'用户名或密码错误'
)
// user.value.userName = userName
// user.value.password = password
// throw new Error('用户名或密码错误')
}
}
console
.
log
(
'找到用户:'
,
user
.
user
n
ame
)
console
.
log
(
'找到用户:'
,
user
.
user
N
ame
)
console
.
log
(
'输入的密码:'
,
password
)
console
.
log
(
'输入的密码:'
,
password
)
console
.
log
(
'输入的密码编码后:'
,
btoa
(
password
))
console
.
log
(
'输入的密码编码后:'
,
btoa
(
password
))
console
.
log
(
'存储的密码:'
,
user
.
password
)
console
.
log
(
'存储的密码:'
,
user
.
password
)
...
@@ -130,7 +132,7 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -130,7 +132,7 @@ export const useAuthStore = defineStore('auth', () => {
// 验证密码
// 验证密码
if
(
user
.
password
!==
btoa
(
password
))
{
if
(
user
.
password
!==
btoa
(
password
))
{
console
.
log
(
'密码不匹配'
)
console
.
log
(
'密码不匹配'
)
throw
new
Error
(
'用户名或密码错误'
)
//
throw new Error('用户名或密码错误')
}
}
console
.
log
(
'密码验证成功'
)
console
.
log
(
'密码验证成功'
)
...
@@ -272,7 +274,7 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -272,7 +274,7 @@ export const useAuthStore = defineStore('auth', () => {
const
adminPassword
=
'123456'
const
adminPassword
=
'123456'
const
adminUser
=
{
const
adminUser
=
{
id
:
'admin'
,
id
:
'admin'
,
user
n
ame
:
'admin'
,
user
N
ame
:
'admin'
,
password
:
btoa
(
adminPassword
),
password
:
btoa
(
adminPassword
),
email
:
''
,
email
:
''
,
createdAt
:
new
Date
().
toISOString
(),
createdAt
:
new
Date
().
toISOString
(),
...
@@ -290,7 +292,7 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -290,7 +292,7 @@ export const useAuthStore = defineStore('auth', () => {
console
.
log
(
'管理员密码编码后:'
,
btoa
(
adminPassword
))
console
.
log
(
'管理员密码编码后:'
,
btoa
(
adminPassword
))
}
}
console
.
log
(
'当前用户列表:'
,
users
.
value
.
map
(
u
=>
u
.
user
n
ame
))
console
.
log
(
'当前用户列表:'
,
users
.
value
.
map
(
u
=>
u
.
user
N
ame
))
// 尝试恢复当前用户会话
// 尝试恢复当前用户会话
try
{
try
{
...
@@ -301,7 +303,7 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -301,7 +303,7 @@ export const useAuthStore = defineStore('auth', () => {
const
existingUser
=
users
.
value
.
find
(
u
=>
u
.
id
===
userData
.
id
)
const
existingUser
=
users
.
value
.
find
(
u
=>
u
.
id
===
userData
.
id
)
if
(
existingUser
)
{
if
(
existingUser
)
{
setCurrentUser
(
existingUser
)
setCurrentUser
(
existingUser
)
console
.
log
(
'用户会话已恢复:'
,
existingUser
.
user
n
ame
)
console
.
log
(
'用户会话已恢复:'
,
existingUser
.
user
N
ame
)
}
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
src/utils/request.js
0 → 100644
View file @
85482980
// import Vue from 'vue'
import
axios
from
'axios'
export
default
{
post
(
url
,
params
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
url
,
params
||
{},
{
headers
:
{
'content-type'
:
'application/json'
,
'Authorization'
:
sessionStorage
.
getItem
(
"token"
)
||
''
,
}
})
.
then
(
res
=>
{
resolve
(
res
.
data
)
})
.
catch
(
err
=>
{
reject
(
err
.
data
)
})
})
},
// get(url, params) {
// return new Promise((resolve, reject) => {
// axios.get(url, {
// params: params
// }).then(res => {
// resolve(res.data)
// }).catch(err => {
// reject(err.data)
// })
// })
// }
}
\ No newline at end of file
src/views/Downloader.vue
View file @
85482980
This diff is collapsed.
Click to expand it.
src/views/Login.vue
View file @
85482980
This diff is collapsed.
Click to expand it.
src/views/Settings.vue
View file @
85482980
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
<el-form
:model=
"userInfo"
label-width=
"120px"
>
<el-form
:model=
"userInfo"
label-width=
"120px"
>
<el-form-item
label=
"用户名"
>
<el-form-item
label=
"用户名"
>
<el-input
v-model=
"userInfo.user
n
ame"
disabled
/>
<el-input
v-model=
"userInfo.user
N
ame"
disabled
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"邮箱"
>
<el-form-item
label=
"邮箱"
>
...
@@ -121,7 +121,7 @@ const authStore = useAuthStore()
...
@@ -121,7 +121,7 @@ const authStore = useAuthStore()
// 用户信息
// 用户信息
const
userInfo
=
reactive
({
const
userInfo
=
reactive
({
user
n
ame
:
''
,
user
N
ame
:
''
,
email
:
''
,
email
:
''
,
createdAt
:
''
,
createdAt
:
''
,
lastLoginAt
:
''
lastLoginAt
:
''
...
@@ -138,7 +138,7 @@ const downloadSettings = reactive({
...
@@ -138,7 +138,7 @@ const downloadSettings = reactive({
const
initializeData
=
()
=>
{
const
initializeData
=
()
=>
{
const
user
=
authStore
.
user
const
user
=
authStore
.
user
if
(
user
)
{
if
(
user
)
{
userInfo
.
user
name
=
user
.
usern
ame
userInfo
.
user
Name
=
user
.
userN
ame
userInfo
.
email
=
user
.
email
||
'未设置'
userInfo
.
email
=
user
.
email
||
'未设置'
userInfo
.
createdAt
=
new
Date
(
user
.
createdAt
).
toLocaleString
()
userInfo
.
createdAt
=
new
Date
(
user
.
createdAt
).
toLocaleString
()
userInfo
.
lastLoginAt
=
user
.
lastLoginAt
?
new
Date
(
user
.
lastLoginAt
).
toLocaleString
()
:
'从未登录'
userInfo
.
lastLoginAt
=
user
.
lastLoginAt
?
new
Date
(
user
.
lastLoginAt
).
toLocaleString
()
:
'从未登录'
...
...
vite.config.js
View file @
85482980
...
@@ -11,7 +11,14 @@ export default defineConfig({
...
@@ -11,7 +11,14 @@ export default defineConfig({
},
},
server
:
{
server
:
{
port
:
3000
,
port
:
3000
,
open
:
true
open
:
true
,
proxy
:
{
'/api'
:
{
target
:
'http://39.107.245.36:8081'
,
changeOrigin
:
true
,
rewrite
:
path
=>
path
.
replace
(
/^
\/
api/
,
''
)
}
}
},
},
build
:
{
build
:
{
outDir
:
'dist'
,
outDir
:
'dist'
,
...
...
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