Browse Source

change delete file update

master 1.0.1
godo 10 months ago
parent
commit
e787627dd3
  1. 2
      frontend/src/components/builtin/FileList.vue
  2. 3
      frontend/src/components/computer/Computer.vue
  3. 2
      frontend/src/hook/useContextMenu.ts
  4. 57
      frontend/src/hook/useFile.ts
  5. 8
      frontend/src/stores/upgrade.ts
  6. 103
      godo/files/destop.go
  7. 27
      godo/files/fs.go
  8. 10
      godo/files/init.go
  9. 56
      godo/files/os.go
  10. 4
      godo/sys/update.go
  11. 3
      plugins/clock/README.md
  12. BIN
      plugins/clock/frontend/audio/rest.mp3
  13. BIN
      plugins/clock/frontend/audio/tick.mp3
  14. BIN
      plugins/clock/frontend/audio/work.mp3
  15. BIN
      plugins/clock/frontend/audio/work2.mp3
  16. 206
      plugins/clock/frontend/css/index.css
  17. BIN
      plugins/clock/frontend/font/iconfont.ttf
  18. BIN
      plugins/clock/frontend/font/lcd.ttf
  19. BIN
      plugins/clock/frontend/img/favicon.ico
  20. 105
      plugins/clock/frontend/index.html
  21. 2
      plugins/clock/frontend/js/NoSleep.min.js
  22. 45
      plugins/clock/frontend/js/echarts.min.js
  23. 182
      plugins/clock/frontend/js/index.js
  24. 2
      plugins/clock/frontend/js/jquery-3.6.0.min.js
  25. 304
      plugins/clock/frontend/js/tools.js
  26. 18
      plugins/clock/info.json
  27. 10
      plugins/serverAndFront/info.json

2
frontend/src/components/builtin/FileList.vue

@ -361,7 +361,7 @@ function handleRightClick(mouse: MouseEvent, item: OsFileWithoutContent, index:
} }
chosenIndexs.value = []; chosenIndexs.value = [];
props.onRefresh(); props.onRefresh();
if (item.parentPath == '/C/Users/Desktop') { if (item.path.indexOf('Desktop') > -1) {
sys.refershAppList() sys.refershAppList()
} }
}, },

3
frontend/src/components/computer/Computer.vue

@ -242,11 +242,14 @@ const chosenView = ref("icon");
/**------树状列表打开------ */ /**------树状列表打开------ */
const chosenTreePath = ref(""); const chosenTreePath = ref("");
async function onTreeOpen(path: string) { async function onTreeOpen(path: string) {
chosenTreePath.value = path; chosenTreePath.value = path;
const file = await system.fs.stat(path); const file = await system.fs.stat(path);
if (file) { if (file) {
openFolder(file); openFolder(file);
} }
console.log(path)
router_url.value = path;
} }
/**------框选--------- */ /**------框选--------- */

2
frontend/src/hook/useContextMenu.ts

@ -162,6 +162,7 @@ function useContextMenu() {
} }
newFilePath = fspath.join(path, `${title}(${i})${ext}`); newFilePath = fspath.join(path, `${title}(${i})${ext}`);
} }
const content = ''; const content = '';
return await system.fs.writeFile(newFilePath, content); return await system.fs.writeFile(newFilePath, content);
} }
@ -179,7 +180,6 @@ function useContextMenu() {
} }
return await system.fs.mkdir(newFilePath); return await system.fs.mkdir(newFilePath);
} }
function openPropsWindow(path: string) { function openPropsWindow(path: string) {
new BrowserWindow({ new BrowserWindow({
title: t('props'), title: t('props'),

57
frontend/src/hook/useFile.ts

@ -1,57 +0,0 @@
// import * as fs from "@tauri-apps/plugin-fs";
// import { BaseDirectory } from '@tauri-apps/plugin-fs';
// import { convertFileSrc } from "@tauri-apps/api/core";
// console.log(convertFileSrc("data"))
// const basePath = "/Users/rt008/www/osData";
// const baseFilePath = "/Users/rt008/www/osData/"
// export const useFile = () => {
// return {
// async readdir(path) {
// return fs.readDir(basePath + path);
// },
// async stat(path) {
// return fs.stat(basePath + path);
// },
// async exists(path) {
// return fs.exists(basePath + path);
// },
// async readFile(path) {
// return fs.readFile(basePath + path);
// },
// async unlink(path) {
// return fs.remove(basePath + path);
// },
// async rename(oldPath, newPath) {
// return fs.rename(basePath + oldPath, basePath + newPath);
// },
// async rmdir(path) {
// return fs.remove(basePath + path);
// },
// async mkdir(path) {
// return fs.mkdir(basePath + path);
// },
// async copyFile(src, dest) {
// return fs.copyFile(basePath + src, basePath + dest);
// },
// async writeFile(path, content) {
// return fs.writeFile(basePath + path, content);
// },
// async appendFile(path, content) {
// return fs.writeFile(basePath + path, content, { append: true });
// },
// serializeFileSystem() {
// return Promise.reject('fs 不支持序列化');
// },
// deserializeFileSystem(files) {
// return Promise.reject('fs 不支持序列化');
// },
// removeFileSystem() {
// return Promise.reject('fs 不支持清空');
// },
// registerWatcher(path, callback) {
// return fs.watch(basePath + path, (event) => {
// callback(path);
// });
// },
// }
// };

8
frontend/src/stores/upgrade.ts

@ -57,7 +57,7 @@ export const useUpgradeStore = defineStore('upgradeStore', () => {
} }
} }
async function checkUpdate(res:any) { async function checkUpdate(res:any) {
console.log(res) //console.log(res)
const config = getSystemConfig(); const config = getSystemConfig();
currentVersion.value = config.version; currentVersion.value = config.version;
let bottomList:any = [] let bottomList:any = []
@ -70,13 +70,13 @@ export const useUpgradeStore = defineStore('upgradeStore', () => {
hasNotice.value = true hasNotice.value = true
noticeList.value = changeUrl(bottomList) noticeList.value = changeUrl(bottomList)
} }
console.log(noticeList) //console.log(noticeList)
console.log(centerList) //console.log(centerList)
if(centerList && centerList.length > 0){ if(centerList && centerList.length > 0){
hasAd.value = true hasAd.value = true
adList.value = changeUrl(centerList) adList.value = changeUrl(centerList)
} }
console.log(adList.value) //console.log(adList.value)
if(!res.version || res.version == ""){ if(!res.version || res.version == ""){
return return

103
godo/files/destop.go

@ -5,32 +5,11 @@ import (
"time" "time"
) )
type AppInfo struct {
Name string `json:"name"`
Path string `json:"path"`
OldPath string `json:"oldPath"`
ParentPath string `json:"parentPath"`
Content string `json:"content"`
Ext string `json:"ext"`
Title string `json:"title"`
IsSys int `json:"isSys"`
ID int `json:"id"`
IsFile bool `json:"isFile"`
IsDirectory bool `json:"isDirectory"`
IsSymlink bool `json:"isSymlink"`
Size int `json:"size"`
Mtime time.Time `json:"mtime"` // Modified time
Atime time.Time `json:"atime"` // Access time
Birthtime time.Time `json:"birthtime"` // Creation time
Mode int `json:"mode"`
Rdev int `json:"rdev"`
}
// RootObject represents the root object in the JSON data. // RootObject represents the root object in the JSON data.
type RootObject struct { type RootObject struct {
UpdateTime time.Time `json:"updatetime"` UpdateTime time.Time `json:"updatetime"`
Desktop []AppInfo `json:"apps"` Desktop []OsFileInfo `json:"apps"`
Menulist []AppInfo `json:"menulist"` Menulist []OsFileInfo `json:"menulist"`
} }
var RootAppList = []map[string]string{ var RootAppList = []map[string]string{
@ -60,8 +39,8 @@ var RootAppList = []map[string]string{
// GetInitRootList constructs the initial root list. // GetInitRootList constructs the initial root list.
func GetInitRootList() RootObject { func GetInitRootList() RootObject {
var desktopApps []AppInfo var desktopApps []OsFileInfo
var menulistApps []AppInfo var menulistApps []OsFileInfo
nowtime := time.Now() nowtime := time.Now()
var id = 1 var id = 1
for _, app := range RootAppList { for _, app := range RootAppList {
@ -70,47 +49,43 @@ func GetInitRootList() RootObject {
for _, pos := range positions { for _, pos := range positions {
switch pos { switch pos {
case "Desktop": case "Desktop":
newApp := AppInfo{ newApp := OsFileInfo{
Name: app["name"] + ".exe", Name: app["name"] + ".exe",
Path: "/C/Users/Desktop/" + app["name"] + ".exe", Path: "/C/Users/Desktop/" + app["name"] + ".exe",
OldPath: "/C/Users/Desktop/" + app["name"] + ".exe", OldPath: "/C/Users/Desktop/" + app["name"] + ".exe",
ParentPath: "/C/Users/Desktop", ParentPath: "/C/Users/Desktop",
Content: content, Content: content,
Ext: "exe", Ext: "exe",
Title: app["name"], Title: app["name"],
IsSys: 1, ID: id,
ID: id, IsFile: true,
IsFile: true, IsDir: false,
IsDirectory: false, IsSymlink: false,
IsSymlink: false, Size: int64(len(content)), // Size can be set to any value
Size: len(content), // Size can be set to any value ModTime: nowtime,
Mtime: nowtime, AccessTime: nowtime,
Atime: nowtime, CreateTime: nowtime,
Birthtime: nowtime, Mode: 511,
Mode: 511,
Rdev: 0,
} }
desktopApps = append(desktopApps, newApp) desktopApps = append(desktopApps, newApp)
case "Menulist": case "Menulist":
newApp := AppInfo{ newApp := OsFileInfo{
Name: app["name"] + ".exe", Name: app["name"] + ".exe",
Path: "/C/Users/Menulist/" + app["name"] + ".exe", Path: "/C/Users/Menulist/" + app["name"] + ".exe",
OldPath: "/C/Users/Menulist/" + app["name"] + ".exe", OldPath: "/C/Users/Menulist/" + app["name"] + ".exe",
ParentPath: "/C/Users/Menulist", ParentPath: "/C/Users/Menulist",
Content: content, Content: content,
Ext: "exe", Ext: "exe",
Title: app["name"], Title: app["name"],
IsSys: 1, ID: id,
ID: id, IsFile: true,
IsFile: true, IsDir: false,
IsDirectory: false, IsSymlink: false,
IsSymlink: false, Size: int64(len(content)), // Size can be set to any value
Size: len(content), ModTime: nowtime,
Mtime: nowtime, AccessTime: nowtime,
Atime: nowtime, CreateTime: nowtime,
Birthtime: nowtime, Mode: 511,
Mode: 511,
Rdev: 0,
} }
menulistApps = append(menulistApps, newApp) menulistApps = append(menulistApps, newApp)
} }

27
godo/files/fs.go

@ -176,6 +176,10 @@ func HandleUnlink(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusBadRequest, err.Error()) libs.HTTPError(w, http.StatusBadRequest, err.Error())
return return
} }
err := CheckDeleteDesktop(path)
if err != nil {
log.Printf("Error deleting file from desktop: %s", err.Error())
}
basePath, err := libs.GetOsDir() basePath, err := libs.GetOsDir()
if err != nil { if err != nil {
libs.HTTPError(w, http.StatusInternalServerError, err.Error()) libs.HTTPError(w, http.StatusInternalServerError, err.Error())
@ -230,6 +234,10 @@ func HandleRename(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusConflict, err.Error()) libs.HTTPError(w, http.StatusConflict, err.Error())
return return
} }
err = CheckAddDesktop(newPath)
if err != nil {
log.Printf("Error adding file to desktop: %s", err.Error())
}
res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully renamed to '%s'.", oldPath, newPath)} res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully renamed to '%s'.", oldPath, newPath)}
json.NewEncoder(w).Encode(res) json.NewEncoder(w).Encode(res)
} }
@ -251,6 +259,10 @@ func HandleMkdir(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusConflict, err.Error()) libs.HTTPError(w, http.StatusConflict, err.Error())
return return
} }
err = CheckAddDesktop(dirPath)
if err != nil {
log.Printf("Error adding file to desktop: %s", err.Error())
}
res := libs.APIResponse{Message: fmt.Sprintf("Directory '%s' created successfully.", dirPath)} res := libs.APIResponse{Message: fmt.Sprintf("Directory '%s' created successfully.", dirPath)}
json.NewEncoder(w).Encode(res) json.NewEncoder(w).Encode(res)
} }
@ -267,6 +279,10 @@ func HandleRmdir(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusInternalServerError, err.Error()) libs.HTTPError(w, http.StatusInternalServerError, err.Error())
return return
} }
err = CheckDeleteDesktop(dirPath)
if err != nil {
log.Printf("Error deleting file from desktop: %s", err.Error())
}
err = Rmdir(basePath, dirPath) err = Rmdir(basePath, dirPath)
if err != nil { if err != nil {
libs.HTTPError(w, http.StatusConflict, err.Error()) libs.HTTPError(w, http.StatusConflict, err.Error())
@ -294,6 +310,10 @@ func HandleCopyFile(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusConflict, err.Error()) libs.HTTPError(w, http.StatusConflict, err.Error())
return return
} }
err = CheckAddDesktop(dstPath)
if err != nil {
log.Printf("Error adding file to desktop: %s", err.Error())
}
res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully copied to '%s'.", srcPath, dstPath)} res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully copied to '%s'.", srcPath, dstPath)}
json.NewEncoder(w).Encode(res) json.NewEncoder(w).Encode(res)
} }
@ -306,6 +326,7 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusInternalServerError, err.Error()) libs.HTTPError(w, http.StatusInternalServerError, err.Error())
return return
} }
// 获取文件内容 // 获取文件内容
fileContent, _, err := r.FormFile("content") fileContent, _, err := r.FormFile("content")
if err != nil { if err != nil {
@ -314,7 +335,7 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
} }
defer fileContent.Close() defer fileContent.Close()
// 输出到控制台进行调试 // 输出到控制台进行调试
fmt.Printf("Body content: %v\n", fileContent) //fmt.Printf("Body content: %v\n", fileContent)
file, err := os.Create(filepath.Join(basePath, filePath)) file, err := os.Create(filepath.Join(basePath, filePath))
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
@ -327,6 +348,10 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusConflict) http.Error(w, err.Error(), http.StatusConflict)
return return
} }
err = CheckAddDesktop(filePath)
if err != nil {
log.Printf("Error adding file to desktop: %s", err.Error())
}
res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully written.", filePath)} res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully written.", filePath)}
json.NewEncoder(w).Encode(res) json.NewEncoder(w).Encode(res)
} }

10
godo/files/init.go

@ -175,14 +175,13 @@ func WriteDesktop(rootInfo RootObject) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to marshal reqBodies to JSON: %w", err) return fmt.Errorf("failed to marshal reqBodies to JSON: %w", err)
} }
basePath, err := libs.GetOsDir() desktoppath, err := GetDeskTopPath()
if err != nil { if err != nil {
return fmt.Errorf("GetOsDir error: %v", err) return fmt.Errorf("GetDeskTopPath error: %v", err)
} }
desktoppath := filepath.Join(basePath, "C", "System", "desktop.json")
return os.WriteFile(desktoppath, content, 0644) return os.WriteFile(desktoppath, content, 0644)
} }
func AddDesktop(app AppInfo, position string) error { func AddDesktop(app OsFileInfo, position string) error {
applist, err := GetDesktop() applist, err := GetDesktop()
if err != nil { if err != nil {
return fmt.Errorf("GetDesktop error: %v", err) return fmt.Errorf("GetDesktop error: %v", err)
@ -198,6 +197,7 @@ func AddDesktop(app AppInfo, position string) error {
} else { } else {
return fmt.Errorf("position error") return fmt.Errorf("position error")
} }
//log.Printf("add app to desktop %v", applist)
return WriteDesktop(applist) return WriteDesktop(applist)
} }
func DeleteDesktop(name string) error { func DeleteDesktop(name string) error {
@ -221,7 +221,7 @@ func DeleteDesktop(name string) error {
} }
return WriteDesktop(rootInfo) return WriteDesktop(rootInfo)
} }
func checkHasApp(list []AppInfo, app AppInfo) bool { func checkHasApp(list []OsFileInfo, app OsFileInfo) bool {
for _, item := range list { for _, item := range list {
if item.Name == app.Name { if item.Name == app.Name {
return true return true

56
godo/files/os.go

@ -255,3 +255,59 @@ func GetFileInfo(entry interface{}, basePath, parentPath string) (*OsFileInfo, e
return osFileInfo, nil return osFileInfo, nil
} }
func GetDesktopPath() string {
return filepath.Join("C", "Users", "Desktop")
}
// RemoveFirstSlashOrBackslash 检查字符串的第一个字符是否为 '/' 或 '\'
// 如果是,则返回去掉该字符的剩余部分;如果不是,则返回原字符串。
func RemoveFirstSlashOrBackslash(s string) string {
if len(s) > 0 && (s[0] == '/' || s[0] == '\\') {
return s[1:]
}
return s
}
func CheckAddDesktop(filePath string) error {
checkPath := RemoveFirstSlashOrBackslash(filepath.Dir(filePath))
if checkPath != GetDesktopPath() {
return fmt.Errorf("文件不在桌面目录下")
}
basePath, err := libs.GetOsDir()
if err != nil {
return fmt.Errorf("获取系统目录失败")
}
if !Exists(basePath, filePath) {
return fmt.Errorf("文件不存在")
}
osFileInfo, err := GetFileInfo(filePath, basePath, "")
if err != nil {
return fmt.Errorf("获取文件信息失败")
}
err = AddDesktop(*osFileInfo, "Desktop")
if err != nil {
return fmt.Errorf("添加桌面失败")
}
return nil
}
func CheckDeleteDesktop(filePath string) error {
checkPath := RemoveFirstSlashOrBackslash(filepath.Dir(filePath))
if checkPath != GetDesktopPath() {
return fmt.Errorf("文件不在桌面目录下")
}
basePath, err := libs.GetOsDir()
if err != nil {
return fmt.Errorf("获取系统目录失败")
}
if !Exists(basePath, filePath) {
return fmt.Errorf("文件不存在")
}
osFileInfo, err := GetFileInfo(filePath, basePath, "")
if err != nil {
return fmt.Errorf("获取文件信息失败")
}
err = DeleteDesktop(osFileInfo.Name)
if err != nil {
return fmt.Errorf("添加桌面失败")
}
return nil
}

4
godo/sys/update.go

@ -140,7 +140,7 @@ func GetUpdateInfo() (ServerRes, error) {
return updateInfo, fmt.Errorf("update error get info:" + err.Error()) return updateInfo, fmt.Errorf("update error get info:" + err.Error())
} }
updateUrl := "https://godoos.com/version?info=" + info updateUrl := "https://godoos.com/version?info=" + info
log.Printf("updateUrl:%v", updateUrl) //log.Printf("updateUrl:%v", updateUrl)
res, err := http.Get(updateUrl) res, err := http.Get(updateUrl)
if err != nil { if err != nil {
return updateInfo, fmt.Errorf("update error get url:" + err.Error()) return updateInfo, fmt.Errorf("update error get url:" + err.Error())
@ -154,7 +154,7 @@ func GetUpdateInfo() (ServerRes, error) {
return updateInfo, fmt.Errorf("update error read body:" + err.Error()) return updateInfo, fmt.Errorf("update error read body:" + err.Error())
} }
err = json.Unmarshal(body, &updateInfo) err = json.Unmarshal(body, &updateInfo)
log.Printf("updateInfo:%v", updateInfo) //log.Printf("updateInfo:%v", updateInfo)
if err != nil { if err != nil {
fmt.Println("Error unmarshalling JSON:", err) fmt.Println("Error unmarshalling JSON:", err)
return updateInfo, fmt.Errorf("update error unmarshal:" + err.Error()) return updateInfo, fmt.Errorf("update error unmarshal:" + err.Error())

3
plugins/clock/README.md

@ -1,3 +0,0 @@
# 番茄钟
- godoos应用商店Demo

BIN
plugins/clock/frontend/audio/rest.mp3

Binary file not shown.

BIN
plugins/clock/frontend/audio/tick.mp3

Binary file not shown.

BIN
plugins/clock/frontend/audio/work.mp3

Binary file not shown.

BIN
plugins/clock/frontend/audio/work2.mp3

Binary file not shown.

206
plugins/clock/frontend/css/index.css

@ -1,206 +0,0 @@
/* 设置字体 */
@font-face {
font-family: 'lcd';
src: url('../font/lcd.ttf') format('truetype');
}
@font-face {
font-family: 'icon';
src: url('../font/iconfont.ttf') format('truetype');
}
/*css 初始化 */
html, body, ul, li, ol, dl, dd, dt, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, img { margin:0; padding:0; }
fieldset, img,input,button { font-family:"Times New Roman","Microsoft YaHei","SimSun"; ;border:none; padding:0;margin:0;outline-style:none; } /*去掉边框、去掉轮廓(比如输入框外面的蓝边框)*/
/*去掉列表前面的圆点*/
ul, ol {
list-style: none;
}
/* 设置隐藏 */
.none {
display: none;
}
.flex {
display: flex;
}
/* 设置版心并居中 */
.w {
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
width: 95vw;
}
/* 设置字体 */
.iconfont {
font-family:"icon" !important;
font-style:normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
#n1,#n2,#n4,#n5{
width: 23%;
}
#n3 {
width: 8%;
transform: translate(20%,-25%);
}
.lcd {
font-family:"lcd" !important;
font-size:45vw;font-style:normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
/* 帮助界面 */
.p0 {
margin: 0 auto;
padding: 0 14vw;
position: relative;
}
h3 {
position: absolute;
left: 50%;
top: -7vw;
transform: translateX(-50%);
font-size: 4vw;
}
.tip {
border: 1px solid #999;
}
.p0 p {
margin: 2vw 0 ;
text-align: center;
font-size: 3vw;
}
/* 开始第一页 */
.top {
position: relative;
z-index: 999;
}
.top div{
width: 33.3%;
font-size: 3vw;
}
.top-left {
text-align: left;
}
.top-center {
text-align: center;
}
.top-right {
text-align: right;
white-space: nowrap;
}
.footer div{
width: 33.3%;
text-align: center;
font-size: 5vw;
}
.main {
margin: 1.5vw 0 2.5vw;
padding: 1vw 3vw;
border-top: 1px solid black;
border-bottom: 1px solid black;
}
/* 开始第二页 */
ol {
margin: 0 auto;
width: 50vw;
}
ol li {
text-align: center;
line-height: 7.4vw;
font-size: 4vw;
border-bottom: 1px solid #e1e1e1;
}
ol li:nth-last-child(1){
border-bottom: none;
}
/* 开始第三页 */
.p3 {
font-size: 4vw;
padding: 0 20%;
overflow: hidden;
}
button{
background-color: #fff;
border: 1px solid black;
font-size: 4vw;
padding: 0.2vw 0.7vw;
}
.line1,.line2 {
margin: 5vw auto;
display: flex;
justify-content: space-between;
}
.line1 {
margin-top: 0;
}
.p3 input{
width: 100%;
text-align: center;
font-size: 4vw;
border: 1px solid black;
}
.p3-main span{
width: 50%;
}
.p3-bottom {
padding: 0 2vw;
display: flex;
justify-content: space-between;
}
.p3-bottom button{
width: 40%;
}
/* 第四页 */
.p4 {
font-size: 4vw;
padding: 0 20%;
overflow: hidden;
}
.p4 input{
width: 100%;
text-align: center;
font-size: 4vw;
border: 1px solid black;
}
.p4-main span{
width: 50%;
}
.p4-bottom {
padding: 0 2vw;
display: flex;
justify-content: space-between;
}
.p4-bottom button{
width: 40%;
}
.p5 {
position: relative;
}
.p5 .back {
position: absolute;
right: 10%;
bottom: 2vw;
font-size: 2vw;
border: 1px solid black;
padding: 0.5vw;
}
/* 全屏 */
::backdrop {
z-index:0;
background-color: white !important;
}
html, *:fullscreen, *:-webkit-full-screen, *:-moz-full-screen {
background-color: white !important;
z-index:1;
}

BIN
plugins/clock/frontend/font/iconfont.ttf

Binary file not shown.

BIN
plugins/clock/frontend/font/lcd.ttf

Binary file not shown.

BIN
plugins/clock/frontend/img/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

105
plugins/clock/frontend/index.html

@ -1,105 +0,0 @@
<!DOCTYPE html>
<html lang="zh_CN" >
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
<title>番茄钟</title>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<script src="js/NoSleep.min.js"></script>
<script src="js/jquery-3.6.0.min.js"></script>
<script src="js/echarts.min.js"></script>
<script src="js/tools.js"></script>
<script src="js/index.js"></script>
<!-- 版心 -->
<div class="w">
<!-- 帮助界面 -->
<div class="class page p0 ">
<h3>提示(点击进入主页)</h3>
<div class="tip">
<p>点击屏幕中间进入/退出全屏</p>
<p>点击左上角的番茄钟获取提示</p>
<p>点击中上角的时间电量切换钟表模式</p>
<p>点击右上角的已工作时间切换显示计划时间</p>
</div>
</div>
<!-- 第一页:主界面 -->
<div class="page p1 none">
<div class="top flex">
<!-- 顶部状态栏 -->
<div class="top-left iconfont">&#xe602;番茄钟</div>
<div class="top-center"><span class="now-time">00:00:00</span></div>
<div class="top-right">好好学习,天天向上</div>
</div>
<div class="main flex ">
<!-- 主要的时钟部分 -->
<div class="lcd" id="n1">4</div>
<div class="lcd" id="n2">5</div>
<div class="lcd" id="n3">:</div>
<div class="lcd" id="n4">0</div>
<div class="lcd" id="n5">0</div>
</div>
<div class="footer flex">
<!-- 底部 -->
<div class="footer-left play iconfont">&#xe769;</div>
<div class="footer-center reset iconfont">&#xe60a;</div>
<div class="footer-right setting iconfont">&#xe631;</div>
</div>
</div>
<!-- 第二页:设置界面 -->
<div class="page p2 none">
<ol>
<li class="option">设置工作/休息时间</li>
<li class="option">设置计划倒计时</li>
<li class="option">查看工作历史</li>
<li class="option">清除本地数据</li>
<li class="option">返回</li>
</ol>
</div>
<!-- 第三页:设置工作/休息时间 -->
<div class="page p3 none">
<div class="p3-main">
<div class="line1">
<span>工作时间(分):</span>
<span><input type="text" name="study-time" id="input-study-time" value="45"></span>
</div>
<div class="line2">
<span>休息时间(分):</span>
<span ><input type="text" name="rest-time" id="input-rest-time" value="5"></span>
</div>
</div>
<div class="p3-bottom">
<button>应用</button>
<button>返回</button>
</div>
</div>
<!-- 第四页:设置计划倒计时 -->
<div class="page p4 none">
<div class="p4-main">
<div class="line1">
<span>计划名称:</span>
<span><input type="text" name="plan-name" id="input-plan-name" value=""></span>
</div>
<div class="line2">
<span>截止日期:</span>
<span ><input type="text" name="plan-time" id="input-plan-time" value="2021/12/31"></span>
</div>
</div>
<div class="p4-bottom">
<button>应用</button>
<button>返回</button>
</div>
</div>
<!-- 第五页:展示历史工作时间 -->
<div class="page p5 none ">
<div id="echarts" style="width:85vw;height: 50vw; margin: 0 auto;">
</div>
</div>
</div>
</body>
</html>

2
plugins/clock/frontend/js/NoSleep.min.js

File diff suppressed because one or more lines are too long

45
plugins/clock/frontend/js/echarts.min.js

File diff suppressed because one or more lines are too long

182
plugins/clock/frontend/js/index.js

@ -1,182 +0,0 @@
// 入口函数
$(()=>{
let myChart ;
let isFullScreen = false;
//屏幕常量!
let noSleep = new NoSleep();
let playSound = (src) => {
au = document.createElement("audio");
au.preload="auto";
au.src = '/admin/tools/clock/audio/' + src + '.mp3';
au.play();
}
//绑定事件
// 全屏
$(".main").on("click",()=>{
if(isFullScreen){
document.exitFullscreen();
}
else{
document.body.requestFullscreen();
}
isFullScreen = !isFullScreen;
});
//绑定提示取消
$(".p0").on("click",()=>{
$(".page").hide();
$(".p1").show();
noSleep.enable();
});
$(".top-left").on("click",()=>{
$(".page").hide();
$(".p0").show();
});
//切换工作时间/计划倒计时
$(".top-right").on("click",()=>{
isShowPlan = !isShowPlan;
});
//切换时钟
$(".top-center").on("click",()=>{
isClock = !isClock;
showNowTime();
});
//播放按钮
$(".play").on("click",()=>{
//如果没播放并且在休息,按两下直接开始工作
if (!isPlay && isRest){
res_time = t_study;
isRest = false;
}
if (!isPlay){
$(".play").html(icon_stop);
playSound('tick');
}
if (isPlay){
$(".play").html(icon_play);
}
isPlay = !isPlay;
});
//重置时间
$(".reset").on("click",()=>{
if (isRest){
res_time = t_rest ;
}
else {
res_time = t_study ;
}
showRestTime();
});
//设置
$(".setting").on("click",()=>{
$(".page").hide();
$(".p2").show();
});
//设置工作/休息时间
$(".p2 .option").eq(0).on("click",()=>{
$(".page").hide();
$(".p3").show();
});
//设置计划倒计时
$(".p2 .option").eq(1).on("click",()=>{
$(".page").hide();
$(".p4").show();
});
//查看工作历史
$(".p2 .option").eq(2).on("click",()=>{
$(".page").hide();
$(".p5").show();
myChart = showEcharts();
});
//清除本地数据
$(".p2 .option").eq(3).on("click",()=>{
window.localStorage.clear();
localData = [];
alert("已清除!");
});
//返回
$(".p2 .option").eq(4).on("click",()=>{
$(".page").hide();
$(".p1").show();
});
//第三页设置工作/休息时间
$(".p3-bottom button").eq(0).on("click",()=>{
t_study = $(".p3 input").eq(0).val() * 60;
t_rest = $(".p3 input").eq(1).val() * 60;
if(isRest){
res_time = t_rest;
}
else {
res_time = t_study;
}
showRestTime();
saveSetting();
// alert("完成!");
// console.log(t_study);
});
$(".p3-bottom button").eq(1).on("click",()=>{
$(".page").hide();
$(".p2").show();
});
//第四页 设置计划倒计时
$(".p4-bottom button").eq(0).on("click",()=>{
plan_name = $(".p4 input").eq(0).val();
plan_time = $(".p4 input").eq(1).val() + " " + "08:00:00";
if(isShowPlan){
showPlan();
}
saveSetting();
// alert("完成!");
// console.log(plan_name);
});
$(".p4-bottom button").eq(1).on("click",()=>{
$(".page").hide();
$(".p2").show();
});
//第五页返回
$(".p5").on("click",()=>{
$(".page").hide();
$(".p2").show();
myChart.clear();
});
//开始初始化,设置计时器
loadLocalData();
setInterval(()=>{
showTopBar();
//如果倒计时归零
if(!res_time){
isRest = !isRest;
//该休息了
if(isRest){
$(".top-left").html(icon_rest+"休息中");
playSound('rest');
res_time = t_rest;
}
//该工作了
else{
$(".top-left").html(icon_study+"工作中");
playSound('work');
res_time = t_study;
}
}
//如果在播放
if (isPlay && !isClock){
if(!isRest){
$(".top-left").html(icon_study+"工作中");
study_time++;
}
res_time--;
saveStudyTime();
showRestTime();
}
},1000);
});

2
plugins/clock/frontend/js/jquery-3.6.0.min.js

File diff suppressed because one or more lines are too long

304
plugins/clock/frontend/js/tools.js

@ -1,304 +0,0 @@
// 初始化变量和常量
const icon_play = "&#xe769;";
const icon_stop = "&#xe637;";
const icon_study = "&#xe61e;";
const icon_rest = "&#xe623;";
let t_study = 45*60;
let t_rest = 5*60;
let plan_name = "godo发布";
let plan_time = "2021/12/31 18:00:00";
let isPlay = false;
let isRest = false;
let isShowPlan = false;
let isClock = false;
let localData = {};
let today = null;
let res_time = t_study;
let study_time = 0;
//获取现在的日期并返回
function getToday(){
let t = new Date();
let day = t.getDate();
let month = t.getMonth() +1 ;
let year = t.getFullYear();
let tmp = year +
(month < 10 ? "0" + month : month) +
(day < 10 ? "0" + day : day);
return tmp;
}
//更新today变量为最新的当前日期
function updateToday(){
today = getToday();
}
//读取本地的存储,放到localDate对象中
function loadLocalData(){
updateToday();
//如果存在本地数据
if(window.localStorage && window.localStorage.length){
for (let i=0;i<window.localStorage.length;i++){
let date = window.localStorage.key(i);
let data = window.localStorage.getItem(date);
localData[date] = data;
}
//console.log('本地数据读取完成:'+JSON.stringify(localData));
//如果有今天的数据,那今天的工作时间叠加
if(localData[today]){
study_time+=localData[today];
}
if(localData['plan-name']){
plan_name = localData['plan-name'];
$(".p4 input").eq(0).val(plan_name);
}
if(localData['plan-time']){
plan_time = localData['plan-time'];
$(".p4 input").eq(1).val(plan_time.substr(0,10));
}
if(localData['t_rest']){
t_rest = localData['t_rest'];
$(".p3 input").eq(1).val(t_rest/60);
}
if(localData['t_study']){
t_study = localData['t_study'];
$(".p3 input").eq(0).val(t_study/60);
res_time = t_study;
showRestTime();
}
}
else {
study_time = 0;
}
}
//把剩余的秒数计算成四个要显示的数字并返回
function calTime(t){
let min = Math.floor(t/60);
let sec = t %60;
return [Math.floor(min/10) , min%10 , Math.floor(sec/10) , sec %10];
}
//更新计数器时间
function showRestTime(){
let arr = calTime(res_time);
$("#n1").text(arr[0]);
if(arr[0]==1){
$("#n1").css("transform","translate(30%)");
}
else {
$("#n1").css("transform","none");
}
$("#n2").text(arr[1]);
if(arr[1]==1){
$("#n2").css("transform","translate(30%)");
}
else {
$("#n2").css("transform","none");
}
$("#n4").text(arr[2]);
if(arr[2]==1){
$("#n4").css("transform","translate(30%)");
}
else {
$("#n4").css("transform","none");
}
$("#n5").text(arr[3]);
if(arr[3]==1){
$("#n5").css("transform","translate(30%)");
}
else {
$("#n5").css("transform","none");
}
}
//更新现在的时间和电量
function showNowTime(){
let t = new Date();
let h = t.getHours();
h = h < 10 ? "0" + h : h;
let m = t.getMinutes();
m = m < 10 ? "0" + m : m;
let s = t.getSeconds();
s = s < 10 ? "0" + s : s;
if(navigator.getBattery){
navigator.getBattery().then((result)=>{
$(".now-time").text(h + ":" + m + ":" + s +" 电量:"+parseInt(result.level*100)+"%") ;
})
}
else {
$(".now-time").text(h + ":" + m + ":" + s);
}
//是否开启钟表模式
if(isClock){
//console.log(h+m);
let arr = [h.toString()[0],h.toString()[1],m.toString()[0],m.toString()[1]]
$("#n1").text(arr[0]);
$("#n2").text(arr[1]);
$("#n4").text(arr[2]);
$("#n5").text(arr[3]);
if(arr[0]==1){
$("#n1").css("transform","translate(30%)");
}
else {
$("#n1").css("transform","none");
}
$("#n2").text(arr[1]);
if(arr[1]==1){
$("#n2").css("transform","translate(30%)");
}
else {
$("#n2").css("transform","none");
}
$("#n4").text(arr[2]);
if(arr[2]==1){
$("#n4").css("transform","translate(30%)");
}
else {
$("#n4").css("transform","none");
}
$("#n5").text(arr[3]);
if(arr[3]==1){
$("#n5").css("transform","translate(30%)");
}
else {
$("#n5").css("transform","none");
}
}
else{
showRestTime();
}
}
//更新计划倒计时
function showPlan(){
let t = new Date();
let t0 = new Date(plan_time);
let ss = t0.getTime() - t.getTime();
let r_plan_days = parseInt(ss / 1000/60/60/24);
let r_plan_hours = parseInt((ss / 1000/60/60)%24);
$(".top-right").text("距" + plan_name+"还有:" + r_plan_days + "天" + r_plan_hours + "小时");
}
//存储工作时间
function saveStudyTime(){
console.log('存储数据');
if (getToday()!==today){
study_time = 0 ;
updateToday();
}
localData[today]=study_time.toFixed(2);
window.localStorage.setItem(today,study_time);
}
//更新今天已工作时间
function showStudyTime(){
$(".top-right").text("今天已工作:" +
String(Math.floor(study_time / 60)) +
"分钟" +
String(study_time % 60) +
"秒");
}
//更新最上面一栏
function showTopBar(){
showNowTime();
if(isShowPlan){
showPlan();
}
else{
showStudyTime();
}
}
//保存数据
function saveSetting (){
localData['plan-name'] = plan_name;
localData['plan-time'] = plan_name;
localData['t_study'] = t_study;
localData['t_rest'] = t_rest;
window.localStorage.setItem('plan-name',plan_name);
window.localStorage.setItem('plan-time',plan_time);
window.localStorage.setItem('t_study',t_study);
window.localStorage.setItem('t_rest',t_rest);
}
//展示图表
function showEcharts(){
//console.log("缓存数据:"+ window.localStorage);
//console.log('localData'+localData);
let myChart = echarts.init(document.getElementById('echarts'));
let dateArr = [];
let timeArr = [];
let re = /^20[0-9]{2}/;
for (let i in localData){
if(re.test(i)){
timeArr.push((localData[i]/60).toFixed(2));
//处理原来的数据
let re1 = /^0/;
if (re1.test(i.substr(4,4))){
dateArr.push(i[5]+'/'+i[6]+i[7]);
}
}
}
//处理数据补0
if (dateArr.length<4){
let n = 4 - dateArr.length;
if (dateArr.length==0){
let t = new Date();
t = t.getMonth()+1 + '/'+t.getDate();
dateArr.push(t);
timeArr.push(0);
}
for (let j=0;j<n;j++){
let t = new Date();
t=t.setDate(t.getDate()+j+1);
t = new Date(t);
dateArr.push(t.getMonth()+1+'/'+t.getDate());
timeArr.push(0);
}
}
// console.log(dateArr);
// console.log(timeArr);
let option = {
title: {
text: '工作记录',
subtext: '任意点击返回',
subtextStyle: {
align: 'right'
},
left: 'center',
icon : 'none',
textStyle: {
fontSize: 26
},
},
xAxis: {
data: dateArr,
name: '日期'
},
yAxis: {
name: '工作时间/分钟',
max: function(value){
return value.max<30?30:value.max;
}
},
series: [{
name: '时间(分)',
type: 'bar',
data: timeArr,
barMaxWidth: '40%',
itemStyle:{
color: '#555',
normal: {
label: {
show: true,
position: 'top',
formatter: '{c}分钟'
}
}
}
}]
};
myChart.setOption(option);
return myChart;
}

18
plugins/clock/info.json

@ -1,18 +0,0 @@
{
"name": "todo",
"version": "0.0.1",
"description": "todo worker",
"main": "frontend/index.html",
"icon":"",
"position":["desktop","magnet"],
"width":800,
"height":600,
"usetype":["person","member","compony"],
"category":["work","life","productivity"],
"releases":[""],
"platform": "any",
"arch": "any",
"author": "aiok",
"license": "MIT",
"dependencies": {}
}

10
plugins/serverAndFront/info.json

@ -1,10 +0,0 @@
{
"name" : "godoos",
"version" : "0.0.1",
"description" : "godoos",
"main" : "frontend",
"platform" : ["windows","darwin","linux"],
"author" : "aiok",
"license" : "MIT",
"dependencies" : {}
}
Loading…
Cancel
Save