- 升级tauri1.4 - 隐藏未完的页面 - 修复一些bug
@ -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
@ -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
|
||||
|
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"
|
||||
)]
|
||||
|
||||
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");
|
||||
}
|
||||
|
@ -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
@ -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
|
||||
// 接口地址 : /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:{
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ export default createStore({
|
||||
backSnaps: [], //返回快照
|
||||
lastHistoryPos: -1,
|
||||
lashHistoryLength: 0,
|
||||
firstShow: false, //第一次显示
|
||||
settings: {
|
||||
currentRoute: "/discover/recommend", //当前路由
|
||||
songId: 0, //歌曲id
|
||||
|
@ -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);
|
||||
// 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();
|
||||
"
|
||||
>
|
||||
视频
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 }">
|
||||
|
@ -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();
|
||||
|
@ -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,7 +340,8 @@ const play = (id) => {
|
||||
//#region 轮播图片
|
||||
let banners = ref([]);
|
||||
banners.value = store.getters.cache('banners')
|
||||
getBanner(0)
|
||||
const loadBanners = () => {
|
||||
getBanner(0)
|
||||
.then((res) => {
|
||||
banners.value = res.data.banners;
|
||||
store.commit("saveCaches", {
|
||||
@ -324,6 +353,8 @@ getBanner(0)
|
||||
.catch((err) => {
|
||||
console.log("getBanner err", err);
|
||||
});
|
||||
}
|
||||
loadBanners()
|
||||
|
||||
const clickBanner = (id, type) => {
|
||||
switch(type){
|
||||
@ -343,10 +374,11 @@ topSongs.value = store.getters.cache('topSongs')
|
||||
// console.log('载入Caches');
|
||||
// }
|
||||
//最新音乐
|
||||
getTopSong()
|
||||
const loadTopSong = () => {
|
||||
getTopSong()
|
||||
.then((res) => {
|
||||
topSongs.value = res.data.data.filter((item, index) => {
|
||||
return index < 10;
|
||||
return index < 100;
|
||||
});
|
||||
store.commit("saveCaches", {
|
||||
topSongs: { data: topSongs.value, time: Date.now() },
|
||||
@ -356,6 +388,28 @@ getTopSong()
|
||||
.catch((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) {
|
||||
if (alias.length > 0) return "[" + alias.join(",") + "]";
|
||||
@ -403,6 +457,11 @@ getPersonalizedMV()
|
||||
});
|
||||
//#endregion
|
||||
|
||||
setInterval(() => {
|
||||
console.log("定时刷新Recommend!")
|
||||
loadBanners()
|
||||
loadTopSong()
|
||||
}, 1 * 60 * 60 * 1000);
|
||||
</script>
|
||||
|
||||
|
||||
|
@ -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_'],
|
||||
|
||||
})
|
||||
|