From b0039f0946b02777ad99ad8c92f6555792aa8996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:22:08 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E9=96=8B=E7=99=BA=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=A7=E3=83=95=E3=83=AD=E3=83=B3=E3=83=88=E3=82=A8?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=81=A8=E3=83=90=E3=83=83=E3=82=AF=E3=82=A8?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=82=92=E7=8B=AC=E7=AB=8B=E3=81=97=E3=81=A6?= =?UTF-8?q?=E8=B5=B7=E5=8B=95=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B=EF=BC=88=E5=86=8D=EF=BC=89=20(#12593)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [wip]run standalone vite * [wip]run standalone vite * some fix (tabler icons, sw, streaming) * fix theme * fix run scripts * favicon * client-assets * cssの読み込み順序とCSP設定の変更 * fix lang change * fix clientManifest * baseを相対パスにしてドメイン直下とサブディレクトリ配下両方に対応 * 色々修正 * 色々修正 * 色々修正 * fix * Revert "client-assets" This reverts commit 582601e90eb771875bdf8aba263da2316a59d01b. # Conflicts: # packages/frontend/vite.config.ts * 色々修正 * fix * fix * add url and proxy to server proxy * Update packages/frontend/src/index.html * wip * Merge remote-tracking branch 'origin/develop' into feat/launch-standalone-frontend # Conflicts: # packages/frontend/src/pages/welcome.entrance.a.vue * Merge remote-tracking branch 'origin/develop' into feat/launch-standalone-frontend # Conflicts: # packages/frontend/src/pages/welcome.entrance.a.vue * fix tabler load * Apply suggestions from code review * Update packages/frontend/src/index.html * fix * fix vite.config.local-dev.ts * fix CONTRIBUTING.md --------- Co-authored-by: FruitRiin Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com> Co-authored-by: 果物リン Co-authored-by: syuilo Co-authored-by: ozelot --- CONTRIBUTING.md | 5 ++ docker-compose.local-db.yml | 42 +++++++++++++++ package.json | 2 +- packages/backend/package.json | 1 + packages/frontend/package.json | 1 + packages/frontend/src/_dev_boot_.ts | 11 ++++ packages/frontend/src/boot/common.ts | 6 +++ packages/frontend/src/index.html | 30 +++++++++++ .../frontend/src/pages/settings/general.vue | 1 + .../frontend/src/pages/welcome.entrance.a.vue | 4 +- packages/frontend/vite.config.local-dev.ts | 53 +++++++++++++++++++ 11 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 docker-compose.local-db.yml create mode 100644 packages/frontend/src/_dev_boot_.ts create mode 100644 packages/frontend/src/index.html create mode 100644 packages/frontend/vite.config.local-dev.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13e065604..f8b4fe593 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -138,6 +138,11 @@ After finishing the migration, run the `pnpm dev` command to start the developme pnpm dev ``` +To access Misskey once it's launched, type `http://localhost:[port]` in your browser's address bar. +The [port] part will contain the value set in the port item of .config/default.yml (3000 will be entered by default) + +caution: If you use a port other than 3000, you need to change the proxy settings in packages/frontend/vite.config.local-dev.ts. + ## Testing - Test codes are located in [`/packages/backend/test`](/packages/backend/test). diff --git a/docker-compose.local-db.yml b/docker-compose.local-db.yml new file mode 100644 index 000000000..16ba4b49e --- /dev/null +++ b/docker-compose.local-db.yml @@ -0,0 +1,42 @@ +version: "3" + +# このconfigは、 dockerでMisskey本体を起動せず、 redisとpostgresql などだけを起動します + +services: + redis: + restart: always + image: redis:7-alpine + ports: + - "6379:6379" + volumes: + - ./redis:/data + healthcheck: + test: "redis-cli ping" + interval: 5s + retries: 20 + + db: + restart: always + image: postgres:15-alpine + ports: + - "5432:5432" + env_file: + - .config/docker.env + volumes: + - ./db:/var/lib/postgresql/data + healthcheck: + test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB" + interval: 5s + retries: 20 + +# meilisearch: +# restart: always +# image: getmeili/meilisearch:v1.3.4 +# environment: +# - MEILI_NO_ANALYTICS=true +# - MEILI_ENV=production +# env_file: +# - .config/meilisearch.env +# volumes: +# - ./meili_data:/meili_data + diff --git a/package.json b/package.json index e814d71dc..7e00d43db 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "check:connect": "cd packages/backend && pnpm check:connect", "migrateandstart": "pnpm migrate && pnpm start", "watch": "pnpm dev", - "dev": "node ./scripts/dev.mjs", + "dev": "pnpm -r dev", "lint": "pnpm -r lint", "cy:open": "pnpm cypress open --browser --e2e --config-file=cypress.config.ts", "cy:run": "pnpm cypress run", diff --git a/packages/backend/package.json b/packages/backend/package.json index fa2045809..25984214e 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -16,6 +16,7 @@ "watch:swc": "swc src -d built -D -w", "build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json", "watch": "node watch.mjs", + "dev": "node ./built/boot/entry.js", "typecheck": "tsc --noEmit", "eslint": "eslint --quiet \"src/**/*.ts\"", "lint": "pnpm typecheck && pnpm eslint", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 9ecb47afb..594649010 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -4,6 +4,7 @@ "type": "module", "scripts": { "watch": "vite", + "dev": "vite --config vite.config.local-dev.ts", "build": "vite build", "storybook-dev": "nodemon --verbose --watch src --ext \"mdx,ts,vue\" --ignore \"*.stories.ts\" --exec \"pnpm build-storybook-pre && pnpm exec storybook dev -p 6006 --ci\"", "build-storybook-pre": "(tsc -p .storybook || echo done.) && node .storybook/generate.js && node .storybook/preload-locale.js && node .storybook/preload-theme.js", diff --git a/packages/frontend/src/_dev_boot_.ts b/packages/frontend/src/_dev_boot_.ts new file mode 100644 index 000000000..2e95a0357 --- /dev/null +++ b/packages/frontend/src/_dev_boot_.ts @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +// devモードで起動される際(index.htmlを使うとき)はrouterが暴発してしまってうまく読み込めない。 +// よって、devモードとして起動されるときはビルド時に組み込む形としておく。 +// (pnpm start時はpugファイルの中で静的リソースとして読み込むようになっており、この問題は起こっていない) +import '@tabler/icons-webfont/tabler-icons.scss'; + +import('@/_boot_.js'); diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 6e216a78b..60f2781fd 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -187,6 +187,12 @@ export async function common(createVue: () => App) { if (instance.defaultLightTheme != null) ColdDeviceStorage.set('lightTheme', JSON.parse(instance.defaultLightTheme)); if (instance.defaultDarkTheme != null) ColdDeviceStorage.set('darkTheme', JSON.parse(instance.defaultDarkTheme)); defaultStore.set('themeInitial', false); + } else { + if (defaultStore.state.darkMode) { + applyTheme(darkTheme.value); + } else { + applyTheme(lightTheme.value); + } } }); diff --git a/packages/frontend/src/index.html b/packages/frontend/src/index.html new file mode 100644 index 000000000..4db52747a --- /dev/null +++ b/packages/frontend/src/index.html @@ -0,0 +1,30 @@ + + + + + + + + + misskey + + + + + +
+ + + diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index f108a0c64..98a07d907 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -293,6 +293,7 @@ const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroup watch(lang, () => { miLocalStorage.setItem('lang', lang.value as string); miLocalStorage.removeItem('locale'); + miLocalStorage.removeItem('localeVersion'); }); watch(fontSize, () => { diff --git a/packages/frontend/src/pages/welcome.entrance.a.vue b/packages/frontend/src/pages/welcome.entrance.a.vue index a8ce4537e..9c27eeec5 100644 --- a/packages/frontend/src/pages/welcome.entrance.a.vue +++ b/packages/frontend/src/pages/welcome.entrance.a.vue @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- +
@@ -38,6 +38,7 @@ import * as Misskey from 'misskey-js'; import XTimeline from './welcome.timeline.vue'; import MarqueeText from '@/components/MkMarquee.vue'; import MkFeaturedPhotos from '@/components/MkFeaturedPhotos.vue'; +import misskeysvg from '/client-assets/misskey.svg'; import MkInfo from '@/components/MkInfo.vue'; import { instanceName } from '@/config.js'; import * as os from '@/os.js'; @@ -55,7 +56,6 @@ function getInstanceIcon(instance: Misskey.entities.FederationInstance): string if (!instance.iconUrl) { return ''; } - return getProxiedImageUrl(instance.iconUrl, 'preview'); } diff --git a/packages/frontend/vite.config.local-dev.ts b/packages/frontend/vite.config.local-dev.ts new file mode 100644 index 000000000..6b4bb73ff --- /dev/null +++ b/packages/frontend/vite.config.local-dev.ts @@ -0,0 +1,53 @@ +import dns from 'dns'; +import { defineConfig } from 'vite'; +import { getConfig } from './vite.config.js'; + +dns.setDefaultResultOrder('ipv4first'); + +const defaultConfig = getConfig(); + +const devConfig = { + // 基本の設定は vite.config.js から引き継ぐ + ...defaultConfig, + root: 'src', + publicDir: '../assets', + base: './', + server: { + host: 'localhost', + port: 5173, + proxy: { + '/api': { + changeOrigin: true, + target: 'http://localhost:3000/', + }, + '/assets': 'http://localhost:3000/', + '/files': 'http://localhost:3000/', + '/twemoji': 'http://localhost:3000/', + '/fluent-emoji': 'http://localhost:3000/', + '/sw.js': 'http://localhost:3000/', + '/streaming': { + target: 'ws://localhost:3000/', + ws: true, + }, + '/favicon.ico': 'http://localhost:3000/', + '/identicon': { + target: 'http://localhost:3000/', + rewrite(path) { + return path.replace('@localhost:5173', ''); + }, + }, + '/url': 'http://localhost:3000', + '/proxy': 'http://localhost:3000', + }, + }, + build: { + ...defaultConfig.build, + rollupOptions: { + ...defaultConfig.build?.rollupOptions, + input: 'index.html', + }, + }, +}; + +export default defineConfig(({ command, mode }) => devConfig); +