重构界面ui
This commit is contained in:
9
index/src/app/utils/color.ts
Normal file
9
index/src/app/utils/color.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const ColorList: { bgColor: string, fontColor: string }[] = [
|
||||
{bgColor: '#7bcfa6', fontColor: '#000000'}, // 石青
|
||||
{bgColor: '#bce672', fontColor: '#000000'}, // 松花色
|
||||
{bgColor: '#ff8936', fontColor: '#000000'}, // 橘黄
|
||||
{bgColor: '#f0c239', fontColor: '#000000'}, // 缃色
|
||||
{bgColor: '#808080', fontColor: '#ffffff'}, // 灰色
|
||||
{bgColor: '#3eede7', fontColor: '#000000'}, // 碧蓝
|
||||
{bgColor: '#177cb0', fontColor: '#ffffff'}, // 靛青
|
||||
];
|
||||
12
index/src/app/utils/local-storage.service.spec.ts
Normal file
12
index/src/app/utils/local-storage.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LocalStorageService } from './local-storage.service';
|
||||
|
||||
describe('LocalStorageService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: LocalStorageService = TestBed.get(LocalStorageService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
63
index/src/app/utils/local-storage.service.ts
Normal file
63
index/src/app/utils/local-storage.service.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {User} from '../class/User';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LocalStorageService {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
// 1分钟
|
||||
readonly place = 60 * 1000;
|
||||
|
||||
getToken(): string {
|
||||
return localStorage.getItem('token');
|
||||
}
|
||||
|
||||
setToken(token: string) {
|
||||
localStorage.setItem('t', new Date().valueOf().toString());
|
||||
localStorage.setItem('token', token);
|
||||
}
|
||||
|
||||
removeToken() {
|
||||
localStorage.removeItem('token');
|
||||
}
|
||||
|
||||
isLogin() {
|
||||
return this.getToken() != null;
|
||||
}
|
||||
|
||||
setUser(user: User) {
|
||||
// TODO: 简单加个密
|
||||
localStorage.setItem('t', new Date().valueOf().toString());
|
||||
return localStorage.setItem('user', JSON.stringify(user));
|
||||
}
|
||||
|
||||
getUser(): User {
|
||||
if (!this.checkNeedNet()) {
|
||||
return JSON.parse(localStorage.getItem('user'));
|
||||
}
|
||||
}
|
||||
|
||||
removeUser() {
|
||||
return localStorage.removeItem('user');
|
||||
}
|
||||
|
||||
clear() {
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('user');
|
||||
return localStorage.removeItem('t');
|
||||
}
|
||||
|
||||
checkNeedNet() {
|
||||
const t: number = Number.parseInt(localStorage.getItem('t'), 10);
|
||||
if (isNaN(t) || new Date().valueOf() - t > this.place) {
|
||||
localStorage.removeItem('t');
|
||||
localStorage.removeItem('user');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
42
index/src/app/utils/logger.ts
Normal file
42
index/src/app/utils/logger.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import {environment} from '../../environments/environment';
|
||||
|
||||
export class Logger {
|
||||
|
||||
private static inited = false;
|
||||
|
||||
static info(obj: object) {
|
||||
this.printLogInfo();
|
||||
if (environment.logger) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.info(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static debug(obj: object) {
|
||||
this.printLogInfo();
|
||||
if (environment.logger) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.debug(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static error(obj: object) {
|
||||
this.printLogInfo();
|
||||
if (environment.logger) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.error(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static printLogInfo() {
|
||||
const option = {
|
||||
environment: environment.production ? 'release' : 'debug',
|
||||
};
|
||||
if (!this.inited) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.info(option);
|
||||
this.inited = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
index/src/app/utils/svgIconUtil.ts
Normal file
11
index/src/app/utils/svgIconUtil.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export class SvgIconUtil {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:max-line-length
|
||||
static readonly nameIcon = '<svg t="1581933298087" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3223" width="200" height="200"><path d="M983.04 163.84H40.96c-24.576 0-40.96 16.384-40.96 40.96v614.4c0 20.48 16.384 40.96 40.96 40.96h942.08c20.48 0 40.96-20.48 40.96-40.96V204.8c0-24.576-20.48-40.96-40.96-40.96zM253.952 749.568c0-102.4 61.44-192.512 147.456-233.472-28.672-24.576-45.056-61.44-45.056-102.4 0-77.824 65.536-143.36 143.36-143.36s143.36 65.536 143.36 143.36c0 40.96-12.288 73.728-36.864 98.304 94.208 36.864 163.84 131.072 163.84 237.568H253.952z" p-id="3224" fill="#1296db"></path></svg>';
|
||||
|
||||
// tslint:disable-next-line:max-line-length
|
||||
static readonly locationIcon = '<svg t="1581933583276" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3981" width="200" height="200"><path d="M511.932268 0c-213.943865 0-387.880498 170.933833-387.880499 381.06211 0 164.815346 238.869364 485.098975 341.66447 620.247558a58.249807 58.249807 0 0 0 46.216029 22.690332c18.129688 0 35.491743-8.443964 46.328916-22.690332 102.704796-135.126006 341.709624-455.432213 341.709624-620.247558C899.970808 170.933833 725.89871 0 511.932268 0z m0 519.574733c-91.393496 0-165.786176-72.902569-165.786176-162.670489 0-89.722765 74.39268-162.738221 165.786176-162.73822 91.438651 0 165.718443 73.015456 165.718443 162.73822 0 89.76792-74.279793 162.670488-165.718443 162.670489z" fill="#1296db" p-id="3982"></path></svg>';
|
||||
}
|
||||
17
index/src/app/utils/util.ts
Normal file
17
index/src/app/utils/util.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
class DataProperties {
|
||||
static windowsMode: 'small' | 'middle' | 'large' = null;
|
||||
}
|
||||
|
||||
export function windowWidthChange(func) {
|
||||
DataProperties.windowsMode = window.innerWidth < 910 ? 'small' : (window.innerWidth > 1300 ? 'large' : 'middle');
|
||||
// 监听宽度变化
|
||||
window.addEventListener('resize', () => {
|
||||
DataProperties.windowsMode = window.innerWidth < 910 ? 'small' : (window.innerWidth > 1300 ? 'large' : 'middle');
|
||||
func();
|
||||
});
|
||||
}
|
||||
|
||||
export function windowsMode() {
|
||||
return DataProperties.windowsMode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user