Merge branch 'develop' into 'master'

fix: 修改忽略文件

See merge request web-project/aircraft-carrier-fleet!11
This commit is contained in:
刘汉华 2024-03-22 15:17:48 +08:00
commit bedcd654f4
27 changed files with 249 additions and 11312 deletions

3
.env
View File

@ -1,3 +1,4 @@
# 默认配置
DID_YOU_KNOW=none
PORT=30058
PORT=30058
APP_ENV=production

1
.env.production Normal file
View File

@ -0,0 +1 @@
APP_ENV=production

3
.gitignore vendored
View File

@ -13,4 +13,5 @@
.swc
aircraft-carrier-fleet
dist
.idea
.idea
pnpm-lock.yaml

2
.npmrc
View File

@ -1,2 +1,2 @@
registry=https://registry.npmmirror.com/
@zhst:registry="http://10.0.0.77:4874"

View File

@ -1,37 +0,0 @@
import { defineConfig } from '@umijs/max';
export default defineConfig({
favicons: ['/assets/logo.jpg'],
access: {},
model: {},
initialState: {},
layout: false,
qiankun: {
master: {
prefetch: false,
},
},
routes: [
{
name: 'intelligent-file-cabinet',
path: '/intelligent-file-cabinet/*',
microApp: 'intelligent-file-cabinet',
},
{
name: 'algorithm-warehouse',
path: '/algorithm-warehouse/*',
microApp: 'algorithm-warehouse',
},
{
name: 'smart-video-analysis',
path: '/smart-video-analysis/*',
microApp: 'smart-video-analysis',
},
{
name: '物料库',
path: '/communal-facilities-pages/*',
microApp: 'communal-facilities-pages',
},
],
npmClient: 'pnpm',
});

23
config/config.ts Normal file
View File

@ -0,0 +1,23 @@
import { defineConfig } from '@umijs/max';
import routes from './routes';
export default defineConfig({
favicons: ['/assets/logo.jpg'],
access: {},
model: {},
dva: {},
request: {},
initialState: {},
layout: false,
qiankun: {
master: {
prefetch: false,
},
},
mfsu: false,
routes,
npmClient: 'pnpm',
define: {
APP_ENV: process.env.APP_ENV || 'development',
},
});

View File

@ -1,3 +1,23 @@
export default {
routes: [],
};
const routes = [
{
name: 'cabinet',
path: '/cabinet/*',
microApp: 'cabinet',
},
{
name: 'algorithm',
path: '/algorithm/*',
microApp: 'algorithm',
},
{
name: 'video',
path: '/video/*',
microApp: 'video',
},
{
name: '物料库',
path: '/material/*',
microApp: 'material',
},
];
export default routes;

1
global.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare const APP_ENV: string;

View File

@ -3,13 +3,13 @@
"private": true,
"author": "dev <710328466@qq.com>",
"scripts": {
"dev": "max dev",
"build:master": "max build",
"comp": "cross-env max g component",
"dev": "max dev",
"format": "prettier --cache --write .",
"prepare": "husky install",
"postinstall": "max setup",
"page": "cross-env max g page",
"comp": "cross-env max g component",
"prepare": "husky install",
"setup": "max setup",
"start": "npm run dev"
},
@ -17,6 +17,7 @@
"@ant-design/icons": "^5.3.0",
"@ant-design/pro-components": "^2.6.49",
"@umijs/max": "^4.1.1",
"@zhst/func": "^0.8.1",
"antd": "^5.14.1",
"cross-env": "^7.0.3"
},

File diff suppressed because it is too large Load Diff

12
src/actions/index.ts Normal file
View File

@ -0,0 +1,12 @@
import { useState } from 'react';
export default function useQiankunStateForSlave() {
const [globalState, setGlobalState] = useState<any>({
fatherName: 'zhst',
});
return {
globalState,
setGlobalState,
};
}

View File

@ -1,52 +1,68 @@
import { useState } from 'react';
import doRequest from '@/utils/request';
import useFatherAction from './actions';
// 运行时配置
export async function getInitialState(): Promise<{ name: string }> {
return { name: '@umijs/max' };
}
export function useQiankunStateForSlave() {
const [globalState, setGlobalState] = useState<any>({
slogan: 'qiankun father',
});
export async function getInitialState(): Promise<{
name: string;
useLogin: boolean;
}> {
return {
globalState,
setGlobalState,
name: '主应用',
useLogin: false,
};
}
// 给子应用暴露的方法
export const useQiankunStateForSlave = useFatherAction;
const hostname = location.hostname;
export const qiankun = {
apps: [
{
name: 'intelligent-file-cabinet', // 盒子管理
entry: `//${hostname}:30068/intelligent-file-cabinet/`,
props: {
accountInfo: {
username: 'admin',
password: 'test123',
},
},
name: 'cabinet', // 盒子管理
entry:
APP_ENV === 'production'
? `//${hostname}:30068/cabinet/`
: '//localhost:30068/',
props: {},
singular: false,
credentials: true,
},
{
name: 'smart-video-analysis', // AI 智能分析仓
entry: `//${hostname}:30088/smart-video-analysis/`,
name: 'video', // AI 智能分析仓
entry:
APP_ENV === 'production'
? `//${hostname}:30088/video/`
: '//localhost:30088/',
singular: false,
credentials: true,
},
{
name: 'algorithm-warehouse', // AI 算法分析
entry: `//${hostname}:30078/algorithm-warehouse/`,
name: 'algorithm', // AI 算法分析
entry:
APP_ENV === 'production'
? `//${hostname}:30078/algorithm/`
: '//localhost:30078/',
singular: false,
credentials: true,
},
{
name: 'communal-facilities-pages', // 物料库
entry: `//${hostname}:30098/communal-facilities-pages/`,
name: 'material', // 物料库
entry:
APP_ENV === 'production'
? `//${hostname}:30098/material/`
: '//localhost:30098/',
singular: false,
credentials: true,
},
],
lifeCycles: {
// 所有子应用在挂载完成时,打印 props 信息
async afterMount(props: any) {
console.log('主应用:', props);
async afterMount() {
// console.log('子应用已全部加载:', props);
},
},
};
export const request = doRequest;

4
src/global.less Normal file
View File

@ -0,0 +1,4 @@
* {
padding: 0;
margin: 0;
}

View File

@ -1,13 +1,33 @@
import { Outlet } from '@umijs/max';
import { SettingOutlined, ShopOutlined } from '@ant-design/icons';
import { Outlet } from '@umijs/max';
import { FloatButton } from 'antd';
import React from 'react';
import styles from './index.less';
export default function Layout() {
const Layout = () => {
return (
<div className={styles.layout}>
<div className={styles.layout_tag} style={{ position: 'fixed', zIndex: 9999999999999999 }} >
</div>
<FloatButton.Group
trigger="click"
type="primary"
style={{ right: 32 }}
icon={<SettingOutlined />}
>
<FloatButton
tooltip="物料库"
onClick={() =>
(location.href = 'http://10.0.0.222:30098/communal-cabinets')
}
/>
<FloatButton
tooltip="组件库"
onClick={() => (location.href = 'http://10.0.0.222')}
/>
<FloatButton tooltip="demo 展示" icon={<ShopOutlined />} />
</FloatButton.Group>
<Outlet />
</div>
);
}
};
export default Layout;

View File

@ -1,9 +0,0 @@
const DocsPage = () => {
return (
<div>
<p>This is umi docs.</p>
</div>
);
};
export default DocsPage;

View File

@ -1,3 +1,4 @@
import React from 'react';
export default function HomePage() {
return (
@ -5,4 +6,4 @@ export default function HomePage() {
<h2>error</h2>
</div>
);
}
}

View File

@ -1,8 +1,9 @@
import React from 'react';
export default function HomePage() {
return (
<div>
<h2>Yay! Welcome to umi!</h2>
<h2>welcome home !</h2>
</div>
);
}

View File

@ -1,96 +0,0 @@
/* eslint-disable */
// 该文件由 OneAPI 自动生成,请勿手动修改!
import { request } from '@umijs/max';
/** 此处后端没有提供注释 GET /api/v1/queryUserList */
export async function queryUserList(
params: {
// query
/** keyword */
keyword?: string;
/** current */
current?: number;
/** pageSize */
pageSize?: number;
},
options?: { [key: string]: any },
) {
return request<API.Result_PageInfo_UserInfo__>('/api/v1/queryUserList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/v1/user */
export async function addUser(
body?: API.UserInfoVO,
options?: { [key: string]: any },
) {
return request<API.Result_UserInfo_>('/api/v1/user', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 GET /api/v1/user/${param0} */
export async function getUserDetail(
params: {
// path
/** userId */
userId?: string;
},
options?: { [key: string]: any },
) {
const { userId: param0 } = params;
return request<API.Result_UserInfo_>(`/api/v1/user/${param0}`, {
method: 'GET',
params: { ...params },
...(options || {}),
});
}
/** 此处后端没有提供注释 PUT /api/v1/user/${param0} */
export async function modifyUser(
params: {
// path
/** userId */
userId?: string;
},
body?: API.UserInfoVO,
options?: { [key: string]: any },
) {
const { userId: param0 } = params;
return request<API.Result_UserInfo_>(`/api/v1/user/${param0}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
params: { ...params },
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 DELETE /api/v1/user/${param0} */
export async function deleteUser(
params: {
// path
/** userId */
userId?: string;
},
options?: { [key: string]: any },
) {
const { userId: param0 } = params;
return request<API.Result_string_>(`/api/v1/user/${param0}`, {
method: 'DELETE',
params: { ...params },
...(options || {}),
});
}

View File

@ -1,7 +0,0 @@
/* eslint-disable */
// 该文件由 OneAPI 自动生成,请勿手动修改!
import * as UserController from './UserController';
export default {
UserController,
};

View File

@ -1,68 +0,0 @@
/* eslint-disable */
// 该文件由 OneAPI 自动生成,请勿手动修改!
declare namespace API {
interface PageInfo {
/**
1 */
current?: number;
pageSize?: number;
total?: number;
list?: Array<Record<string, any>>;
}
interface PageInfo_UserInfo_ {
/**
1 */
current?: number;
pageSize?: number;
total?: number;
list?: Array<UserInfo>;
}
interface Result {
success?: boolean;
errorMessage?: string;
data?: Record<string, any>;
}
interface Result_PageInfo_UserInfo__ {
success?: boolean;
errorMessage?: string;
data?: PageInfo_UserInfo_;
}
interface Result_UserInfo_ {
success?: boolean;
errorMessage?: string;
data?: UserInfo;
}
interface Result_string_ {
success?: boolean;
errorMessage?: string;
data?: string;
}
type UserGenderEnum = 'MALE' | 'FEMALE';
interface UserInfo {
id?: string;
name?: string;
/** nick */
nickName?: string;
/** email */
email?: string;
gender?: UserGenderEnum;
}
interface UserInfoVO {
name?: string;
/** nick */
nickName?: string;
/** email */
email?: string;
}
type definitions_0 = null;
}

4
src/utils/constants.ts Normal file
View File

@ -0,0 +1,4 @@
export const API_URL =
APP_ENV === 'production'
? 'http://10.0.0.222:31300'
: 'http://10.0.0.222:31300';

View File

@ -1,4 +1,12 @@
// 示例方法,没有实际意义
export function trim(str: string) {
return str.trim();
}
/**
* url
* @param key
* @param url
*/
export const getValueByUrlParams = (url: string) => {
if (url.indexOf('?') < 0) return;
const _params = new URLSearchParams(url.split('?')[1]);
return _params;
};

86
src/utils/request.ts Normal file
View File

@ -0,0 +1,86 @@
import type { RequestConfig } from '@umijs/max';
import { API_URL } from './constants';
const doRequest: RequestConfig = {
timeout: 1000,
baseURL: API_URL,
errorConfig: {
errorHandler(error, opts) {
console.log('errorHandler', error, opts);
// if (opts?.skipErrorHandler) throw error
// try {
// const { res } = ctx;
// const d = await res.text();
// if (res.status === 401 && store.user.isLogin) {
// store.user.resetLoginState();
// message.warning('登录过期,请重新登录!');
// return;
// }
// const isEmptyRes = d === '' || d.replace(/\s/g,"")=== 'tokenisinvalid'; //有些后端接口成功会返回空 做下兼容
// const body = !isEmptyRes ? JSON.parse(d || '{}') : d;
// const sessionCode = sessionStorage.getItem('zhst_errcode') || '{}'
// const ERROR_CODE = JSON.parse(sessionCode);
// if (Number(res.status) === 200) {
// ctx.res = body;
// } else {
// // 先判断Grpc-Metadata-Errorx-Message
// let errMsg = ERROR_CODE[body.code]?.value || body.message || '您的网络发生异常,无法连接服务器'
// toast && message.error(errMsg || body);
// ctx.res = {
// code: body.code,
// message: errMsg
// };
// }
// } catch (error) {
// if (get(error, 'type') !== 'CustomError') {
// toast && message.error('您的网络发生异常,无法连接服务器');
// }
// throw error;
// }
},
errorThrower(res) {
console.log('res', res);
},
},
// 请求
requestInterceptors: [
// 一个二元组,第一个元素是 request 拦截器,第二个元素是错误处理
[
(url, options) => {
return {
url,
options: {
...options,
headers: {
authorization: 'test',
// ...(refererSuffix ? { zhst_referer: `${baseUrl}${refererSuffix}` } : {}),
},
},
};
},
(error) => {
return Promise.reject(error);
},
],
],
// 返回
responseInterceptors: [
// 一个二元组,第一个元素是 request 拦截器,第二个元素是错误处理
[
(response) => {
if (response.status !== 200) {
throw Error(JSON.stringify(response.data));
}
return response;
},
(error) => {
return Promise.reject(error);
},
],
],
};
export default doRequest;