add url protocol &
add web client on/off by api server
This commit is contained in:
@@ -2,6 +2,7 @@ import { defineStore, acceptHMRUpdate } from 'pinia'
|
||||
import logo from '@/assets/logo.png'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import en from 'element-plus/es/locale/lang/en'
|
||||
import { appConfig } from '@/api/rustdesk'
|
||||
|
||||
export const useAppStore = defineStore({
|
||||
id: 'App',
|
||||
@@ -12,6 +13,9 @@ export const useAppStore = defineStore({
|
||||
logo,
|
||||
lang: localStorage.getItem('lang') || 'zh-CN',
|
||||
locale: localStorage.getItem('lang') === 'en' ? en : zhCn,
|
||||
appConfig: {
|
||||
web_client: 1,
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -27,6 +31,12 @@ export const useAppStore = defineStore({
|
||||
changeLang () {
|
||||
this.setLang(this.setting.lang === 'zh-CN' ? 'en' : 'zh-CN')
|
||||
},
|
||||
getAppConfig () {
|
||||
console.log('getAppConfig')
|
||||
appConfig().then(res => {
|
||||
this.setting.appConfig = res.data
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { defineStore, acceptHMRUpdate } from 'pinia'
|
||||
import { current, login } from '@/api/user'
|
||||
import { setToken, removeToken } from '@/utils/auth'
|
||||
import { useRouteStore } from '@/store/router'
|
||||
import { useAppStore } from '@/store/app'
|
||||
|
||||
export const useUserStore = defineStore({
|
||||
id: 'user',
|
||||
@@ -26,6 +27,7 @@ export const useUserStore = defineStore({
|
||||
async login (form) {
|
||||
const res = await login(form).catch(_ => false)
|
||||
if (res) {
|
||||
useAppStore().getAppConfig()
|
||||
const userData = res.data
|
||||
setToken(userData.token)
|
||||
//
|
||||
@@ -44,6 +46,7 @@ export const useUserStore = defineStore({
|
||||
async info () {
|
||||
const res = await current().catch(_ => false)
|
||||
if (res) {
|
||||
useAppStore().getAppConfig()
|
||||
const userData = res.data
|
||||
setToken(userData.token)
|
||||
this.$patch({
|
||||
|
||||
Reference in New Issue
Block a user