fix(basepath): add basepath

This commit is contained in:
zhangheng
2026-02-28 15:43:50 +08:00
parent bcf46df7ec
commit 4aa29b80d1
14 changed files with 72 additions and 49 deletions

View File

@@ -1,4 +1,6 @@
NEXT_PUBLIC_BASE_PATH="" NEXT_PUBLIC_BASE_PATH="/label"
# NEXT_PUBLIC_BASE_PATH=""
NEXT_PUBLIC_ENV=development NEXT_PUBLIC_ENV=development

View File

@@ -1,4 +1,5 @@
NEXT_PUBLIC_BASE_PATH="" NEXT_PUBLIC_BASE_PATH=""
NEXT_PUBLIC_BASE_PATH="/label"
NEXT_PUBLIC_ENV=staging NEXT_PUBLIC_ENV=staging

View File

@@ -79,7 +79,7 @@ async function httpfetch<T>(options: OptionsProps): Promise<T> {
} }
const pathList = options.url.split("/") const pathList = options.url.split("/")
const request = new Request( const request = new Request(
`/api/${options.isFormData ? "transferFormData" : "transfer"}/${pathList[pathList.length - 1]}`, `${process.env.NEXT_PUBLIC_BASE_PATH}/api/${options.isFormData ? "transferFormData" : "transfer"}/${pathList[pathList.length - 1]}`,
myInit myInit
) )
return request return request

View File

@@ -105,7 +105,9 @@ export const processVideo = async (
const prefix = sanitizePrefix( const prefix = sanitizePrefix(
params.namePrefix || stripFileExt(params.fileName) params.namePrefix || stripFileExt(params.fileName)
) )
const baseURL = params.baseURL || `${window.location.origin}/wasm` const baseURL =
params.baseURL ||
`${window.location.origin}${process.env.NEXT_PUBLIC_BASE_PATH}/wasm`
const inputFile = base64ToFile(params.base64Data, params.fileName) const inputFile = base64ToFile(params.base64Data, params.fileName)
const worker = new Worker( const worker = new Worker(

View File

@@ -2,7 +2,7 @@
import { import {
deleteDailyWorkData, deleteDailyWorkData,
getDailyWorkList, getSelfDailyWorkList,
} from "@/components/label/api/daily" } from "@/components/label/api/daily"
import { Daily } from "@/components/label/api/daily/typing" import { Daily } from "@/components/label/api/daily/typing"
import { getSelfProjectList } from "@/components/label/api/project" import { getSelfProjectList } from "@/components/label/api/project"
@@ -201,7 +201,7 @@ export default function PersonReportPage() {
if (!queryTrigger) return if (!queryTrigger) return
setLoading(true) setLoading(true)
try { try {
const res = await getDailyWorkList(queryParams) const res = await getSelfDailyWorkList(queryParams)
setRecords(res?.daily_work_list ?? []) setRecords(res?.daily_work_list ?? [])
setTotalItems(res?.total_items ?? 0) setTotalItems(res?.total_items ?? 0)
setSummary(res?.total_summary ?? null) setSummary(res?.total_summary ?? null)

View File

@@ -2,7 +2,7 @@
import { import {
deleteDailyWorkData, deleteDailyWorkData,
getDailyWorkList, getTeamDailyWorkList,
lockDailyWorkData, lockDailyWorkData,
} from "@/components/label/api/daily" } from "@/components/label/api/daily"
import { Daily } from "@/components/label/api/daily/typing" import { Daily } from "@/components/label/api/daily/typing"
@@ -163,7 +163,7 @@ export default function TeamDailypaperPage() {
if (!queryTrigger) return if (!queryTrigger) return
setLoading(true) setLoading(true)
try { try {
const res = await getDailyWorkList(queryParams) const res = await getTeamDailyWorkList(queryParams)
setRecords(res?.daily_work_list ?? []) setRecords(res?.daily_work_list ?? [])
setTotalItems(res?.total_items ?? 0) setTotalItems(res?.total_items ?? 0)
setSummary(res?.total_summary ?? null) setSummary(res?.total_summary ?? null)

View File

@@ -4,7 +4,7 @@ import { getUserList } from "@/components/label/api/user"
import { User } from "@/components/label/api/user/typing" import { User } from "@/components/label/api/user/typing"
import useAuth from "@/components/label/hooks/useAuth" import useAuth from "@/components/label/hooks/useAuth"
import { useAllUserStore } from "@/components/label/store/auth" import { useAllUserStore } from "@/components/label/store/auth"
import { Badge, Button, Group, Paper, Stack, TextInput } from "@mantine/core" import { Button, Group, Paper, Stack, TextInput } from "@mantine/core"
import { notifications } from "@mantine/notifications" import { notifications } from "@mantine/notifications"
import { IconEdit, IconRefresh, IconSearch } from "@tabler/icons-react" import { IconEdit, IconRefresh, IconSearch } from "@tabler/icons-react"
import { DataTable, DataTableColumn } from "mantine-datatable" import { DataTable, DataTableColumn } from "mantine-datatable"
@@ -30,7 +30,10 @@ export default function TeamEmployeePage() {
const [importOpened, setImportOpened] = useState(false) const [importOpened, setImportOpened] = useState(false)
const [selectedUser, setSelectedUser] = useState<User.UserInfo | null>(null) const [selectedUser, setSelectedUser] = useState<User.UserInfo | null>(null)
const [queryTrigger, setQueryTrigger] = useState(0)
const load = useCallback(async () => { const load = useCallback(async () => {
if (!queryTrigger) return
try { try {
setLoading(true) setLoading(true)
const params: User.ListRequest = { const params: User.ListRequest = {
@@ -52,48 +55,53 @@ export default function TeamEmployeePage() {
} finally { } finally {
setLoading(false) setLoading(false)
} }
}, [appliedName, page, pageSize]) }, [appliedName, page, pageSize, queryTrigger])
useEffect(() => { useEffect(() => {
queueMicrotask(load) load()
}, [load]) }, [load])
useEffect(() => {
queueMicrotask(() => {
setQueryTrigger((v) => v + 1)
})
}, [])
const columns = useMemo(() => { const columns = useMemo(() => {
const cols: DataTableColumn<User.UserInfo>[] = [ const cols: DataTableColumn<User.UserInfo>[] = [
{ accessor: "uid", title: "UID", width: 120, textAlign: "center" }, { accessor: "uid", title: "UID", width: 80, textAlign: "center" },
{ accessor: "name", title: "姓名", width: 120, textAlign: "center" }, { accessor: "name", title: "姓名", width: 140, textAlign: "center" },
{ // {
accessor: "work_status", // accessor: "work_status",
title: "状态", // title: "状态",
width: 100, // width: 100,
textAlign: "center", // textAlign: "center",
render: (record) => // render: (record) =>
record.work_status === 1 ? ( // record.work_status === 1 ? (
<Badge color="green" variant="light"> // <Badge color="green" variant="light">
// 在职
</Badge> // </Badge>
) : ( // ) : (
<Badge color="gray" variant="light"> // <Badge color="gray" variant="light">
// 离职
</Badge> // </Badge>
), // ),
}, // },
{ // {
accessor: "group_name", // accessor: "group_name",
title: "组织", // title: "组织",
width: 180, // width: 180,
textAlign: "center", // textAlign: "center",
}, // },
{ {
accessor: "base_city", accessor: "base_city",
title: "所在地", title: "所在地",
width: 180,
textAlign: "center", textAlign: "center",
}, },
{ {
accessor: "operation", accessor: "operation",
title: "操作", title: "操作",
width: 220, width: 140,
textAlign: "center", textAlign: "center",
render: (record) => ( render: (record) => (
<Group justify="center" gap={4} wrap="nowrap"> <Group justify="center" gap={4} wrap="nowrap">
@@ -167,6 +175,7 @@ export default function TeamEmployeePage() {
onClick={() => { onClick={() => {
setAppliedName(name) setAppliedName(name)
setPage(1) setPage(1)
setQueryTrigger((v) => v + 1)
}}> }}>
</Button> </Button>
@@ -180,6 +189,7 @@ export default function TeamEmployeePage() {
setAppliedName("") setAppliedName("")
setPage(1) setPage(1)
setPageSize(20) setPageSize(20)
setQueryTrigger((v) => v + 1)
}}> }}>
</Button> </Button>
@@ -222,6 +232,7 @@ export default function TeamEmployeePage() {
<DataTable<User.UserInfo> <DataTable<User.UserInfo>
withTableBorder withTableBorder
withRowBorders withRowBorders
pinLastColumn
fetching={loading} fetching={loading}
records={records} records={records}
columns={columns} columns={columns}

View File

@@ -2,9 +2,16 @@ import httpFetch from "@/api/fetch"
import { Daily } from "./typing" import { Daily } from "./typing"
import { BASE_LABEL_API } from "../const" import { BASE_LABEL_API } from "../const"
export const getDailyWorkList = (data: Daily.Request) => { export const getSelfDailyWorkList = (data: Daily.Request) => {
return httpFetch<Daily.Response>({ return httpFetch<Daily.Response>({
url: BASE_LABEL_API + "/api/v1/label_server/daily_work/list", url: BASE_LABEL_API + "/api/v1/label_server/daily_work/list/self",
method: "POST",
body: JSON.stringify(data),
})
}
export const getTeamDailyWorkList = (data: Daily.Request) => {
return httpFetch<Daily.Response>({
url: BASE_LABEL_API + "/api/v1/label_server/daily_work/list/team",
method: "POST", method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
}) })

View File

@@ -1,8 +1,8 @@
import { Comment } from "./api/label/typing"
import { del, get, set } from "idb-keyval" import { del, get, set } from "idb-keyval"
import superjson from "superjson" import superjson from "superjson"
import { create } from "zustand" import { create } from "zustand"
import { persist, PersistStorage, StorageValue } from "zustand/middleware" import { persist, PersistStorage, StorageValue } from "zustand/middleware"
import { Comment } from "./api/label/typing"
type LabelData = Map<string, Map<string, [number, any[], any, any[]][]>> type LabelData = Map<string, Map<string, [number, any[], any, any[]][]>>
interface LabelState { interface LabelState {

View File

@@ -60,7 +60,7 @@ const FeishuAutoLogin = ({ useUserStore }: { useUserStore: any }) => {
access_token: info.access_token || "", access_token: info.access_token || "",
refresh_token: info.refresh_token || "", refresh_token: info.refresh_token || "",
}) })
window.location.href = "/" window.location.href = `${process.env.NEXT_PUBLIC_BASE_PATH}/`
} catch (err) { } catch (err) {
console.log(err) console.log(err)
} }

View File

@@ -57,7 +57,7 @@ const QrLogin = ({ useUserStore }: { useUserStore: any }) => {
access_token: info.access_token || "", access_token: info.access_token || "",
refresh_token: info.refresh_token || "", refresh_token: info.refresh_token || "",
}) })
window.location.href = "/" window.location.href = `${process.env.NEXT_PUBLIC_BASE_PATH}/`
} catch (err) { } catch (err) {
console.log(err) console.log(err)
} }

View File

@@ -204,7 +204,7 @@ export default function LoginPage({ useUserStore }: { useUserStore: any }) {
access_token: info.access_token || "", access_token: info.access_token || "",
refresh_token: info.refresh_token || "", refresh_token: info.refresh_token || "",
}) })
window.location.href = "/" window.location.href = `${process.env.NEXT_PUBLIC_BASE_PATH}/`
} catch (error) { } catch (error) {
if (error) { if (error) {
const message = const message =

View File

@@ -10,7 +10,7 @@
"prebuild:export-stage": "node scripts/disable-api-route.mjs", "prebuild:export-stage": "node scripts/disable-api-route.mjs",
"build:export-stage": "NEXT_PUBLIC_URL=http://172.16.112.8:9110 NEXT_PUBLIC_OUTPUT_TYPE=export env-cmd -f .env.staging next build --turbopack", "build:export-stage": "NEXT_PUBLIC_URL=http://172.16.112.8:9110 NEXT_PUBLIC_OUTPUT_TYPE=export env-cmd -f .env.staging next build --turbopack",
"postbuild:export-stage": "node scripts/restore-api-route.mjs", "postbuild:export-stage": "node scripts/restore-api-route.mjs",
"build:standalone-prod": "NEXT_PUBLIC_URL=https://frontside2.soft.cowarobot.com NEXT_PUBLIC_OUTPUT_TYPE=standalone env-cmd -f .env.production next build --turbopack", "build:standalone-prod": "NEXT_PUBLIC_URL=http://172.16.112.8:9110 NEXT_PUBLIC_OUTPUT_TYPE=standalone env-cmd -f .env.production next build --turbopack",
"prebuild:export-prod": "node scripts/disable-api-route.mjs", "prebuild:export-prod": "node scripts/disable-api-route.mjs",
"build:export-prod": "NEXT_PUBLIC_URL=http://172.16.112.8:9110 NEXT_PUBLIC_OUTPUT_TYPE=export env-cmd -f .env.production next build --turbopack", "build:export-prod": "NEXT_PUBLIC_URL=http://172.16.112.8:9110 NEXT_PUBLIC_OUTPUT_TYPE=export env-cmd -f .env.production next build --turbopack",
"postbuild:export-prod": "node scripts/restore-api-route.mjs", "postbuild:export-prod": "node scripts/restore-api-route.mjs",

View File

@@ -1,10 +1,10 @@
importScripts("/wasm/ffmpeg-core.js") importScripts(`${process.env.NEXT_PUBLIC_BASE_PATH}/wasm/ffmpeg-core.js`)
const originalCreateFFmpegCore = self.createFFmpegCore const originalCreateFFmpegCore = self.createFFmpegCore
self.createFFmpegCore = (moduleOverrides) => self.createFFmpegCore = (moduleOverrides) =>
originalCreateFFmpegCore({ originalCreateFFmpegCore({
...moduleOverrides, ...moduleOverrides,
INITIAL_MEMORY: 268435456, INITIAL_MEMORY: 268435456,
ALLOW_MEMORY_GROWTH: 1, ALLOW_MEMORY_GROWTH: 1,
}) })