Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codespace laughing capybara 5gvx4jxg4xgfp67p #11230

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import { join } from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './routes';

const { REACT_APP_ENV = 'dev' } = process.env;

export default defineConfig({
/**
* @name 开启 hash 模式
* @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。
* @doc https://umijs.org/docs/api/config#hash
*/
hash: true,

/**
* @name 兼容性设置
* @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖
Expand Down Expand Up @@ -76,7 +73,7 @@ export default defineConfig({
* @name layout 插件
* @doc https://umijs.org/docs/max/layout-menu
*/
title: 'Ant Design Pro',
title: '在线管理系统',
layout: {
locale: true,
...defaultSettings,
Expand All @@ -93,15 +90,7 @@ export default defineConfig({
/**
* @name 国际化插件
* @doc https://umijs.org/docs/max/i18n
*/
locale: {
// default zh-CN
default: 'zh-CN',
antd: true,
// default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true,
},
/**
*/ /**
* @name antd 插件
* @description 内置了 babel import 插件
* @doc https://umijs.org/docs/max/antd#antd
Expand All @@ -125,7 +114,10 @@ export default defineConfig({
*/
headScripts: [
// 解决首次加载时白屏的问题
{ src: '/scripts/loading.js', async: true },
{
src: '/scripts/loading.js',
async: true,
},
],
//================ pro 插件配置 =================
presets: ['umi-presets-pro'],
Expand Down
4 changes: 2 additions & 2 deletions config/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const Settings: ProLayoutProps & {
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
title: 'Ant Design Pro',
title: '在线管理系统',
pwa: true,
logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg',
logo: '/logo.svg',
iconfontUrl: '',
token: {
// 参见ts声明,demo 见文档,通过token 修改样式
Expand Down
63 changes: 13 additions & 50 deletions config/routes.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,26 @@
/**
* @name umi 的路由配置
* @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置
* @param path path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。
* @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径,也可以是相对路径,如果是相对路径,会从 src/pages 开始找起。
* @param routes 配置子路由,通常在需要为多个路径增加 layout 组件时使用。
* @param redirect 配置路由跳转
* @param wrappers 配置路由组件的包装组件,通过包装组件可以为当前的路由组件组合进更多的功能。 比如,可以用于路由级别的权限校验
* @param name 配置路由的标题,默认读取国际化文件 menu.ts 中 menu.xxxx 的值,如配置 name 为 login,则读取 menu.ts 中 menu.login 的取值作为标题
* @param icon 配置路由的图标,取值参考 https://ant.design/components/icon-cn, 注意去除风格后缀和大小写,如想要配置图标为 <StepBackwardOutlined /> 则取值应为 stepBackward 或 StepBackward,如想要配置图标为 <UserOutlined /> 则取值应为 user 或者 User
* @doc https://umijs.org/docs/guides/routes
*/
import component from "@/locales/bn-BD/component";

export default [
{
path: '/user',
layout: false,
routes: [
{
name: 'login',
path: '/user/login',
component: './User/Login',
},
],
},
{
path: '/welcome',
name: 'welcome',
icon: 'smile',
component: './Welcome',
routes: [{ name: '登录', path: '/user/login', component: './User/Login' }],
},
{ path: '/welcome', name: '欢迎', icon: 'smile', component: './Welcome' },
{ path: '/dashboard/workplace', name: '工作台', icon: 'dashboard', component: './dashboard'},
{
path: '/admin',
name: 'admin',
name: '管理页',
icon: 'crown',
access: 'canAdmin',
routes: [
{
path: '/admin',
redirect: '/admin/sub-page',
},
{
path: '/admin/sub-page',
name: 'sub-page',
component: './Admin',
},
{ path: '/admin', redirect: '/admin/sub-page' },
{ path: '/admin/sub-page', name: '二级管理页', component: './Admin' },
],
},
{
name: 'list.table-list',
icon: 'table',
path: '/list',
component: './TableList',
},
{
path: '/',
redirect: '/welcome',
},
{
path: '*',
layout: false,
component: './404',
},
{ name: '设备列表', icon: 'table', path: '/list/device-list', component: './TableList' },
{ name: '设备分组', icon: 'table', path: '/list/group-list', component: './TableList/group' },
{ name: '记录列表', icon: 'table', path: '/list/basic-list', component: './TableList/list' },
{ path: '/', redirect: '/welcome' },
{ path: '*', layout: false, component: './404' },
];
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module app

go 1.22.2

require (
github.com/gorilla/websocket v1.5.1
golang.org/x/sys v0.19.0
)

require golang.org/x/net v0.17.0 // indirect
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 1 addition & 1 deletion public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/logo2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 24 additions & 5 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Footer, Question, SelectLang, AvatarDropdown, AvatarName } from '@/components';
import { AvatarDropdown, AvatarName, Footer, Question } from '@/components';
import { currentUser as queryCurrentUser } from '@/services/ant-design-pro/api';
import { LinkOutlined } from '@ant-design/icons';
import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import { SettingDrawer } from '@ant-design/pro-components';
import type { RunTimeLayoutConfig } from '@umijs/max';
import { history, Link } from '@umijs/max';
import { Link, history } from '@umijs/max';
import defaultSettings from '../config/defaultSettings';
import { errorConfig } from './requestErrorConfig';
import { currentUser as queryCurrentUser } from '@/services/ant-design-pro/api';
import React from 'react';
const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login';

Expand Down Expand Up @@ -50,7 +49,7 @@ export async function getInitialState(): Promise<{
// ProLayout 支持的api https://procomponents.ant.design/components/layout
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
return {
actionsRender: () => [<Question key="doc" />, <SelectLang key="SelectLang" />],
actionsRender: () => [<Question key="doc" />],
avatarProps: {
src: initialState?.currentUser?.avatar,
title: <AvatarName />,
Expand Down Expand Up @@ -131,6 +130,26 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
* 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。
* @doc https://umijs.org/docs/max/request#配置
*/
/**
*
* 对request进行运行时配置,并且该配置会直接透传到umi-request的全局配置。
* 后续直接从umi中引入request或者useRequest直接使用,可以说是非常方便。
*/

/** 请求拦截 */
const requestInterceptor = (url: any, options: any): any => {
const headers = {
...options.headers,
//此处需要修改一下逻辑判断
Authorization: localStorage.getItem('authToken') || '1213',
};
return {
url: url,
options: { ...options, headers: headers },
};
};

export const request = {
...errorConfig,
requestInterceptors: [requestInterceptor], //请求拦截
};
30 changes: 15 additions & 15 deletions src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ const Footer: React.FC = () => {
background: 'none',
}}
links={[
// {
// key: 'Pro',
// title: 'Pro',
// href: '',
// blankTarget: true,
// },
// {
// key: '@@@',
// title: <GithubOutlined />,
// href: '',
// blankTarget: true,
// },
{
key: 'Ant Design Pro',
title: 'Ant Design Pro',
href: 'https://pro.ant.design',
blankTarget: true,
},
{
key: 'github',
title: <GithubOutlined />,
href: 'https://github.com/ant-design/ant-design-pro',
blankTarget: true,
},
{
key: 'Ant Design',
title: 'Ant Design',
href: 'https://ant.design',
key: 'copyright',
title: "2024",
href: '',
blankTarget: true,
},
]}
Expand Down
12 changes: 4 additions & 8 deletions src/components/RightContent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { QuestionCircleOutlined } from '@ant-design/icons';
import { SelectLang as UmiSelectLang } from '@umijs/max';
import React from 'react';

import '@umijs/max';
export type SiderTheme = 'light' | 'dark';

export const SelectLang = () => {
return (
<UmiSelectLang
Expand All @@ -13,17 +10,16 @@ export const SelectLang = () => {
/>
);
};

export const Question = () => {
return (
<div
style={{
display: 'flex',
height: 26,
}}
onClick={() => {
window.open('https://pro.ant.design/docs/getting-started');
}}
// onClick={() => {
// window.open('https://pro.ant.design/docs/getting-started');
// }}
>
<QuestionCircleOutlined />
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* 布局组件
*/
import Footer from './Footer';
import { Question, SelectLang } from './RightContent';
import { Question } from './RightContent';
import { AvatarDropdown, AvatarName } from './RightContent/AvatarDropdown';

export { Footer, Question, SelectLang, AvatarDropdown, AvatarName };
export { AvatarDropdown, AvatarName, Footer, Question };
Loading
Loading