diff --git a/package.json b/package.json index 344ca09..174f5f6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "main.js", "scripts": { "dev": "rollup --config rollup.config.js -w", - "build": "rollup --config rollup.config.js --environment BUILD:production" + "build": "rollup --config rollup.config.js --environment BUILD:production", + "dev2": "obsidian-plugin dev src/main.ts" }, "keywords": [], "author": "Leonard and Ran", @@ -21,6 +22,7 @@ "css-loader": "^6.4.0", "extract-text-webpack-plugin": "^2.1.2", "obsidian": "^0.12.0", + "obsidian-plugin-cli": "^0.4.3", "rollup": "^2.32.1", "style-loader": "^3.3.0", "tslib": "^2.2.0", @@ -32,6 +34,7 @@ "react": "^17.0.2", "react-dom": "^17.0.2", "react-emoji-render": "^1.2.4", + "react-markdown": "^7.1.0", "react-tabs": "^3.2.2" } } diff --git a/src/main.ts b/src/main.ts index 7e628b9..7fdc89b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,7 +15,7 @@ export default class HabiticaSync extends Plugin { view: HabiticaSyncView; async onload() { - console.log("正在加载habitica-sync") + console.log("load plugin: habitica-sync") await this.loadSettings(); this.addSettingTab(new HabiticaSyncSettingsTab(this.app, this)); this.registerView( @@ -33,6 +33,8 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); + this.activateView(); + } async loadSettings() { this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData()) @@ -40,9 +42,10 @@ export default class HabiticaSync extends Plugin { async saveSettings() { await this.saveData(this.settings); } + async onunload() { // await this.view.onClose(); - + this.app.workspace .getLeavesOfType(VIEW_TYPE) .forEach((leaf) => leaf.detach()); diff --git a/src/view.tsx b/src/view.tsx index 827b893..be66720 100644 --- a/src/view.tsx +++ b/src/view.tsx @@ -31,8 +31,7 @@ export class HabiticaSyncView extends ItemView { this.containerEl.children[1] ) } - - // async onClose(){ - // ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); - // } + async onClose(){ + ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); + } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index e456b0b..36879c9 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -51,12 +51,15 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { + // return ( + //
+ //
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
+ // + //
+ // ); return ( -
-
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- -
- ); +
+ ) } else { return null diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index d2d308e..741eb8c 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,11 +1,16 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function DailyItem(props: any) { return (
- -

+ +
+

+ +
+
) } diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 0d0f192..e45c421 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -9,11 +9,11 @@ export default function Index(props: any){ else { const incompleteDailies = props.dailys.map((daily: any) => { if(!daily.completed) - return + return }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) - return + return }) const display =
diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index b09c217..f458752 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -1,5 +1,6 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function HabitItem(props: any) { return ( @@ -10,8 +11,10 @@ function HabitItem(props: any) { -

- +
+

+ +
) } diff --git a/src/view/Components/Taskview/Habitsview/index.tsx b/src/view/Components/Taskview/Habitsview/index.tsx index dc322bb..1ee9eab 100644 --- a/src/view/Components/Taskview/Habitsview/index.tsx +++ b/src/view/Components/Taskview/Habitsview/index.tsx @@ -9,7 +9,7 @@ export default function Index(props: any){ } else { const allHabits = props.habits.map((habit: any) => { - return + return }) const display =
    {allHabits}
diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 0a23b2d..0d86c01 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -1,11 +1,15 @@ import Emoji from "react-emoji-render"; import * as React from "react"; - +import ReactMarkdown from "react-markdown"; function RewardItem(props: any) { return (
+

+ +
+
) } diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx index 6ef7a61..ff60917 100644 --- a/src/view/Components/Taskview/Rewardview/index.tsx +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -9,7 +9,7 @@ export default function Index(props: any){ } else { const allRewards = props.rewards.map((reward: any) => { - return + return }) const display =
    {allRewards}
diff --git a/src/view/Components/Taskview/TodoItem.tsx b/src/view/Components/Taskview/TodoItem.tsx index c02e230..586fdc9 100644 --- a/src/view/Components/Taskview/TodoItem.tsx +++ b/src/view/Components/Taskview/TodoItem.tsx @@ -5,7 +5,7 @@ function TodoItem(props: any) { return (
- +
) } diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 2766dbe..92b3d7f 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,11 +1,16 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function TodoItem(props: any) { return (
-

+ {/*

*/} +
+

+ +
) } diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 7ce2edf..ec61448 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -9,11 +9,11 @@ export default function Index(props: any){ else { const incompleteTodos = props.todos.map((todo: any) => { if(!todo.completed) - return + return }) const completedTodos = props.todos.map((todo: any) => { if(todo.completed) - return + return }) const display =
diff --git a/styles.css b/styles.css index f2c7e5c..10a2bd6 100644 --- a/styles.css +++ b/styles.css @@ -1,5 +1,5 @@ * { - margin: 0; + /* margin: 0; */ padding: 0; } @@ -49,7 +49,7 @@ .habit-plus { /* background-color: #fff; */ border: none; - color: black; + /* color: black; */ padding: 7px 5px; text-align: center; text-decoration: none; @@ -60,7 +60,7 @@ /* background-color: #fff; */ /* border-radius: 50%; */ border: none; - color: black; + /* color: black; */ padding: 7px 5px; text-align: center; text-decoration: none;