- 升级tauri1.4 - 隐藏未完的页面 - 修复一些bug
@ -19,6 +19,7 @@
|
|||||||
"app:build": "yarn build:for:electron && yarn electron:builder"
|
"app:build": "yarn build:for:electron && yarn electron:builder"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@tauri-apps/api": "^1.4.0",
|
||||||
"axios": "^0.22.0",
|
"axios": "^0.22.0",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
@ -39,7 +40,7 @@
|
|||||||
"vuex": "^4.0.0-0"
|
"vuex": "^4.0.0-0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^1.2.2",
|
"@tauri-apps/cli": "^1.4.0",
|
||||||
"@vitejs/plugin-vue": "^1.9.3",
|
"@vitejs/plugin-vue": "^1.9.3",
|
||||||
"@vitejs/plugin-vue-jsx": "^1.3.3",
|
"@vitejs/plugin-vue-jsx": "^1.3.3",
|
||||||
"@vue/cli-plugin-babel": "~4.5.0",
|
"@vue/cli-plugin-babel": "~4.5.0",
|
||||||
|
2028
src-tauri/Cargo.lock
generated
@ -17,7 +17,7 @@ tauri-build = { version = "1.2.1", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
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]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 49 KiB |
BIN
src-tauri/icons/icon_128x128.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
src-tauri/icons/icon_128x128@2x.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
src-tauri/icons/icon_16x16.png
Normal file
After Width: | Height: | Size: 716 B |
BIN
src-tauri/icons/icon_16x16@2x.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src-tauri/icons/icon_256x256.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
src-tauri/icons/icon_256x256@2x.png
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
src-tauri/icons/icon_32x32.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src-tauri/icons/icon_32x32@2x.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src-tauri/icons/icon_512x512.png
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
src-tauri/icons/zmusic.icns
Normal file
BIN
src-tauri/icons/zmusic.ico
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
src-tauri/icons/zmusic.psd
Normal file
@ -3,8 +3,83 @@
|
|||||||
windows_subsystem = "windows"
|
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() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
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!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
"beforeBuildCommand": "yarn build:for:electron",
|
"beforeBuildCommand": "yarn build:for:electron",
|
||||||
"beforeDevCommand": "yarn dev",
|
"beforeDevCommand": "yarn dev",
|
||||||
"devPath": "http://localhost:3301",
|
"devPath": "http://localhost:3301",
|
||||||
"distDir": "../dist"
|
"distDir": "../dist",
|
||||||
|
"withGlobalTauri": true
|
||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "zmusic",
|
"productName": "zmusic",
|
||||||
"version": "0.1.0"
|
"version": "0.1.3"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
@ -23,19 +24,20 @@
|
|||||||
},
|
},
|
||||||
"externalBin": [],
|
"externalBin": [],
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/32x32.png",
|
"icons/icon_32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/icon_32x32@2x.png",
|
||||||
"icons/128x128@2x.png",
|
"icons/icon_128x128.png",
|
||||||
"icons/icon.icns",
|
"icons/icon_128x128@2x.png",
|
||||||
"icons/icon.ico"
|
"icons/zmusic.icns",
|
||||||
|
"icons/zmusic.ico"
|
||||||
],
|
],
|
||||||
"identifier": "com.zlyum.zmusic",
|
"identifier": "com.zlmix.zmusic",
|
||||||
"longDescription": "",
|
"longDescription": "zmusic",
|
||||||
"macOS": {
|
"macOS": {
|
||||||
"entitlements": null,
|
"entitlements": null,
|
||||||
"exceptionDomain": "",
|
"exceptionDomain": "",
|
||||||
"frameworks": [],
|
"frameworks": [],
|
||||||
"providerShortName": null,
|
"providerShortName": "zmusic",
|
||||||
"signingIdentity": null
|
"signingIdentity": null
|
||||||
},
|
},
|
||||||
"resources": [],
|
"resources": [],
|
||||||
@ -51,17 +53,24 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"active": false
|
"active": true,
|
||||||
|
"endpoints": [
|
||||||
|
"https://zlmix.com/zupdater/zmusic/update.json"
|
||||||
|
],
|
||||||
|
"dialog": true,
|
||||||
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDg4MjUyRTQ3M0Y3OTMwNkIKUldSck1Iay9SeTRsaVB6Q3ZNaUJSbUp4dURhWjJRdm8wU2pOcS92bXdJa1VhbzJQeU9VY3haTFQK"
|
||||||
},
|
},
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
"height": 600,
|
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"title": "zmusic",
|
"title": "zmusic",
|
||||||
"width": 800,
|
"width": 800,
|
||||||
|
"height": 620,
|
||||||
"minWidth": 800,
|
"minWidth": 800,
|
||||||
"minHeight": 600
|
"minHeight": 620,
|
||||||
|
"visible": false,
|
||||||
|
"label": "main"
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
11
src-tauri/update.json
Normal 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
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* 环境变量:是否Tauri环境
|
||||||
|
*/
|
||||||
|
export const isTauri = import.meta.env.TAURI_PLATFORM ? true : false;
|
@ -42,9 +42,9 @@ export function getPersonalized(limit=30){
|
|||||||
// 韩国:16
|
// 韩国:16
|
||||||
// 接口地址 : /top/song
|
// 接口地址 : /top/song
|
||||||
// 调用例子 : /top/song?type=96
|
// 调用例子 : /top/song?type=96
|
||||||
export function getTopSong(){
|
export function getTopSong(type = 0){
|
||||||
return request({
|
return request({
|
||||||
url: '/top/song',
|
url: `/top/song?type=${type}`,
|
||||||
params:{
|
params:{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export default createStore({
|
|||||||
backSnaps: [], //返回快照
|
backSnaps: [], //返回快照
|
||||||
lastHistoryPos: -1,
|
lastHistoryPos: -1,
|
||||||
lashHistoryLength: 0,
|
lashHistoryLength: 0,
|
||||||
|
firstShow: false, //第一次显示
|
||||||
settings: {
|
settings: {
|
||||||
currentRoute: "/discover/recommend", //当前路由
|
currentRoute: "/discover/recommend", //当前路由
|
||||||
songId: 0, //歌曲id
|
songId: 0, //歌曲id
|
||||||
|
@ -50,7 +50,8 @@ const route = useRoute();
|
|||||||
const type = ref(snap.type);
|
const type = ref(snap.type);
|
||||||
const page = ref(snap.page);
|
const page = ref(snap.page);
|
||||||
const pageSize = ref(snap.pageSize);
|
const pageSize = ref(snap.pageSize);
|
||||||
const keywords = ref(props.keywords);
|
// const keywords = ref(props.keywords);
|
||||||
|
const keywords = ref('');
|
||||||
|
|
||||||
// type.value=snap.type
|
// type.value=snap.type
|
||||||
// page.value=snap.page
|
// page.value=snap.page
|
||||||
@ -67,20 +68,35 @@ const djRadios = ref([]);
|
|||||||
const mvs = ref([]);
|
const mvs = ref([]);
|
||||||
const videos = ref([]);
|
const videos = ref([]);
|
||||||
|
|
||||||
watch(
|
// watch(
|
||||||
() => [props.keywords, type.value, page.value, pageSize.value],
|
// () => [keywords.value, type.value, page.value, pageSize.value],
|
||||||
([k, t]) => {
|
// ([k, t]) => {
|
||||||
keywords.value = k;
|
// // keywords.value = k;
|
||||||
// console.log('Searching...', keywords.value, type.value, page.value, pageSize.value);
|
// 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();
|
search();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// { immediate: true }
|
});
|
||||||
);
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
search();
|
search();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//卸载组件
|
||||||
|
onUnmounted(() => {
|
||||||
|
pubsub.unsubscribe(token);
|
||||||
|
});
|
||||||
|
|
||||||
// let firstTime = true;
|
// let firstTime = true;
|
||||||
// onActivated(()=>{
|
// onActivated(()=>{
|
||||||
// console.log('actived---------');
|
// console.log('actived---------');
|
||||||
@ -124,7 +140,9 @@ const search = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.code == 200) {
|
if (res.data.code == 200) {
|
||||||
if (type.value == 1) {
|
if (type.value == 1) {
|
||||||
|
// console.log("单曲", res.data.result.songCount, res.data.result.songs.length)
|
||||||
count.value = res.data.result.songCount;
|
count.value = res.data.result.songCount;
|
||||||
|
// console.log(count.value)
|
||||||
songs.value = res.data.result.songs;
|
songs.value = res.data.result.songs;
|
||||||
} else if (type.value == 100) {
|
} else if (type.value == 100) {
|
||||||
count.value = res.data.result.artistCount;
|
count.value = res.data.result.artistCount;
|
||||||
@ -200,6 +218,7 @@ const click = () => {
|
|||||||
const pageChange = (p) => {
|
const pageChange = (p) => {
|
||||||
page.value = p;
|
page.value = p;
|
||||||
saveSnap({ scrollTop: 0 });
|
saveSnap({ scrollTop: 0 });
|
||||||
|
search();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -221,6 +240,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 1;
|
type = 1;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
单曲
|
单曲
|
||||||
@ -231,6 +251,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 100;
|
type = 100;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
歌手
|
歌手
|
||||||
@ -241,6 +262,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 10;
|
type = 10;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
专辑
|
专辑
|
||||||
@ -251,6 +273,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 1000;
|
type = 1000;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
歌单
|
歌单
|
||||||
@ -261,6 +284,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 1009;
|
type = 1009;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
电台
|
电台
|
||||||
@ -271,6 +295,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 1004;
|
type = 1004;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
MV
|
MV
|
||||||
@ -281,6 +306,7 @@ const pageChange = (p) => {
|
|||||||
@click="
|
@click="
|
||||||
type = 1014;
|
type = 1014;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
search();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
视频
|
视频
|
||||||
|
@ -36,20 +36,20 @@ const menuOptions = ref([
|
|||||||
key: "/discover",
|
key: "/discover",
|
||||||
icon: renderIcon(FaXian),
|
icon: renderIcon(FaXian),
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
label: () =>
|
// label: () =>
|
||||||
h(
|
// h(
|
||||||
RouterLink,
|
// RouterLink,
|
||||||
{
|
// {
|
||||||
to: {
|
// to: {
|
||||||
path: "/videos/v",
|
// path: "/videos/v",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{ default: () => "视频" }
|
// { default: () => "视频" }
|
||||||
),
|
// ),
|
||||||
key: "/videos",
|
// key: "/videos",
|
||||||
icon: renderIcon(ShiPin),
|
// icon: renderIcon(ShiPin),
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
label: () =>
|
label: () =>
|
||||||
h(
|
h(
|
||||||
|
@ -13,12 +13,13 @@ const router = useRouter();
|
|||||||
const keywords = ref("");
|
const keywords = ref("");
|
||||||
const elSearch = ref(null);
|
const elSearch = ref(null);
|
||||||
|
|
||||||
const search = () => {
|
const search = async () => {
|
||||||
if (keywords.value.trim().length > 0){
|
if (keywords.value.trim().length > 0){
|
||||||
pubsub.publish("zp.toggleSearch");
|
pubsub.publish("zp.toggleSearch");
|
||||||
// elSearch.value.blur()
|
// elSearch.value.blur()
|
||||||
store.commit('addSearchHistory', keywords.value)
|
store.commit('addSearchHistory', keywords.value)
|
||||||
router.push(`/search/${keywords.value}`);
|
await router.push(`/search/${keywords.value}`);
|
||||||
|
pubsub.publish('zp.search', keywords.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,9 +84,10 @@ onUnmounted(() => {
|
|||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
@close.stop="store.commit('removeSearchHistory', h)"
|
@close.stop="store.commit('removeSearchHistory', h)"
|
||||||
@click="()=>{
|
@click="async ()=>{
|
||||||
pubsub.publish('zp.toggleSearch');
|
pubsub.publish('zp.toggleSearch');
|
||||||
router.push(`/search/${h}`);
|
await router.push(`/search/${h}`);
|
||||||
|
pubsub.publish('zp.search', h);
|
||||||
}"
|
}"
|
||||||
>{{ h }}</NTag
|
>{{ h }}</NTag
|
||||||
>
|
>
|
||||||
@ -98,10 +99,11 @@ onUnmounted(() => {
|
|||||||
class="hot-list"
|
class="hot-list"
|
||||||
v-for="(item, idx) in hotSearch"
|
v-for="(item, idx) in hotSearch"
|
||||||
key="idx"
|
key="idx"
|
||||||
@click="()=>{
|
@click="async ()=>{
|
||||||
pubsub.publish('zp.toggleSearch');
|
pubsub.publish('zp.toggleSearch');
|
||||||
store.commit('addSearchHistory', item.searchWord)
|
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 }">
|
<div class="idx" :class="{ idxHot: item.iconType == 1 }">
|
||||||
|
@ -7,6 +7,8 @@ import {
|
|||||||
onBeforeRouteUpdate,
|
onBeforeRouteUpdate,
|
||||||
onBeforeRouteLeave,
|
onBeforeRouteLeave,
|
||||||
} from "vue-router";
|
} from "vue-router";
|
||||||
|
import { invoke } from '@tauri-apps/api/tauri'
|
||||||
|
import { emit, listen } from "@tauri-apps/api/event"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NButton,
|
NButton,
|
||||||
@ -17,6 +19,10 @@ import {
|
|||||||
} from "naive-ui";
|
} from "naive-ui";
|
||||||
|
|
||||||
console.log('Discove 初始化');
|
console.log('Discove 初始化');
|
||||||
|
onMounted(() => {
|
||||||
|
console.log("Discove onMounted.")
|
||||||
|
// emit('dom-loaded', 'discover/recommend')
|
||||||
|
})
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
console.log('Discove 卸载');
|
console.log('Discove 卸载');
|
||||||
})
|
})
|
||||||
@ -38,71 +44,71 @@ const menuOptions = [
|
|||||||
),
|
),
|
||||||
key: "/discover/recommend",
|
key: "/discover/recommend",
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
label: () =>
|
// label: () =>
|
||||||
h(
|
// h(
|
||||||
RouterLink,
|
// RouterLink,
|
||||||
{
|
// {
|
||||||
to: {
|
// to: {
|
||||||
path: "/discover/songlist",
|
// path: "/discover/songlist",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{ default: () => "歌单" }
|
// { default: () => "歌单" }
|
||||||
),
|
// ),
|
||||||
key: "/discover/songlist",
|
// key: "/discover/songlist",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: () =>
|
// label: () =>
|
||||||
h(
|
// h(
|
||||||
RouterLink,
|
// RouterLink,
|
||||||
{
|
// {
|
||||||
to: {
|
// to: {
|
||||||
path: "/discover/anchor",
|
// path: "/discover/anchor",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{ default: () => "主播" }
|
// { default: () => "主播" }
|
||||||
),
|
// ),
|
||||||
key: "/discover/anchor",
|
// key: "/discover/anchor",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: () =>
|
// label: () =>
|
||||||
h(
|
// h(
|
||||||
RouterLink,
|
// RouterLink,
|
||||||
{
|
// {
|
||||||
to: {
|
// to: {
|
||||||
path: "/discover/ranking",
|
// path: "/discover/ranking",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{ default: () => "排行" }
|
// { default: () => "排行" }
|
||||||
),
|
// ),
|
||||||
key: "/discover/ranking",
|
// key: "/discover/ranking",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: () =>
|
// label: () =>
|
||||||
h(
|
// h(
|
||||||
RouterLink,
|
// RouterLink,
|
||||||
{
|
// {
|
||||||
to: {
|
// to: {
|
||||||
path: "/discover/singer",
|
// path: "/discover/singer",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{ default: () => "歌手" }
|
// { default: () => "歌手" }
|
||||||
),
|
// ),
|
||||||
key: "/discover/singer",
|
// key: "/discover/singer",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: () =>
|
// label: () =>
|
||||||
h(
|
// h(
|
||||||
RouterLink,
|
// RouterLink,
|
||||||
{
|
// {
|
||||||
to: {
|
// to: {
|
||||||
path: "/discover/latest",
|
// path: "/discover/latest",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{ default: () => "最新" }
|
// { default: () => "最新" }
|
||||||
),
|
// ),
|
||||||
key: "/discover/latest",
|
// key: "/discover/latest",
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -43,8 +43,12 @@
|
|||||||
:key="song.id"
|
:key="song.id"
|
||||||
>
|
>
|
||||||
<div class="c2-list">
|
<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 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
|
<n-button
|
||||||
text
|
text
|
||||||
class="start-play-bg"
|
class="start-play-bg"
|
||||||
@ -68,7 +72,14 @@
|
|||||||
</n-button>
|
</n-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="title">
|
<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 }}
|
{{ song.name }}
|
||||||
<span class="alias"
|
<span class="alias"
|
||||||
><template
|
><template
|
||||||
@ -294,6 +305,9 @@ import {
|
|||||||
} from "@/network/discover";
|
} from "@/network/discover";
|
||||||
import pubsub from "pubsub-js";
|
import pubsub from "pubsub-js";
|
||||||
import ArtistsSpan from "@/components/ArtistsSpan.vue";
|
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恢复滚动条位置
|
//使用useBackSnaps恢复滚动条位置
|
||||||
import { useBackSnaps } from "@/lib/useBackSnaps";
|
import { useBackSnaps } from "@/lib/useBackSnaps";
|
||||||
@ -305,6 +319,20 @@ useBackSnaps()
|
|||||||
// })
|
// })
|
||||||
const store = useStore();
|
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) => {
|
const play = (id) => {
|
||||||
pubsub.publish("zp.play", { id, im: true });
|
pubsub.publish("zp.play", { id, im: true });
|
||||||
};
|
};
|
||||||
@ -312,7 +340,8 @@ const play = (id) => {
|
|||||||
//#region 轮播图片
|
//#region 轮播图片
|
||||||
let banners = ref([]);
|
let banners = ref([]);
|
||||||
banners.value = store.getters.cache('banners')
|
banners.value = store.getters.cache('banners')
|
||||||
getBanner(0)
|
const loadBanners = () => {
|
||||||
|
getBanner(0)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
banners.value = res.data.banners;
|
banners.value = res.data.banners;
|
||||||
store.commit("saveCaches", {
|
store.commit("saveCaches", {
|
||||||
@ -324,6 +353,8 @@ getBanner(0)
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("getBanner err", err);
|
console.log("getBanner err", err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
loadBanners()
|
||||||
|
|
||||||
const clickBanner = (id, type) => {
|
const clickBanner = (id, type) => {
|
||||||
switch(type){
|
switch(type){
|
||||||
@ -343,10 +374,11 @@ topSongs.value = store.getters.cache('topSongs')
|
|||||||
// console.log('载入Caches');
|
// console.log('载入Caches');
|
||||||
// }
|
// }
|
||||||
//最新音乐
|
//最新音乐
|
||||||
getTopSong()
|
const loadTopSong = () => {
|
||||||
|
getTopSong()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
topSongs.value = res.data.data.filter((item, index) => {
|
topSongs.value = res.data.data.filter((item, index) => {
|
||||||
return index < 10;
|
return index < 100;
|
||||||
});
|
});
|
||||||
store.commit("saveCaches", {
|
store.commit("saveCaches", {
|
||||||
topSongs: { data: topSongs.value, time: Date.now() },
|
topSongs: { data: topSongs.value, time: Date.now() },
|
||||||
@ -356,6 +388,28 @@ getTopSong()
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("getTopSong err", err);
|
console.log("getTopSong err", err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
loadTopSong()
|
||||||
|
|
||||||
function songAlias(alias) {
|
function songAlias(alias) {
|
||||||
if (alias.length > 0) return "[" + alias.join(",") + "]";
|
if (alias.length > 0) return "[" + alias.join(",") + "]";
|
||||||
@ -403,6 +457,11 @@ getPersonalizedMV()
|
|||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
console.log("定时刷新Recommend!")
|
||||||
|
loadBanners()
|
||||||
|
loadTopSong()
|
||||||
|
}, 1 * 60 * 60 * 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,11 +23,20 @@ export default defineConfig({
|
|||||||
svgBuilder('./src/assets/svgs/')
|
svgBuilder('./src/assets/svgs/')
|
||||||
],
|
],
|
||||||
// server:{
|
// server:{
|
||||||
// fs:{
|
// hmr: {
|
||||||
// strict: false,
|
// overlay: false
|
||||||
// allow:[
|
// },
|
||||||
// '.'
|
// // 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_'],
|
||||||
|
|
||||||
})
|
})
|
||||||
|