Skip to content

Commit

Permalink
bugfix visi (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
zizdlp authored Aug 25, 2024
1 parent c5ea813 commit d33896f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
14 changes: 3 additions & 11 deletions zbook_backend/gapi/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,24 +272,16 @@ func (server *Server) LogRedisVisitor(ctx context.Context) (err error) {
UserAgent := mtdt.UserAgent
ClientIp := mtdt.ClientIP

if strings.HasPrefix(ClientIp, "::1") {
ClientIp = "127.0.0.1" + strings.TrimPrefix(ClientIp, "::1")
}
// 分隔ClientIp并取第一个部分
if ClientIp == "" {
ClientIp = "unknown"
} else {
// 分隔ClientIp并取第一个部分
ClientIpParts := strings.Split(ClientIp, ",")
ClientIp = ClientIpParts[0]
}
ClientIpParts := strings.Split(ClientIp, ",")
ClientIp = ClientIpParts[0]
location, err := time.LoadLocation(server.config.TIMEZONE)
if err != nil {
return fmt.Errorf("failed to load location:%v", err)
}
today := time.Now().In(location).Format("2006-01-02")
redisKey := fmt.Sprintf("%s:%s:%s:%s", "logvisitor", ClientIp, UserAgent, today)
log.Info().Msgf("inser to redis: %s", redisKey)
log.Info().Msgf("insert key: %s", redisKey)
return server.insertRedisKey(redisKey, 1000000, 24*31) //保留31天,设置较大使用限制
}

Expand Down
2 changes: 1 addition & 1 deletion zbook_backend/statik/statik.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion zbook_frontend/src/components/navbars/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function NavBar() {
return (
<div
className="sticky top-0 flex justify-center z-50
xl:border-b border-slate-900/10 dark:border-slate-50/[0.06]
xl:border-b border-slate-900/10 dark:border-slate-50/[0.06] print:hidden
backdrop-blur-xl xl:backdrop-blur supports-backdrop-blur:bg-white/60 bg-transparent"
>
<div
Expand Down
19 changes: 16 additions & 3 deletions zbook_frontend/src/components/sidebars/RepoSideBarSettting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Anchor } from "@/types/interface";
import RepoSideBarSettingItem from "./RepoSideBarSetttingItem";
import { FaDiscord, FaGithub } from "react-icons/fa";
import { ThemeColor } from "../TableOfContent";

import { usePathname } from "@/navigation";
export default function RepoSideBarSetting({
username,
reponame,
Expand All @@ -29,6 +29,19 @@ export default function RepoSideBarSetting({
visibility_level: string;
theme_color: ThemeColor;
}) {
const pathname = usePathname();
let page_type = "";
if (pathname !== undefined) {
const regex = new RegExp(
`^\/([^\/]+)?\/?workspace\/${username}\/(?:[^\/]*)\/(?:[^\/]*)\/([^\/]*)`
);
const matches = pathname.match(regex);
if (matches) {
page_type = matches[2] || "";
}
console.log("page_type:", page_type);
}

const t = useTranslations("SideBar");
async function manualSyncRepoHandler() {
const id = toast(t("SynchronizingRepository"), {
Expand Down Expand Up @@ -70,7 +83,7 @@ export default function RepoSideBarSetting({
<>
<RepoSideBarSettingItem
href={`/workspace/${username}/o/${reponame}`}
selected={true}
selected={page_type != "~visi"}
icon={IoBook}
text={t("RepoHome")}
theme_color={theme_color}
Expand All @@ -92,7 +105,7 @@ export default function RepoSideBarSetting({
<RepoSideBarSettingItem
href={`/workspace/${username}/o/${reponame}/~visi`}
text={t("VisibleTo")}
selected={false}
selected={page_type == "~visi"}
icon={MdOutlineVisibility}
theme_color={theme_color}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function SideBarToggleSmall() {
);
return (
<div
className={`lg:hidden fixed bottom-5 z-50 right-5 h-11 w-11 rounded-md backdrop-blur-sm`}
className={`lg:hidden fixed bottom-5 z-50 right-5 h-11 w-11 rounded-md backdrop-blur-sm print:hidden`}
>
<IconText
Icon={sideBarOpen === false ? RiMenuLine : RiMenu4Line}
Expand Down

0 comments on commit d33896f

Please sign in to comment.