Browse Source

change setsystem

master
godo 10 months ago
parent
commit
209a6effa9
  1. 6
      frontend/src/components/setting/SetSystem.vue
  2. 56
      frontend/src/system/event/SystemEvent.ts
  3. 22
      frontend/src/system/index.ts
  4. 2
      godo/sys/setting.go
  5. 11
      godo/webdav/httpclient.go

6
frontend/src/components/setting/SetSystem.vue

@ -38,7 +38,7 @@
<label>服务器地址</label> <label>服务器地址</label>
<el-input <el-input
v-model="config.storenet.url" v-model="config.storenet.url"
placeholder="http://192.168.1.16 不要加斜杠" placeholder="http://192.168.1.16:56780 不要加斜杠"
/> />
</div> </div>
</template> </template>
@ -195,8 +195,8 @@ function submitOsInfo() {
RestartApp(); RestartApp();
} }
if (saveData.storeType === "webdav") { if (saveData.storeType === "webdav") {
const urlRegex = /^(https?:\/\/)[^\/]+$/; const urlRegex = /^(https?:\/\/)/;
if (!urlRegex.test(saveData.webdavClient.url)) { if (!urlRegex.test(saveData.webdavClient.url.trim())) {
Dialog.showMessageBox({ Dialog.showMessageBox({
message: "服务器地址格式错误", message: "服务器地址格式错误",
type: "error", type: "error",

56
frontend/src/system/event/SystemEvent.ts

@ -2,7 +2,7 @@ import { mountEvent, emitEvent } from './EventHook';
import { RootState } from '../root'; import { RootState } from '../root';
import { useSystem } from '../index'; import { useSystem } from '../index';
import { join } from '../core/Path'; //import { join } from '../core/Path';
function initSizeEvent() { function initSizeEvent() {
const rootState = useSystem()._rootState; const rootState = useSystem()._rootState;
@ -54,35 +54,35 @@ function initNetworkEvent() {
rootState.info.connection = connection; rootState.info.connection = connection;
}); });
} }
function setAlertTask(time: number, callback: any) { // function setAlertTask(time: number, callback: any) {
const date = new Date(); //现在时刻 // const date = new Date(); //现在时刻
const dateIntegralPoint = new Date(time); // const dateIntegralPoint = new Date(time);
setTimeout(() => { // setTimeout(() => {
callback(); // callback();
}, dateIntegralPoint.getTime() - date.getTime()); //用户登录后的下一个整点执行。 // }, dateIntegralPoint.getTime() - date.getTime()); //用户登录后的下一个整点执行。
} // }
async function initAlertEvent() { async function initAlertEvent() {
const sys = useSystem(); // const sys = useSystem();
const chosenDay = new Date(); // const chosenDay = new Date();
const fileName = `${chosenDay.getFullYear()}-${chosenDay.getMonth() + 1}-${chosenDay.getDate()}.json`; // const fileName = `${chosenDay.getFullYear()}-${chosenDay.getMonth() + 1}-${chosenDay.getDate()}.json`;
const alredyNotes = await sys.fs.readFile( // const alredyNotes = await sys.fs.readFile(
join(sys._rootState.options.userLocation || '', '/Schedule', fileName) // join(sys._rootState.options.userLocation || '', '/Schedule', fileName)
); // );
if (alredyNotes) { // if (alredyNotes) {
const alertList = JSON.parse(alredyNotes); // const alertList = JSON.parse(alredyNotes);
alertList.forEach((item: any) => { // alertList.forEach((item: any) => {
if (item.time < Date.now()) return; // if (item.time < Date.now()) return;
setAlertTask(item.time, () => { // setAlertTask(item.time, () => {
sys.createNotify({ // sys.createNotify({
title: '日程提醒', // title: '日程提醒',
content: `今日${new Date(item.time).getHours()}${new Date(item.time).getMinutes()}分 的提醒: ${ // content: `今日${new Date(item.time).getHours()}时${new Date(item.time).getMinutes()}分 的提醒: ${
item.text // item.text
}`, // }`,
}); // });
}); // });
}); // });
} // }
} }
export { initSizeEvent, initBatteryEvent, initNetworkEvent, initAlertEvent }; export { initSizeEvent, initBatteryEvent, initNetworkEvent, initAlertEvent };

22
frontend/src/system/index.ts

@ -117,11 +117,13 @@ export class System {
} }
const upgradeStore = useUpgradeStore(); const upgradeStore = useUpgradeStore();
upgradeStore.checkUpdate() upgradeStore.checkUpdate()
// setTimeout(() => { setTimeout(() => {
// if (this._rootState.magnet?.length < 1) { if (this._rootState.magnet?.length < 1) {
// this.recover() //this.recover()
// } clearSystemConfig();
// }, 3000); RestartApp();
}
}, 3000);
}, 6000); }, 6000);
} }
@ -248,11 +250,7 @@ export class System {
private async initFileSystem() { private async initFileSystem() {
const storeType = getSystemKey("storeType") const storeType = getSystemKey("storeType")
if (storeType == 'local' || storeType == 'net'){ if(storeType == 'browser'){
//this.fs = this._options.fs;
this.fs = useOsFile();
await this.initOutSystem()
} else {
this.fs = await new OsFileSystem().initFileSystem(this._options); this.fs = await new OsFileSystem().initFileSystem(this._options);
(this.fs as OsFileSystem).on('error', (err: string) => { (this.fs as OsFileSystem).on('error', (err: string) => {
this.emitError(err); this.emitError(err);
@ -260,6 +258,10 @@ export class System {
this.fs.registerWatcher(new RegExp(`^${this._options.userLocation}`), () => { this.fs.registerWatcher(new RegExp(`^${this._options.userLocation}`), () => {
this.initAppList(); this.initAppList();
}); });
}else{
//this.fs = this._options.fs;
this.fs = useOsFile();
await this.initOutSystem()
} }
} }
async initOutSystem() { async initOutSystem() {

2
godo/sys/setting.go

@ -38,7 +38,7 @@ func ConfigHandler(w http.ResponseWriter, r *http.Request) {
libs.SetConfig(req) libs.SetConfig(req)
err := webdav.InitWebdav() err := webdav.InitWebdav()
if err != nil { if err != nil {
libs.ErrorMsg(w, "The webdav client init is error!") libs.ErrorMsg(w, "The webdav client init is error:"+err.Error())
return return
} }
} }

11
godo/webdav/httpclient.go

@ -17,22 +17,23 @@ func InitWebdav() error {
return fmt.Errorf("failed to find configuration for webdavClient") return fmt.Errorf("failed to find configuration for webdavClient")
} }
infoMap, ok := clientInfo.(map[string]string) // 检查 clientInfo 是否为 map 类型
infoMap, ok := clientInfo.(map[string]interface{})
if !ok { if !ok {
return fmt.Errorf("configuration for webdavClient is not a map[string]string") return fmt.Errorf("configuration for webdavClient is not a map")
} }
url, ok := infoMap["url"] url, ok := infoMap["url"].(string)
if !ok { if !ok {
return fmt.Errorf("missing 'url' in webdavClient configuration") return fmt.Errorf("missing 'url' in webdavClient configuration")
} }
username, ok := infoMap["username"] username, ok := infoMap["username"].(string)
if !ok { if !ok {
return fmt.Errorf("missing 'username' in webdavClient configuration") return fmt.Errorf("missing 'username' in webdavClient configuration")
} }
password, ok := infoMap["password"] password, ok := infoMap["password"].(string)
if !ok { if !ok {
return fmt.Errorf("missing 'password' in webdavClient configuration") return fmt.Errorf("missing 'password' in webdavClient configuration")
} }

Loading…
Cancel
Save