This commit is contained in:
2026-03-05 11:00:46 +08:00
parent ec8bd3967d
commit 15275b4ff3
6 changed files with 40 additions and 7 deletions

View File

@@ -37,7 +37,7 @@ export const getFileUrl = (code?: string, appendBaseUrl = true) => {
if (!code) {
return;
}
const url = `/anon/file/download/${code}?time=` + Date.now();
const url = `/file/download/${code}?time=` + Date.now();
if (appendBaseUrl && baseUrl != "/") {
return baseUrl + url;
}
@@ -157,7 +157,7 @@ export const modifyFileStatus = (data: any) => {
};
export const getShareFileList = ({ shareId, ...params }: any) => {
return http.get(`/anon/share_user_file/${shareId}`, { params });
return http.get(`/share_user_file/${shareId}`, { params });
};
export const getDiffRiskRule = (fileCode: string) => {

View File

@@ -67,10 +67,18 @@ export const setupInterceptors = (instance: AxiosInstance) => {
return Promise.resolve(res.data);
}
// 未登录、登录超时、无权访问,重定向到登录页面
if (["401", "402"].includes(code)) {
if (
["401", "402"].includes(code) &&
router.state.location.pathname !== "/login"
) {
toast.error(msg || "未登录/无权限");
useUserStore.setState({ token: null });
router.navigate({ to: "/login", replace: true });
router.navigate({
to:
"/login?redirect=" +
encodeURIComponent(encodeURIComponent(router.state.location.href)),
replace: true,
});
return Promise.reject();
}
// token变更

View File

@@ -61,7 +61,7 @@ export function ViewLinkDialog({ open, setOpen, data }: ViewLinkDialogProps) {
<div className="grid w-full items-center gap-2">
<Label>分享内容</Label>
<div className="flex items-center gap-2">
<Textarea value={shareLink} disabled />
<Textarea value={shareLink} disabled className="min-h-[100px]" />
</div>
</div>
</div>

View File

@@ -24,6 +24,8 @@ import { useMutation } from "@tanstack/react-query";
import { Spinner } from "@/components/ui/spinner";
import { toast } from "sonner";
import { TriangleAlert } from "lucide-react";
import { useIsLoggedIn } from "@/stores/user";
import { Navigate, useLocation } from "@tanstack/react-router";
export const Route = createFileRoute("/extract/")({
component: RouteComponent,
@@ -79,6 +81,20 @@ function RouteComponent() {
);
};
const isLoggedIn = useIsLoggedIn();
const location = useLocation();
if (!isLoggedIn && location.pathname === "/extract") {
return (
<Navigate
to={
"/login?redirect=" +
encodeURIComponent(encodeURIComponent(location.href))
}
/>
);
}
return (
<div className="flex items-center justify-center min-h-screen box-border">
<div>

View File

@@ -49,11 +49,20 @@ function RouteComponent() {
mutationFn: login,
onSuccess(res) {
useUserStore.setState({ token: res.data.token });
router.navigate({ to: "/", replace: true });
router.navigate({
to: decodeURIComponent(
decodeURIComponent(router.state.location.search.redirect || "/"),
),
replace: true,
});
},
});
const onSubmit = (values: z.infer<typeof formSchema>) => {
console.log(
"router.state.location.search.redirect=======",
router.state.location.search.redirect,
);
const promise = mutateAsync({
...values,
userType: 1,

View File

@@ -27,7 +27,7 @@ export default defineConfig({
proxy: {
"/api": {
// target: "http://192.168.71.2:8080/", // 家
target: "http://192.168.1.28:8080/", // 公司
target: "http://192.168.1.23:8080/", // 公司
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
}