diff --git a/.env b/.env index 6a8f6c0..0029708 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -VUE_APP_API_HOST=10.0.235.4:9000 -VUE_APP_TITLE=包管理系统 +VUE_APP_API_HOST=127.0.0.1:8000 +VUE_APP_TITLE=管理平台 VUE_APP_TITLE_EN=PROJECT PACKAGE MANAGER \ No newline at end of file diff --git a/src/components/page.ts b/src/components/page.ts index a52e7fc..af30551 100644 --- a/src/components/page.ts +++ b/src/components/page.ts @@ -8,8 +8,6 @@ import { import { Table, TableColumn } from "view-design"; import Events from "@/utils/Events"; import { TableExportCsvParams } from "view-design/types/table"; -import { stringify } from "postcss"; -import Project from "@/views/home/pages/project/project"; @Component diff --git a/src/utils/Url.ts b/src/utils/Url.ts index fe63ef1..8d1417b 100644 --- a/src/utils/Url.ts +++ b/src/utils/Url.ts @@ -2,104 +2,16 @@ * 前台地址 */ export default class Url { - static readonly WORK_LOGIN : string = 'work/login' - static readonly LOGIN : string = "login"; + static readonly GET_NONCE : string = 'get-nonce' + static readonly METAMASK_LOGIN : string = 'metamask-login' static readonly LOGOUT : string = "logout"; // TODO 菜单 static readonly MENUS : string = "menu"; static readonly DELETE_MENU : string = "menu/%d"; static readonly SHOW_MENU : string = "menu/%d"; static readonly UPDATE_MENU : string = "menu/%d"; - // TODO 用户 - static readonly USERS : string = "user"; - static readonly DISABLE_USER : string = 'user/%d'; - static readonly ENABLE_USER : string = "user/start/%d"; - static readonly SHOW_USER : string = 'user/%d'; - static readonly UPDATE_USER : string = 'user/%d'; - static readonly UPDATE_USERNAME : string = 'user/update_name/%d'; - static readonly MY_MENUS : string = "my_menu"; - static readonly MY_POWER : string = "my_power"; - static readonly MY_PROJECT : string = "my_project"; - static readonly UPDATE_MY_NAME : string = "update/my/name"; - - - // TODO 权限 - static readonly POWER : string = "power"; - static readonly SHOW_POWER : string = "power/%d"; - static readonly UPDATE_POWER : string = "power/%d"; - static readonly DELETE_POWER : string = "power/%d"; - - // TODO 权限组 - static readonly POWER_GROUP : string = "power_group"; - static readonly SHOW_POWER_GROUP : string = "power_group/%d"; - static readonly UPDATE_POWER_GROUP : string = "power_group/%d"; - static readonly DELETE_POWER_GROUP : string = "power_group/%d"; - - // TODO 项目 - static readonly PROJECT : string = 'project'; - static readonly SHOW_PROJECT : string = "project/%d"; - static readonly UPDATE_PROJECT : string = "project/%d"; - static readonly DELETE_PROJECT : string = "project/%d"; - - static readonly WATCH_PROJECT : string = "project/watch/%d"; - static readonly UN_WATCH_PROJECT : string = "project/watch/%d"; - static readonly SHOW_PROJECT_ITEM : string = "project_item/%d"; - static readonly DElETE_PROJECT_ITEM : string = "project_item/%d"; - static readonly DElETE_PROJECT_PRODUCT : string = "project_product/%d"; - static readonly UPDATE_PROJECT_PRODUCT : string = "project_product/%d"; - static readonly SHOW_PROJECT_PRODUCT : string = "project_product/%d"; - static readonly DOWNLOAD_PROJECT_PRODUCT : string = "project_product/download/%d"; - static readonly SHOW_PRODUCT_Log : string = "show_log/%d"; - static readonly SHOW_DOWNLOAD_IP : string = "product/download_ip/%d"; - static readonly DOWNLOAD_IP : string = "download_ip"; - static readonly DELETE_DOWNLOAD_IP : string = "download_ip/%d"; - static readonly UPDATE_DOWNLOAD_IP : string = "download_ip/%d"; - - - //TODO 用户分配 - static readonly ALLOT_MENT : string = 'allot_menu/%d'; - static readonly ALLOT_POWER : string = 'allot_power/%d'; - static readonly ALLOT_PROJECT : string = 'allot_project/%d'; - - - //TODO 自动化(设备) - static readonly DEVICE : string = 'device'; - static readonly UPLOAD_IMAGE : string = 'device/upload_pic'; - static readonly DELETE_DEVICE : string = 'device/%d'; - static readonly UPDATE_DEVICE : string = 'device/%d'; - - //TODO 自动化(脚本) - static readonly SCRIPT : string = 'script'; - static readonly UPLOAD_SCRIPT : string = 'script/upload'; - static readonly UPDATE_SCRIPT : string = 'script/%d'; - static readonly DELETE_SCRIPT : string = 'script/%d'; - static readonly DOWNLOAD_SCRIPT : string = 'script/download/%d'; - - //TODO 自动化(脚本集) - static readonly SCRIPT_COLLECTION : string = 'collection'; - static readonly UPDATE_SCRIPT_COLLECTION : string = 'collection/%d'; - static readonly DELETE_SCRIPT_COLLECTION : string = 'collection/%d'; - static readonly DOWNLOAD_SCRIPT_COLLECTION : string = 'collection/download/%d'; - - //TODO 自动化(任务) - static readonly TASK : string = 'task'; - static readonly UPDATE_TASK : string = 'task/%d'; - static readonly DELETE_TASK : string = 'task/%d'; - static readonly TASK_LOG : string = 'task_log'; - static readonly TASK_DEFAULT_STATUS_CHANGE : string = 'task/set_default/%d' - static readonly TASK_REPORT : string = 'task_report/%d' - - //TODO 自动化(数据仓库) - static readonly DATA :string = 'data' - static readonly DELETE_DATA :string = 'data/%d' - - //TODO 首页 - static readonly OVERVIEW : string = 'overview' - static readonly OVERVIEW_SCRIPT : string = 'overview_scripts' - static readonly OVERVIEW_PRODUCT : string = 'overview_products' - } /** diff --git a/src/utils/login-request.ts b/src/utils/login-request.ts index 567ee6b..bf5e691 100644 --- a/src/utils/login-request.ts +++ b/src/utils/login-request.ts @@ -39,14 +39,14 @@ instance.interceptors.response.use( ) export const Http_getNonce = (params) => instance({ - url: 'https://market.cebg.games/webapp/index.php?c=Market&a=getNonce', + url: 'http://127.0.0.1:8000/api/get-nonce', method: 'get', params: params }) export const Http_login = (data) => instance({ - url: 'https://market.cebg.games/webapp/index.php?c=Market&a=auth', - method: 'get', + url: 'http://127.0.0.1:8000/api/metamask-login', + method: 'post', params: data }) \ No newline at end of file diff --git a/src/views/home/Common/Types.ts b/src/views/home/Common/Types.ts index e283acf..bc1f95a 100644 --- a/src/views/home/Common/Types.ts +++ b/src/views/home/Common/Types.ts @@ -7,58 +7,6 @@ export interface MenuInterface { children? : MenuInterface[] } -export interface PowerInterface { - id? : number; - name : string; - pid : number; - controller : string; - action : string; - children? : PowerInterface[] -} - -export interface PowerGroupInterface { - id? : number; - name : string; -} - -export interface ProjectInterface { - name : string; - tapd_id : any; - id? : number; -} - -export interface ProjectItemInterface { - id? : number; - name : string; - type : string; -} - -export interface ProjectProductInterface { - id? : number; - name : string; - commit_message : string; - days : number; - download_times : number; - build_result?: string; - state ?: boolean; -} -export interface ProjectProductLogInterface { - id? : number; - userName : string; - addTime : any; - productName : string; - days : number; - content : string -} - -export interface ProductIpsInterface { - id? : number; - project_item_id ?: number; - server_ip :string; - created_at ?: string; - old_ip ?: string; -} - export interface UserInterface { id? : number; username : string; diff --git a/src/views/home/main.ts b/src/views/home/main.ts index 925abfb..fd658ee 100644 --- a/src/views/home/main.ts +++ b/src/views/home/main.ts @@ -13,7 +13,7 @@ import '@/icons' Http.store = store; Http.router = router; -Http.baseUri = '/rest/' +Http.baseUri = '/api/' Vue.prototype.$http = Http; Vue.config.devtools = process.env.NODE_ENV !== 'production'; // Vue.config.devtools = true; diff --git a/src/views/home/pages/home/home.less b/src/views/home/pages/home/home.less index 95779f9..e69de29 100644 --- a/src/views/home/pages/home/home.less +++ b/src/views/home/pages/home/home.less @@ -1,87 +0,0 @@ -.boxx{ - margin: 0 0 18px 20px; - font-size: 40px -} -.demo-split1{ - height: 450px; - -} -.demo-split-pane1{ - padding: 10px; - -} -.demo-split{ - height: 680px; - margin-top: 50px; - background-color: #FFFFFF; - -} -.demo-split-pane{ - padding: 10px; - //border: 1px solid red; -} -.demo-split-pane.no-padding{ - height: 680px; - padding: 0; -} -.tag{ - background-color: #374151; - color: white; - padding: 8px 100px 8px 20px; - -} - -.arrow1 { - padding: 15px 0; - margin-left: 20px; - &-wrap { - //margin: 0 auto; - width: 120px; - height: 34px; - background-image: linear-gradient(to right, #227190 , #63c7ed); - color: #FFFFFF; - line-height: 34px; - text-align: start; - position: relative; - &::after { - content: ''; - position: absolute; - right: -34px; - border: 17px solid transparent; - border-left: 17px solid #63c7ed; - } - } -} -.arrow2 { - padding: 15px 0; - margin-left: 20px; - &-wrap { - //margin: 0 auto; - width: 180px; - height: 34px; - background-image: linear-gradient(to right, #008B8B , #7FFFD4); - color: #FFFFFF; - line-height: 34px; - text-align: start; - position: relative; - &::after { - content: ''; - position: absolute; - right: -34px; - border: 17px solid transparent; - border-left: 17px solid #7FFFD4; - } - } -} - -.progress:hover:before{ - content:attr(content); - background:#585e6b; - color:#fff; - padding:.8em 1em; - position:absolute; - bottom: -35px; - border-radius: 5px; - margin-left:30%; - -} diff --git a/src/views/home/pages/home/home.ts b/src/views/home/pages/home/home.ts index 76ba243..16957b0 100644 --- a/src/views/home/pages/home/home.ts +++ b/src/views/home/pages/home/home.ts @@ -9,184 +9,58 @@ import { import HomeParent from "@/views/home/Common/HomeParent"; import CustomPage from "@/components/page.vue"; import SvgIcon from '@/components/SvgIcon.vue' -import * as echarts from 'echarts' +import { TableColumn } from "view-design" + @Component({ components : { - SvgIcon + SvgIcon,CustomPage } }) export default class Home extends HomeParent { name : string = 'home' - public scriptList :any = [{ script_name: undefined, date: undefined,content:undefined}]; - public projectList :any = [{ product_name: undefined, date: undefined}] - public myChart; - public cardProductData:object = { - product_count_trashed:undefined, - product_today:undefined, - day_rate:undefined, - day_icon:undefined, - week_rate:undefined, - week_icon:undefined, + public noDataText = '没有数据的提示语' + public List :any = [] + public columns: TableColumn[] = [{ + width: 80, + key: 'id', + align: 'center', + }, { + title: "名称", + key: "name" + }, { + title: "TAPD", + key: "tapd_id" + }, { + title: "操作", + slot: "operation" + }] + + public total: number = 0; + public search: { page: number, size: number , keywords? : string } = { + page: 1, size: 10 , keywords : "" } - public cardScriptData:object = { - script_week:undefined, - use_rate:undefined - } - public cardTaskData:object = { - day_rate:undefined, - task_count:undefined, - task_month_sum:undefined - } - public userNumber:number=0; public created() { // this._getData() // this._getScriptLog() // this._getProductLog() + this.List = [ + {id:1,name:'tom',tapd_id:10086}, + {id:2,name:'jam',tapd_id:10086}, + {id:3,name:'any',tapd_id:10086}, + {id:4,name:'som',tapd_id:10086}, + ] } - private createChart(data) { - this.myChart = echarts.init(this.$refs['myChart'] as HTMLCanvasElement); - this.myChart.setOption(this.option(data)); - this.myChart.on('updateAxisPointer', (event)=> { - const xAxisInfo = event.axesInfo[0]; - if (xAxisInfo) { - const dimension = xAxisInfo.value + 1; - this.myChart.setOption({ - series: { - id: 'pie', - label: { - formatter: '{b}: {@[' + dimension + ']} ({d}%)' - }, - encode: { - value: dimension, - tooltip: dimension - } - } - }); - } - }); - } - public shortcut(str){ - this._push({name:str}) - } - - private option(data) { - return { - legend: {}, - tooltip: { - trigger: 'axis', - showContent: false - }, - dataset: { - source: data - }, - xAxis: { type: 'category' }, - yAxis: { gridIndex: 0 }, - grid: { top: '55%' }, - series: [ - { - type: 'line', - smooth: true, - seriesLayoutBy: 'row', - emphasis: { focus: 'series' } - }, - { - type: 'line', - smooth: true, - seriesLayoutBy: 'row', - emphasis: { focus: 'series' } - }, - { - type: 'line', - smooth: true, - seriesLayoutBy: 'row', - emphasis: { focus: 'series' } - }, - { - type: 'line', - smooth: true, - seriesLayoutBy: 'row', - emphasis: { focus: 'series' } - }, - { - type: 'pie', - id: 'pie', - radius: '30%', - center: ['50%', '25%'], - emphasis: { - focus: 'self' - }, - label: { - formatter: '{b}: {@2012} ({d}%)' - }, - encode: { - itemName: 'product', - value: '2012', - tooltip: '2012' - } - } - ] - } - } private _getData():void{ - this.$http.get(Url.OVERVIEW).then((res)=>{ - this.createChart(res.data.recent_task_logs) - this.cardProductData = this.alterProduct(res.data.card_data.product) - this.cardTaskData = this.alterTask(res.data.card_data.task) - this.cardScriptData = this.alterScript(res.data.card_data.script) - this.userNumber = res.data.card_data.user - - }).catch((msg:string)=>{ - this.error(msg) - }) } - private _getScriptLog():void{ - this.$http.get(Url.OVERVIEW_SCRIPT).then((res)=>{ - this.scriptList = res.data - }).catch((msg:string)=>{ - this.error(msg) - }) - } - private _getProductLog():void{ - this.$http.get(Url.OVERVIEW_PRODUCT).then((res)=>{ - this.projectList = res.data - }).catch((msg:string)=>{ - this.error(msg) - }) - } - private alterProduct(data):object{ - return { - product_count_trashed:data.product_count_trashed, - product_today:data.product_today, - day_rate:data.product_yesterday==0?'(昨日无构建)':Math.abs(Math.floor(((parseInt(data.product_today)-parseInt(data.product_yesterday)) / parseInt(data.product_yesterday ))*100))+'%', - day_icon:parseInt(data.product_today) > parseInt(data.product_yesterday)?1:2, - week_rate:Math.abs(Math.floor(((parseInt(data.product_current_week)-parseInt(data.product_last_week)) / parseInt(data.product_last_week ))*100))+'%', - week_icon:parseInt(data.product_current_week) > parseInt(data.product_last_week)?1:2, - } - } - - private alterTask(data):object{ - return { - task_count:data.task_count, - task_month_sum:data.task_month_sum, - day_rate:Math.abs(Math.floor((parseInt(data.task_end_sum)/ parseInt(data.task_logs_sum ))*100)) - } - } - - private alterScript(data):object{ - return { - script_week:data.script_week, - use_rate:Math.abs(Math.floor((parseInt(data.script_used)/ parseInt(data.script_count ))*100))+'%' - } - } } \ No newline at end of file diff --git a/src/views/home/pages/home/home.vue b/src/views/home/pages/home/home.vue index 6aeca3d..61225ac 100644 --- a/src/views/home/pages/home/home.vue +++ b/src/views/home/pages/home/home.vue @@ -1,184 +1,20 @@ + - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/home/pages/layout/layout.ts b/src/views/home/pages/layout/layout.ts index 715caad..eb484a8 100644 --- a/src/views/home/pages/layout/layout.ts +++ b/src/views/home/pages/layout/layout.ts @@ -11,6 +11,7 @@ import HomeParent, { BreadItem } from "@/views/home/Common/HomeParent"; import { EVENT_TYPE, MenuInterface, ProjectInterface } from "@/views/home/Common/Types"; import { Route, RouteRecord } from "vue-router"; import { Menu } from "view-design"; +import store from "@/views/home/store"; @@ -51,53 +52,16 @@ export default class Layout extends HomeParent { public onDropdownEvent(name: string): void { switch (name) { case "logout" : this.logout();break; - case "updateName" : this.updateName();break; + // case "updateName" : this.updateName();break; } } public logout() { - this.$http.get(Url.LOGOUT).then(res => { - this._push('/login') - }); + store.commit('del_token') + this.goPage("login"); } - public updateName(){ - let self = this; - this.$Modal.confirm({ - title:"修改昵称", - render: function(h) { - return h('Input', { - props: { - value: self.$store.getters.user.name, - autofocus: true, - placeholder: 'Please enter your name...' - }, - on: { - input: (val) => { - this.value = val; - } - } - }) - }, - onOk :function() { - self.onVisibleChange(true) - if (!this.value || this.value == self.$store.getters.user.name || this.value == '') { - return; - } - let data = {name:this.value}; - self.$http.put(Url.UPDATE_MY_NAME,data).then(res=>{ - self.success('修改成功',()=>{ - self.$store.getters.user.name = res.data.name - let obj = JSON.parse(window.localStorage.getItem('home')); - obj.user.user.name = res.data.name - window.localStorage.setItem('home',JSON.stringify(obj)); - }) - }).catch((err)=>{ - self.error(err) - }) - } - }) - } + /** * 跳转页面时关闭dropdown @@ -117,24 +81,20 @@ export default class Layout extends HomeParent { private _getMyMenu() { - this.myMenus = [ - {id:1,name:'用户管理',url:'/user',children:[ - {id:2,name:'用户列表',url:'/user/list',children:[]}, - {id:3,name:'用户权限',url:'/user/node',children:[]}, - {id:4,name:'用户菜单',url:'/user/menu',children:[]}, - ]}, - {id:5,name:'表格',url:'/table',children:[ - {id:6,name:'普通表格',url:'/table/base',children:[]}, - {id:7,name:'复杂表格',url:'/table/complex',children:[]}, - ]} - ] + this.myMenus = [ + {id:1,name:'用户管理',url:'/user',children:[ + {id:2,name:'用户列表',url:'/user/list',children:[]}, + {id:3,name:'用户权限',url:'/user/node',children:[]}, + {id:4,name:'用户菜单',url:'/user/menu',children:[]}, + ]}, + {id:5,name:'表格',url:'/table',children:[ + {id:6,name:'普通表格',url:'/table/base',children:[]}, + {id:7,name:'复杂表格',url:'/table/complex',children:[]}, + ]} + ] } - private _getMyProject() { - this.$http.get(Url.MY_PROJECT).then(res => { - this.myProject = res.data; - }); - } + private _parseTreeData(list: any[]) { return list.map((item: any) => { diff --git a/src/views/home/pages/layout/layout.vue b/src/views/home/pages/layout/layout.vue index 0c29733..8155c53 100644 --- a/src/views/home/pages/layout/layout.vue +++ b/src/views/home/pages/layout/layout.vue @@ -1,53 +1,53 @@ diff --git a/src/views/home/pages/login/login.less b/src/views/home/pages/login/login.less index e050be5..f7a2421 100644 --- a/src/views/home/pages/login/login.less +++ b/src/views/home/pages/login/login.less @@ -90,10 +90,10 @@ margin-left: 7px; } } - .slideSty .slide-verify { - margin: 13px auto 0 auto; - width: 350px !important; - } +.slideSty .slide-verify { + margin: 13px auto 0 auto; + width: 350px !important; +} .slideSty .slide-verify-slider { width: 100% !important; } diff --git a/src/views/home/pages/login/login.ts b/src/views/home/pages/login/login.ts index a736267..d461c4b 100644 --- a/src/views/home/pages/login/login.ts +++ b/src/views/home/pages/login/login.ts @@ -32,72 +32,51 @@ declare let window: Window } }) export default class Login extends HomeParent { - @Action('Login') Login; - public context : ActionContext + // @Action('Login') Login + public provider:any public web3:Web3 public chainId:number public account:string public nonce:string + public isLogin:boolean - public async btn(){ - if (!this.$store.getters.step){ - try { + public created(){ + if (store.state.token){ + this.isLogin = true + }else { + this.isLogin = false + } + } + + public async doLogin(){ + // let apiHost = process.env.NODE_ENV !== 'production' ? process.env.VUE_APP_API_HOST : document.location.host; + // let scheme = document.location.protocol; + // console.log(scheme + "//" + apiHost);return + if (!this.isLogin){ + try{ await this.connect() await this.checkNance() } catch (err) { Message({ message: err.message, type: 'error', - duration: 5 * 1000 + duration: 3 * 1000, }) Promise.reject(err) } + }else { + Message({ + message: '已经登录过了!', + type: 'warning', + duration:2*1000, + onClose:()=>{ + this.goPage('home') + } + }) } } - - - - - public get accessToken(): string { - let token: string = this.$route.query.access_token as string; - return token; - } - - public rules: object = { - username: [{required: true, trigger: 'blur', message: "请输入登录名"}], - password: [{required: true, trigger: 'blur', message: "请输入登录密码"}], - } - - public created() { - // if(!this.accessToken) { - // this._getData(); - // } - } - - private _getData(): void { - this.$http.get(Url.WORK_LOGIN).then(res => { - window["WwLogin"]({ - id: "loginPage", - goto: res.data - }) - }) - } - - // public doLogin(): void { - // let form: Form = this.$refs["login"] as Form; - // form.validate((valid: boolean) => { - // if (!valid) { - // return; - // } - // // this.Login(this.form).then((user) => { - // // this.goPage("home"); - // // }).catch((msg: string) => { - // // this.error(msg); - // // }) - // }); - // } private async login( account, chainId, nonce) { nonce += '' const tips = 'This signature is only used for verify your account' @@ -134,21 +113,26 @@ export default class Login extends HomeParent { net_id: chainId } const res:any = await Http_login(authData) - if (!res.errcode && res.token) { - store.commit('set_token',res.token) - console.log(store.getters) + if (res.code == 200) { + store.commit('set_token',res.data.token) + this.goPage("home"); } } private async checkNance() { try { + // store.commit('del_nonce');return let nonce = store.getters.nonce if (!nonce) { let params = {account:this.account, net_id:this.chainId} + // await this.$http.get(Url.GET_NONCE,params).then(res => { + // console.log(res.data) + // }) const res:any = await Http_getNonce(params); - store.commit('set_nonce',res.nonce) - this.nonce = res.nonce + // console.log('@@@',res) + store.commit('set_nonce',res.data) + this.nonce = res.data } - this.login(this.account,this.chainId,this.nonce) + this.login(this.account,this.chainId,store.getters.nonce) } catch (err) { Promise.reject(err) } diff --git a/src/views/home/pages/login/login.vue b/src/views/home/pages/login/login.vue index b1ede5f..e9e5ab5 100644 --- a/src/views/home/pages/login/login.vue +++ b/src/views/home/pages/login/login.vue @@ -2,7 +2,7 @@
系统
-
+
diff --git a/src/views/home/router/index.ts b/src/views/home/router/index.ts index 4605019..82670cf 100644 --- a/src/views/home/router/index.ts +++ b/src/views/home/router/index.ts @@ -12,26 +12,29 @@ const routes : Array = [ ] const router = new VueRouter({ - base : "/dashboard/", + // base : "/dashboard/", mode : "history", routes, }) function setTitle(title : string) : void { - window.document.title = title; + window.document.title = '管理平台'; } router.beforeEach((to, from, next) => { LoadingBar.start(); - let title : string = process.env.VUE_APP_TITLE; - setTitle(to.meta.title + '-' + title); - let token : string = to.query.access_token as string; - if (token) { - Store.commit(Types.SET_USER_TOKEN, token); - next({name : to.name === 'login'? 'home' : to.name}) - return; + if (to.path === '/login') { + next(); + } else { + // 从本地存储里获取token + let token = Store.state.token as string + // 判断token是否为空如果为空则跳转到登录页 如果有则放行 + if (!token) { + next({path:'/login'}); + } else { + next(); + } } - next(); }) router.afterEach((to, from) => { diff --git a/src/views/home/store/index.ts b/src/views/home/store/index.ts index d629e56..a113f5a 100644 --- a/src/views/home/store/index.ts +++ b/src/views/home/store/index.ts @@ -15,7 +15,6 @@ export default new Vuex.Store({ getters : { token : (state : StateInterface) => state.user.token, user : (state : StateInterface) => state.user.user, - step:state => state.step, nonce:state => state.nonce }, modules : { @@ -42,13 +41,17 @@ export default new Vuex.Store({ state.nonce = nonce // sessionStorage.nonce = nonce }, + del_nonce(state) { + state.nonce = '' + // sessionStorage.nonce = nonce + }, set_token(state, token) { state.token = token - sessionStorage.token = token + // sessionStorage.token = token }, del_token(state) { state.token = '' - sessionStorage.removeItem('token') + // sessionStorage.removeItem('token') } } }) diff --git a/src/views/home/store/user.ts b/src/views/home/store/user.ts index ac03407..b9e6201 100644 --- a/src/views/home/store/user.ts +++ b/src/views/home/store/user.ts @@ -9,7 +9,6 @@ const sprintf = require('sprintf-js'); export interface UserState { user : UserInterface, token : string | undefined, - isLogin : boolean, } export default { @@ -22,17 +21,15 @@ export default { }, actions : { Login(context : ActionContext, form : any) { - return Http.post(Url.LOGIN, form).then((res : ResponseInterface) => { - context.commit(Types.SET_USER_INFO, res.data); - context.commit(Types.SET_USER_TOKEN, res.data.access_token); - return Promise.resolve(res.data); - }).catch((err : string) => { - return Promise.reject(err); - }) + // return Http.post(Url.LOGIN, form).then((res : ResponseInterface) => { + // context.commit(Types.SET_USER_INFO, res.data); + // context.commit(Types.SET_USER_TOKEN, res.data.access_token); + // return Promise.resolve(res.data); + // }).catch((err : string) => { + // return Promise.reject(err); + // }) }, - getMenus() { - // return Http.get() - } + }, mutations : { [Types.SET_USER_INFO](state : UserState, user : UserInterface) { @@ -40,7 +37,7 @@ export default { }, [Types.SET_USER_TOKEN](state : UserState, token : string) { state.token = token; - state.isLogin = token.length > 0; + // state.isLogin = token.length > 0; }, } } \ No newline at end of file