fix
This commit is contained in:
parent
ac57825452
commit
933c74804c
6 changed files with 71 additions and 68 deletions
|
|
@ -4,11 +4,9 @@ import zhCnTrans from "./i18n/zh-cn.json";
|
|||
import { initReactI18next } from 'react-i18next';
|
||||
|
||||
const lang = window.localStorage.getItem('language');
|
||||
// console.log(lang)
|
||||
|
||||
i18n.use(initReactI18next)
|
||||
.init({
|
||||
//资源文件
|
||||
.init({
|
||||
resources: {
|
||||
en: {
|
||||
translation: enUsTrans,
|
||||
|
|
@ -22,6 +20,6 @@ i18n.use(initReactI18next)
|
|||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
export default i18n;
|
||||
|
|
@ -11,5 +11,11 @@
|
|||
"submit": "添加",
|
||||
"No Dailies Present": "目前每日任务为空",
|
||||
"No habits present.": "目前习惯为空",
|
||||
"No Rewards present.": "目前奖励为空"
|
||||
"No Rewards present.": "目前奖励为空",
|
||||
"There was an error running the cron. Please try again later.": "运行定时失败出错,请稍后再试。",
|
||||
"Login Failed, Please check credentials and try again!": "登录失败, 请检查凭据后再次尝试",
|
||||
"API Error: Please check credentials": "API错误,请检查凭据",
|
||||
"Resyncing, please try again": "重新同步失败,请稍后再试",
|
||||
"Add!": "已添加",
|
||||
"Loading....": "加载中...."
|
||||
}
|
||||
10
src/main.ts
10
src/main.ts
|
|
@ -1,6 +1,6 @@
|
|||
import { Plugin } from "obsidian";
|
||||
import { HabiticaSyncSettingsTab } from "./settings";
|
||||
import { HabiticaSyncView, VIEW_TYPE} from "./view"
|
||||
import { HabiticaSyncView, VIEW_TYPE } from "./view"
|
||||
|
||||
interface HabiticaSyncSettings {
|
||||
userID: string
|
||||
|
|
@ -15,7 +15,6 @@ export default class HabiticaSync extends Plugin {
|
|||
view: HabiticaSyncView;
|
||||
|
||||
async onload() {
|
||||
// console.log("load plugin: habitica-sync")
|
||||
await this.loadSettings();
|
||||
this.addSettingTab(new HabiticaSyncSettingsTab(this.app, this));
|
||||
this.registerView(
|
||||
|
|
@ -28,7 +27,7 @@ export default class HabiticaSync extends Plugin {
|
|||
this.addCommand({
|
||||
id: "habitica-view-open",
|
||||
name: "Open Pane",
|
||||
hotkeys: [{ modifiers: ["Mod", "Shift"], key: "h"}],
|
||||
hotkeys: [{ modifiers: ["Mod", "Shift"], key: "h" }],
|
||||
callback: () => {
|
||||
this.activateView();
|
||||
}
|
||||
|
|
@ -44,8 +43,9 @@ export default class HabiticaSync extends Plugin {
|
|||
}
|
||||
|
||||
async onunload() {
|
||||
// await this.view.onClose();
|
||||
|
||||
if (this.view) {
|
||||
await this.view.onClose();
|
||||
}
|
||||
this.app.workspace
|
||||
.getLeavesOfType(VIEW_TYPE)
|
||||
.forEach((leaf) => leaf.detach());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ItemView,WorkspaceLeaf } from "obsidian";
|
||||
import { ItemView, WorkspaceLeaf } from "obsidian";
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
import App from "./view/App"
|
||||
|
|
@ -27,11 +27,11 @@ export class HabiticaSyncView extends ItemView {
|
|||
|
||||
async onOpen() {
|
||||
ReactDOM.render(
|
||||
<App plugin={this.plugin}/>,
|
||||
<App plugin={this.plugin} />,
|
||||
this.containerEl.children[1]
|
||||
)
|
||||
}
|
||||
async onClose(){
|
||||
async onClose() {
|
||||
ReactDOM.unmountComponentAtNode(this.containerEl.children[1]);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import { getStats, scoreTask, makeCronReq, costReward, addTask, deleteTask, upda
|
|||
import Statsview from "./Components/Statsview"
|
||||
import Taskview from "./Components/Taskview"
|
||||
import "../i18n"
|
||||
import { exit } from "process";
|
||||
|
||||
class App extends React.Component<any, any> {
|
||||
private _username = "";
|
||||
|
|
@ -167,7 +166,7 @@ class App extends React.Component<any, any> {
|
|||
}
|
||||
}
|
||||
|
||||
async sendUpdateTask(id: string, type: string,message: string, title: string, notes: string) {
|
||||
async sendUpdateTask(id: string, type: string, message: string, title: string, notes: string) {
|
||||
try {
|
||||
let response = await updateTask(this.username, this.credentials, id, type, title, notes);
|
||||
let result = await response.json();
|
||||
|
|
@ -218,13 +217,13 @@ class App extends React.Component<any, any> {
|
|||
this.state.tasks.dailys.forEach((element: any) => {
|
||||
if (element.id == event.target.id) {
|
||||
if (element.id == event.target.id) {
|
||||
if ( event.target.attributes.title.value == 'submit' ) {
|
||||
const task_title = event.target.attributes['data-title'].value ? event.target.attributes['data-title'].value:element.text
|
||||
const task_notes = event.target.attributes['data-notes'].value ? event.target.attributes['data-notes'].value:element.notes
|
||||
this.sendUpdateTask(event.target.id,'daily',"Update!",task_title,task_notes)
|
||||
if (event.target.attributes.title.value == 'submit') {
|
||||
const task_title = event.target.attributes['data-title'].value ? event.target.attributes['data-title'].value : element.text
|
||||
const task_notes = event.target.attributes['data-notes'].value ? event.target.attributes['data-notes'].value : element.notes
|
||||
this.sendUpdateTask(event.target.id, 'daily', "Update!", task_title, task_notes)
|
||||
} else if (event.target.attributes.title.value == 'delete') {
|
||||
this.sendDeleteTask(event.target.id, "Deleted!")
|
||||
} else if ( !element.completed) {
|
||||
} else if (!element.completed) {
|
||||
this.sendScore(event.target.id, "up", "Checked!")
|
||||
} else {
|
||||
this.sendScore(event.target.id, "down", "Un-Checked!")
|
||||
|
|
@ -274,7 +273,7 @@ class App extends React.Component<any, any> {
|
|||
if (event.target.innerText == 'clear') {
|
||||
this.sendDeleteTask(event.target.id, "Deleted!")
|
||||
} else if (event.target.innerText == 'create') {
|
||||
this.sendUpdateTask(event.target.id,'reward',"Edit!","1","1")
|
||||
this.sendUpdateTask(event.target.id, 'reward', "Edit!", "1", "1")
|
||||
} else {
|
||||
this.sendReward(target_id, "down", "Cost!")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue