From 552357b004332dbb0fc80e033dffe1f21590714f Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 16 May 2023 09:26:43 +0800 Subject: [PATCH 1/4] set package.json` type`to ` module` --- modules/web/package.json | 1 + modules/web/vite.config.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/web/package.json b/modules/web/package.json index 64664a545..a654bc818 100644 --- a/modules/web/package.json +++ b/modules/web/package.json @@ -2,6 +2,7 @@ "name": "legado-web", "version": "1.0.0", "private": true, + "type": "module", "engines": { "node": ">=16", "pnpm": ">=8" diff --git a/modules/web/vite.config.js b/modules/web/vite.config.js index db4479ef7..a25828f84 100644 --- a/modules/web/vite.config.js +++ b/modules/web/vite.config.js @@ -1,4 +1,4 @@ -import { resolve } from "path"; +import { fileURLToPath, URL } from "node:url"; import { defineConfig, splitVendorChunkPlugin } from "vite"; import vue from "@vitejs/plugin-vue"; import Icons from "unplugin-icons/vite"; @@ -47,9 +47,9 @@ export default ({ mode }) => }, resolve: { alias: { - "@": resolve(__dirname, "./src"), - "@api": resolve(__dirname, "./src/api"), - "@utils": resolve(__dirname, "./src/utils/"), + "@": fileURLToPath(new URL("./src", import.meta.url)), + "@api": fileURLToPath(new URL("./src/api", import.meta.url)), + "@utils": fileURLToPath(new URL("./src/utils/", import.meta.url)), }, }, }); From bc8179eb580e1f2dcb97673b0788020b615562af Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 16 May 2023 10:02:01 +0800 Subject: [PATCH 2/4] [skip ci]modules:web auto cp dist files --- .github/workflows/web.yml | 7 +------ modules/web/package.json | 2 +- modules/web/scripts/sync.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 modules/web/scripts/sync.js diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 3ad6f172b..27ef4d224 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -49,15 +49,10 @@ jobs: ${{ runner.os }}-pnpm-store- - name: Build and move files + - working-directory: $GITHUB_WORKSPACE/modules/web run: | - rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/source - rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/bookshelf - rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/vue - mkdir $GITHUB_WORKSPACE/app/src/main/assets/web/vue - cd $GITHUB_WORKSPACE/modules/web pnpm i pnpm build - mv -f ./dist/* $GITHUB_WORKSPACE/app/src/main/assets/web/vue/ version="v$(date -d "8 hour" -u +3.%y.%m%d%H)" echo "APP_VER=$version" >> $GITHUB_ENV diff --git a/modules/web/package.json b/modules/web/package.json index a654bc818..edc9c46db 100644 --- a/modules/web/package.json +++ b/modules/web/package.json @@ -9,7 +9,7 @@ }, "scripts": { "dev": "vite", - "build": "vite build", + "build": "vite build && node scripts/sync.js", "preview": "vite preview", "lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" }, diff --git a/modules/web/scripts/sync.js b/modules/web/scripts/sync.js new file mode 100644 index 000000000..8c2cd0719 --- /dev/null +++ b/modules/web/scripts/sync.js @@ -0,0 +1,28 @@ +import { URL } from "node:url"; +import fs from "node:fs"; + +const LEGADO_ASSETS_WEB_VUE_DIR = new URL("../../../legado/app/src/main/assets/web/vue", import.meta.url) +const VUE_DIST_DIR = new URL("../dist", import.meta.url) + +console.log("> delete", LEGADO_ASSETS_WEB_VUE_DIR.pathname) +// 删除 +fs.rm(LEGADO_ASSETS_WEB_VUE_DIR, { + force: true, + recursive: true +}, (error) => { + if (error) console.log(error); + console.log("> mkdir", LEGADO_ASSETS_WEB_VUE_DIR.pathname); + fs.mkdir(LEGADO_ASSETS_WEB_VUE_DIR, error => { + if (error) return console.error(error) + console.log("> cp dist files") + fs.cp(VUE_DIST_DIR, LEGADO_ASSETS_WEB_VUE_DIR, { + recursive: true + }, (error) => { + if (error) { + console.warn("> cp error, you may copy files yourshelf"); + throw error; + } + console.log("> cp success") + }) + }) +}); \ No newline at end of file From 2cbf6e5aecc53369f0afe83c806b43b5d0dc2dea Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 16 May 2023 10:46:06 +0800 Subject: [PATCH 3/4] [skip ci]modules:web auto cp dist files --- modules/web/scripts/sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/web/scripts/sync.js b/modules/web/scripts/sync.js index 8c2cd0719..fb61acf81 100644 --- a/modules/web/scripts/sync.js +++ b/modules/web/scripts/sync.js @@ -1,7 +1,7 @@ import { URL } from "node:url"; import fs from "node:fs"; -const LEGADO_ASSETS_WEB_VUE_DIR = new URL("../../../legado/app/src/main/assets/web/vue", import.meta.url) +const LEGADO_ASSETS_WEB_VUE_DIR = new URL("../../../app/src/main/assets/web/vue", import.meta.url) const VUE_DIST_DIR = new URL("../dist", import.meta.url) console.log("> delete", LEGADO_ASSETS_WEB_VUE_DIR.pathname) From 7cafa41ac3da0911fff3ea95763f7588d26b957a Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 16 May 2023 10:56:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[skip=20ci]=20=E7=99=BB=E5=BD=95=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=94=AF=E6=8C=81=E7=9B=B8=E5=AF=B9=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/login/WebViewLoginFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt b/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt index 4b8d608dd..429e32193 100644 --- a/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt +++ b/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt @@ -17,6 +17,7 @@ import io.legado.app.databinding.FragmentWebViewLoginBinding import io.legado.app.help.http.CookieStore import io.legado.app.lib.theme.accentColor import io.legado.app.utils.gone +import io.legado.app.utils.NetworkUtils import io.legado.app.utils.snackbar import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -47,7 +48,8 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) { binding.titleBar.snackbar(R.string.check_host_cookie) viewModel.source?.let { source -> source.loginUrl?.let { - binding.webView.loadUrl(it, source.getHeaderMap(true)) + val absoluteUrl = NetworkUtils.getAbsoluteURL(source.getKey(), it) + binding.webView.loadUrl(absoluteUrl, source.getHeaderMap(true)) } } }