system.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. // SiYuan - Refactor your thinking
  2. // Copyright (c) 2020-present, b3log.org
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. package api
  17. import (
  18. "io"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strings"
  23. "sync"
  24. "time"
  25. "github.com/88250/gulu"
  26. "github.com/88250/lute"
  27. "github.com/gin-gonic/gin"
  28. "github.com/jinzhu/copier"
  29. "github.com/siyuan-note/logging"
  30. "github.com/siyuan-note/siyuan/kernel/conf"
  31. "github.com/siyuan-note/siyuan/kernel/model"
  32. "github.com/siyuan-note/siyuan/kernel/util"
  33. )
  34. func getNetwork(c *gin.Context) {
  35. ret := gulu.Ret.NewResult()
  36. defer c.JSON(http.StatusOK, ret)
  37. maskedConf, err := model.GetMaskedConf()
  38. if err != nil {
  39. ret.Code = -1
  40. ret.Msg = "get conf failed: " + err.Error()
  41. return
  42. }
  43. ret.Data = map[string]interface{}{
  44. "proxy": maskedConf.System.NetworkProxy,
  45. }
  46. }
  47. func getChangelog(c *gin.Context) {
  48. ret := gulu.Ret.NewResult()
  49. defer c.JSON(http.StatusOK, ret)
  50. data := map[string]interface{}{"show": false, "html": ""}
  51. ret.Data = data
  52. changelogsDir := filepath.Join(util.WorkingDir, "changelogs")
  53. if !gulu.File.IsDir(changelogsDir) {
  54. return
  55. }
  56. if !model.Conf.ShowChangelog {
  57. return
  58. }
  59. changelogPath := filepath.Join(changelogsDir, "v"+util.Ver, "v"+util.Ver+"_"+model.Conf.Lang+".md")
  60. if !gulu.File.IsExist(changelogPath) {
  61. changelogPath = filepath.Join(changelogsDir, "v"+util.Ver, "v"+util.Ver+".md")
  62. if !gulu.File.IsExist(changelogPath) {
  63. logging.LogErrorf("changelog not found: %s", changelogPath)
  64. return
  65. }
  66. }
  67. contentData, err := os.ReadFile(changelogPath)
  68. if err != nil {
  69. logging.LogErrorf("read changelog failed: %s", err)
  70. return
  71. }
  72. model.Conf.ShowChangelog = false
  73. luteEngine := lute.New()
  74. htmlContent := luteEngine.MarkdownStr("", string(contentData))
  75. htmlContent = util.LinkTarget(htmlContent, "")
  76. data["show"] = true
  77. data["html"] = htmlContent
  78. ret.Data = data
  79. }
  80. func getEmojiConf(c *gin.Context) {
  81. ret := gulu.Ret.NewResult()
  82. defer c.JSON(http.StatusOK, ret)
  83. builtConfPath := filepath.Join(util.AppearancePath, "emojis", "conf.json")
  84. data, err := os.ReadFile(builtConfPath)
  85. if err != nil {
  86. logging.LogErrorf("read emojis conf.json failed: %s", err)
  87. ret.Code = -1
  88. ret.Msg = err.Error()
  89. return
  90. }
  91. var conf []map[string]interface{}
  92. if err = gulu.JSON.UnmarshalJSON(data, &conf); err != nil {
  93. logging.LogErrorf("unmarshal emojis conf.json failed: %s", err)
  94. ret.Code = -1
  95. ret.Msg = err.Error()
  96. return
  97. }
  98. customConfDir := filepath.Join(util.DataDir, "emojis")
  99. custom := map[string]interface{}{
  100. "id": "custom",
  101. "title": "Custom",
  102. "title_zh_cn": "自定义",
  103. "title_ja_jp": "カスタム",
  104. }
  105. items := []map[string]interface{}{}
  106. custom["items"] = items
  107. if gulu.File.IsDir(customConfDir) {
  108. model.CustomEmojis = sync.Map{}
  109. customEmojis, err := os.ReadDir(customConfDir)
  110. if err != nil {
  111. logging.LogErrorf("read custom emojis failed: %s", err)
  112. } else {
  113. for _, customEmoji := range customEmojis {
  114. name := customEmoji.Name()
  115. if strings.HasPrefix(name, ".") {
  116. continue
  117. }
  118. if customEmoji.IsDir() {
  119. // 子级
  120. subCustomEmojis, err := os.ReadDir(filepath.Join(customConfDir, name))
  121. if err != nil {
  122. logging.LogErrorf("read custom emojis failed: %s", err)
  123. continue
  124. }
  125. for _, subCustomEmoji := range subCustomEmojis {
  126. if subCustomEmoji.IsDir() {
  127. continue
  128. }
  129. name = subCustomEmoji.Name()
  130. if strings.HasPrefix(name, ".") {
  131. continue
  132. }
  133. addCustomEmoji(customEmoji.Name()+"/"+name, &items)
  134. }
  135. continue
  136. }
  137. addCustomEmoji(name, &items)
  138. }
  139. }
  140. }
  141. custom["items"] = items
  142. conf = append([]map[string]interface{}{custom}, conf...)
  143. ret.Data = conf
  144. return
  145. }
  146. func addCustomEmoji(name string, items *[]map[string]interface{}) {
  147. ext := filepath.Ext(name)
  148. nameWithoutExt := strings.TrimSuffix(name, ext)
  149. emoji := map[string]interface{}{
  150. "unicode": name,
  151. "description": nameWithoutExt,
  152. "description_zh_cn": nameWithoutExt,
  153. "description_ja_jp": nameWithoutExt,
  154. "keywords": nameWithoutExt,
  155. }
  156. *items = append(*items, emoji)
  157. imgSrc := "/emojis/" + name
  158. model.CustomEmojis.Store(nameWithoutExt, imgSrc)
  159. }
  160. func checkUpdate(c *gin.Context) {
  161. ret := gulu.Ret.NewResult()
  162. defer c.JSON(http.StatusOK, ret)
  163. arg, ok := util.JsonArg(c, ret)
  164. if !ok {
  165. return
  166. }
  167. showMsg := arg["showMsg"].(bool)
  168. model.CheckUpdate(showMsg)
  169. }
  170. func exportLog(c *gin.Context) {
  171. ret := gulu.Ret.NewResult()
  172. defer c.JSON(http.StatusOK, ret)
  173. zipPath := model.ExportSystemLog()
  174. ret.Data = map[string]interface{}{
  175. "zip": zipPath,
  176. }
  177. }
  178. func exportConf(c *gin.Context) {
  179. ret := gulu.Ret.NewResult()
  180. defer c.JSON(http.StatusOK, ret)
  181. logging.LogInfof("exporting conf...")
  182. name := "siyuan-conf-" + time.Now().Format("20060102150405") + ".json"
  183. tmpDir := filepath.Join(util.TempDir, "export")
  184. if err := os.MkdirAll(tmpDir, 0755); err != nil {
  185. logging.LogErrorf("export conf failed: %s", err)
  186. ret.Code = -1
  187. ret.Msg = err.Error()
  188. return
  189. }
  190. clonedConf := &model.AppConf{}
  191. if err := copier.CopyWithOption(clonedConf, model.Conf, copier.Option{IgnoreEmpty: false, DeepCopy: true}); err != nil {
  192. logging.LogErrorf("export conf failed: %s", err)
  193. ret.Code = -1
  194. ret.Msg = err.Error()
  195. return
  196. }
  197. if nil != clonedConf.Appearance {
  198. clonedConf.Appearance.DarkThemes = nil
  199. clonedConf.Appearance.LightThemes = nil
  200. clonedConf.Appearance.Icons = nil
  201. }
  202. if nil != clonedConf.Editor {
  203. clonedConf.Editor.Emoji = []string{}
  204. }
  205. if nil != clonedConf.Export {
  206. clonedConf.Export.PandocBin = ""
  207. }
  208. clonedConf.UserData = ""
  209. clonedConf.Account = nil
  210. clonedConf.AccessAuthCode = ""
  211. if nil != clonedConf.System {
  212. clonedConf.System.ID = ""
  213. clonedConf.System.Name = ""
  214. clonedConf.System.OSPlatform = ""
  215. clonedConf.System.Container = ""
  216. clonedConf.System.IsMicrosoftStore = false
  217. clonedConf.System.IsInsider = false
  218. }
  219. clonedConf.Sync = nil
  220. clonedConf.Stat = nil
  221. clonedConf.Api = nil
  222. clonedConf.Repo = nil
  223. clonedConf.Publish = nil
  224. clonedConf.CloudRegion = 0
  225. clonedConf.DataIndexState = 0
  226. data, err := gulu.JSON.MarshalIndentJSON(clonedConf, "", " ")
  227. if err != nil {
  228. logging.LogErrorf("export conf failed: %s", err)
  229. ret.Code = -1
  230. ret.Msg = err.Error()
  231. return
  232. }
  233. tmp := filepath.Join(tmpDir, name)
  234. if err = os.WriteFile(tmp, data, 0644); err != nil {
  235. logging.LogErrorf("export conf failed: %s", err)
  236. ret.Code = -1
  237. ret.Msg = err.Error()
  238. return
  239. }
  240. zipFile, err := gulu.Zip.Create(tmp + ".zip")
  241. if err != nil {
  242. logging.LogErrorf("export conf failed: %s", err)
  243. ret.Code = -1
  244. ret.Msg = err.Error()
  245. return
  246. }
  247. if err = zipFile.AddEntry(name, tmp); err != nil {
  248. logging.LogErrorf("export conf failed: %s", err)
  249. ret.Code = -1
  250. ret.Msg = err.Error()
  251. return
  252. }
  253. if err = zipFile.Close(); err != nil {
  254. logging.LogErrorf("export conf failed: %s", err)
  255. ret.Code = -1
  256. ret.Msg = err.Error()
  257. return
  258. }
  259. logging.LogInfof("exported conf")
  260. zipPath := "/export/" + name + ".zip"
  261. ret.Data = map[string]interface{}{
  262. "name": name,
  263. "zip": zipPath,
  264. }
  265. }
  266. func importConf(c *gin.Context) {
  267. ret := gulu.Ret.NewResult()
  268. defer c.JSON(200, ret)
  269. logging.LogInfof("importing conf...")
  270. form, err := c.MultipartForm()
  271. if err != nil {
  272. logging.LogErrorf("read upload file failed: %s", err)
  273. ret.Code = -1
  274. ret.Msg = err.Error()
  275. return
  276. }
  277. files := form.File["file"]
  278. if 1 != len(files) {
  279. ret.Code = -1
  280. ret.Msg = "invalid upload file"
  281. return
  282. }
  283. f := files[0]
  284. fh, err := f.Open()
  285. if err != nil {
  286. logging.LogErrorf("read upload file failed: %s", err)
  287. ret.Code = -1
  288. ret.Msg = err.Error()
  289. return
  290. }
  291. data, err := io.ReadAll(fh)
  292. fh.Close()
  293. if err != nil {
  294. logging.LogErrorf("read upload file failed: %s", err)
  295. ret.Code = -1
  296. ret.Msg = err.Error()
  297. return
  298. }
  299. tmpDir := filepath.Join(util.TempDir, "import")
  300. if err = os.MkdirAll(tmpDir, 0755); err != nil {
  301. logging.LogErrorf("import conf failed: %s", err)
  302. ret.Code = -1
  303. ret.Msg = err.Error()
  304. return
  305. }
  306. tmp := filepath.Join(tmpDir, f.Filename)
  307. if err = os.WriteFile(tmp, data, 0644); err != nil {
  308. logging.LogErrorf("import conf failed: %s", err)
  309. ret.Code = -1
  310. ret.Msg = err.Error()
  311. return
  312. }
  313. if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
  314. logging.LogErrorf("import conf failed: %s", err)
  315. ret.Code = -1
  316. ret.Msg = err.Error()
  317. return
  318. }
  319. tmp = filepath.Join(tmpDir, f.Filename[:len(f.Filename)-4])
  320. data, err = os.ReadFile(tmp)
  321. if err != nil {
  322. logging.LogErrorf("import conf failed: %s", err)
  323. ret.Code = -1
  324. ret.Msg = err.Error()
  325. return
  326. }
  327. importedConf := model.NewAppConf()
  328. if err = gulu.JSON.UnmarshalJSON(data, importedConf); err != nil {
  329. logging.LogErrorf("import conf failed: %s", err)
  330. ret.Code = -1
  331. ret.Msg = err.Error()
  332. return
  333. }
  334. if err = copier.CopyWithOption(model.Conf, importedConf, copier.Option{IgnoreEmpty: true, DeepCopy: true}); err != nil {
  335. logging.LogErrorf("import conf failed: %s", err)
  336. ret.Code = -1
  337. ret.Msg = err.Error()
  338. return
  339. }
  340. logging.LogInfof("imported conf")
  341. model.Close(false, true, 1)
  342. }
  343. func getConf(c *gin.Context) {
  344. ret := gulu.Ret.NewResult()
  345. defer c.JSON(http.StatusOK, ret)
  346. maskedConf, err := model.GetMaskedConf()
  347. if err != nil {
  348. ret.Code = -1
  349. ret.Msg = "get conf failed: " + err.Error()
  350. return
  351. }
  352. if !maskedConf.Sync.Enabled || (0 == maskedConf.Sync.Provider && !model.IsSubscriber()) {
  353. maskedConf.Sync.Stat = model.Conf.Language(53)
  354. }
  355. // REF: https://github.com/siyuan-note/siyuan/issues/11364
  356. role := model.GetGinContextRole(c)
  357. if model.IsReadOnlyRole(role) {
  358. maskedConf.ReadOnly = true
  359. }
  360. if !model.IsValidRole(role, []model.Role{
  361. model.RoleAdministrator,
  362. }) {
  363. model.HideConfSecret(maskedConf)
  364. }
  365. ret.Data = map[string]interface{}{
  366. "conf": maskedConf,
  367. "start": !util.IsUILoaded,
  368. }
  369. }
  370. func setUILayout(c *gin.Context) {
  371. ret := gulu.Ret.NewResult()
  372. defer c.JSON(http.StatusOK, ret)
  373. if util.ReadOnly {
  374. return
  375. }
  376. arg, ok := util.JsonArg(c, ret)
  377. if !ok {
  378. return
  379. }
  380. param, err := gulu.JSON.MarshalJSON(arg["layout"])
  381. if err != nil {
  382. ret.Code = -1
  383. ret.Msg = err.Error()
  384. return
  385. }
  386. uiLayout := &conf.UILayout{}
  387. if err = gulu.JSON.UnmarshalJSON(param, uiLayout); err != nil {
  388. ret.Code = -1
  389. ret.Msg = err.Error()
  390. return
  391. }
  392. model.Conf.SetUILayout(uiLayout)
  393. model.Conf.Save()
  394. }
  395. func setAPIToken(c *gin.Context) {
  396. ret := gulu.Ret.NewResult()
  397. defer c.JSON(http.StatusOK, ret)
  398. arg, ok := util.JsonArg(c, ret)
  399. if !ok {
  400. return
  401. }
  402. token := arg["token"].(string)
  403. model.Conf.Api.Token = token
  404. model.Conf.Save()
  405. }
  406. func setAccessAuthCode(c *gin.Context) {
  407. ret := gulu.Ret.NewResult()
  408. defer c.JSON(http.StatusOK, ret)
  409. arg, ok := util.JsonArg(c, ret)
  410. if !ok {
  411. return
  412. }
  413. aac := arg["accessAuthCode"].(string)
  414. if model.MaskedAccessAuthCode == aac {
  415. aac = model.Conf.AccessAuthCode
  416. }
  417. model.Conf.AccessAuthCode = aac
  418. model.Conf.Save()
  419. session := util.GetSession(c)
  420. workspaceSession := util.GetWorkspaceSession(session)
  421. workspaceSession.AccessAuthCode = aac
  422. session.Save(c)
  423. go func() {
  424. time.Sleep(200 * time.Millisecond)
  425. util.ReloadUI()
  426. }()
  427. return
  428. }
  429. func setFollowSystemLockScreen(c *gin.Context) {
  430. ret := gulu.Ret.NewResult()
  431. defer c.JSON(http.StatusOK, ret)
  432. arg, ok := util.JsonArg(c, ret)
  433. if !ok {
  434. return
  435. }
  436. lockScreenMode := int(arg["lockScreenMode"].(float64))
  437. model.Conf.System.LockScreenMode = lockScreenMode
  438. model.Conf.Save()
  439. return
  440. }
  441. func getSysFonts(c *gin.Context) {
  442. ret := gulu.Ret.NewResult()
  443. defer c.JSON(http.StatusOK, ret)
  444. ret.Data = util.GetSysFonts(model.Conf.Lang)
  445. }
  446. func version(c *gin.Context) {
  447. ret := gulu.Ret.NewResult()
  448. defer c.JSON(http.StatusOK, ret)
  449. ret.Data = util.Ver
  450. }
  451. func currentTime(c *gin.Context) {
  452. ret := gulu.Ret.NewResult()
  453. defer c.JSON(http.StatusOK, ret)
  454. ret.Data = util.CurrentTimeMillis()
  455. }
  456. func bootProgress(c *gin.Context) {
  457. ret := gulu.Ret.NewResult()
  458. defer c.JSON(http.StatusOK, ret)
  459. progress, details := util.GetBootProgressDetails()
  460. ret.Data = map[string]interface{}{"progress": progress, "details": details}
  461. }
  462. func setAppearanceMode(c *gin.Context) {
  463. ret := gulu.Ret.NewResult()
  464. defer c.JSON(http.StatusOK, ret)
  465. arg, ok := util.JsonArg(c, ret)
  466. if !ok {
  467. return
  468. }
  469. mode := int(arg["mode"].(float64))
  470. model.Conf.Appearance.Mode = mode
  471. if 0 == mode {
  472. model.Conf.Appearance.ThemeJS = gulu.File.IsExist(filepath.Join(util.ThemesPath, model.Conf.Appearance.ThemeLight, "theme.js"))
  473. } else {
  474. model.Conf.Appearance.ThemeJS = gulu.File.IsExist(filepath.Join(util.ThemesPath, model.Conf.Appearance.ThemeDark, "theme.js"))
  475. }
  476. model.Conf.Save()
  477. ret.Data = map[string]interface{}{
  478. "appearance": model.Conf.Appearance,
  479. }
  480. }
  481. func setNetworkServe(c *gin.Context) {
  482. ret := gulu.Ret.NewResult()
  483. defer c.JSON(http.StatusOK, ret)
  484. arg, ok := util.JsonArg(c, ret)
  485. if !ok {
  486. return
  487. }
  488. networkServe := arg["networkServe"].(bool)
  489. model.Conf.System.NetworkServe = networkServe
  490. model.Conf.Save()
  491. util.PushMsg(model.Conf.Language(42), 1000*15)
  492. time.Sleep(time.Second * 3)
  493. }
  494. func setGoogleAnalytics(c *gin.Context) {
  495. ret := gulu.Ret.NewResult()
  496. defer c.JSON(http.StatusOK, ret)
  497. arg, ok := util.JsonArg(c, ret)
  498. if !ok {
  499. return
  500. }
  501. googleAnalytics := arg["googleAnalytics"].(bool)
  502. model.Conf.System.DisableGoogleAnalytics = !googleAnalytics
  503. model.Conf.Save()
  504. }
  505. func setUploadErrLog(c *gin.Context) {
  506. ret := gulu.Ret.NewResult()
  507. defer c.JSON(http.StatusOK, ret)
  508. arg, ok := util.JsonArg(c, ret)
  509. if !ok {
  510. return
  511. }
  512. uploadErrLog := arg["uploadErrLog"].(bool)
  513. model.Conf.System.UploadErrLog = uploadErrLog
  514. model.Conf.Save()
  515. util.PushMsg(model.Conf.Language(42), 1000*15)
  516. time.Sleep(time.Second * 3)
  517. }
  518. func setAutoLaunch(c *gin.Context) {
  519. ret := gulu.Ret.NewResult()
  520. defer c.JSON(http.StatusOK, ret)
  521. arg, ok := util.JsonArg(c, ret)
  522. if !ok {
  523. return
  524. }
  525. autoLaunch := int(arg["autoLaunch"].(float64))
  526. model.Conf.System.AutoLaunch2 = autoLaunch
  527. model.Conf.Save()
  528. }
  529. func setDownloadInstallPkg(c *gin.Context) {
  530. ret := gulu.Ret.NewResult()
  531. defer c.JSON(http.StatusOK, ret)
  532. arg, ok := util.JsonArg(c, ret)
  533. if !ok {
  534. return
  535. }
  536. downloadInstallPkg := arg["downloadInstallPkg"].(bool)
  537. model.Conf.System.DownloadInstallPkg = downloadInstallPkg
  538. model.Conf.Save()
  539. }
  540. func setNetworkProxy(c *gin.Context) {
  541. ret := gulu.Ret.NewResult()
  542. defer c.JSON(http.StatusOK, ret)
  543. arg, ok := util.JsonArg(c, ret)
  544. if !ok {
  545. return
  546. }
  547. scheme := arg["scheme"].(string)
  548. host := arg["host"].(string)
  549. port := arg["port"].(string)
  550. model.Conf.System.NetworkProxy = &conf.NetworkProxy{
  551. Scheme: scheme,
  552. Host: host,
  553. Port: port,
  554. }
  555. model.Conf.Save()
  556. proxyURL := model.Conf.System.NetworkProxy.String()
  557. util.SetNetworkProxy(proxyURL)
  558. util.PushMsg(model.Conf.Language(102), 3000)
  559. }
  560. func addUIProcess(c *gin.Context) {
  561. pid := c.Query("pid")
  562. util.UIProcessIDs.Store(pid, true)
  563. }
  564. func exit(c *gin.Context) {
  565. ret := gulu.Ret.NewResult()
  566. defer c.JSON(http.StatusOK, ret)
  567. arg, ok := util.JsonArg(c, ret)
  568. if !ok {
  569. return
  570. }
  571. forceArg := arg["force"]
  572. var force bool
  573. if nil != forceArg {
  574. force = forceArg.(bool)
  575. }
  576. execInstallPkgArg := arg["execInstallPkg"] // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
  577. execInstallPkg := 0
  578. if nil != execInstallPkgArg {
  579. execInstallPkg = int(execInstallPkgArg.(float64))
  580. }
  581. exitCode := model.Close(force, true, execInstallPkg)
  582. ret.Code = exitCode
  583. switch exitCode {
  584. case 0:
  585. case 1: // 同步执行失败
  586. ret.Msg = model.Conf.Language(96) + "<div class=\"fn__space\"></div><button class=\"b3-button b3-button--white\">" + model.Conf.Language(97) + "</button>"
  587. ret.Data = map[string]interface{}{"closeTimeout": 0}
  588. case 2: // 提示新安装包
  589. ret.Msg = model.Conf.Language(61)
  590. ret.Data = map[string]interface{}{"closeTimeout": 0}
  591. }
  592. }