Commit 3344c4a5 by 焦子成

1

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