From a731f54ec01722b7093e798cd4ddfb3d6d09b2de Mon Sep 17 00:00:00 2001 From: 2183691628 <2183691628@qq.com> Date: Mon, 6 Dec 2021 18:29:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20=E5=B0=81=E8=A3=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80=20-=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20=E7=99=BB=E5=BD=95=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81=20tel?= =?UTF-8?q?po=20telpo#1234?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 +- .env.production | 4 +- .env.test | 3 +- README.md | 11 +++- src/api/off-limits-manage.js | 22 ++++++++ src/api/user.js | 22 +++++--- src/assets/telpo.png | Bin 0 -> 7339 bytes src/layout/components/Navbar.vue | 20 ++++--- src/permission.js | 10 +++- src/store/getters.js | 8 +++ src/store/modules/user.js | 52 +++++++++++------- src/utils/appId.js | 7 +++ src/utils/auth-token.js | 22 ++++++++ src/utils/auth.js | 9 ++- src/utils/request.js | 6 +- src/views/dashboard/index.vue | 5 +- src/views/login/index.vue | 25 +++++---- .../alarm-recognition/index.vue | 20 ++++++- 18 files changed, 188 insertions(+), 61 deletions(-) create mode 100644 src/api/off-limits-manage.js create mode 100644 src/assets/telpo.png create mode 100644 src/utils/appId.js create mode 100644 src/utils/auth-token.js diff --git a/.env.development b/.env.development index de583d0..0b34745 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,5 @@ ENV = 'development' # base api -VUE_APP_BASE_API = '/dev-api' +#VUE_APP_BASE_API = '/dev-api' +VUE_APP_BASE_API = 'https://id.ssjlai.com/gateway/core' diff --git a/.env.production b/.env.production index 80c8103..0b6c033 100644 --- a/.env.production +++ b/.env.production @@ -1,6 +1,6 @@ # just a flag ENV = 'production' -# base api -VUE_APP_BASE_API = '/prod-api' +#VUE_APP_BASE_API = '/dev-api' +VUE_APP_BASE_API = 'https://ai.ssjlai.com/gateway/core' diff --git a/.env.test b/.env.test index 7586884..9c2e43b 100644 --- a/.env.test +++ b/.env.test @@ -4,5 +4,6 @@ NODE_ENV = production ENV = 'test' # base api -VUE_APP_BASE_API = '/stage-api' +#VUE_APP_BASE_API = '/dev-api' +VUE_APP_BASE_API = 'https://id.ssjlai.com/gateway/core' diff --git a/README.md b/README.md index a868564..f443f1e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ @@ -38,4 +38,11 @@ FEATURE - 取消 右键标签刷新操作 - 修改 右键标签为中文 - 增加 标签刷新 -- 修复 刷新错误的问题 \ No newline at end of file +- 修复 刷新错误的问题 + + +## v1.0.4F +`2021年12月6日` +FEATURE +- 增加 封装接口地址 +- 修改 登录账号密码 telpo telpo#1234 \ No newline at end of file diff --git a/src/api/off-limits-manage.js b/src/api/off-limits-manage.js new file mode 100644 index 0000000..93db29c --- /dev/null +++ b/src/api/off-limits-manage.js @@ -0,0 +1,22 @@ +/* + * @Date: 2021-12-06 17:31:43 + * @LastEditors: JinxuChen + * @LastEditTime: 2021-12-06 18:07:02 + * @FilePath: \GpsCardAdmin\src\api\off-limits-manage.js + * @description: 封装告警识别内容接口 + */ +import request from '@/utils/request' +export const APILimits = { + getRecognition +}; +export default APILimits; + + +// 自动报警通用关键词查询 +function getRecognition(params) { + return request({ + url: '/api/v1/Fence/AreaGeneralFilterQuery', + method: 'post', + data: params, + }); +} \ No newline at end of file diff --git a/src/api/user.js b/src/api/user.js index 8ff4389..7a06c2c 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,18 +1,26 @@ +/* + * @Date: 2021-11-30 15:35:16 + * @LastEditors: JinxuChen + * @LastEditTime: 2021-12-06 17:23:57 + * @FilePath: \GpsCardAdmin\src\api\user.js + * @description: + */ import request from '@/utils/request' -export function login(data) { +const baseUrl = process.env.VUE_APP_BASE_API.replace('core', 'auth'); +export function login(params) { return request({ - url: '/vue-admin-template/user/login', + url: `${baseUrl}/identityController/login`, method: 'post', - data + data: params }) } -export function getInfo(token) { +export function getInfo(params) { return request({ - url: '/vue-admin-template/user/info', - method: 'get', - params: { token } + url: '/api/v1/Ability/study_ai/terminal/auth', + method: 'post', + data: params }) } diff --git a/src/assets/telpo.png b/src/assets/telpo.png new file mode 100644 index 0000000000000000000000000000000000000000..ed759acb146fc9fcb24614a4e877d698734039bf GIT binary patch literal 7339 zcmYM119Ke=)U8i)V!N@8MvZM-C$?>)jdS8OcABQKZQHhOHcr02_ul#Lo>}`@vuEue zup*TerH~Qu5dZ)HvW&F2>OZpmCpgG|J3*i15CA|jw-ysqmJt&pRd#W-u(mS?0Hh<6 zQ(^UzqzJmNh|(#`g>l(>4GM;lNGU?FMTCn;>B-w+8#TA!hgWbNeB6@fPFc{ zgBx_R@{tm2##x{+U{x3q7lNcym~5|qKmrH~TkA^I(t;?kVQwk4d$0TK!tu|SCIbLu z!n5eq;cm&A070p6X1Ah%h?O_X?1wUc<&FQxTT|kENF;)E#n8y&okor0LY1w!((Um8o=E3iIx}E-=)7$|=%Jj1p)KAd(SqsWa zgG@&NNHQf-4hb)Y+2su@M5vw_Ee@DCj916%;Z@yk;jrma#=xnp4b9f=@7&<~Yj>J( z8|qK4aGKq3uQ9AYWQk< zKXU%V|cRM;7napui(eV4J51oq|$E`Us(fj7o4O6YC&X zhB_dTEIj?gFpPi7gpZ$qNGv)Dt3rzUp@|Zc7(1SVL@XS+Pf~}NSLIz@`tm`yCoEGh zSwPr0HjB4N8HO$vnb7Z4fawqgyZhnw%@3yUG`7xp%h*xq1d|wp7yc1W3r;_TV2+CF zmf0^It~Kx7NufVIS1NiFtDgs> z$C791SY@4-b|3;n-uca?u(7UjDFRzVQfMk}b!j}I+(pW#Gb{I1J14X{=0z1#H;SlR z(Riqaec8Aiy}H^Igy})dSFoGFac^XWj68)Sw6FBFp5l4P&u=2DRGxnQblqot)AmI; z-%2yzCfM0>*kX)oWmgmjHUL_jF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xIf IMU8&^4 literal 0 HcmV?d00001 diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index c28b843..aae9253 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -7,13 +7,15 @@ /> -
- 当前用户:{{currentUser}} + +
+ 当前用户:{{name}}
- + +
@@ -36,18 +38,20 @@ import { mapGetters } from "vuex"; import Breadcrumb from "@/components/Breadcrumb"; import Hamburger from "@/components/Hamburger"; - +import { getToken, setToken, removeToken } from '@/utils/auth'; +import { resetRouter } from '@/router' export default { components: { Breadcrumb, Hamburger }, computed: { - ...mapGetters(["sidebar", "avatar"]) + ...mapGetters(["sidebar", "avatar", "name"]) }, data() { return { - currentUser: this.$store.getters.name + /* currentUser: this.$store.getters.name, */ + avatarImg: require('../../assets/telpo.png') } }, methods: { @@ -55,7 +59,9 @@ export default { this.$store.dispatch("app/toggleSideBar"); }, async logout() { - await this.$store.dispatch("user/logout"); + /* await this.$store.dispatch("user/logout"); */ + removeToken() // must remove token first + resetRouter() this.$router.push(`/login?redirect=${this.$route.fullPath}`); } } diff --git a/src/permission.js b/src/permission.js index fa1ea19..75e5eb6 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,3 +1,10 @@ +/* + * @Date: 2021-11-30 15:34:49 + * @LastEditors: JinxuChen + * @LastEditTime: 2021-12-06 18:06:34 + * @FilePath: \GpsCardAdmin\src\permission.js + * @description: + */ import router from './router' import store from './store' import { Message } from 'element-ui' @@ -32,8 +39,7 @@ router.beforeEach(async(to, from, next) => { } else { try { // get user info - await store.dispatch('user/getInfo') - + /* await store.dispatch('user/getInfo'); */ next() } catch (error) { // remove token and go to login page to re-login diff --git a/src/store/getters.js b/src/store/getters.js index aa9203f..9b52ad6 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,9 +1,17 @@ +/* + * @Date: 2021-11-30 15:35:16 + * @LastEditors: JinxuChen + * @LastEditTime: 2021-12-06 16:07:16 + * @FilePath: \GpsCardAdmin\src\store\getters.js + * @description: + */ const getters = { sidebar: state => state.app.sidebar, device: state => state.app.device, visitedViews: state => state.tagsView.visitedViews, cachedViews: state => state.tagsView.cachedViews, token: state => state.user.token, + authToken: state => state.user.authToken, avatar: state => state.user.avatar, name: state => state.user.name, roles: state => state.user.roles, diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 2f6423f..28abfb7 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,10 +1,13 @@ -import { login, logout, getInfo } from '@/api/user' -import { getToken, setToken, removeToken } from '@/utils/auth' +import { login, logout, getInfo } from '@/api/user'; +import { getToken, setToken, removeToken } from '@/utils/auth'; +import { getAuthToken, setAuthToken, removeAuthToken } from '@/utils/auth-token'; +import APPId from '@/utils/appId' import { resetRouter } from '@/router' const getDefaultState = () => { return { token: getToken(), + authToken: getAuthToken(), name: '', avatar: '' } @@ -19,44 +22,51 @@ const mutations = { SET_TOKEN: (state, token) => { state.token = token }, + SET_AUTH_TOKEN: (state, authToken) => { + state.authToken = authToken + }, SET_NAME: (state, name) => { state.name = name }, SET_AVATAR: (state, avatar) => { state.avatar = avatar + }, + SET_ROLES: (state, roles) => { + state.roles = roles } } const actions = { // user login login({ commit }, userInfo) { - const { username, password } = userInfo + const { loginName, password } = userInfo return new Promise((resolve, reject) => { - login({ username: username.trim(), password: password }).then(response => { - const { data } = response - commit('SET_TOKEN', data.token) - setToken(data.token) - resolve() + login({ loginName: loginName.trim(), password: password, appId: APPId }).then(response => { + console.log("response", response); + const { data } = response; + commit('SET_TOKEN', data.authToken); + setToken(data.authToken) + resolve(data) }).catch(error => { reject(error) }) }) }, - // get user info - getInfo({ commit, state }) { + getInfo({ commit}) { return new Promise((resolve, reject) => { - getInfo(state.token).then(response => { - const { data } = response - + let manufactorId = '5bf13062-a41e-4d00-ba14-1101aad12650' + getInfo({manufactorId: manufactorId}).then(response => { + const { data } = response; + /* data['roles'] = ['admin'] */ if (!data) { - return reject('Verification failed, please Login again.') + return reject('验证过期,请重新登录!') } - - const { name, avatar } = data - - commit('SET_NAME', name) - commit('SET_AVATAR', avatar) + /* const { roles, name} = data + commit('SET_ROLES', roles) + commit('SET_NAME', name) */ + commit('SET_AUTH_TOKEN', data); + setAuthToken(data); resolve(data) }).catch(error => { reject(error) @@ -79,13 +89,13 @@ const actions = { }, // remove token - resetToken({ commit }) { + resetToken({ commit, state }) { return new Promise(resolve => { removeToken() // must remove token first commit('RESET_STATE') resolve() }) - } + }, } export default { diff --git a/src/utils/appId.js b/src/utils/appId.js new file mode 100644 index 0000000..b536af3 --- /dev/null +++ b/src/utils/appId.js @@ -0,0 +1,7 @@ +const APPID = process.env.NODE_ENV === 'production' + ? + '0e2654a6-b323-4147-aa92-43ec1b092694' /* pro 生产环境 appid */ + : + // 'fe76405a-4b2c-4403-bef8-91728f23ef0c'; /* dev 开发环境 appid */ + '0e2654a6-b323-4147-aa92-43ec1b092694'; /* 开发环境使用正式环境的 appid 方便调试 */ +export default APPID; \ No newline at end of file diff --git a/src/utils/auth-token.js b/src/utils/auth-token.js new file mode 100644 index 0000000..1f1d259 --- /dev/null +++ b/src/utils/auth-token.js @@ -0,0 +1,22 @@ +/* + * @Date: 2021-11-30 15:34:34 + * @LastEditors: JinxuChen + * @LastEditTime: 2021-12-06 16:10:40 + * @FilePath: \GpsCardAdmin\src\utils\auth-token.js + * @description: + */ +import Cookies from 'js-cookie' + +const TokenKey = 'authtoken' + +export function getAuthToken() { + return Cookies.get(TokenKey) +} + +export function setAuthToken(token) { + return Cookies.set(TokenKey, token) +} + +export function removeAuthToken() { + return Cookies.remove(TokenKey) +} diff --git a/src/utils/auth.js b/src/utils/auth.js index 059af18..eadc9df 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,6 +1,13 @@ +/* + * @Date: 2021-11-30 15:34:34 + * @LastEditors: JinxuChen + * @LastEditTime: 2021-12-06 14:32:08 + * @FilePath: \GpsCardAdmin\src\utils\auth.js + * @description: + */ import Cookies from 'js-cookie' -const TokenKey = 'vue_admin_template_token' +const TokenKey = 'token' export function getToken() { return Cookies.get(TokenKey) diff --git a/src/utils/request.js b/src/utils/request.js index 2fb95ac..bbc37c5 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth' const service = axios.create({ baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url // withCredentials: true, // send cookies when cross-domain requests - timeout: 5000 // request timeout + /* timeout: 5000 */// request timeout }) // request interceptor @@ -19,7 +19,7 @@ service.interceptors.request.use( // let each request carry token // ['X-Token'] is a custom headers key // please modify it according to the actual situation - config.headers['X-Token'] = getToken() + config.headers['AuthToken'] = store.getters.token; } return config }, @@ -46,7 +46,7 @@ service.interceptors.response.use( const res = response.data // if the custom code is not 20000, it is judged as an error. - if (res.code !== 20000) { + if (res.code !== 0) { Message({ message: res.message || 'Error', type: 'error', diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 387d813..ab8086b 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,7 +1,7 @@ @@ -20,6 +20,9 @@ export default { ...mapGetters([ 'name' ]) + }, + mounted() { + console.log(this.$store.getters.name); } } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 1db2464..f19dd3e 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -3,7 +3,7 @@