mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-10 19:50:53 +08:00
feat: 增加判断系统是否是 demo 接口
This commit is contained in:
parent
e120bb0612
commit
6c99e04aee
7 changed files with 37 additions and 20 deletions
|
|
@ -167,6 +167,15 @@ func (b *BaseApi) InitUserInfo(c *gin.Context) {
|
||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Tags Auth
|
||||||
|
// @Summary Check System isDemo
|
||||||
|
// @Description 判断是否为demo环境
|
||||||
|
// @Success 200
|
||||||
|
// @Router /auth/demo [get]
|
||||||
|
func (b *BaseApi) CheckIsDemo(c *gin.Context) {
|
||||||
|
helper.SuccessWithData(c, global.CONF.System.IsDemo)
|
||||||
|
}
|
||||||
|
|
||||||
func saveLoginLogs(c *gin.Context, err error) {
|
func saveLoginLogs(c *gin.Context, err error) {
|
||||||
var logs model.LoginLog
|
var logs model.LoginLog
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) {
|
||||||
baseApi := v1.ApiGroupApp.BaseApi
|
baseApi := v1.ApiGroupApp.BaseApi
|
||||||
{
|
{
|
||||||
appRouter.POST("/sync", baseApi.SyncApp)
|
appRouter.POST("/sync", baseApi.SyncApp)
|
||||||
appRouter.POST("/checkupdate", baseApi.GetAppListUpdate)
|
appRouter.GET("/checkupdate", baseApi.GetAppListUpdate)
|
||||||
appRouter.POST("/search", baseApi.SearchApp)
|
appRouter.POST("/search", baseApi.SearchApp)
|
||||||
appRouter.GET("/:key", baseApi.GetApp)
|
appRouter.GET("/:key", baseApi.GetApp)
|
||||||
appRouter.GET("/detail/:appId/:version", baseApi.GetAppDetail)
|
appRouter.GET("/detail/:appId/:version", baseApi.GetAppDetail)
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,6 @@ func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) {
|
||||||
baseRouter.GET("/status", baseApi.CheckIsFirstLogin)
|
baseRouter.GET("/status", baseApi.CheckIsFirstLogin)
|
||||||
baseRouter.POST("/init", baseApi.InitUserInfo)
|
baseRouter.POST("/init", baseApi.InitUserInfo)
|
||||||
baseRouter.POST("/logout", baseApi.LogOut)
|
baseRouter.POST("/logout", baseApi.LogOut)
|
||||||
|
baseRouter.GET("/demo", baseApi.CheckIsDemo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ export const SyncApp = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetAppListUpdate = () => {
|
export const GetAppListUpdate = () => {
|
||||||
return http.post<App.AppUpdateRes>('apps/checkupdate', {});
|
return http.get<App.AppUpdateRes>('apps/checkupdate');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SearchApp = (req: App.AppReq) => {
|
export const SearchApp = (req: App.AppReq) => {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ export const loginStatus = () => {
|
||||||
export const checkIsFirst = () => {
|
export const checkIsFirst = () => {
|
||||||
return http.get<boolean>('/auth/status');
|
return http.get<boolean>('/auth/status');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initUser = (params: Login.InitUser) => {
|
export const initUser = (params: Login.InitUser) => {
|
||||||
return http.post(`/auth/init`, params);
|
return http.post(`/auth/init`, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const checkIsDemo = () => {
|
||||||
|
return http.get<boolean>('/auth/demo');
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,11 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<div class="demo">
|
||||||
|
<span v-if="isDemo">
|
||||||
|
{{ $t('commons.login.username') }}:demo {{ $t('commons.login.password') }}:1panel
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -167,7 +172,7 @@
|
||||||
import { ref, reactive, onMounted } from 'vue';
|
import { ref, reactive, onMounted } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import type { ElForm } from 'element-plus';
|
import type { ElForm } from 'element-plus';
|
||||||
import { loginApi, getCaptcha, mfaLoginApi, checkIsFirst, initUser } from '@/api/modules/auth';
|
import { loginApi, getCaptcha, mfaLoginApi, checkIsFirst, initUser, checkIsDemo } from '@/api/modules/auth';
|
||||||
import { GlobalStore } from '@/store';
|
import { GlobalStore } from '@/store';
|
||||||
import { MenuStore } from '@/store/modules/menu';
|
import { MenuStore } from '@/store/modules/menu';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
|
|
@ -180,6 +185,7 @@ const menuStore = MenuStore();
|
||||||
const errAuthInfo = ref(false);
|
const errAuthInfo = ref(false);
|
||||||
const errCaptcha = ref(false);
|
const errCaptcha = ref(false);
|
||||||
const errMfaInfo = ref(false);
|
const errMfaInfo = ref(false);
|
||||||
|
const isDemo = ref(false);
|
||||||
|
|
||||||
const isFirst = ref();
|
const isFirst = ref();
|
||||||
|
|
||||||
|
|
@ -315,6 +321,11 @@ const checkStatus = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkIsSystemDemo = async () => {
|
||||||
|
const res = await checkIsDemo();
|
||||||
|
isDemo.value = res.data;
|
||||||
|
};
|
||||||
|
|
||||||
function checkPassword(rule: any, value: any, callback: any) {
|
function checkPassword(rule: any, value: any, callback: any) {
|
||||||
if (registerForm.password !== registerForm.rePassword) {
|
if (registerForm.password !== registerForm.rePassword) {
|
||||||
return callback(new Error(i18n.global.t('commons.rule.rePassword')));
|
return callback(new Error(i18n.global.t('commons.rule.rePassword')));
|
||||||
|
|
@ -325,6 +336,7 @@ function checkPassword(rule: any, value: any, callback: any) {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.title = globalStore.themeConfig.panelName;
|
document.title = globalStore.themeConfig.panelName;
|
||||||
checkStatus();
|
checkStatus();
|
||||||
|
checkIsSystemDemo();
|
||||||
document.onkeydown = (e: any) => {
|
document.onkeydown = (e: any) => {
|
||||||
e = window.event || e;
|
e = window.event || e;
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
|
|
@ -351,15 +363,11 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-title {
|
.login-title {
|
||||||
// margin-top: 50px;
|
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
letter-spacing: 0;
|
letter-spacing: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #646a73;
|
color: #646a73;
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
// @media only screen and (max-width: 1280px) {
|
|
||||||
// margin-top: 20px;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
.no-border {
|
.no-border {
|
||||||
:deep(.el-input__wrapper) {
|
:deep(.el-input__wrapper) {
|
||||||
|
|
@ -421,5 +429,12 @@ onMounted(() => {
|
||||||
height: 45px;
|
height: 45px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.demo {
|
||||||
|
text-align: center;
|
||||||
|
span {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -55,19 +55,10 @@ const getStatus = async () => {
|
||||||
statusCode.value = 1;
|
statusCode.value = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// watch(
|
|
||||||
// () => screenWidth.value,
|
|
||||||
// (newVal) => {
|
|
||||||
// console.log()
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getStatus();
|
getStatus();
|
||||||
// 屏幕适配
|
|
||||||
screenWidth.value = document.body.clientWidth;
|
screenWidth.value = document.body.clientWidth;
|
||||||
window.onresize = () => {
|
window.onresize = () => {
|
||||||
//屏幕尺寸变化就重新赋值
|
|
||||||
return (() => {
|
return (() => {
|
||||||
screenWidth.value = document.body.clientWidth;
|
screenWidth.value = document.body.clientWidth;
|
||||||
})();
|
})();
|
||||||
|
|
@ -118,8 +109,6 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-title {
|
.login-title {
|
||||||
// margin-top: 10%;
|
|
||||||
// margin-right: 15%;
|
|
||||||
margin-left: 10%;
|
margin-left: 10%;
|
||||||
span:first-child {
|
span:first-child {
|
||||||
color: $primary-color;
|
color: $primary-color;
|
||||||
|
|
@ -138,11 +127,9 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.login-container {
|
.login-container {
|
||||||
// margin-left: 15%;
|
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
padding: 40px 0;
|
padding: 40px 0;
|
||||||
width: 390px;
|
width: 390px;
|
||||||
// height: 422px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: rgba(255, 255, 255, 0.55);
|
background-color: rgba(255, 255, 255, 0.55);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue