mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-31 09:12:10 +08:00
feat: 配置项抽取至ENV 环境变量中维护
This commit is contained in:
parent
d67eefb708
commit
6114c3d6c5
20
.env
20
.env
@ -1,5 +1,14 @@
|
|||||||
# port 端口号
|
# 前端加密密钥
|
||||||
VITE_PORT = 8888
|
VITE_PWD_ENC_KEY='pigxpigxpigxpigx'
|
||||||
|
|
||||||
|
# OAUTH2 密码模式客户端信息
|
||||||
|
VITE_OAUTH2_PASSWORD_CLIENT='pig:pig'
|
||||||
|
|
||||||
|
# OAUTH2 短信客户端信息
|
||||||
|
VITE_OAUTH2_MOBILE_CLIENT='app:app'
|
||||||
|
|
||||||
|
# OAUTH2 社交登录客户端信息
|
||||||
|
VITE_OAUTH2_SOCIAL_CLIENT='social:social'
|
||||||
|
|
||||||
# ADMIN 服务地址
|
# ADMIN 服务地址
|
||||||
VITE_ADMIN_PROXY_PATH = http://localhost:9999
|
VITE_ADMIN_PROXY_PATH = http://localhost:9999
|
||||||
@ -7,5 +16,12 @@ VITE_ADMIN_PROXY_PATH = http://localhost:9999
|
|||||||
# 代码生成服务地址
|
# 代码生成服务地址
|
||||||
VITE_GEN_PROXY_PATH = http://localhost:5003
|
VITE_GEN_PROXY_PATH = http://localhost:5003
|
||||||
|
|
||||||
|
# 是否开启websocket 消息接受,
|
||||||
|
VITE_WEBSOCKET_ENABLE = false
|
||||||
|
|
||||||
|
# 是否开启注册
|
||||||
|
VITE_REGISTER_ENABLE = false
|
||||||
|
|
||||||
# 代码代码前缀
|
# 代码代码前缀
|
||||||
VITE_PUBLIC_PATH = /
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ import { useUserInfo } from "/@/stores/userInfo";
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export const login = (data: any) => {
|
export const login = (data: any) => {
|
||||||
let basicAuth = 'Basic ' + window.btoa('pig:pig')
|
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT)
|
||||||
|
Session.set('basicAuth', basicAuth)
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/oauth2/token',
|
url: '/admin/oauth2/token',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -24,7 +25,8 @@ export const login = (data: any) => {
|
|||||||
export const loginByMobile = (mobile: any, code: any) => {
|
export const loginByMobile = (mobile: any, code: any) => {
|
||||||
const grant_type = 'mobile'
|
const grant_type = 'mobile'
|
||||||
const scope = 'server'
|
const scope = 'server'
|
||||||
let basicAuth = 'Basic ' + window.btoa('app:app')
|
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_MOBILE_CLIENT)
|
||||||
|
Session.set('basicAuth', basicAuth)
|
||||||
|
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/oauth2/token',
|
url: '/admin/oauth2/token',
|
||||||
@ -41,7 +43,8 @@ export const loginByMobile = (mobile: any, code: any) => {
|
|||||||
export const loginBySocial = (state: string, code: string) => {
|
export const loginBySocial = (state: string, code: string) => {
|
||||||
const grant_type = 'mobile'
|
const grant_type = 'mobile'
|
||||||
const scope = 'server'
|
const scope = 'server'
|
||||||
let basicAuth = 'Basic ' + window.btoa('social:social')
|
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_SOCIAL_CLIENT)
|
||||||
|
Session.set('basicAuth', basicAuth)
|
||||||
|
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/oauth2/token',
|
url: '/admin/oauth2/token',
|
||||||
@ -66,7 +69,7 @@ export const refreshTokenApi = (refresh_token: string) => {
|
|||||||
const grant_type = 'refresh_token'
|
const grant_type = 'refresh_token'
|
||||||
const scope = 'server'
|
const scope = 'server'
|
||||||
// 获取当前选中的 basic 认证信息
|
// 获取当前选中的 basic 认证信息
|
||||||
let basicAuth = 'Basic ' + window.btoa('pig:pig')
|
const basicAuth = Session.get('basicAuth')
|
||||||
|
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/oauth2/token',
|
url: '/admin/oauth2/token',
|
||||||
@ -85,7 +88,7 @@ export const refreshTokenApi = (refresh_token: string) => {
|
|||||||
* @param refreshLock
|
* @param refreshLock
|
||||||
*/
|
*/
|
||||||
export const checkToken = (refreshTime: number, refreshLock: boolean) => {
|
export const checkToken = (refreshTime: number, refreshLock: boolean) => {
|
||||||
let basicAuth = 'Basic ' + window.btoa('pig:pig')
|
const basicAuth = Session.get('basicAuth')
|
||||||
request({
|
request({
|
||||||
url: '/admin/token/check_token',
|
url: '/admin/token/check_token',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -23,11 +23,8 @@
|
|||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<el-dropdown :show-timeout="70" :hide-timeout="50" trigger="click" @command="onLanguageChange">
|
<el-dropdown :show-timeout="70" :hide-timeout="50" trigger="click" @command="onLanguageChange">
|
||||||
<div class="layout-navbars-breadcrumb-user-icon">
|
<div class="layout-navbars-breadcrumb-user-icon">
|
||||||
<i
|
<i class="iconfont" :class="state.disabledI18n === 'en' ? 'icon-fuhao-yingwen' : 'icon-fuhao-zhongwen'"
|
||||||
class="iconfont"
|
:title="$t('user.title1')"></i>
|
||||||
:class="state.disabledI18n === 'en' ? 'icon-fuhao-yingwen' : 'icon-fuhao-zhongwen'"
|
|
||||||
:title="$t('user.title1')"
|
|
||||||
></i>
|
|
||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
@ -59,11 +56,8 @@
|
|||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<div class="layout-navbars-breadcrumb-user-icon mr10" @click="onScreenfullClick">
|
<div class="layout-navbars-breadcrumb-user-icon mr10" @click="onScreenfullClick">
|
||||||
<i
|
<i class="iconfont" :title="state.isScreenfull ? $t('user.title6') : $t('user.title5')"
|
||||||
class="iconfont"
|
:class="!state.isScreenfull ? 'icon-fullscreen' : 'icon-tuichuquanping'"></i>
|
||||||
:title="state.isScreenfull ? $t('user.title6') : $t('user.title5')"
|
|
||||||
:class="!state.isScreenfull ? 'icon-fullscreen' : 'icon-tuichuquanping'"
|
|
||||||
></i>
|
|
||||||
</div>
|
</div>
|
||||||
<el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick">
|
<el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick">
|
||||||
<span class="layout-navbars-breadcrumb-user-link">
|
<span class="layout-navbars-breadcrumb-user-link">
|
||||||
@ -82,7 +76,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<Search ref="searchRef" />
|
<Search ref="searchRef" />
|
||||||
<global-websocket uri="/admin/ws/info" v-if="themeConfig.isWebsocket" @rollback="rollback"/>
|
<global-websocket uri="/admin/ws/info" v-if="websocketEnable" @rollback="rollback" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -122,6 +116,9 @@ const state = reactive({
|
|||||||
disabledSize: 'large',
|
disabledSize: 'large',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 是否开启websocket
|
||||||
|
const websocketEnable = ref(import.meta.env.VITE_WEBSOCKET_ENABLE === 'true')
|
||||||
|
|
||||||
// 设置分割样式
|
// 设置分割样式
|
||||||
const layoutUserFlexNum = computed(() => {
|
const layoutUserFlexNum = computed(() => {
|
||||||
let num: string | number = '';
|
let num: string | number = '';
|
||||||
|
@ -141,11 +141,7 @@ export const useThemeConfig = defineStore('themeConfig', {
|
|||||||
// 默认初始语言,可选值"<zh-cn|en|zh-tw>",默认 zh-cn
|
// 默认初始语言,可选值"<zh-cn|en|zh-tw>",默认 zh-cn
|
||||||
globalI18n: 'zh-cn',
|
globalI18n: 'zh-cn',
|
||||||
// 默认全局组件大小,可选值"<large|'default'|small>",默认 'large'
|
// 默认全局组件大小,可选值"<large|'default'|small>",默认 'large'
|
||||||
globalComponentSize: 'large',
|
globalComponentSize: 'large'
|
||||||
// 是否开启websocket 消息接受,
|
|
||||||
isWebsocket: false,
|
|
||||||
// 是否开启注册
|
|
||||||
isRegister: true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
@ -24,7 +24,7 @@ export const useUserInfo = defineStore('userInfo', {
|
|||||||
// 密码加密
|
// 密码加密
|
||||||
const user = other.encryption({
|
const user = other.encryption({
|
||||||
data: data,
|
data: data,
|
||||||
key: 'pigxpigxpigxpigx',
|
key: import.meta.env.VITE_PWD_ENC_KEY,
|
||||||
param: ['password']
|
param: ['password']
|
||||||
})
|
})
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
2
src/types/pinia.d.ts
vendored
2
src/types/pinia.d.ts
vendored
@ -82,8 +82,6 @@ declare interface ThemeConfigState {
|
|||||||
columnsAsideLayout: string;
|
columnsAsideLayout: string;
|
||||||
layout: string;
|
layout: string;
|
||||||
isRequestRoutes: boolean;
|
isRequestRoutes: boolean;
|
||||||
isWebsocket: boolean;
|
|
||||||
isRegister: boolean,
|
|
||||||
globalTitle: string;
|
globalTitle: string;
|
||||||
globalViceTitle: string;
|
globalViceTitle: string;
|
||||||
globalViceTitleMsg: string;
|
globalViceTitleMsg: string;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<Social @signInSuccess="signInSuccess" />
|
<Social @signInSuccess="signInSuccess" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<!-- 注册 -->
|
<!-- 注册 -->
|
||||||
<el-tab-pane :label="$t('label.register')" name="register" v-if="getThemeConfig.isRegister">
|
<el-tab-pane :label="$t('label.register')" name="register" v-if="registerEnable">
|
||||||
<Register @afterSuccess="tabsActiveName = 'account'" />
|
<Register @afterSuccess="tabsActiveName = 'account'" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
@ -74,6 +74,9 @@ const {t} = useI18n()
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
// 是否开启注册
|
||||||
|
const registerEnable = ref(import.meta.env.VITE_REGISTER_ENABLE === 'true')
|
||||||
|
|
||||||
// 默认选择账号密码登录方式
|
// 默认选择账号密码登录方式
|
||||||
const tabsActiveName = ref('account')
|
const tabsActiveName = ref('account')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user