Commit 3344c4a5 by 焦子成

1

parent bd08d501
...@@ -2,7 +2,8 @@ var apiHost = ""; ...@@ -2,7 +2,8 @@ var apiHost = "";
var domain = ""; var domain = "";
let env = process.env.NODE_ENV || ""; let env = process.env.NODE_ENV || "";
if (env == "production") { if (env == "production") {
apiHost = "https://taskh5.htangcloud.com"; apiHost = "https://downloader.rongketech.com/api";
domain = 'https://downloader.rongketech.com/api'
} else if (env == "test") { } else if (env == "test") {
apiHost = "https://testapp.rongketech.com"; apiHost = "https://testapp.rongketech.com";
} else { } else {
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
<el-icon> <el-icon>
<User /> <User />
</el-icon> </el-icon>
{{ authStore.user?.userName }} <!-- {{ authStore.user?.userName }} -->
{{ userName }}
<el-icon> <el-icon>
<ArrowDown /> <ArrowDown />
</el-icon> </el-icon>
...@@ -808,11 +809,12 @@ const updateDownloadPath = () => { ...@@ -808,11 +809,12 @@ const updateDownloadPath = () => {
// 更新store中的文件名前缀 // 更新store中的文件名前缀
downloadStore.setCustomSubFolder(customSubFolder.value) downloadStore.setCustomSubFolder(customSubFolder.value)
} }
const userName = ref('')
// 组件挂载时初始化 // 组件挂载时初始化
onMounted(() => { onMounted(() => {
// 先初始化下载store // 先初始化下载store
downloadStore.initialize() downloadStore.initialize()
userName.value = sessionStorage.getItem('userName') || ''
// 从下载store中同步文件名前缀 // 从下载store中同步文件名前缀
customSubFolder.value = downloadStore.customSubFolder || '' customSubFolder.value = downloadStore.customSubFolder || ''
...@@ -820,6 +822,7 @@ onMounted(() => { ...@@ -820,6 +822,7 @@ onMounted(() => {
detectBrowserDownloadPath() detectBrowserDownloadPath()
loadUpTableData() loadUpTableData()
loadDetailTableData() loadDetailTableData()
}) })
const statusMap = { const statusMap = {
0: 'pending', 0: 'pending',
......
...@@ -450,7 +450,7 @@ const clearAllHistory = async () => { ...@@ -450,7 +450,7 @@ const clearAllHistory = async () => {
} }
) )
// authStore.clearDownloadHistory() authStore.clearDownloadHistory()
// loadHistory() // loadHistory()
// ElMessage.success('历史记录已清空') // ElMessage.success('历史记录已清空')
http.post(config.uploadDetailDeleteAll, { http.post(config.uploadDetailDeleteAll, {
......
...@@ -124,6 +124,7 @@ import { Check, Close, Download } from '@element-plus/icons-vue' ...@@ -124,6 +124,7 @@ import { Check, Close, Download } from '@element-plus/icons-vue'
import { useAuthStore } from '../stores/auth' import { useAuthStore } from '../stores/auth'
import http from '@/utils/request.js'; import http from '@/utils/request.js';
import config from '@/api/api.js'; import config from '@/api/api.js';
import { lo } from 'element-plus/es/locales.mjs'
const router = useRouter() const router = useRouter()
const authStore = useAuthStore() const authStore = useAuthStore()
...@@ -259,6 +260,21 @@ function handleLogin() { ...@@ -259,6 +260,21 @@ function handleLogin() {
loading.value = false loading.value = false
if (res.code === 200) { if (res.code === 200) {
sessionStorage.setItem("token", res.data) sessionStorage.setItem("token", res.data)
let user = {
"id": res.data,
"username": loginForm.userName,
"password": loginForm.password,
"email": "",
"createdAt": new Date(),
"lastLoginAt": new Date(),
"settings": {
"maxConcurrentDownloads": 3,
"enableNotifications": true,
"fileNamePrefix": ""
}
}
authStore.setCurrentUser(user)
sessionStorage.setItem("userName", loginForm.userName)
router.push('/downloader') router.push('/downloader')
} else { } else {
errorMessage.value = res.message errorMessage.value = res.message
...@@ -300,23 +316,9 @@ const handleLogin1 = async () => { ...@@ -300,23 +316,9 @@ const handleLogin1 = async () => {
console.log('登录表单验证通过,用户名:', loginForm.userName) console.log('登录表单验证通过,用户名:', loginForm.userName)
await authStore.login(loginForm.userName, loginForm.password) await authStore.login(loginForm.userName, loginForm.password)
// console.log('登录成功,跳转到下载器页面') console.log('登录成功,跳转到下载器页面')
// ElMessage.success('登录成功!') ElMessage.success('登录成功!')
// router.push('/downloader') router.push('/downloader')
http.post(config.login, { ...loginForm }).then(res => {
loading.value = false
console.log('-->res:', res)
if (res.code === 200) {
console.log('-->res.data:', res.data)
ElMessage.success('登录成功!')
sessionStorage.setItem("token", res.data)
router.push('/downloader')
// console.log('router:',router)
} else {
ElMessage.error(res.message)
}
})
} catch (error) { } catch (error) {
console.error('登录失败:', error) console.error('登录失败:', error)
const errorMsg = error.message || '登录失败,请检查用户名和密码' const errorMsg = error.message || '登录失败,请检查用户名和密码'
......
...@@ -115,6 +115,8 @@ import { useRouter } from 'vue-router' ...@@ -115,6 +115,8 @@ import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { Setting } from '@element-plus/icons-vue' import { Setting } from '@element-plus/icons-vue'
import { useAuthStore } from '../stores/auth' import { useAuthStore } from '../stores/auth'
import http from '@/utils/request.js';
import config from '@/api/api.js';
const router = useRouter() const router = useRouter()
const authStore = useAuthStore() const authStore = useAuthStore()
...@@ -174,6 +176,13 @@ const clearHistory = async () => { ...@@ -174,6 +176,13 @@ const clearHistory = async () => {
authStore.clearDownloadHistory() authStore.clearDownloadHistory()
ElMessage.success('历史记录已清除') ElMessage.success('历史记录已清除')
http.post(config.uploadDetailDeleteAll, {
type: 1
}).then(res => {
if (res.code === 200) {
} else {
}
})
} catch { } catch {
// 用户取消 // 用户取消
} }
...@@ -218,6 +227,7 @@ const goBack = () => { ...@@ -218,6 +227,7 @@ const goBack = () => {
// 组件挂载时初始化 // 组件挂载时初始化
onMounted(() => { onMounted(() => {
initializeData() initializeData()
userInfo.userName = sessionStorage.getItem("userName") || ''
}) })
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment