mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-10 17:13:30 +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)
|
||||
}
|
||||
|
||||
// @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) {
|
||||
var logs model.LoginLog
|
||||
if err != nil {
|
||||
|
|
|
@ -16,7 +16,7 @@ func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) {
|
|||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
{
|
||||
appRouter.POST("/sync", baseApi.SyncApp)
|
||||
appRouter.POST("/checkupdate", baseApi.GetAppListUpdate)
|
||||
appRouter.GET("/checkupdate", baseApi.GetAppListUpdate)
|
||||
appRouter.POST("/search", baseApi.SearchApp)
|
||||
appRouter.GET("/:key", baseApi.GetApp)
|
||||
appRouter.GET("/detail/:appId/:version", baseApi.GetAppDetail)
|
||||
|
|
|
@ -17,5 +17,6 @@ func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) {
|
|||
baseRouter.GET("/status", baseApi.CheckIsFirstLogin)
|
||||
baseRouter.POST("/init", baseApi.InitUserInfo)
|
||||
baseRouter.POST("/logout", baseApi.LogOut)
|
||||
baseRouter.GET("/demo", baseApi.CheckIsDemo)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export const SyncApp = () => {
|
|||
};
|
||||
|
||||
export const GetAppListUpdate = () => {
|
||||
return http.post<App.AppUpdateRes>('apps/checkupdate', {});
|
||||
return http.get<App.AppUpdateRes>('apps/checkupdate');
|
||||
};
|
||||
|
||||
export const SearchApp = (req: App.AppReq) => {
|
||||
|
|
|
@ -28,6 +28,11 @@ export const loginStatus = () => {
|
|||
export const checkIsFirst = () => {
|
||||
return http.get<boolean>('/auth/status');
|
||||
};
|
||||
|
||||
export const initUser = (params: Login.InitUser) => {
|
||||
return http.post(`/auth/init`, params);
|
||||
};
|
||||
|
||||
export const checkIsDemo = () => {
|
||||
return http.get<boolean>('/auth/demo');
|
||||
};
|
||||
|
|
|
@ -158,6 +158,11 @@
|
|||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="demo">
|
||||
<span v-if="isDemo">
|
||||
{{ $t('commons.login.username') }}:demo {{ $t('commons.login.password') }}:1panel
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -167,7 +172,7 @@
|
|||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
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 { MenuStore } from '@/store/modules/menu';
|
||||
import i18n from '@/lang';
|
||||
|
@ -180,6 +185,7 @@ const menuStore = MenuStore();
|
|||
const errAuthInfo = ref(false);
|
||||
const errCaptcha = ref(false);
|
||||
const errMfaInfo = ref(false);
|
||||
const isDemo = ref(false);
|
||||
|
||||
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) {
|
||||
if (registerForm.password !== registerForm.rePassword) {
|
||||
return callback(new Error(i18n.global.t('commons.rule.rePassword')));
|
||||
|
@ -325,6 +336,7 @@ function checkPassword(rule: any, value: any, callback: any) {
|
|||
onMounted(() => {
|
||||
document.title = globalStore.themeConfig.panelName;
|
||||
checkStatus();
|
||||
checkIsSystemDemo();
|
||||
document.onkeydown = (e: any) => {
|
||||
e = window.event || e;
|
||||
if (e.keyCode === 13) {
|
||||
|
@ -351,15 +363,11 @@ onMounted(() => {
|
|||
}
|
||||
|
||||
.login-title {
|
||||
// margin-top: 50px;
|
||||
font-size: 30px;
|
||||
letter-spacing: 0;
|
||||
text-align: center;
|
||||
color: #646a73;
|
||||
margin-bottom: 30px;
|
||||
// @media only screen and (max-width: 1280px) {
|
||||
// margin-top: 20px;
|
||||
// }
|
||||
}
|
||||
.no-border {
|
||||
:deep(.el-input__wrapper) {
|
||||
|
@ -421,5 +429,12 @@ onMounted(() => {
|
|||
height: 45px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.demo {
|
||||
text-align: center;
|
||||
span {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -55,19 +55,10 @@ const getStatus = async () => {
|
|||
statusCode.value = 1;
|
||||
};
|
||||
|
||||
// watch(
|
||||
// () => screenWidth.value,
|
||||
// (newVal) => {
|
||||
// console.log()
|
||||
// },
|
||||
// );
|
||||
|
||||
onMounted(() => {
|
||||
getStatus();
|
||||
// 屏幕适配
|
||||
screenWidth.value = document.body.clientWidth;
|
||||
window.onresize = () => {
|
||||
//屏幕尺寸变化就重新赋值
|
||||
return (() => {
|
||||
screenWidth.value = document.body.clientWidth;
|
||||
})();
|
||||
|
@ -118,8 +109,6 @@ onMounted(() => {
|
|||
}
|
||||
|
||||
.login-title {
|
||||
// margin-top: 10%;
|
||||
// margin-right: 15%;
|
||||
margin-left: 10%;
|
||||
span:first-child {
|
||||
color: $primary-color;
|
||||
|
@ -138,11 +127,9 @@ onMounted(() => {
|
|||
}
|
||||
}
|
||||
.login-container {
|
||||
// margin-left: 15%;
|
||||
margin-top: 40px;
|
||||
padding: 40px 0;
|
||||
width: 390px;
|
||||
// height: 422px;
|
||||
box-sizing: border-box;
|
||||
background-color: rgba(255, 255, 255, 0.55);
|
||||
border-radius: 4px;
|
||||
|
|
Loading…
Reference in a new issue