Skip to content

Commit

Permalink
Merge pull request #9 from wflixu/dev
Browse files Browse the repository at this point in the history
v0.4.0
  • Loading branch information
wflixu authored May 3, 2024
2 parents 6970991 + 61a9f4f commit 77d3211
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 259 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "build pkg"

on:
push:
-branches:
branches:
- release

jobs:
Expand Down Expand Up @@ -37,8 +37,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: ${{ matrix.platform == 'macos-latest' && '--target universal-apple-darwin' || '' }}
tagName: v__VERSION__-dev.${{ github.run_number }} # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "Development Build v__VERSION__-dev.${{ github.run_number }}"
tagName: v__VERSION__.${{ github.run_number }} # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "Development Build v__VERSION__.${{ github.run_number }}"
releaseBody: "This is a development release from the master branch (Commit ${{ github.sha }})."
releaseDraft: false
prerelease: true
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ A W.I.P desktop application for a new markup-based typesetting language, [typst]
Typster is built using [Tauri](https://tauri.app/).


# screenshot
# features
- [ ]
- [ ]


## screenshot


![typster](./public/imgs/screen_projects.png)
Expand All @@ -29,7 +34,7 @@ Typster is built using [Tauri](https://tauri.app/).


```
xattr -c /Applications/appname.app
xattr -c /Applications/typster.app
```
### rebuild app icon

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typster",
"private": true,
"version": "0.3.0",
"version": "0.4.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -17,14 +17,14 @@
"@ant-design/icons-vue": "^7.0.1",
"@tauri-apps/api": "^1.5.3",
"ant-design-vue": "4.x",
"github-markdown-css": "^5.5.1",
"monaco-editor": "^0.46.0",
"pinia": "^2.1.7",
"radash": "^12.1.0",
"today-ui": "^0.0.23",
"vue": "^3.4.21",
"vue-router": "^4.3.0",
"vscode-oniguruma": "^2.0.1",
"vscode-textmate": "^9.0.0"
"vscode-textmate": "^9.0.0",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@tauri-apps/cli": "^1.5.10",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"package": {
"productName": "typster",
"version": "0.3.0"
"version": "0.4.0"
},
"tauri": {
"macOSPrivateApi": true,
Expand Down
28 changes: 11 additions & 17 deletions src/components/MonacoEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

<script setup lang="ts">
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
import { PropType, onMounted, ref, watch } from "vue";
import { TypstCompileResult, TypstPage } from "../pages/typst/interface";
import { PropType, onMounted, ref, warn, watch } from "vue";
import { TypstCompileResult } from "../pages/typst/interface";
import type { editor as editorType } from "monaco-editor";
import { invoke } from "@tauri-apps/api";
import { throttle, debounce, relativePath } from './../shared/util'
import { relativePath } from './../shared/util'
import { throttle, debounce } from 'radash'
type IModelChangedEvent = editorType.IModelChangedEvent;
type IModelContentChangedEvent = editorType.IModelContentChangedEvent;
Expand All @@ -26,18 +27,12 @@ const emit = defineEmits<{
(e: 'compiled', data: TypstCompileResult): void
}>()
const boxRef = ref<HTMLElement>();
let monacoEditor: monaco.editor.IStandaloneCodeEditor | null = null;
const updateContent = async (editor: ICodeEditor, path: string) => {
console.warn('updateContent -------')
if (!editor) return;
// Prevent further updates and immediately flush pending updates
Expand Down Expand Up @@ -83,23 +78,23 @@ const handleSave = async () => {
const model = monacoEditor?.getModel();
if (model) {
// Removing the preceding slash
const path = relativePath(props.root!, props.path!);
const path = relativePath(props.root!, props.path!);
await invoke("fs_write_file_text", { path, content: model.getValue() });
await handleCompile();
}
};
//@ts-ignore
const handleCompileThrottle = throttle(handleCompile);
const handleSaveDebounce = debounce(handleSave, 200, { maxWait: 5000 });
const handleCompileThrottle = throttle({ interval: 1000 }, handleCompile);
const handleSaveDebounce = debounce({ delay: 500 }, handleSave);
onMounted(() => {
if (!boxRef.value) {
return;
}
monacoEditor = monaco.editor.create(boxRef.value!, {
language: "typst",
fontSize: 16,
Expand All @@ -113,11 +108,10 @@ onMounted(() => {
handleCompileThrottle();
});
monacoEditor.onDidChangeModelContent((evt: IModelContentChangedEvent) => {
// Compile will update the source file directly in the memory without
// writing to the file system first, this will reduce the preview delay.
// 输入的时候 每隔1秒执行一次编译
handleCompileThrottle();
// 输入完毕后 500ms 后执行一次保存
handleSaveDebounce();
// handleCompile()
});
updateContent(monacoEditor, props.path!)
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createApp } from "vue";
import "github-markdown-css";
import "ant-design-vue/dist/reset.css";
import "./style/styles.css";
import "./shared/monaco-hook";
Expand Down
36 changes: 27 additions & 9 deletions src/pages/home/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<template #overlay>
<a-menu @click="({ key: menuKey }: any) => onContextMenuClick(treeKey, menuKey)">
<a-menu-item key="delete">删除</a-menu-item>
<a-menu-item key="rename">重命名</a-menu-item>
</a-menu>
</template>
</a-dropdown>
Expand All @@ -35,7 +36,6 @@
<a-menu-item v-for="pro in projects" :key="pro.path">
<span>{{ pro.title }}</span> : <span>{{ pro.path }}</span>
</a-menu-item>

</a-menu>
</template>
</a-dropdown>
Expand All @@ -48,27 +48,27 @@
import type { TreeProps } from 'ant-design-vue';
import { ref, h, reactive, onMounted, computed } from 'vue';
import { PlusOutlined, FolderOpenOutlined } from '@ant-design/icons-vue'
import { readDir, FileEntry, writeTextFile, removeFile } from '@tauri-apps/api/fs';
import { readDir, FileEntry, writeTextFile, removeFile, renameFile } from '@tauri-apps/api/fs';
import { useSystemStoreHook } from '../../store/store';
import { DataNode } from 'ant-design-vue/es/tree';
import SidebarToggle from './SidebarToggle.vue';
import { save } from '@tauri-apps/api/dialog';
import { save , } from '@tauri-apps/api/dialog';
const systemStore = useSystemStoreHook();
const expandedKeys = ref<string[]>([]);
const selectedKeys = ref<string[]>([]);
const treeData: TreeProps['treeData'] = reactive([]);
const projects = computed(() =>{
const projects = computed(() => {
return systemStore.projects;
})
const initFiles = async () => {
if (treeData.length > 0) {
treeData.splice(0, treeData.length);
}
const curProject = systemStore.editingProject
if (!curProject) {
return
Expand All @@ -93,6 +93,7 @@ const initFiles = async () => {
const node = { title: entry.path.split('/').pop(), key: entry.path, children: [], selectable: true };
if (entry.children) {
node.selectable = false;
processEntries(entry.children, node)
}
parent.children?.push(node)
Expand All @@ -109,10 +110,28 @@ const initFiles = async () => {
const onContextMenuClick = async (treeKey: string, menuKey: string | number) => {
console.log(`treeKey: ${treeKey}, menuKey: ${menuKey}`);
if (menuKey == 'delete' && treeKey) {
if (treeKey.endsWith('main.typ')) {
alert('The main.typ file cannot be deleted')
return
}
await removeFile(treeKey);
await initFiles();
}
if (menuKey == 'rename' && treeKey) {
const filePath = await save({
title: "Rename file",
filters: [{
name: 'untitled',
extensions: ['typ', 'bib', 'yml']
}],
defaultPath: treeKey
});
if (filePath) {
await renameFile(treeKey, filePath);
}
}
await initFiles();
};
const onSelect = (selectedKeys: string[]) => {
Expand All @@ -136,12 +155,11 @@ const onCreateFile = async () => {
}
}
const onSelectProject = ({key}:any) =>{
const onSelectProject = ({ key }: any) => {
let selectedProject = systemStore.projects.find(item => item.path == key)
if(selectedProject) {
if (selectedProject) {
systemStore.selectProject(selectedProject)
systemStore.setEditingFilePath(selectedProject.path + '/main.typ');
window.location.reload();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/SidebarToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const systemStore = useSystemStoreHook();
const router = useRouter();
const back = () => {
systemStore.selectProject(null);
router.push('/project')
}
const onToggle = () => {
Expand Down
Loading

0 comments on commit 77d3211

Please sign in to comment.