Skip to content

Commit

Permalink
1231: v0.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
MuTsunTsai committed Dec 1, 2022
1 parent 7d2589c commit 9d33daa
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/app/components/gadget/menu/dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
protected get ready(): boolean { return core.initialized; }
protected init(): void {
public init(): void {
if(this.initialized) return;
this.initialized = true;
libReady.then(() => {
Expand Down
20 changes: 17 additions & 3 deletions src/app/components/toolbar/filemenu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<dropdown icon="bp-file-alt" :title="$t('toolbar.file.title')" @hide="reset" @show="init">
<dropdown icon="bp-file-alt" :title="$t('toolbar.file.title')" @hide="reset" @show="init" ref="menu">
<template v-slot>
<div class="dropdown-item" @click="core.projects.create()">
<i class="far fa-file"></i>
Expand Down Expand Up @@ -106,17 +106,31 @@
</template>

<script lang="ts">
import { Component } from 'vue-property-decorator';
import { Component, Vue } from 'vue-property-decorator';
import BaseComponent from '../mixins/baseComponent';
import Download from '../gadget/file/download.vue';
import SaveAs from '../gadget/file/saveas.vue';
import type Dropdown from 'components/gadget/menu/dropdown.vue';
@Component
export default class FileMenu extends BaseComponent {
mounted(): void {
registerHotkey(() => (this.$refs.open as Executor).execute(), "o");
registerHotkey(() => {
// 一般來說 Dropdown 元件只有在第一次被按下的時候才會初始化,
// 但 opn 元件是一個例外,因為它要提供快速鍵 Ctrl + O 的功能,
// 而這個快速鍵有可能在第一次開啟選單之前就被按下,
// 此時我們需要手動進行選單的初始化,以便使用該元件的功能。
const opn = this.$refs.open as Executor;
if(opn) {
opn.execute();
} else {
(this.$refs.menu as Dropdown).init();
Vue.nextTick(() => (this.$refs.open as Executor).execute());
}
}, "o");
registerHotkey(() => {
if(!core.design) return;
let bps = this.$refs.bps as Executor;
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/welcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="col-12 col-sm-6 col-lg-5 col-xl-4 recent">
<div v-if="recent.length">
<h4 class="mb-3" v-t="'welcome.recent'"></h4>
<div v-for="(h,i) in recent" :key="i" @click="open(h, true)" class="link-primary">{{h.name}}</div>
<div v-for="(h,i) in recent" :key="i" @click="open([h], true)" class="link-primary">{{h.name}}</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -131,8 +131,8 @@
return core.handles.recent;
}
protected open(handle: FileSystemFileHandle, request: boolean): void {
Files.open([handle], request);
protected open(handles: FileHandleList, request: boolean): void {
Files.open(handles, request);
}
}
</script>
Expand Down
19 changes: 15 additions & 4 deletions src/app/shared/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ namespace Session {
if(sessionString) {
let session = JSON.parse(sessionString);
let jsons = session.jsons as unknown[];
for(let i = 0; i < jsons.length; i++) {
let design = bp.restore(jsons[i]);
core.projects.add(design, false);
}
for(let i = 0; i < jsons.length; i++) tryRestore(jsons[i]);
if(session.open >= 0) core.projects.select(core.designs[session.open]);
bp.update();
}
Expand All @@ -34,6 +31,20 @@ namespace Session {
return haveSession;
}

function tryRestore(json: unknown): void {
try {
let design = bp.restore(json);
core.projects.add(design, false);
} catch(e) {
// 如果專案載入失敗的話,也只好忽略這個 session 存檔
// 因為是 session 的關係,就不顯示任何錯誤了。
if(e instanceof Error) {
// 但是還是送出一個紀錄來備考
gtag('event', 'session_error', { error: e.message });
}
}
}

/** 檢查當前的 App 實體是否具有工作階段儲存權 */
function checkSession(): Promise<boolean> {
const SESSION_CHECK_TIMEOUT = 250;
Expand Down
21 changes: 15 additions & 6 deletions src/core/design/Design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,17 @@ import type { IDesign, ITagObject } from "bp/content/interface";
// Tree 相依於 HistoryManager
this.$tree = new Tree(this, data.tree.edges);

// Junctions 相依於 Tree
// 所有的容器都要等到 Tree 有了之後才能建立
this.$vertices = new CT.VertexContainer(this);
this.$edges = new CT.EdgeContainer(this);
this.$rivers = new CT.RiverContainer(this);
this.$flaps = new CT.FlapContainer(this);

// Junction 相依於 Flap
this.$junctions = new CT.JunctionContainer(this);

// Stretch 相依於 Junction
this.$stretches = new CT.StretchContainer(this);
}

public readonly $tag = "design";
Expand Down Expand Up @@ -106,11 +115,11 @@ import type { IDesign, ITagObject } from "bp/content/interface";
return (this.$mountTarget as Studio).$design == this;
}

public readonly $vertices = new CT.VertexContainer(this);
public readonly $edges = new CT.EdgeContainer(this);
public readonly $rivers = new CT.RiverContainer(this);
public readonly $flaps = new CT.FlapContainer(this);
public readonly $stretches = new CT.StretchContainer(this);
public readonly $vertices: CT.VertexContainer;
public readonly $edges: CT.EdgeContainer;
public readonly $rivers: CT.RiverContainer;
public readonly $flaps: CT.FlapContainer;
public readonly $stretches: CT.StretchContainer;
public readonly $junctions: CT.JunctionContainer;

/** @exports */
Expand Down
1 change: 1 addition & 0 deletions src/log/20220205.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Patches:
- 0.5.3: Two minor patches: [#41](https://github.com/bp-studio/box-pleating-studio/pull/41) and [#42](https://github.com/bp-studio/box-pleating-studio/pull/42).
- 0.5.4: Fix dark mode coloration [#43](https://github.com/bp-studio/box-pleating-studio/pull/43).
- 0.5.5: Fix one minor startup error handling bug.
- 0.5.6: Fix one critical startup bug, welcome screen file opening bug, and one minor hotkey bug.
4 changes: 2 additions & 2 deletions src/public/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, width=device-width, user-scalable=no">
<meta name="description" content="Super-complex origami design made easy!">
<meta name="google" content="notranslate">
<meta name="version" content="0.5.5">
<meta name="version" content="0.5.6">

<!-- Preload -->
<link rel="preload" as="font" type="font/woff2" crossorigin href="assets/bps/fonts/bps.woff2">
Expand All @@ -32,7 +32,7 @@
page_title: document.title,
page_path: "/",
app_name: document.title,
app_version: "1229"
app_version: "1231"
};
gtag('js', new Date());
gtag('config', 'G-GG1TEZGBCQ', app_config);
Expand Down

0 comments on commit 9d33daa

Please sign in to comment.