From dcd499d62b2586b6d6b8dba96982845dc47c1b86 Mon Sep 17 00:00:00 2001 From: JiJi Date: Thu, 7 Nov 2024 11:27:38 +0800 Subject: [PATCH] Fix some bugs --- README.md | 2 +- build.js | 26 +++++++++++++------------- src/App.vue | 2 +- src/components/Content.vue | 8 ++++---- src/components/Preview.vue | 4 ++-- src/components/Sidebar.vue | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 7473b99..61660a2 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ ```yaml version: 1.0 # 配置文件版本,默认 1.0 album: - - name: travel # 相册文件夹名 + - name: travel # 相册文件夹名(注意不能为`default`) friendly_name: 旅行 # 相册显示名 preview: IMG_0001.jpg # 预览图(一定要填写实际存在的文件名) - name: secret diff --git a/build.js b/build.js index ff7b9b7..f7e1065 100644 --- a/build.js +++ b/build.js @@ -76,15 +76,15 @@ const main = async () => { console.log('Generated meta.json.'); // 创建相册目录 - fs.mkdirSync(`${DIST_PATH}/_default`); // 默认相册 - fs.mkdirSync(`${DIST_PATH}/_recent`); // 最近相册 + fs.mkdirSync(`${DIST_PATH}/default`); // 默认相册 + // fs.mkdirSync(`${DIST_PATH}/recent`); // 最近相册 for(const i of album) { fs.mkdirSync(`${DIST_PATH}/${i.name}`); if(!i.password) { // 非加密相册 fs.cpSync(`${ALBUM_PATH}/${i.name}`, `${DIST_PATH}/${i.name}/raw`, { recursive: true }); - fs.mkdirSync(`${DIST_PATH}/${i.name}/_cache`); + fs.mkdirSync(`${DIST_PATH}/${i.name}/cache`); fs.readdirSync(`${DIST_PATH}/${i.name}/raw`).forEach(async j => { - await compress(`${DIST_PATH}/${i.name}/raw/${j}`, `${DIST_PATH}/${i.name}/_cache/${j}`); + await compress(`${DIST_PATH}/${i.name}/raw/${j}`, `${DIST_PATH}/${i.name}/cache/${j}`); }); await compress(`${DIST_PATH}/${i.name}/raw/${i.preview}`, `${DIST_PATH}/${i.name}/preview.jpg`); } else { // 加密相册 @@ -104,7 +104,7 @@ const main = async () => { for(const i of album) { if(!i.password) { // 非加密相册 const list = await getFiles(`${DIST_PATH}/${i.name}/raw/`); - fs.writeFileSync(`${DIST_PATH}/${i.name}/_meta.json`, JSON.stringify({ count: list.length })); + fs.writeFileSync(`${DIST_PATH}/${i.name}/meta.json`, JSON.stringify({ count: list.length })); const pageJson = []; for(const j of list) { const dimensions = sizeOf(`${DIST_PATH}/${i.name}/raw/${j}`); @@ -120,12 +120,12 @@ const main = async () => { } const pages = splitArray(pageJson, PHOTO_PER_PAGE); for(let j in pages) { - fs.writeFileSync(`${DIST_PATH}/${i.name}/_page_${j}.json`, JSON.stringify(pages[j])); + fs.writeFileSync(`${DIST_PATH}/${i.name}/page_${j}.json`, JSON.stringify(pages[j])); } } else { // 加密相册 const md5password = md5(String(i.password)); const list = await getFiles(`${DIST_PATH}/${i.name}/${md5password}/`); - fs.writeFileSync(`${DIST_PATH}/${i.name}/_meta.json`, JSON.stringify({ + fs.writeFileSync(`${DIST_PATH}/${i.name}/meta.json`, JSON.stringify({ count: list.length - 1, // without probe.json secret: true, hint: i.hint, @@ -145,24 +145,24 @@ const main = async () => { } const pages = splitArray(pageJson, PHOTO_PER_PAGE); for(let j in pages) { - fs.writeFileSync(`${DIST_PATH}/${i.name}/_page_${j}.json`, JSON.stringify(pages[j])); + fs.writeFileSync(`${DIST_PATH}/${i.name}/page_${j}.json`, JSON.stringify(pages[j])); } } } const defaultPages = splitArray(defaultJson.sort((a, b) => b.ct - a.ct), PHOTO_PER_PAGE); // 按时间倒序 for(let i in defaultPages) { - fs.writeFileSync(`${DIST_PATH}/_default/_page_${i}.json`, JSON.stringify(defaultPages[i])); + fs.writeFileSync(`${DIST_PATH}/default/page_${i}.json`, JSON.stringify(defaultPages[i])); } - fs.writeFileSync(`${DIST_PATH}/_default/_meta.json`, JSON.stringify({ count: defaultJson.length })); + fs.writeFileSync(`${DIST_PATH}/default/meta.json`, JSON.stringify({ count: defaultJson.length })); // const recentJson = defaultJson.sort((a, b) => b.ct - a.ct).slice(0, RECENT_SLICE); // 按时间倒序 // const recentPages = splitArray(recentJson, PHOTO_PER_PAGE); // for(let i in recentPages) { - // fs.writeFileSync(`${DIST_PATH}/_recent/_page_${i}.json`, JSON.stringify(recentPages[i])); + // fs.writeFileSync(`${DIST_PATH}/_recent/page_${i}.json`, JSON.stringify(recentPages[i])); // } - // fs.writeFileSync(`${DIST_PATH}/_recent/_meta.json`, JSON.stringify({ count: recentJson.length })); + // fs.writeFileSync(`${DIST_PATH}/_recent/meta.json`, JSON.stringify({ count: recentJson.length })); - console.log('Generated _meta.json and _page.json.'); + console.log('Generated meta.json and page.json.'); } main(); diff --git a/src/App.vue b/src/App.vue index 0f71fc9..aa30408 100644 --- a/src/App.vue +++ b/src/App.vue @@ -50,7 +50,7 @@ export default { preview_current_obj: '', preview_password: '', - contentAlbumName: "_default", + contentAlbumName: "default", contentFriendlyName: "最近项目", }), methods: { diff --git a/src/components/Content.vue b/src/components/Content.vue index cb06ae8..fe99e53 100644 --- a/src/components/Content.vue +++ b/src/components/Content.vue @@ -114,10 +114,10 @@ export default { }, computed: { album_get_meta_json_name() { - return `${this.base_name}/_meta`; + return `${this.base_name}/meta`; }, album_get_image_at_current_page_json_name() { - return this.base_name + `/_page_` + String(this.current_page_to_load); + return this.base_name + `/page_` + String(this.current_page_to_load); } }, watch: { @@ -187,7 +187,7 @@ export default { this.response_load_new = true; }, get_thumbnail_image(alumn_name ,image_name) { - return `${utils.publicPath}/api/${alumn_name}/${this.password}_cache/${image_name}`; + return `${utils.publicPath}/api/${alumn_name}/${this.password ? `${this.password}_` : ''}cache/${image_name}`; }, async initialize() { @@ -246,7 +246,7 @@ export default { // load page 0 first if (this.page_count > 0) { const args = await utils.parse_args(); - if(args.i) { // 解决多线程异步竞争导致 _page_0 被 _default 抢先加载消耗 count++ 的问题 + if(args.i) { // 解决多线程异步竞争导致 page_0 被 default 抢先加载消耗 count++ 的问题 setTimeout(()=>{ this.load_image(); }, 10); diff --git a/src/components/Preview.vue b/src/components/Preview.vue index 7fafd4a..fb4222b 100644 --- a/src/components/Preview.vue +++ b/src/components/Preview.vue @@ -37,7 +37,7 @@ export default { return this.current_photo_filename.replace(/\.[a-z|A-Z|0-9]*$/g, ""); }, thumbnail_path() { - return `${utils.publicPath}/api/${this.current_album_name}/${this.password}_cache/${this.current_photo_filename}`; + return `${utils.publicPath}/api/${this.current_album_name}/${this.password ? `${this.password}_` : ''}cache/${this.current_photo_filename}`; }, photo_path() { return `${utils.publicPath}/api/${this.current_album_name}/${this.password || 'raw'}/${this.current_photo_filename}`; @@ -48,7 +48,7 @@ export default { this.$emit('hide-preview'); }, thumbnail_path_at_index(i) { - return `${utils.publicPath}/api/${this.image_list[i].al}/_cache/${this.image_list[i].name}`; + return `${utils.publicPath}/api/${this.image_list[i].al}/${this.image_list[i].name}`; }, photo_path_at_index(i) { return `${utils.publicPath}/api/${this.image_list[i].al}/raw/${this.image_list[i].name}`; diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index fba9e38..dd08f15 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -26,13 +26,13 @@
+ :class="selected('default')" + @click="switch_album('default', '最近项目')"> 最近项目