build(frontend): 添加不同环境的环境变量配置文件
添加开发、预发和生产环境的环境变量配置文件,包含端口、代理路径和API基地址等配置项
This commit is contained in:
@ -117,7 +117,7 @@ export default function Logs() {
|
||||
<PageHeader items={["系统管理","日志管理"]} title="" />
|
||||
<Form form={form} layout="inline" onFinish={() => fetchData(1, pageSize)} style={{ marginBottom: 12 }}>
|
||||
<Form.Item label="请求路径" name="path">
|
||||
<Input placeholder="like /users" allowClear style={{ width: 260 }} />
|
||||
<Input placeholder="like /users" allowClear style={{ width: 320 }} />
|
||||
</Form.Item>
|
||||
<Form.Item label="发起时间" name="time">
|
||||
<DatePicker.RangePicker showTime allowClear />
|
||||
|
||||
@ -448,7 +448,7 @@ export default function Menus(){
|
||||
|
||||
<Form form={searchForm} layout="inline" onFinish={(vals: any)=>{ const kw = String(vals?.keyword ?? '').trim(); setKeyword(kw); fetchMenus(kw) }} style={{ marginBottom: 12 }}>
|
||||
<Form.Item name="keyword">
|
||||
<Input allowClear placeholder="搜索菜单名称/路径/权限" style={{ width: 360 }} />
|
||||
<Input allowClear placeholder="搜索菜单名称/路径/权限" style={{ width: 320 }} />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space>
|
||||
|
||||
@ -346,9 +346,9 @@ export default function Users(){
|
||||
columns={columns}
|
||||
pagination={{ current: page, pageSize, total, showSizeChanger: true, onChange: (p: number, ps?: number) => fetchUsers(p, ps ?? pageSize, keyword) }}
|
||||
/>
|
||||
<Typography.Paragraph type="secondary" style={{ marginTop: 12 }}>
|
||||
{/* <Typography.Paragraph type="secondary" style={{ marginTop: 12 }}>
|
||||
提示:此页面已支持分页、创建、编辑与重置密码。
|
||||
</Typography.Paragraph>
|
||||
</Typography.Paragraph> */}
|
||||
|
||||
<Modal title="新增用户" open={createOpen} onOk={handleCreate} onCancel={() => setCreateOpen(false)} okText="创建" width={840}>
|
||||
<Form form={form} layout="horizontal" labelCol={{ span: 2 }} wrapperCol={{ span: 22 }} labelAlign="right">
|
||||
|
||||
@ -7,11 +7,9 @@ export type ApiResp<T> = { code: number; message?: string; data?: T }
|
||||
// 在请求配置上携带一次性重试标记
|
||||
type RetryConfig = InternalAxiosRequestConfig & { _retry?: boolean }
|
||||
|
||||
// 使用 Vite 的环境变量类型
|
||||
const isDev = import.meta.env.DEV
|
||||
const configuredBase = import.meta.env?.VITE_API_BASE || ''
|
||||
const baseURL = isDev ? '' : configuredBase
|
||||
const api: AxiosInstance = axios.create({ baseURL: baseURL ? `${baseURL}/api` : '/api', withCredentials: true })
|
||||
// 从 .env 读取 VITE_API_BASE,若未配置则回退到相对路径 /api
|
||||
const configuredBase = (import.meta.env?.VITE_API_BASE as string | undefined)?.trim() || ''
|
||||
const api: AxiosInstance = axios.create({ baseURL: configuredBase ? `${configuredBase}/api` : '/api', withCredentials: true })
|
||||
|
||||
let isRefreshing = false
|
||||
let pendingQueue: { resolve: () => void; reject: (e: unknown) => void; config: RetryConfig }[] = []
|
||||
|
||||
Reference in New Issue
Block a user