feat: 增加判断系统是否是 demo 接口

This commit is contained in:
zhengkunwang223 2023-03-14 15:03:46 +08:00 committed by zhengkunwang223
parent e120bb0612
commit 6c99e04aee
7 changed files with 37 additions and 20 deletions

View file

@ -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 {

View file

@ -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)

View file

@ -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)
}
}

View file

@ -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) => {

View file

@ -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');
};

View file

@ -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>

View file

@ -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;