Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yongxinda-admin
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
yongxinda-admin
Commits
0aa8f812
提交
0aa8f812
authored
12月 14, 2022
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加lic控制权限
上级
1927fdf2
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
96 行增加
和
5 行删除
+96
-5
main.ts
src/main.ts
+1
-1
index.ts
src/router/index.ts
+5
-0
config.ts
src/services/api/config.ts
+3
-2
login.ts
src/services/api/login/login.ts
+18
-0
index.vue
src/views/importLic/index.vue
+67
-0
vite.config.ts
vite.config.ts
+2
-2
没有找到文件。
src/main.ts
浏览文件 @
0aa8f812
...
@@ -61,7 +61,7 @@ router.beforeEach(async (to, from, next) => {
...
@@ -61,7 +61,7 @@ router.beforeEach(async (to, from, next) => {
}
}
}
else
{
}
else
{
//判断是否在白名单中
//判断是否在白名单中
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
//存在白名单,放行
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
||
to
.
path
===
'/import/lic'
)
{
//存在白名单,放行
next
();
next
();
}
else
{
//不存在,登录
}
else
{
//不存在,登录
next
({
path
:
'/login'
})
next
({
path
:
'/login'
})
...
...
src/router/index.ts
浏览文件 @
0aa8f812
...
@@ -38,6 +38,11 @@ const routes: Array<RouteRecordRaw> = [
...
@@ -38,6 +38,11 @@ const routes: Array<RouteRecordRaw> = [
component
:
()
=>
import
(
"@/views/login/login.vue"
),
component
:
()
=>
import
(
"@/views/login/login.vue"
),
},
},
{
{
path
:
"/import/lic"
,
name
:
"importLic"
,
component
:
()
=>
import
(
"@/views/importLic/index.vue"
),
},
{
path
:
"/404"
,
path
:
"/404"
,
name
:
"404"
,
name
:
"404"
,
component
:
()
=>
import
(
"@/views/exception/404.vue"
),
component
:
()
=>
import
(
"@/views/exception/404.vue"
),
...
...
src/services/api/config.ts
浏览文件 @
0aa8f812
import
axios
,
{
AxiosInstance
}
from
'axios'
import
axios
,
{
AxiosInstance
}
from
'axios'
import
{
ElMessage
}
from
'element-plus'
import
{
ElMessage
}
from
'element-plus'
import
router
from
'@/router/index'
// api路径
// api路径
const
API_URL
:
string
=
import
.
meta
.
env
.
VITE_APP_BASE_URL
const
API_URL
:
string
=
import
.
meta
.
env
.
VITE_APP_BASE_URL
...
@@ -33,7 +32,6 @@ service.interceptors.response.use(
...
@@ -33,7 +32,6 @@ service.interceptors.response.use(
error
=>
{
error
=>
{
// 数据请求失败后的相应操作
// 数据请求失败后的相应操作
const
response
=
error
.
response
;
const
response
=
error
.
response
;
// 根据返回的code值来做不同的处理(和后端约定)
// 根据返回的code值来做不同的处理(和后端约定)
switch
(
response
.
status
)
{
switch
(
response
.
status
)
{
case
401
:
case
401
:
...
@@ -41,6 +39,9 @@ service.interceptors.response.use(
...
@@ -41,6 +39,9 @@ service.interceptors.response.use(
window
.
location
.
href
=
"/#/login"
;
window
.
location
.
href
=
"/#/login"
;
sessionStorage
.
clear
()
sessionStorage
.
clear
()
return
ElMessage
.
error
(
'请重新登录'
)
return
ElMessage
.
error
(
'请重新登录'
)
}
else
if
(
response
.
data
.
code
===
913
)
{
window
.
location
.
href
=
'/#/import/lic'
return
ElMessage
.
error
(
'请重新导入lic文件'
)
}
}
ElMessage
.
error
(
'错误请求'
)
ElMessage
.
error
(
'错误请求'
)
break
;
break
;
...
...
src/services/api/login/login.ts
浏览文件 @
0aa8f812
...
@@ -19,3 +19,21 @@ export function toLogin(
...
@@ -19,3 +19,21 @@ export function toLogin(
// method: 'get',
// method: 'get',
// })
// })
// }
// }
// 获取mac地址
export
function
getMacAddress
()
{
return
request
({
url
:
'/api/lic/info/mac'
,
method
:
'post'
})
}
// 导入文件
export
function
importFile
(
data
:
any
)
{
return
request
({
url
:
"/api/lic/info/file/import"
,
method
:
'post'
,
headers
:
{
'Content-Type'
:
'multipart/form-data'
},
data
})
}
src/views/importLic/index.vue
0 → 100644
浏览文件 @
0aa8f812
<
template
>
<el-alert
title=
"lic已失效,请通过mac地址,重新导入lic文件"
type=
"warning"
:closable=
'false'
center
/>
<div
class=
'app-container'
>
mac地址:
{{
macAddress
}}
<el-button
type=
"primary"
style=
"width: 100px; margin-top: 20px;"
@
click=
"handleSelected"
>
导入lic文件
</el-button>
<input
ref=
"uploadInput"
type=
"file"
style=
"display: none;"
accept=
".tmp"
@
change=
"submitUpload"
/>
</div>
</
template
>
<
script
setup
lang=
'ts'
>
import
{
ref
}
from
'vue'
import
{
getMacAddress
,
importFile
}
from
'@/services/api/login/login'
import
{
ElMessage
}
from
'element-plus'
const
macAddress
=
ref
()
const
uploadInput
=
ref
()
const
handleSelected
=
()
=>
uploadInput
.
value
.
click
()
// //选好文件之后点击打开按钮
const
submitUpload
=
(
e
:
any
)
=>
{
const
files
=
e
.
target
.
files
const
rawFile
=
files
[
0
]
console
.
log
(
rawFile
);
if
(
!
rawFile
)
return
upload
(
rawFile
)
}
//上传
const
upload
=
(
rawFile
:
any
)
=>
{
uploadInput
.
value
=
null
uploadSectionFile
(
rawFile
)
}
const
uploadSectionFile
=
(
file
:
any
,
params
?:
any
)
=>
{
// let data = params
let
fromData
=
new
FormData
()
// FormData 对象
let
fileObj
=
file
// 相当于input里取得的files
fromData
.
append
(
'file'
,
fileObj
)
// 文件对象
importFile
(
fromData
).
then
((
res
:
any
)
=>
{
//调用上传接口
if
(
res
.
code
===
200
)
{
sessionStorage
.
clear
()
ElMessage
({
type
:
'success'
,
message
:
'导入成功!'
})
}
})
}
getMacAddress
().
then
((
res
:
any
)
=>
{
if
(
res
.
code
===
200
)
{
macAddress
.
value
=
res
.
data
.
macAddress
}
})
</
script
>
<
style
lang =
"scss"
scoped
>
.app-container
{
display
:
flex
;
flex-direction
:
column
;
margin
:
10%
auto
;
justify-content
:
center
;
align-items
:
center
;
}
</
style
>
\ No newline at end of file
vite.config.ts
浏览文件 @
0aa8f812
...
@@ -89,11 +89,11 @@ export default ({ command, mode }) => {
...
@@ -89,11 +89,11 @@ export default ({ command, mode }) => {
// '/foo': '',
// '/foo': '',
// 选项写法
// 选项写法
"/admin"
:
{
"/admin"
:
{
target
:
"http://192.168.0.
60:82
/"
,
target
:
"http://192.168.0.
9:8089
/"
,
// rewrite: (path) => path.replace(/^\/api/, '') http://192.168.0.9:8089/
// rewrite: (path) => path.replace(/^\/api/, '') http://192.168.0.9:8089/
},
},
"/wx"
:
{
"/wx"
:
{
target
:
"http://192.168.0.
60:82
/"
,
target
:
"http://192.168.0.
9:8089
/"
,
// rewrite: (path) => path.replace(/^\/api/, '')
// rewrite: (path) => path.replace(/^\/api/, '')
},
},
// 正则表达式写法
// 正则表达式写法
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论