修复播放列表在Linux下路径显示有问题的BUG

This commit is contained in:
fangxiang 2022-01-18 16:35:19 +08:00
parent fa2f8c76cf
commit 1b31a87a91
1 changed files with 27 additions and 19 deletions

View File

@ -171,24 +171,22 @@ export default defineComponent({
} }
} catch {}*/ } catch {}*/
console.log(prefix);
let temp_str = decodeURI(new URL(item).pathname).replace(
/\\/g,
"/"
);
if ( if (
(GlobalData.getInstance().applicationConfig?.runtime_os ?? (GlobalData.getInstance().applicationConfig?.runtime_os ??
"UNKNOW") == "WINDOWS" "UNKNOW") == "WINDOWS"
) { ) {
let temp_str = decodeURI(new URL(item).pathname) temp_str = temp_str.substr(1);
.substr(1)
.replace(/\\/g, "/");
if (temp_str.startsWith(prefix)) {
temp_str = temp_str.substr(prefix.length + 1);
}
play_list.value.push(temp_str);
} else {
let temp_str = decodeURI(new URL(item).pathname).replace(
/\\/g,
"/"
);
play_list.value.push(temp_str);
} }
if (temp_str.startsWith(prefix)) {
temp_str = temp_str.substr(prefix.length + 1);
}
play_list.value.push(temp_str);
} catch (e) { } catch (e) {
console.warn(e); console.warn(e);
} }
@ -267,16 +265,26 @@ export default defineComponent({
const temp = const temp =
GlobalData.getInstance().applicationConfig GlobalData.getInstance().applicationConfig
?.application_data_dir ?? ""; ?.application_data_dir ?? "";
console.log(temp);
let str = ""; let str = "";
for (const item of play_list.value) { for (const item of play_list.value) {
try { try {
if (item.startsWith("/")) { if (
str += item + ";"; (GlobalData.getInstance().applicationConfig?.runtime_os ??
} else if (item[1] == ":") { "UNKNOW") == "WINDOWS"
// windows ) {
str += "file:///" + (item + ";"); /** windows */
if (item.startsWith("/")) {
str += item + ";";
} else if (item[1] == ":") {
// windows
str += "file:///" + (item + ";");
} else {
str += new URL(temp + "/" + item).toString() + ";";
}
} else { } else {
str += new URL(temp + "/" + item).toString() + ";"; /** linux */
str += item + ";";
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);