Skip to content

Commit

Permalink
chore: chore code
Browse files Browse the repository at this point in the history
  • Loading branch information
devcui committed Feb 22, 2024
1 parent b52cbb7 commit 4e88cea
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 71 deletions.
82 changes: 41 additions & 41 deletions _mock/_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ const avatars = [
'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap
'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React
'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue
'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack
'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png' // Webpack
];
const covers = [
'https://gw.alipayobjects.com/zos/rmsportal/HrxcVbrKnCJOZvtzSqjN.png',
'https://gw.alipayobjects.com/zos/rmsportal/alaPpKWajEbIYEUvvVNf.png',
'https://gw.alipayobjects.com/zos/rmsportal/RLwlKSYGSXGHuWSojyvp.png',
'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png',
'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png'
];
const desc = [
'那是一种内在的东西, 他们到达不了,也无法触及的',
'希望是一个好东西,也许是最好的,好东西是不会消亡的',
'生命就像一盒巧克力,结果往往出人意料',
'城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
'那时候我只会想自己想要什么,从不想自己拥有什么',
'那时候我只会想自己想要什么,从不想自己拥有什么'
];

const user = ['yunzai-bot', 'yunzai-bot', '付小小', '曲丽丽', '林东东', '周星星', '吴加好', '朱偏右', '鱼酱', '乐哥', '谭小仪', '仲尼'];
Expand Down Expand Up @@ -60,17 +60,17 @@ function getFakeList(count: number = 20): any[] {
members: [
{
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
name: '曲丽丽',
name: '曲丽丽'
},
{
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
name: '王昭君',
name: '王昭君'
},
{
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
name: '董娜娜',
},
],
name: '董娜娜'
}
]
});
}

Expand All @@ -87,7 +87,7 @@ function getNotice(): any[] {
updatedAt: new Date(),
member: '科学搬砖组',
href: '',
memberLink: '',
memberLink: ''
},
{
id: 'xxx2',
Expand All @@ -97,7 +97,7 @@ function getNotice(): any[] {
updatedAt: new Date('2017-07-24'),
member: '全组都是吴彦祖',
href: '',
memberLink: '',
memberLink: ''
},
{
id: 'xxx3',
Expand All @@ -107,7 +107,7 @@ function getNotice(): any[] {
updatedAt: new Date(),
member: '中二少女团',
href: '',
memberLink: '',
memberLink: ''
},
{
id: 'xxx4',
Expand All @@ -117,7 +117,7 @@ function getNotice(): any[] {
updatedAt: new Date('2017-07-23'),
member: '程序员日常',
href: '',
memberLink: '',
memberLink: ''
},
{
id: 'xxx5',
Expand All @@ -127,7 +127,7 @@ function getNotice(): any[] {
updatedAt: new Date('2017-07-23'),
member: '高逼格设计天团',
href: '',
memberLink: '',
memberLink: ''
},
{
id: 'xxx6',
Expand All @@ -137,8 +137,8 @@ function getNotice(): any[] {
updatedAt: new Date('2017-07-23'),
member: '骗你来学计算机',
href: '',
memberLink: '',
},
memberLink: ''
}
];
}

Expand All @@ -149,107 +149,107 @@ function getActivities(): any[] {
updatedAt: new Date(),
user: {
name: '林东东',
avatar: avatars[0],
avatar: avatars[0]
},
group: {
name: '高逼格设计天团',
link: 'http://github.com/',
link: 'http://github.com/'
},
project: {
name: '六月迭代',
link: 'http://github.com/',
link: 'http://github.com/'
},
template: '在 @{group} 新建项目 @{project}',
template: '在 @{group} 新建项目 @{project}'
},
{
id: 'trend-2',
updatedAt: new Date(),
user: {
name: '付小小',
avatar: avatars[1],
avatar: avatars[1]
},
group: {
name: '高逼格设计天团',
link: 'http://github.com/',
link: 'http://github.com/'
},
project: {
name: '六月迭代',
link: 'http://github.com/',
link: 'http://github.com/'
},
template: '在 @{group} 新建项目 @{project}',
template: '在 @{group} 新建项目 @{project}'
},
{
id: 'trend-3',
updatedAt: new Date(),
user: {
name: '曲丽丽',
avatar: avatars[2],
avatar: avatars[2]
},
group: {
name: '中二少女团',
link: 'http://github.com/',
link: 'http://github.com/'
},
project: {
name: '六月迭代',
link: 'http://github.com/',
link: 'http://github.com/'
},
template: '在 @{group} 新建项目 @{project}',
template: '在 @{group} 新建项目 @{project}'
},
{
id: 'trend-4',
updatedAt: new Date(),
user: {
name: '周星星',
avatar: avatars[3],
avatar: avatars[3]
},
project: {
name: '5 月日常迭代',
link: 'http://github.com/',
link: 'http://github.com/'
},
template: '将 @{project} 更新至已发布状态',
template: '将 @{project} 更新至已发布状态'
},
{
id: 'trend-5',
updatedAt: new Date(),
user: {
name: '朱偏右',
avatar: avatars[4],
avatar: avatars[4]
},
project: {
name: '工程效能',
link: 'http://github.com/',
link: 'http://github.com/'
},
comment: {
name: '留言',
link: 'http://github.com/',
link: 'http://github.com/'
},
template: '在 @{project} 发布了 @{comment}',
template: '在 @{project} 发布了 @{comment}'
},
{
id: 'trend-6',
updatedAt: new Date(),
user: {
name: '乐哥',
avatar: avatars[5],
avatar: avatars[5]
},
group: {
name: '程序员日常',
link: 'http://github.com/',
link: 'http://github.com/'
},
project: {
name: '品牌迭代',
link: 'http://github.com/',
link: 'http://github.com/'
},
template: '在 @{group} 新建项目 @{project}',
},
template: '在 @{group} 新建项目 @{project}'
}
];
}

export const APIS = {
'/api/list': (req: MockRequest) => getFakeList(req.queryString.count),
'/api/notice': () => getNotice(),
'/api/activities': () => getActivities(),
'POST /api/auth/refresh': { msg: 'ok', token: 'new-token-by-refresh' },
'POST /api/auth/refresh': { msg: 'ok', access_token: 'new-token-by-refresh' },
'/api/401': () => {
throw new MockStatusError(401);
},
Expand All @@ -261,5 +261,5 @@ export const APIS = {
},
'/api/500': () => {
throw new MockStatusError(500);
},
}
};
42 changes: 21 additions & 21 deletions _mock/_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for (let i = 0; i < total; i += 1) {
href: 'https://ant.design',
avatar: [
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png'
][i % 2],
no: `TradeCode ${i}`,
title: `一个任务名称 ${i}`,
Expand All @@ -20,7 +20,7 @@ for (let i = 0; i < total; i += 1) {
status: Math.floor(Math.random() * 10) % 4,
updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
createdAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
progress: Math.ceil(Math.random() * 100),
progress: Math.ceil(Math.random() * 100)
});
}

Expand All @@ -31,14 +31,14 @@ function genData(params: any): { total: number; list: any[] } {
const start = (pi - 1) * ps;

if (params.no) {
ret = ret.filter((data) => data.no.indexOf(params.no) > -1);
ret = ret.filter(data => data.no.indexOf(params.no) > -1);
}

return { total: ret.length, list: ret.slice(start, ps * pi) };
}

function saveData(id: number, value: any): { msg: string } {
const item = list.find((w) => w.id === id);
const item = list.find(w => w.id === id);
if (!item) {
return { msg: '无效用户信息' };
}
Expand All @@ -48,7 +48,7 @@ function saveData(id: number, value: any): { msg: string } {

export const USERS = {
'/user': (req: MockRequest) => genData(req.queryString),
'/user/:id': (req: MockRequest) => list.find((w) => w.id === +req.params.id),
'/user/:id': (req: MockRequest) => list.find(w => w.id === +req.params.id),
'POST /user/:id': (req: MockRequest) => saveData(+req.params.id, req.body),
'/user/current': {
name: 'Cipchk',
Expand All @@ -61,43 +61,43 @@ export const USERS = {
tags: [
{
key: '0',
label: '很有想法的',
label: '很有想法的'
},
{
key: '1',
label: '专注撩妹',
label: '专注撩妹'
},
{
key: '2',
label: '帅~',
label: '帅~'
},
{
key: '3',
label: '通吃',
label: '通吃'
},
{
key: '4',
label: '专职后端',
label: '专职后端'
},
{
key: '5',
label: '海纳百川',
},
label: '海纳百川'
}
],
notifyCount: 12,
country: 'China',
geographic: {
province: {
label: '上海',
key: '330000',
key: '330000'
},
city: {
label: '市辖区',
key: '330100',
},
key: '330100'
}
},
address: 'XX区XXX路 XX 号',
phone: '你猜-你猜你猜猜猜',
phone: '你猜-你猜你猜猜猜'
},
'POST /user/avatar': 'ok',
'POST /login/account': (req: MockRequest) => {
Expand All @@ -108,15 +108,15 @@ export const USERS = {
return {
msg: 'ok',
user: {
token: '123456789',
access_token: '123456789',
name: data.userName,
email: `${data.userName}@qq.com`,
id: 10000,
time: +new Date(),
},
time: +new Date()
}
};
},
'POST /register': {
msg: 'ok',
},
msg: 'ok'
}
};
3 changes: 1 addition & 2 deletions src/app/core/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { Platform } from '@angular/cdk/platform';
import { registerLocaleData } from '@angular/common';
import { Injectable } from '@angular/core';
import { YUNZAI_LANGS } from '@yelon/bis/layout';
import { YelonLocaleService, SettingsService, _HttpClient, YunzaiI18nBaseService, YunzaiI18NType } from '@yelon/theme';
import { YelonLocaleService, SettingsService, _HttpClient, YunzaiI18nBaseService, YunzaiI18NType, YUNZAI_LANGS } from '@yelon/theme';
import { YunzaiConfigService } from '@yelon/util/config';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzI18nService } from 'ng-zorro-antd/i18n';
Expand Down
5 changes: 3 additions & 2 deletions src/app/core/net/refresh-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ let refreshToken$: BehaviorSubject<any> = new BehaviorSubject<any>(null);
* > 由于已经发起的请求,不会再走一遍 `@yelon/auth` 因此需要结合业务情况重新附加新的 Token
*/
function reAttachToken(injector: Injector, req: HttpRequest<any>): HttpRequest<any> {
const token = injector.get(YA_SERVICE_TOKEN).get()?.token;
// eslint-disable-next-line prettier/prettier
const token = injector.get(YA_SERVICE_TOKEN).get()?.access_token;
return req.clone({
setHeaders: {
token: `Bearer ${token}`
Expand Down Expand Up @@ -80,7 +81,7 @@ function buildAuthRefresh(injector: Injector) {
.subscribe({
next: res => {
// TODO: Mock expired value
res.expired = +new Date() + 1000 * 60 * 5;
res.expires_in = +new Date() + 1000 * 60 * 5;
refreshToking = false;
tokenSrv.set(res);
},
Expand Down
Loading

0 comments on commit 4e88cea

Please sign in to comment.