forked from miao-moe/QZMusic_PC
feat:
- 搜索页UI - 插件系统支持搜索单曲接口 - 修复音量初始化和状态 - 搜索关键词匹配优化
This commit is contained in:
@@ -66,6 +66,7 @@ class QzpController extends EventEmitter {
|
||||
this.send(["observe_property", 3, "duration"]);
|
||||
this.send(["observe_property", 4, "idle-active"]);
|
||||
this.send(["observe_property", 5, "eof-reached"]);
|
||||
this.send(["set_property", "volume", 50]);
|
||||
});
|
||||
this.socket.on("data", (data) => {
|
||||
this.handleData(data);
|
||||
@@ -148,6 +149,27 @@ class PluginSystem {
|
||||
this.pluginId = pluginId;
|
||||
this.loadPlugin();
|
||||
}
|
||||
async search(query, page, limit) {
|
||||
var _a, _b;
|
||||
if (!((_b = (_a = this.plugin) == null ? void 0 : _a.musicSearch) == null ? void 0 : _b.search)) {
|
||||
return {
|
||||
list: [],
|
||||
total: 0,
|
||||
allPage: 0,
|
||||
error: "Search not implemented"
|
||||
};
|
||||
}
|
||||
try {
|
||||
return await this.plugin.musicSearch.search(query, page, limit);
|
||||
} catch (e) {
|
||||
return {
|
||||
list: [],
|
||||
total: 0,
|
||||
allPage: 0,
|
||||
error: e.message || "Plugin search error"
|
||||
};
|
||||
}
|
||||
}
|
||||
loadPlugin() {
|
||||
try {
|
||||
const pluginPath = path.join(
|
||||
@@ -175,7 +197,17 @@ class PluginSystem {
|
||||
};
|
||||
}
|
||||
try {
|
||||
return await this.plugin.getUrl(id, quality);
|
||||
const url = await this.plugin.getUrl(id, quality);
|
||||
if (typeof url !== "string" || !url.startsWith("http")) {
|
||||
return {
|
||||
success: false,
|
||||
error: "Invalid URL scheme"
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
url
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
success: false,
|
||||
|
||||
@@ -19,7 +19,8 @@ electron.contextBridge.exposeInMainWorld("electronAPI", {
|
||||
},
|
||||
// Plugin System
|
||||
plugin: {
|
||||
call: (pluginId, method, args) => electron.ipcRenderer.invoke("plugin:call", pluginId, method, args)
|
||||
call: (pluginId, method, args) => electron.ipcRenderer.invoke("plugin:call", pluginId, method, args),
|
||||
search: (pluginId, query, page, limit) => electron.ipcRenderer.invoke("plugin:call", pluginId, "search", [query, page, limit])
|
||||
},
|
||||
// Cache Control
|
||||
getCacheInfo: () => electron.ipcRenderer.invoke("cache:getInfo"),
|
||||
|
||||
Reference in New Issue
Block a user