Skip to content

Commit

Permalink
Merge branch 'dev' into feat/manual-action
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban authored Nov 27, 2024
2 parents 238a47b + 970aced commit 6429eae
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 157 deletions.
7 changes: 3 additions & 4 deletions apps/renderer/src/hooks/biz/useRouteParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ const parseRouteParams = (params: Params<any>, search: URLSearchParams): BizRout
}

export const useRouteParams = () => {
const params = useParams()
const [search] = useSearchParams()

return parseRouteParams(params, search)
return useRouteParamsSelector((s) => s)
}

const noop = [] as any[]

export const useRouteParamsSelector = <T>(
selector: (params: BizRouteParams) => T,
deps = noop,
Expand Down
5 changes: 2 additions & 3 deletions apps/renderer/src/modules/entry-column/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ export const useEntriesByView = ({
onReset?: () => void
isArchived?: boolean
}) => {
const routeParams = useRouteParams()
const unreadOnly = useGeneralSettingKey("unreadOnly")
const { feedId, isAllFeeds, view, isCollection, inboxId, listId } = useRouteParams()

const { feedId, view, isAllFeeds, isCollection, listId, inboxId } = routeParams
const unreadOnly = useGeneralSettingKey("unreadOnly")

const folderIds = useFolderFeedsByFeedId({
feedId,
Expand Down
15 changes: 0 additions & 15 deletions apps/renderer/src/pages/(external)/layout.tsx

This file was deleted.

125 changes: 0 additions & 125 deletions apps/renderer/src/pages/(external)/login.tsx

This file was deleted.

1 change: 0 additions & 1 deletion apps/renderer/src/store/feed/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export const useInboxByIdSelector = <T>(

export const useFeedHeaderTitle = () => {
const { t } = useTranslation()

const { feedId: currentFeedId, view, listId, inboxId } = useRouteParams()

const listTitle = useListByIdSelector(listId, getPreferredTitle)
Expand Down
4 changes: 2 additions & 2 deletions apps/server/client/pages/(login)/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ function Login() {
) : (
<>
<Button
className="h-[48px] w-[320px] rounded-[8px] !bg-black font-sans text-base text-white hover:!bg-black/80 focus:!border-black/80 focus:!ring-black/80"
buttonClassName="h-[48px] w-[320px] rounded-[8px] !bg-black font-sans text-base text-white hover:!bg-black/80 focus:!border-black/80 focus:!ring-black/80"
onClick={() => {
loginHandler("github")
}}
>
<i className="i-mgc-github-cute-fi mr-2 text-xl" /> {t("login.continueWithGitHub")}
</Button>
<Button
className="h-[48px] w-[320px] rounded-[8px] bg-blue-500 font-sans text-base text-white hover:bg-blue-500/90 focus:!border-blue-500/80 focus:!ring-blue-500/80"
buttonClassName="h-[48px] w-[320px] rounded-[8px] bg-blue-500 font-sans text-base text-white hover:bg-blue-500/90 focus:!border-blue-500/80 focus:!ring-blue-500/80"
onClick={() => {
loginHandler("google")
}}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dev:debug": "export DEBUG=true && vite --debug",
"dev:server": "pnpm run --filter=server dev",
"dev:web": "vite",
"dev:web-with-server": "turbo run @follow/web#dev @follow/server#dev",
"format": "prettier --write .",
"format:check": "prettier --check .",
"generator:i18n-template": "tsx scripts/generate-i18n-locale.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/atoms/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { atom, useAtomValue } from "jotai"
import { selectAtom } from "jotai/utils"
import { useMemo } from "react"
import type { Location, NavigateFunction, Params } from "react-router"
import { shallow } from "zustand/shallow"

interface RouteAtom {
params: Readonly<Params<string>>
Expand All @@ -29,7 +30,8 @@ const noop = []
export const useReadonlyRouteSelector = <T>(
selector: (route: RouteAtom) => T,
deps: any[] = noop,
): T => useAtomValue(useMemo(() => selectAtom(routeAtom, (route) => selector(route)), deps))
): T =>
useAtomValue(useMemo(() => selectAtom(routeAtom, (route) => selector(route), shallow), deps))

// Vite HMR will create new router instance, but RouterProvider always stable

Expand Down
50 changes: 44 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url"
import legacy from "@vitejs/plugin-legacy"
import { minify as htmlMinify } from "html-minifier-terser"
import { cyan, dim, green } from "kolorist"
import { parseHTML } from "linkedom"
import type { PluginOption, ViteDevServer } from "vite"
import { defineConfig, loadEnv } from "vite"
import { analyzer } from "vite-bundle-analyzer"
Expand Down Expand Up @@ -65,17 +66,54 @@ export default ({ mode }) => {
watch: {
ignored: ["**/dist/**", "**/out/**", "**/public/**", ".git/**"],
},
...(env.VITE_DEV_PROXY
? {
proxy: {
proxy: {
"/login": {
target: "http://localhost:2234",
changeOrigin: true,
selfHandleResponse: true,
configure: (proxy, _options) => {
proxy.on("proxyRes", (proxyRes, req, res) => {
const body = [] as any[]
proxyRes.on("data", (chunk: any) => body.push(chunk))
proxyRes.on("end", () => {
const html = parseHTML(Buffer.concat(body).toString())
const doc = html.document

const $scripts = doc.querySelectorAll("script")
$scripts.forEach((script) => {
const src = script.getAttribute("src")
if (src) {
script.setAttribute("src", `http://localhost:2234${src}`)
}
})

const $links = doc.querySelectorAll("link")
$links.forEach((link) => {
const href = link.getAttribute("href")
if (href) {
link.setAttribute("href", `http://localhost:2234${href}`)
}
})

res.setHeader("Content-Type", "text/html; charset=utf-8")

const modifiedHtml = doc.toString()
res.end(modifiedHtml)
})
})
},
},

...(env.VITE_DEV_PROXY
? {
[env.VITE_DEV_PROXY]: {
target: env.VITE_DEV_PROXY_TARGET,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${env.VITE_DEV_PROXY}`), ""),
},
},
}
: {}),
}
: {}),
},
},
resolve: {
alias: {
Expand Down

0 comments on commit 6429eae

Please sign in to comment.