mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
custom
This commit is contained in:
parent
1e9c5ec317
commit
3f4af8fdd6
@ -37,13 +37,20 @@ import { LayoutDefaultOptions } from '../../theme/layout-default';
|
|||||||
],
|
],
|
||||||
template: `
|
template: `
|
||||||
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
|
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
|
||||||
<layout-default-header-item direction="left">
|
<layout-default-header-item direction="left" *ngIf="!inst.custom">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<img src="./assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
|
<img src="./assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
|
||||||
<div class="alain-default__header-title"> Max<span style="color: #FFD700;">Key</span>{{ 'mxk.title' | i18n }} </div>
|
<div class="alain-default__header-title"> Max<span style="color: #FFD700;">Key</span>{{ 'mxk.title' | i18n }} </div>
|
||||||
</a>
|
</a>
|
||||||
</layout-default-header-item>
|
</layout-default-header-item>
|
||||||
|
|
||||||
|
<layout-default-header-item direction="left" *ngIf="inst.custom">
|
||||||
|
<a href="#">
|
||||||
|
<img src="{{ inst.logo }}" alt="logo" style="height: 50px;height: 50px;float: left;" />
|
||||||
|
<div class="alain-default__header-title"> {{ inst.title }} </div>
|
||||||
|
</a>
|
||||||
|
</layout-default-header-item>
|
||||||
|
|
||||||
<layout-default-header-item direction="right" hidden="mobile">
|
<layout-default-header-item direction="right" hidden="mobile">
|
||||||
<div layout-default-header-item-trigger (click)="profile()"> {{ user.name }}</div>
|
<div layout-default-header-item-trigger (click)="profile()"> {{ user.name }}</div>
|
||||||
</layout-default-header-item>
|
</layout-default-header-item>
|
||||||
@ -135,6 +142,7 @@ export class LayoutBasicComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.inst = this.authnService.getInst();
|
this.inst = this.authnService.getInst();
|
||||||
if (this.inst == null) {
|
if (this.inst == null) {
|
||||||
|
this.inst = { custom: false };
|
||||||
this.authnService.initInst().subscribe(res => {
|
this.authnService.initInst().subscribe(res => {
|
||||||
this.authnService.setInst(res.data, !knowHost());
|
this.authnService.setInst(res.data, !knowHost());
|
||||||
this.inst = this.authnService.getInst();
|
this.inst = this.authnService.getInst();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<div nz-row style="border-bottom: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff">
|
<div nz-row style="border-bottom: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff">
|
||||||
<div nz-col nzMd="2"></div>
|
<div nz-col nzMd="2"></div>
|
||||||
<div nz-col nzMd="2" style="text-align: right">
|
<div nz-col nzMd="2" style="text-align: right">
|
||||||
<img *ngIf="this.inst == null || !inst.custom" style="margin-top: 6px" class="logo" src="./assets/logo.jpg" />
|
<img *ngIf="!inst.custom" style="margin-top: 6px" class="logo" src="./assets/logo.jpg" />
|
||||||
<img *ngIf="inst.custom" style="margin-top: 6px" class="logo" src="{{ inst.logo }}" />
|
<img *ngIf="inst.custom" style="margin-top: 6px" class="logo" src="{{ inst.logo }}" />
|
||||||
</div>
|
</div>
|
||||||
<div nz-col nzMd="10">
|
<div nz-col nzMd="10">
|
||||||
|
|||||||
@ -51,6 +51,7 @@ export class LayoutPassportComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.inst = this.authnService.getInst();
|
this.inst = this.authnService.getInst();
|
||||||
if (this.inst == null) {
|
if (this.inst == null) {
|
||||||
|
this.inst = { custom: false };
|
||||||
this.authnService.initInst().subscribe(res => {
|
this.authnService.initInst().subscribe(res => {
|
||||||
this.authnService.setInst(res.data, !knowHost());
|
this.authnService.setInst(res.data, !knowHost());
|
||||||
this.inst = this.authnService.getInst();
|
this.inst = this.authnService.getInst();
|
||||||
|
|||||||
@ -14,11 +14,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { SettingsService, User } from '@delon/theme';
|
import { SettingsService, User } from '@delon/theme';
|
||||||
import { environment } from '@env/environment';
|
import { environment } from '@env/environment';
|
||||||
|
import { AuthnService } from 'src/app/service/authn.service';
|
||||||
import { CONSTS } from 'src/app/shared/consts';
|
import { CONSTS } from 'src/app/shared/consts';
|
||||||
|
|
||||||
|
import { knowHost } from '../../shared/utils/knowhost';
|
||||||
import { LayoutDefaultOptions } from '../../theme/layout-default';
|
import { LayoutDefaultOptions } from '../../theme/layout-default';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -33,7 +35,7 @@ import { LayoutDefaultOptions } from '../../theme/layout-default';
|
|||||||
],
|
],
|
||||||
template: `
|
template: `
|
||||||
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
|
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
|
||||||
<layout-default-header-item direction="left">
|
<layout-default-header-item direction="left" *ngIf="!inst.custom">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<img src="./assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
|
<img src="./assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
|
||||||
<div
|
<div
|
||||||
@ -48,6 +50,21 @@ import { LayoutDefaultOptions } from '../../theme/layout-default';
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</layout-default-header-item>
|
</layout-default-header-item>
|
||||||
|
<layout-default-header-item direction="left" *ngIf="inst.custom">
|
||||||
|
<a href="#">
|
||||||
|
<img src="{{ inst.logo }}" alt="logo" style="height: 50px;height: 50px;float: left;" />
|
||||||
|
<div
|
||||||
|
class="alain-default__nav-item_title"
|
||||||
|
style="letter-spacing: 2px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bolder;
|
||||||
|
width: 450px;
|
||||||
|
margin-top: 12px;"
|
||||||
|
>
|
||||||
|
{{ inst.title }}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</layout-default-header-item>
|
||||||
|
|
||||||
<layout-default-header-item direction="right" hidden="mobile">
|
<layout-default-header-item direction="right" hidden="mobile">
|
||||||
<div layout-default-header-item-trigger>
|
<div layout-default-header-item-trigger>
|
||||||
@ -110,8 +127,9 @@ import { LayoutDefaultOptions } from '../../theme/layout-default';
|
|||||||
<theme-btn></theme-btn>
|
<theme-btn></theme-btn>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class LayoutBasicComponent {
|
export class LayoutBasicComponent implements OnInit {
|
||||||
version = CONSTS.VERSION;
|
version = CONSTS.VERSION;
|
||||||
|
inst: any;
|
||||||
options: LayoutDefaultOptions = {
|
options: LayoutDefaultOptions = {
|
||||||
logoExpanded: `./assets/logo-full.svg`,
|
logoExpanded: `./assets/logo-full.svg`,
|
||||||
logoCollapsed: `./assets/logo.svg`,
|
logoCollapsed: `./assets/logo.svg`,
|
||||||
@ -123,5 +141,16 @@ export class LayoutBasicComponent {
|
|||||||
return this.settingsService.user;
|
return this.settingsService.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService) { }
|
ngOnInit(): void {
|
||||||
|
this.inst = this.authnService.getInst();
|
||||||
|
if (this.inst == null) {
|
||||||
|
this.inst = { custom: false };
|
||||||
|
this.authnService.initInst().subscribe(res => {
|
||||||
|
this.authnService.setInst(res.data, !knowHost());
|
||||||
|
this.inst = this.authnService.getInst();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private settingsService: SettingsService, private authnService: AuthnService) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
<div nz-row style="border-bottom: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff">
|
<div nz-row style="border-bottom: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff">
|
||||||
<div nz-col nzMd="2"></div>
|
<div nz-col nzMd="2"></div>
|
||||||
<div nz-col nzMd="2" style="text-align: right">
|
<div nz-col nzMd="2" style="text-align: right">
|
||||||
<img *ngIf="!isTitle" style="margin-top: 6px" class="logo" src="./assets/logo.jpg" />
|
<img *ngIf="!inst.custom" style="margin-top: 6px" class="logo" src="./assets/logo.jpg" />
|
||||||
<img *ngIf="isTitle" style="margin-top: 6px" class="logo" src="{{ inst.logo }}" />
|
<img *ngIf="inst.custom" style="margin-top: 6px" class="logo" src="{{ inst.logo }}" />
|
||||||
</div>
|
</div>
|
||||||
<div nz-col nzMd="10">
|
<div nz-col nzMd="10">
|
||||||
<div *ngIf="!isTitle" class="title">Max<span style="color: #ffd700">Key</span>{{ 'mxk.title' | i18n }}</div>
|
<div *ngIf="!inst.custom" class="title"> Max<span style="color: #ffd700">Key</span> {{ 'mxk.title' | i18n }}
|
||||||
<div *ngIf="isTitle" class="title">{{ inst.title }}</div>
|
</div>
|
||||||
|
<div *ngIf="inst.custom" class="title">{{ inst.title }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div nz-col nzMd="6"></div>
|
<div nz-col nzMd="6"></div>
|
||||||
<div nz-col nzXs="0" nzSm="0" nzMd="2">
|
<div nz-col nzXs="0" nzSm="0" nzMd="2">
|
||||||
@ -18,7 +19,7 @@
|
|||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="top" nz-col nzXs="0" nzSm="0" nzMd="24">
|
<div class="top" nz-col nzXs="0" nzSm="0" nzMd="24">
|
||||||
<div class="desc">{{ 'mxk.login.title.sub' | i18n }}</div>
|
<div class="desc" *ngIf="inst == null || !inst.custom">{{ 'mxk.login.title.sub' | i18n }}</div>
|
||||||
</div>
|
</div>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
<global-footer style="border-top: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff">
|
<global-footer style="border-top: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff">
|
||||||
|
|||||||
@ -19,6 +19,8 @@ import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
|
|||||||
import { AuthnService } from 'src/app/service/authn.service';
|
import { AuthnService } from 'src/app/service/authn.service';
|
||||||
import { CONSTS } from 'src/app/shared/consts';
|
import { CONSTS } from 'src/app/shared/consts';
|
||||||
|
|
||||||
|
import { knowHost } from '../../shared/utils/knowhost';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'layout-passport',
|
selector: 'layout-passport',
|
||||||
templateUrl: './passport.component.html',
|
templateUrl: './passport.component.html',
|
||||||
@ -26,7 +28,6 @@ import { CONSTS } from 'src/app/shared/consts';
|
|||||||
})
|
})
|
||||||
export class LayoutPassportComponent implements OnInit {
|
export class LayoutPassportComponent implements OnInit {
|
||||||
version = CONSTS.VERSION;
|
version = CONSTS.VERSION;
|
||||||
isTitle: boolean = false;
|
|
||||||
inst: any;
|
inst: any;
|
||||||
links = [
|
links = [
|
||||||
{
|
{
|
||||||
@ -42,15 +43,13 @@ export class LayoutPassportComponent implements OnInit {
|
|||||||
constructor(@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService, private authnService: AuthnService) { }
|
constructor(@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService, private authnService: AuthnService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (
|
this.inst = this.authnService.getInst();
|
||||||
window.location.hostname != 'localhost' &&
|
if (this.inst == null) {
|
||||||
window.location.hostname != 'sso.maxkey.top' &&
|
this.inst = { custom: false };
|
||||||
window.location.hostname != 'mgt.maxkey.top'
|
this.authnService.initInst().subscribe(res => {
|
||||||
) {
|
this.authnService.setInst(res.data, !knowHost());
|
||||||
this.inst = this.authnService.getInst();
|
this.inst = this.authnService.getInst();
|
||||||
if (this.inst != null) {
|
});
|
||||||
this.isTitle = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.tokenService.clear();
|
this.tokenService.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,8 +94,7 @@ export class UserLoginComponent implements OnInit, OnDestroy {
|
|||||||
this.error = res.msg;
|
this.error = res.msg;
|
||||||
} else {
|
} else {
|
||||||
// 清空路由复用信息
|
// 清空路由复用信息
|
||||||
console.log(res.data);
|
//console.log(res.data);
|
||||||
this.authnService.setInst(res.data.inst);
|
|
||||||
this.state = res.data.state;
|
this.state = res.data.state;
|
||||||
//init image captcha
|
//init image captcha
|
||||||
this.imageCaptchaService.captcha({ state: this.state }).subscribe(res => {
|
this.imageCaptchaService.captcha({ state: this.state }).subscribe(res => {
|
||||||
|
|||||||
@ -94,12 +94,24 @@ export class AuthnService {
|
|||||||
this.tokenService.get()?.expired;
|
this.tokenService.get()?.expired;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInst(inst: any) {
|
setInst(inst: any, custom: boolean) {
|
||||||
localStorage.setItem(CONSTS.INST, JSON.stringify({ id: inst.id, name: inst.name, title: inst.consoleTitle, logo: inst.logo }));
|
localStorage.setItem(
|
||||||
|
CONSTS.INST,
|
||||||
|
JSON.stringify({ custom: custom, id: inst.id, name: inst.name, title: inst.consoleTitle, logo: inst.logo })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInst() {
|
getInst() {
|
||||||
return JSON.parse(`${localStorage.getItem(CONSTS.INST)}`);
|
let strInst = `${localStorage.getItem(CONSTS.INST)}`;
|
||||||
|
if (strInst == null || strInst === '') {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return JSON.parse(strInst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initInst() {
|
||||||
|
return this.http.get(`/inst/get?_allow_anonymous=true`);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(authJwt: any) {
|
navigate(authJwt: any) {
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
export function knowHost() {
|
||||||
|
let hostArray: string[] = new Array('localhost', 'sso.maxkey.top', 'mgt.maxkey.top', 'sso.maxsso.net', 'mgt.maxsso.net');
|
||||||
|
for (var i = 0; i < hostArray.length; i++) {
|
||||||
|
if (hostArray[i] == location.hostname) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user