- 升级tauri1.4 - 隐藏未完的页面 - 修复一些bug

This commit is contained in:
ZilongYang 2023-06-29 14:40:56 +08:00
parent a3c872c7d7
commit 3cc551fe0d
45 changed files with 5698 additions and 4692 deletions

View File

@ -19,6 +19,7 @@
"app:build": "yarn build:for:electron && yarn electron:builder"
},
"dependencies": {
"@tauri-apps/api": "^1.4.0",
"axios": "^0.22.0",
"core-js": "^3.6.5",
"crypto-js": "^4.1.1",
@ -39,7 +40,7 @@
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@tauri-apps/cli": "^1.2.2",
"@tauri-apps/cli": "^1.4.0",
"@vitejs/plugin-vue": "^1.9.3",
"@vitejs/plugin-vue-jsx": "^1.3.3",
"@vue/cli-plugin-babel": "~4.5.0",

2028
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ tauri-build = { version = "1.2.1", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2.2", features = ["api-all", "devtools"] }
tauri = { version = "1.4.0", features = [ "updater", "api-all", "devtools"] }
[features]
# by default Tauri runs in production mode

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

BIN
src-tauri/icons/zmusic.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/zmusic.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
src-tauri/icons/zmusic.psd Normal file

Binary file not shown.

View File

@ -3,8 +3,83 @@
windows_subsystem = "windows"
)]
use tauri::Manager;
use serde::{Deserialize, Serialize};
use serde_json::{Result, Value, json};
#[derive(Serialize, Deserialize, Debug)]
struct ZEvent {
sender: String,
data: Option<String>
}
impl ZEvent {
fn default() -> Self {
ZEvent { sender: String::default(), data: None }
}
}
fn main() {
tauri::Builder::default()
.setup(move |app| {
// let sp = app.get_window("splashscreen").unwrap();
let main = app.get_window("main").unwrap();
// sp.show().unwrap();
app.listen_global("dom-loaded", move |event| {
// let data = event.payload();
let v = json!(
{
"sender": "haah",
"data": {
"id": 234421,
"message": "测试消息"
}
}
);
if let Some(data) = event.payload() {
let jdata: Value = serde_json::from_str(data).unwrap();
let ev: Option<ZEvent> = serde_json::from_str(data).ok();
// match serde_json::from_str(data) {
// Ok(ev) => {}
// _ => {}
// }
println!("jdata is {}, ev is {:?}", jdata, ev);
// return;
// match ev.sender.as_str() {
// "discover/recommend" => {
// main.show().unwrap();
// println!("main is ready to show");
// }
// _ => {}
// }
if let Some(data) = jdata["data"].as_object() {
}
if let Some(sender) = jdata["sender"].as_str() {
match sender {
"discover/recommend" => {
main.show().unwrap();
println!("main is ready to show");
}
_ => {}
}
}
}
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -4,11 +4,12 @@
"beforeBuildCommand": "yarn build:for:electron",
"beforeDevCommand": "yarn dev",
"devPath": "http://localhost:3301",
"distDir": "../dist"
"distDir": "../dist",
"withGlobalTauri": true
},
"package": {
"productName": "zmusic",
"version": "0.1.0"
"version": "0.1.3"
},
"tauri": {
"allowlist": {
@ -23,19 +24,20 @@
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
"icons/icon_32x32.png",
"icons/icon_32x32@2x.png",
"icons/icon_128x128.png",
"icons/icon_128x128@2x.png",
"icons/zmusic.icns",
"icons/zmusic.ico"
],
"identifier": "com.zlyum.zmusic",
"longDescription": "",
"identifier": "com.zlmix.zmusic",
"longDescription": "zmusic",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"providerShortName": "zmusic",
"signingIdentity": null
},
"resources": [],
@ -51,17 +53,24 @@
},
"updater": {
"active": false
"active": true,
"endpoints": [
"https://zlmix.com/zupdater/zmusic/update.json"
],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDg4MjUyRTQ3M0Y3OTMwNkIKUldSck1Iay9SeTRsaVB6Q3ZNaUJSbUp4dURhWjJRdm8wU2pOcS92bXdJa1VhbzJQeU9VY3haTFQK"
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "zmusic",
"width": 800,
"height": 620,
"minWidth": 800,
"minHeight": 600
"minHeight": 620,
"visible": false,
"label": "main"
}
]

11
src-tauri/update.json Normal file
View File

@ -0,0 +1,11 @@
{
"version": "v0.1.3",
"notes": "修复搜索问题",
"pub_date": "2023-06-29T09:00:00Z",
"platforms": {
"darwin-aarch64": {
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSck1Iay9SeTRsaURvSVRKMEQxZ2Zwb2tEek9pem1LdVNMUWoxVU1LSzRRMzBGNlBKRE1VRU5weFh1c1FFNWRmM1VSd1phZ2drdVlMSHVRSkJ3YUhFbDBVQ3FrZHlRZUEwPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNjg4MDAxNTg3CWZpbGU6em11c2ljLmFwcC50YXIuZ3oKZUJaK0tmS2JPN1h1UVVXQWlSbHovWHppb0pFbVdJV0ROcTRIR2IrWnRXSjVtakFZKzh0ZmRkekVreDBoLzdmOGppSkNqam0wT09VQjM1a1JaUmpWQUE9PQo=",
"url": "https://zlmix.com/zupdater/zmusic/0.1.3/zmusic.app.tar.gz"
}
}
}

5
src/env.js Normal file
View File

@ -0,0 +1,5 @@
/**
* 环境变量是否Tauri环境
*/
export const isTauri = import.meta.env.TAURI_PLATFORM ? true : false;

View File

@ -42,9 +42,9 @@ export function getPersonalized(limit=30){
// 韩国:16
// 接口地址 : /top/song
// 调用例子 : /top/song?type=96
export function getTopSong(){
export function getTopSong(type = 0){
return request({
url: '/top/song',
url: `/top/song?type=${type}`,
params:{
}

View File

@ -9,6 +9,7 @@ export default createStore({
backSnaps: [], //返回快照
lastHistoryPos: -1,
lashHistoryLength: 0,
firstShow: false, //第一次显示
settings: {
currentRoute: "/discover/recommend", //当前路由
songId: 0, //歌曲id

View File

@ -50,7 +50,8 @@ const route = useRoute();
const type = ref(snap.type);
const page = ref(snap.page);
const pageSize = ref(snap.pageSize);
const keywords = ref(props.keywords);
// const keywords = ref(props.keywords);
const keywords = ref('');
// type.value=snap.type
// page.value=snap.page
@ -67,20 +68,35 @@ const djRadios = ref([]);
const mvs = ref([]);
const videos = ref([]);
watch(
() => [props.keywords, type.value, page.value, pageSize.value],
([k, t]) => {
keywords.value = k;
// console.log('Searching...', keywords.value, type.value, page.value, pageSize.value);
search();
// watch(
// () => [keywords.value, type.value, page.value, pageSize.value],
// ([k, t]) => {
// // keywords.value = k;
// console.log('watch Searching...', keywords.value, type.value, page.value, pageSize.value);
// search();
// }
// // { immediate: true }
// );
const token = pubsub.subscribe("zp", (msg, data) => {
switch (msg) {
case "zp.search":
keywords.value = data;
page.value = 1
search();
break;
}
// { immediate: true }
);
});
onMounted(() => {
search();
});
//
onUnmounted(() => {
pubsub.unsubscribe(token);
});
// let firstTime = true;
// onActivated(()=>{
// console.log('actived---------');
@ -124,7 +140,9 @@ const search = () => {
.then((res) => {
if (res.data.code == 200) {
if (type.value == 1) {
// console.log("", res.data.result.songCount, res.data.result.songs.length)
count.value = res.data.result.songCount;
// console.log(count.value)
songs.value = res.data.result.songs;
} else if (type.value == 100) {
count.value = res.data.result.artistCount;
@ -200,6 +218,7 @@ const click = () => {
const pageChange = (p) => {
page.value = p;
saveSnap({ scrollTop: 0 });
search();
};
</script>
@ -221,6 +240,7 @@ const pageChange = (p) => {
@click="
type = 1;
page = 1;
search();
"
>
单曲
@ -231,6 +251,7 @@ const pageChange = (p) => {
@click="
type = 100;
page = 1;
search();
"
>
歌手
@ -241,6 +262,7 @@ const pageChange = (p) => {
@click="
type = 10;
page = 1;
search();
"
>
专辑
@ -251,6 +273,7 @@ const pageChange = (p) => {
@click="
type = 1000;
page = 1;
search();
"
>
歌单
@ -261,6 +284,7 @@ const pageChange = (p) => {
@click="
type = 1009;
page = 1;
search();
"
>
电台
@ -271,6 +295,7 @@ const pageChange = (p) => {
@click="
type = 1004;
page = 1;
search();
"
>
MV
@ -281,6 +306,7 @@ const pageChange = (p) => {
@click="
type = 1014;
page = 1;
search();
"
>
视频

View File

@ -36,20 +36,20 @@ const menuOptions = ref([
key: "/discover",
icon: renderIcon(FaXian),
},
{
label: () =>
h(
RouterLink,
{
to: {
path: "/videos/v",
},
},
{ default: () => "视频" }
),
key: "/videos",
icon: renderIcon(ShiPin),
},
// {
// label: () =>
// h(
// RouterLink,
// {
// to: {
// path: "/videos/v",
// },
// },
// { default: () => "" }
// ),
// key: "/videos",
// icon: renderIcon(ShiPin),
// },
{
label: () =>
h(

View File

@ -13,12 +13,13 @@ const router = useRouter();
const keywords = ref("");
const elSearch = ref(null);
const search = () => {
const search = async () => {
if (keywords.value.trim().length > 0){
pubsub.publish("zp.toggleSearch");
// elSearch.value.blur()
store.commit('addSearchHistory', keywords.value)
router.push(`/search/${keywords.value}`);
await router.push(`/search/${keywords.value}`);
pubsub.publish('zp.search', keywords.value);
}
};

View File

@ -84,9 +84,10 @@ onUnmounted(() => {
size="small"
type="primary"
@close.stop="store.commit('removeSearchHistory', h)"
@click="()=>{
@click="async ()=>{
pubsub.publish('zp.toggleSearch');
router.push(`/search/${h}`);
await router.push(`/search/${h}`);
pubsub.publish('zp.search', h);
}"
>{{ h }}</NTag
>
@ -98,10 +99,11 @@ onUnmounted(() => {
class="hot-list"
v-for="(item, idx) in hotSearch"
key="idx"
@click="()=>{
@click="async ()=>{
pubsub.publish('zp.toggleSearch');
store.commit('addSearchHistory', item.searchWord)
router.push(`/search/${item.searchWord}`);
await router.push(`/search/${item.searchWord}`);
pubsub.publish('zp.search', item.searchWord);
}"
>
<div class="idx" :class="{ idxHot: item.iconType == 1 }">

View File

@ -7,6 +7,8 @@ import {
onBeforeRouteUpdate,
onBeforeRouteLeave,
} from "vue-router";
import { invoke } from '@tauri-apps/api/tauri'
import { emit, listen } from "@tauri-apps/api/event"
import {
NButton,
@ -17,6 +19,10 @@ import {
} from "naive-ui";
console.log('Discove 初始化');
onMounted(() => {
console.log("Discove onMounted.")
// emit('dom-loaded', 'discover/recommend')
})
onUnmounted(() => {
console.log('Discove 卸载');
})
@ -38,71 +44,71 @@ const menuOptions = [
),
key: "/discover/recommend",
},
{
label: () =>
h(
RouterLink,
{
to: {
path: "/discover/songlist",
},
},
{ default: () => "歌单" }
),
key: "/discover/songlist",
},
{
label: () =>
h(
RouterLink,
{
to: {
path: "/discover/anchor",
},
},
{ default: () => "主播" }
),
key: "/discover/anchor",
},
{
label: () =>
h(
RouterLink,
{
to: {
path: "/discover/ranking",
},
},
{ default: () => "排行" }
),
key: "/discover/ranking",
},
{
label: () =>
h(
RouterLink,
{
to: {
path: "/discover/singer",
},
},
{ default: () => "歌手" }
),
key: "/discover/singer",
},
{
label: () =>
h(
RouterLink,
{
to: {
path: "/discover/latest",
},
},
{ default: () => "最新" }
),
key: "/discover/latest",
},
// {
// label: () =>
// h(
// RouterLink,
// {
// to: {
// path: "/discover/songlist",
// },
// },
// { default: () => "" }
// ),
// key: "/discover/songlist",
// },
// {
// label: () =>
// h(
// RouterLink,
// {
// to: {
// path: "/discover/anchor",
// },
// },
// { default: () => "" }
// ),
// key: "/discover/anchor",
// },
// {
// label: () =>
// h(
// RouterLink,
// {
// to: {
// path: "/discover/ranking",
// },
// },
// { default: () => "" }
// ),
// key: "/discover/ranking",
// },
// {
// label: () =>
// h(
// RouterLink,
// {
// to: {
// path: "/discover/singer",
// },
// },
// { default: () => "" }
// ),
// key: "/discover/singer",
// },
// {
// label: () =>
// h(
// RouterLink,
// {
// to: {
// path: "/discover/latest",
// },
// },
// { default: () => "" }
// ),
// key: "/discover/latest",
// },
];
const route = useRoute();

View File

@ -43,8 +43,12 @@
:key="song.id"
>
<div class="c2-list">
<div class="play-btn" @click="play(song.id)">
<div v-if="idx<6" class="play-btn" @click="play(song.id)">
<img v-lazy="song.album.blurPicUrl.replace('http://', 'https://')" />
<!-- <img :src="song.album.blurPicUrl.replace('http://', 'https://')" /> -->
<!-- <div class="w-[60px] h-[60px]">
</div> -->
<n-button
text
class="start-play-bg"
@ -68,7 +72,14 @@
</n-button>
</div>
<div class="title">
<span class="name">
<span
class="name cursor-pointer hover:underline"
:class="[]"
:style="{
color: store.state.theme.themeOverrides.common.primaryColor,
}"
@click="play(song.id)"
>
{{ song.name }}
<span class="alias"
><template
@ -294,6 +305,9 @@ import {
} from "@/network/discover";
import pubsub from "pubsub-js";
import ArtistsSpan from "@/components/ArtistsSpan.vue";
import { invoke } from '@tauri-apps/api/tauri'
import { emit, listen } from "@tauri-apps/api/event"
import { isTauri} from "@/env"
//使useBackSnaps
import { useBackSnaps } from "@/lib/useBackSnaps";
@ -305,6 +319,20 @@ useBackSnaps()
// })
const store = useStore();
onMounted(() => {
console.log("Recomment onMounted.")
if (isTauri && !store.firstShow)
emit('dom-loaded', {
sender: 'discover/recommend',
data: {
id: 12324112,
success: true,
message: "测试消息"
}
})
store.firstShow = true
})
const play = (id) => {
pubsub.publish("zp.play", { id, im: true });
};
@ -312,18 +340,21 @@ const play = (id) => {
//#region
let banners = ref([]);
banners.value = store.getters.cache('banners')
getBanner(0)
.then((res) => {
banners.value = res.data.banners;
store.commit("saveCaches", {
banners: { data: banners.value, time: Date.now() },
const loadBanners = () => {
getBanner(0)
.then((res) => {
banners.value = res.data.banners;
store.commit("saveCaches", {
banners: { data: banners.value, time: Date.now() },
});
// console.log(banners.value);
// console.log("recommend ");
})
.catch((err) => {
console.log("getBanner err", err);
});
// console.log(banners.value);
// console.log("recommend ");
})
.catch((err) => {
console.log("getBanner err", err);
});
}
loadBanners()
const clickBanner = (id, type) => {
switch(type){
@ -343,19 +374,42 @@ topSongs.value = store.getters.cache('topSongs')
// console.log('Caches');
// }
//
getTopSong()
.then((res) => {
topSongs.value = res.data.data.filter((item, index) => {
return index < 10;
const loadTopSong = () => {
getTopSong()
.then((res) => {
topSongs.value = res.data.data.filter((item, index) => {
return index < 100;
});
store.commit("saveCaches", {
topSongs: { data: topSongs.value, time: Date.now() },
});
// console.log(topSongs.value);
})
.catch((err) => {
console.log("getTopSong err", err);
});
store.commit("saveCaches", {
topSongs: { data: topSongs.value, time: Date.now() },
}
loadTopSong()
//
let topSongsCN = ref([]);
topSongsCN.value = store.getters.cache('topSongsCN')
const loadTopSongCN = () => {
getTopSong(7)
.then((res) => {
topSongsCN.value = res.data.data.filter((item, index) => {
return index < 10;
});
store.commit("saveCaches", {
topSongsCN: { data: topSongsCN.value, time: Date.now() },
});
// console.log(topSongs.value);
})
.catch((err) => {
console.log("getTopSong err", err);
});
// console.log(topSongs.value);
})
.catch((err) => {
console.log("getTopSong err", err);
});
}
loadTopSong()
function songAlias(alias) {
if (alias.length > 0) return "[" + alias.join(",") + "]";
@ -403,6 +457,11 @@ getPersonalizedMV()
});
//#endregion
setInterval(() => {
console.log("定时刷新Recommend")
loadBanners()
loadTopSong()
}, 1 * 60 * 60 * 1000);
</script>

View File

@ -23,11 +23,20 @@ export default defineConfig({
svgBuilder('./src/assets/svgs/')
],
// server:{
// fs:{
// strict: false,
// allow:[
// '.'
// ]
// }
// hmr: {
// overlay: false
// },
// // fs:{
// // strict: false,
// // allow:[
// // '.'
// // ]
// // }
// }
// to make use of `TAURI_PLATFORM`, `TAURI_ARCH`, `TAURI_FAMILY`,
// `TAURI_PLATFORM_VERSION`, `TAURI_PLATFORM_TYPE` and `TAURI_DEBUG`
// env variables
envPrefix: ['VITE_', 'TAURI_'],
})

7875
yarn.lock

File diff suppressed because it is too large Load Diff