From 3b800e451ff907743cbc517afb2f04b9f96e48d8 Mon Sep 17 00:00:00 2001 From: Atdunbg Date: Sat, 16 May 2026 00:11:37 +0800 Subject: [PATCH] =?UTF-8?q?-=20**=E6=AD=8C=E6=89=8B=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0**:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=AD=8C=E6=9B=B2=E7=9A=84=E8=89=BA=E6=9C=AF=E5=AE=B6=E5=85=A5?= =?UTF-8?q?=E5=8F=A3,=20=20=20=E6=AD=8C=E6=9B=B2=E7=9A=84=E8=89=BA?= =?UTF-8?q?=E6=9C=AF=E5=AE=B6=E7=8E=B0=E5=8F=AF=E7=82=B9=E5=87=BB=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E5=85=B6=E4=BB=96=E6=AD=8C=E6=9B=B2=EF=BC=8C=E4=B8=93?= =?UTF-8?q?=E8=BE=91=E5=92=8C=E4=BB=8B=E7=BB=8D=20-=20**=E6=AD=8C=E6=9B=B2?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0**:=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AD=8C=E6=9B=B2=E7=9A=84=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复私人漫游自动播放下一首调用多次问题 - 优化播放逻辑,歌曲列表在点击时候不在单首累加, 而是直接获取当前列表所有的歌曲作为播放内容 --- .github/workflow/release.yml | 57 +++++++++ src-tauri/src/api.rs | 183 +++++++++++++++++++++++++++ src-tauri/src/lib.rs | 51 +++++--- src-tauri/tauri.conf.json | 10 +- src/App.vue | 40 +++++- src/components/CommentSection.vue | 149 ++++++++++++++++++++++ src/components/PlayerBar.vue | 19 ++- src/components/SongItemMenu.vue | 42 +++++++ src/router/index.ts | 2 + src/stores/player.ts | 31 +++-- src/utils/song.ts | 3 + src/views/AlbumDetail.vue | 156 +++++++++++++++++++++++ src/views/ArtistDetail.vue | 202 ++++++++++++++++++++++++++++++ src/views/DailySongs.vue | 13 +- src/views/Discover.vue | 11 +- src/views/FavoriteSongs.vue | 13 +- src/views/PlaylistDetail.vue | 19 ++- src/views/RecentPlays.vue | 13 +- src/views/Roam.vue | 17 +-- tsconfig.node.json | 10 -- vite.config.ts | 45 ------- 21 files changed, 978 insertions(+), 108 deletions(-) create mode 100644 .github/workflow/release.yml create mode 100644 src/components/CommentSection.vue create mode 100644 src/components/SongItemMenu.vue create mode 100644 src/views/AlbumDetail.vue create mode 100644 src/views/ArtistDetail.vue delete mode 100644 tsconfig.node.json delete mode 100644 vite.config.ts diff --git a/.github/workflow/release.yml b/.github/workflow/release.yml new file mode 100644 index 0000000..1eaeb1d --- /dev/null +++ b/.github/workflow/release.yml @@ -0,0 +1,57 @@ +name: Release with Updater +on: + push: + tags: + - 'v*' + +jobs: + publish: + strategy: + matrix: + include: + - os: ubuntu-latest + platform: linux + - os: windows-latest + platform: windows + - os: macos-latest + platform: macos + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Install Linux dependencies + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential \ + libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev + + - name: Install npm dependencies + run: npm install + + - name: Build and publish with Tauri Action + uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # 私钥:需要先保存在 GitHub Secrets 中,名字叫 TAURI_PRIVATE_KEY + TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + with: + # 标签名(自动取触发标签) + tagName: ${{ github.ref_name }} + # 发布标题 + releaseName: 'v__VERSION__' + # 发布说明文件(可选) + releaseBody: 'See CHANGELOG.md for details.' + # 如果该平台不生成某些包,不会报错 + releaseDraft: false + prerelease: false \ No newline at end of file diff --git a/src-tauri/src/api.rs b/src-tauri/src/api.rs index 43bea60..fb20552 100644 --- a/src-tauri/src/api.rs +++ b/src-tauri/src/api.rs @@ -728,3 +728,186 @@ fn sanitize_filename(name: &str) -> String { .trim() .to_string() } + +#[tauri::command] +pub async fn artist_detail(id: u64, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let q = state.build_query().param("id", &id.to_string()); + client.artist_detail(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[tauri::command] +pub async fn artist_songs(query: ArtistSongsQuery, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let mut q = state.build_query().param("id", &query.id.to_string()); + if let Some(ref order) = query.order { + q = q.param("order", order); + } + if let Some(limit) = query.limit { + q = q.param("limit", &limit.to_string()); + } + if let Some(offset) = query.offset { + q = q.param("offset", &offset.to_string()); + } + client.artist_songs(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ArtistSongsQuery { + pub id: u64, + pub order: Option, + pub limit: Option, + pub offset: Option, +} + +#[tauri::command] +pub async fn artist_album(id: u64, limit: Option, offset: Option, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let mut q = state.build_query().param("id", &id.to_string()); + if let Some(limit) = limit { + q = q.param("limit", &limit.to_string()); + } + if let Some(offset) = offset { + q = q.param("offset", &offset.to_string()); + } + client.artist_album(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[tauri::command] +pub async fn artist_desc(id: u64, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let q = state.build_query().param("id", &id.to_string()); + client.artist_desc(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[tauri::command] +pub async fn album_detail(id: u64, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let q = state.build_query().param("id", &id.to_string()); + client.album(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[tauri::command] +pub async fn comment_new(query: CommentNewQuery, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let mut q = state.build_query() + .param("type", &query.r#type.to_string()) + .param("id", &query.id.to_string()); + if let Some(sort_type) = query.sort_type { + q = q.param("sortType", &sort_type.to_string()); + } + if let Some(page_no) = query.page_no { + q = q.param("pageNo", &page_no.to_string()); + } + if let Some(page_size) = query.page_size { + q = q.param("pageSize", &page_size.to_string()); + } + if let Some(cursor) = query.cursor { + q = q.param("cursor", &cursor.to_string()); + } + client.comment_new(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[derive(Deserialize)] +pub struct CommentNewQuery { + pub r#type: u8, + pub id: u64, + #[serde(rename = "sortType")] + pub sort_type: Option, + #[serde(rename = "pageNo")] + pub page_no: Option, + #[serde(rename = "pageSize")] + pub page_size: Option, + pub cursor: Option, +} + +#[tauri::command] +pub async fn comment_hot(query: CommentHotQuery, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let mut q = state.build_query() + .param("type", &query.r#type.to_string()) + .param("id", &query.id.to_string()); + if let Some(limit) = query.limit { + q = q.param("limit", &limit.to_string()); + } + if let Some(offset) = query.offset { + q = q.param("offset", &offset.to_string()); + } + if let Some(before) = query.before { + q = q.param("before", &before.to_string()); + } + client.comment_hot(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[derive(Deserialize)] +pub struct CommentHotQuery { + pub r#type: u8, + pub id: u64, + pub limit: Option, + pub offset: Option, + pub before: Option, +} + +#[tauri::command] +pub async fn comment_floor(query: CommentFloorQuery, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let mut q = state.build_query() + .param("parentCommentId", &query.parent_comment_id.to_string()) + .param("type", &query.r#type.to_string()) + .param("id", &query.id.to_string()); + if let Some(limit) = query.limit { + q = q.param("limit", &limit.to_string()); + } + if let Some(time) = query.time { + q = q.param("time", &time.to_string()); + } + client.comment_floor(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[derive(Deserialize)] +pub struct CommentFloorQuery { + #[serde(rename = "parentCommentId")] + pub parent_comment_id: u64, + pub r#type: u8, + pub id: u64, + pub limit: Option, + pub time: Option, +} + +#[tauri::command] +pub async fn comment_like(query: CommentLikeQuery, state: State<'_, ApiController>) -> Result { + let client = state.client.lock().await; + let q = state.build_query() + .param("t", &query.t.to_string()) + .param("type", &query.r#type.to_string()) + .param("id", &query.id.to_string()) + .param("cid", &query.cid.to_string()); + client.comment_like(&q).await + .map(|r| r.body.to_string()) + .map_err(|e| e.to_string()) +} + +#[derive(Deserialize)] +pub struct CommentLikeQuery { + pub t: u8, + pub r#type: u8, + pub id: u64, + pub cid: u64, +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 3ad6a93..29bdffd 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,6 +1,6 @@ use tauri::{ tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}, - menu::{MenuBuilder, MenuItemBuilder}, + menu::{MenuBuilder, MenuItemBuilder, PredefinedMenuItem}, Manager, Emitter, }; use std::sync::atomic::{AtomicBool, Ordering}; @@ -17,7 +17,6 @@ pub fn run() { tauri::Builder::default() .setup(|app| { - // 注入控制器 let app_data_dir = app.path().app_data_dir().expect("无法获取应用数据目录"); let api_controller = ApiController::new(app_data_dir); app.manage(api_controller); @@ -26,37 +25,38 @@ pub fn run() { let app_audio = AppAudio(std::sync::Mutex::new(audio_controller)); app.manage(app_audio); - // 托盘菜单 let show = MenuItemBuilder::with_id("show", "显示窗口").build(app)?; + let _sep1 = PredefinedMenuItem::separator(app)?; + let prev = MenuItemBuilder::with_id("prev", "上一首").build(app)?; let play_pause = MenuItemBuilder::with_id("play_pause", "播放/暂停").build(app)?; let next = MenuItemBuilder::with_id("next", "下一首").build(app)?; - let prev = MenuItemBuilder::with_id("prev", "上一首").build(app)?; + let _sep2 = PredefinedMenuItem::separator(app)?; let quit = MenuItemBuilder::with_id("quit", "退出").build(app)?; let menu = MenuBuilder::new(app) .item(&show) .separator() - .item(&play_pause) - .item(&next) - .item(&prev) + .items(&[&prev, &play_pause, &next]) .separator() .item(&quit) .build()?; - // 托盘图标(使用应用默认图标) let icon = app.default_window_icon().cloned().unwrap(); let _tray = TrayIconBuilder::with_id("main-tray") - .tooltip("Nekosonic") + .tooltip("Nekosonic Music") .icon(icon) + .show_menu_on_left_click(false) .menu(&menu) .on_menu_event(|app, event| { - let window = app.get_webview_window("main").unwrap(); match event.id().as_ref() { "show" => { - window.show().unwrap(); - window.set_focus().unwrap(); - let _ = app.emit("window-shown", ()); + if let Some(window) = app.get_webview_window("main") { + let _ = window.show(); + let _ = window.unminimize(); + let _ = window.set_focus(); + let _ = app.emit("window-shown", ()); + } } "play_pause" => { let _ = app.emit("tray-play-pause", ()); @@ -84,15 +84,16 @@ pub fn run() { } = event { let app = tray.app_handle(); - let window = app.get_webview_window("main").unwrap(); - window.show().unwrap(); - window.set_focus().unwrap(); - let _ = app.emit("window-shown", ()); + if let Some(window) = app.get_webview_window("main") { + let _ = window.show(); + let _ = window.unminimize(); + let _ = window.set_focus(); + let _ = app.emit("window-shown", ()); + } } }) .build(app)?; - // 点击关闭按钮时隐藏到托盘 let window = app.get_webview_window("main").unwrap(); let window_clone = window.clone(); let app_handle = app.handle().clone(); @@ -149,7 +150,17 @@ pub fn run() { api::list_local_songs, api::delete_local_song, api::check_local_song, - api::get_default_download_path + api::get_default_download_path, + + api::artist_detail, + api::artist_songs, + api::artist_album, + api::artist_desc, + api::album_detail, + api::comment_new, + api::comment_hot, + api::comment_floor, + api::comment_like, ]) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_opener::init()) @@ -165,4 +176,4 @@ pub fn run() { })) .run(tauri::generate_context!()) .expect("error while running Nekosonic"); -} \ No newline at end of file +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 22c1c40..08884c9 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -40,5 +40,13 @@ "type": "downloadBootstrapper" } } + }, + "plugins": { + "updater": { + "endpoints": [ + "https://github.com/atdunbg/Nekosonic-Music/releases/latest/download/latest.json" + ], + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDM1MDdCMTJCRTE3MUI4N0QKUldSOXVISGhLN0VITmM3ZkJlbjF3UGJrK3h6ellWZ2xSUG03b3d1RWlDeldSWk1nc0pic2J2MVkK" + } } -} +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 69bc7ae..b74c46e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -161,10 +161,31 @@

{{ roamSong?.name }}

-

{{ roamArtists }}

+

+ + +

-
+
+ + +
+

暂无歌词
+
+ +
@@ -238,6 +262,7 @@ import { useUserStore } from './stores/user'; import { useSettingsStore, type CloseAction } from './stores/settings'; import PlayerBar from './components/PlayerBar.vue'; import ToastContainer from './components/ToastContainer.vue'; +import CommentSection from './components/CommentSection.vue'; import { usePlayerStore } from './stores/player'; import { useLyric } from './composables/UserLyric'; import { getCurrentWindow } from '@tauri-apps/api/window'; @@ -274,6 +299,7 @@ const roamLyricHovering = ref(false); const roamLyricPadPx = ref(0); const roamSong = computed(() => player.currentSong); const roamCoverError = ref(false); +const roamTab = ref<'lyric' | 'comment'>('lyric'); const roamCoverUrl = computed(() => { if (!roamSong.value) return ''; return roamSong.value.al?.picUrl || roamSong.value.album?.picUrl || ''; @@ -289,6 +315,7 @@ function updateRoamLyricPad() { watch(() => player.showRoamDrawer, (val) => { if (val) { + roamTab.value = player.roamInitialTab; nextTick(() => { updateRoamLyricPad(); if (roamResizeObserver) roamResizeObserver.disconnect(); @@ -312,10 +339,6 @@ onBeforeUnmount(() => { roamResizeObserver = null; } }); -const roamArtists = computed(() => { - if (!roamSong.value) return ''; - return roamSong.value.ar?.map((a: any) => a.name).join(' / ') || ''; -}); watch(currentLyricIdx, () => { if (player.showRoamDrawer && !roamLyricHovering.value) { @@ -347,6 +370,11 @@ function seekToRoamLyric(time: number) { } } +function navigateFromDrawer(routeLocation: { name: string; params: any }) { + player.closeRoamDrawer(); + router.push(routeLocation); +} + async function openRoamFromSidebar() { if (player.isFmMode) { player.openRoamDrawer(); diff --git a/src/components/CommentSection.vue b/src/components/CommentSection.vue new file mode 100644 index 0000000..9c10a44 --- /dev/null +++ b/src/components/CommentSection.vue @@ -0,0 +1,149 @@ + + + diff --git a/src/components/PlayerBar.vue b/src/components/PlayerBar.vue index 83d748f..9d90aa2 100644 --- a/src/components/PlayerBar.vue +++ b/src/components/PlayerBar.vue @@ -23,13 +23,23 @@

{{ player.currentSong?.name }}

- {{player.currentSong?.ar?.map((a: any) => a.name).join('/')}} + +

+ @@ -110,7 +120,10 @@

{{ song.name }}

- {{song.ar?.map((a: any) => a.name).join('/')}} +

+
+ +
+ + + + diff --git a/src/router/index.ts b/src/router/index.ts index ecbd90b..808736a 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -21,6 +21,8 @@ const routes = [ { path: '/local-music', name: 'local-music', component: LocalMusic }, { path: '/login', name: 'login', component: Login }, { path: '/playlist/:id', name: 'playlist', component: PlaylistDetail }, + { path: '/artist/:id', name: 'artist', component: () => import('@/views/ArtistDetail.vue') }, + { path: '/album/:id', name: 'album', component: () => import('@/views/AlbumDetail.vue') }, { path: '/settings', name: 'settings', component: Settings }, ]; diff --git a/src/stores/player.ts b/src/stores/player.ts index aee4904..e727edb 100644 --- a/src/stores/player.ts +++ b/src/stores/player.ts @@ -11,8 +11,8 @@ export type PlayMode = 'loop' | 'shuffle' | 'repeat-one'; export interface Song { id: number; name: string; - ar: { name: string }[]; - al: { picUrl: string; name?: string }; + ar: { id?: number; name: string }[]; + al: { id?: number; picUrl: string; name?: string }; dt?: number; album?: { picUrl?: string; name?: string }; @@ -292,11 +292,11 @@ export const usePlayerStore = defineStore('player', () => { if (tickInterval) clearInterval(tickInterval); tickInterval = setInterval(() => { if (playing.value && duration.value > 0) { - currentTime.value += 0.25; - if (currentTime.value >= duration.value) { - currentTime.value = duration.value; - if (tickInterval) { clearInterval(tickInterval); tickInterval = null; } - next(); + if (currentTime.value < duration.value) { + currentTime.value += 0.25; + if (currentTime.value > duration.value) { + currentTime.value = duration.value; + } } } }, 250); @@ -416,11 +416,19 @@ export const usePlayerStore = defineStore('player', () => { } const showRoamDrawer = ref(false); + const roamInitialTab = ref<'lyric' | 'comment'>('lyric'); + const commentSongId = ref(null); - function openRoamDrawer() { + function openRoamDrawer(tab: 'lyric' | 'comment' = 'lyric') { + roamInitialTab.value = tab; showRoamDrawer.value = true; } + function openCommentForSong(songId: number) { + commentSongId.value = songId; + openRoamDrawer('comment'); + } + function closeRoamDrawer() { showRoamDrawer.value = false; } @@ -493,9 +501,7 @@ listen('audio-ended', () => { if (tickInterval) { clearInterval(tickInterval); tickInterval = null; } if (isFmMode.value && fmNextCallback) { fmNextCallback(); - return; - } - if (playing.value && !isFmMode.value) { + } else { next(); } }); @@ -552,6 +558,9 @@ watch(playing, (val) => { toggleLike, showRoamDrawer, + roamInitialTab, + commentSongId, + openCommentForSong, openRoamDrawer, closeRoamDrawer, toggleRoamDrawer, diff --git a/src/utils/song.ts b/src/utils/song.ts index e7a7a01..698c649 100644 --- a/src/utils/song.ts +++ b/src/utils/song.ts @@ -9,6 +9,9 @@ export function normalizeSong(song: any) { if (!normalized.al?.name && normalized.album?.name) { normalized.al = { ...normalized.al, name: normalized.album.name }; } + if (!normalized.al?.id && normalized.album?.id) { + normalized.al = { ...normalized.al, id: normalized.album.id }; + } if (!normalized.ar || normalized.ar.length === 0) { normalized.ar = normalized.artists || []; } diff --git a/src/views/AlbumDetail.vue b/src/views/AlbumDetail.vue new file mode 100644 index 0000000..8820940 --- /dev/null +++ b/src/views/AlbumDetail.vue @@ -0,0 +1,156 @@ + + + diff --git a/src/views/ArtistDetail.vue b/src/views/ArtistDetail.vue new file mode 100644 index 0000000..8fa203a --- /dev/null +++ b/src/views/ArtistDetail.vue @@ -0,0 +1,202 @@ + + + diff --git a/src/views/DailySongs.vue b/src/views/DailySongs.vue index e5abeed..5d50a28 100644 --- a/src/views/DailySongs.vue +++ b/src/views/DailySongs.vue @@ -39,7 +39,14 @@

{{ song.name }}

- {{ song.ar?.map((a: any) => a.name).join(' / ') }} + +

+ {{ formatDuration(song.dt) }} @@ -59,13 +67,16 @@ diff --git a/src/views/Roam.vue b/src/views/Roam.vue index cdbd631..1c4622c 100644 --- a/src/views/Roam.vue +++ b/src/views/Roam.vue @@ -26,7 +26,14 @@

{{ currentSong.name }}

- {{ artists }} + +

@@ -58,8 +65,10 @@ import { ref, computed, watch, onMounted } from 'vue'; import { usePlayerStore } from '../stores/player'; import { invoke } from '@tauri-apps/api/core'; import { normalizeSong } from '../utils/song'; +import { useRouter } from 'vue-router'; const player = usePlayerStore(); +const router = useRouter(); const coverError = ref(false); const currentSong = computed(() => { @@ -76,12 +85,6 @@ const coverUrl = computed(() => { watch(coverUrl, () => { coverError.value = false; }); -const artists = computed(() => { - if (!currentSong.value) return ''; - return currentSong.value.ar?.map((a: any) => a.name).join(' / ') || - currentSong.value.artists?.map((a: any) => a.name).join(' / ') || ''; -}); - onMounted(async () => { if (!player.isFmMode || !player.currentSong) { await startFm(); diff --git a/tsconfig.node.json b/tsconfig.node.json deleted file mode 100644 index 42872c5..0000000 --- a/tsconfig.node.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/vite.config.ts b/vite.config.ts deleted file mode 100644 index 6d6ba4f..0000000 --- a/vite.config.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { defineConfig } from "vite"; -import vue from "@vitejs/plugin-vue"; -import tailwindcss from "@tailwindcss/vite"; -import Icons from "unplugin-icons/vite"; -import { fileURLToPath, URL } from "node:url"; - - -// \@ts-expect-error process is a nodejs global -const host = process.env.TAURI_DEV_HOST; - -// https://vite.dev/config/ -export default defineConfig(async () => ({ - plugins: [ - vue(), - tailwindcss(), - Icons({ compiler: "vue3" }), - ], - resolve: { - alias: { - "@": fileURLToPath(new URL("./src", import.meta.url)), - }, - }, - - // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` - // - // 1. prevent Vite from obscuring rust errors - clearScreen: false, - // 2. tauri expects a fixed port, fail if that port is not available - server: { - port: 1420, - strictPort: true, - host: host || false, - hmr: host - ? { - protocol: "ws", - host, - port: 1421, - } - : undefined, - watch: { - // 3. tell Vite to ignore watching `src-tauri` - ignored: ["**/src-tauri/**"], - }, - }, -}));