index.html.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <?php
  2. namespace zin;
  3. $this->app->loadConfig('message');
  4. h::css("
  5. #versionTitle {background-image: url('{$config->webRoot}theme/default/images/main/version-upgrade.svg');}
  6. .icon-version {width: 20px; height: 24px; margin: -4px 3px 0px 0px; background-image: url('{$config->webRoot}theme/default/images/main/version-new.svg');}
  7. .icon-version:before {content:'';}
  8. ");
  9. $upgradeBtn = null;
  10. if(trim($config->visions, ',') == 'lite')
  11. {
  12. $version = $config->liteVersion;
  13. $versionName = $lang->liteName . $config->liteVersion;
  14. }
  15. else
  16. {
  17. $version = $config->version;
  18. $versionName = $lang->pmsName . $config->version;
  19. $upgradeBtn = $config->systemMode != 'PLM' ? btn
  20. (
  21. setID('bizLink'),
  22. on::click()->do(<<<'JS'
  23. $('#upgradeContent').toggle();
  24. $('#bizLink').toggleClass('active', $('#upgradeContent').prop('style') && $('#upgradeContent').prop('style').display != 'none');
  25. event.preventDefault();
  26. JS
  27. ),
  28. setClass('ghost'),
  29. set::target('_blank'),
  30. span(setClass('upgrade'), $lang->index->upgrade),
  31. icon('up-circle', setClass('text-danger'))
  32. ) : null;
  33. }
  34. if(!empty($latestVersionList))
  35. {
  36. $lastVersionList = (array)$latestVersionList;
  37. $lastVersion = end($lastVersionList);
  38. $versionItems = array();
  39. foreach($latestVersionList as $versionNumber => $versionInfo)
  40. {
  41. if(!isset($versionInfo['name'])) continue;
  42. $versionItems[] = div
  43. (
  44. setClass('version-list py-2'),
  45. div
  46. (
  47. setClass('version-name flex h-6 items-center'),
  48. icon('version', setClass('version-upgrade')),
  49. h5($versionInfo['name'])
  50. ),
  51. div
  52. (
  53. setClass('version-detail text-gray my-2'),
  54. $versionInfo['explain']
  55. ),
  56. div
  57. (
  58. setClass('version-footer flex justify-between'),
  59. btn
  60. (
  61. setData(array('toggle' => 'modal')),
  62. setClass('ghost'),
  63. set::url(inLink('changeLog', 'version=' . $versionNumber)),
  64. $lang->index->log
  65. ),
  66. btn
  67. (
  68. setClass('primary upgrade-now'),
  69. set::url($versionInfo['link']),
  70. set::target('_blank'),
  71. $lang->index->upgradeNow
  72. )
  73. )
  74. );
  75. if($versionInfo['name'] != $lastVersion['name']) $versionItems[] = h::hr(setClass('version-hr'));
  76. }
  77. $upgradeContent = div
  78. (
  79. setClass('version-content'),
  80. $versionItems
  81. );
  82. }
  83. else
  84. {
  85. $upgradeContent = div
  86. (
  87. setClass('table-empty-tip py-10 mt-8 center'),
  88. btn
  89. (
  90. setClass('secondary-outline bg-secondary-50'),
  91. set::url($lang->website),
  92. set::target('_blank'),
  93. set::text($lang->index->website . ': '. $lang->website)
  94. )
  95. );
  96. h::css("#upgradeContent {height: 262px;} latestVersionList {height: 200px;} ");
  97. }
  98. $scoreNotice = '';
  99. if($config->vision != 'lite') $scoreNotice = $this->loadModel('score')->getNotice();
  100. if($config->systemMode == 'light') unset($lang->searchObjects['program'], $lang->searchObjects['charter']);
  101. unset($lang->searchObjects['all']);
  102. $searchItems = array();
  103. $searchItems[] = array('key' => 'search', 'text' => $lang->searchAB . ' {0}');
  104. foreach($lang->searchObjects as $key => $module) $searchItems[] = array('key' => $key, 'text' => $module . ' #{0}');
  105. jsVar('scoreNotice', $scoreNotice);
  106. jsVar('edition', $config->edition);
  107. jsVar('vision', $config->vision);
  108. jsVar('navGroup', $lang->navGroup);
  109. jsVar('appNotFound', $lang->appNotFound);
  110. jsVar('oldPages', $config->index->oldPages);
  111. jsVar('allAppsItems', $allAppsItems);
  112. jsVar('isTutorialMode', common::isTutorialMode());
  113. jsVar('defaultOpen', !empty($open) ? $open : '');
  114. jsVar('manualText', $lang->manual);
  115. jsVar('manualUrl', ((!empty($config->isINT)) ? $config->manualUrl['int'] : $config->manualUrl['home']) . '&theme=' . $_COOKIE['theme']);
  116. jsVar('langData', array_merge(array('search' => $lang->index->search, 'searchAB' => $lang->searchAB), (array)$lang->index->dock));
  117. jsVar('browserMessage', $browserMessage);
  118. jsVar('pollTime', (!empty($config->message->browser->turnon) && !empty($config->message->browser->pollTime)) ? $config->message->browser->pollTime : 600);
  119. jsVar('turnon', empty($config->message->browser->turnon) ? 0 : 1);
  120. jsVar('runnable', $this->loadModel('cron')->runnable());
  121. jsVar('showFeatures', $showFeatures);
  122. set::zui(true);
  123. set::bodyClass($this->cookie->hideMenu ? 'hide-menu' : 'show-menu');
  124. h::jsVar('window.appsItems', $appsItems, setID('appsItemsData'));
  125. h::jsVar('window.searchItems', $searchItems, setID('searchItemsData'));
  126. h::jsVar('window.userVisions', explode(',', $app->user->visions), setID('userVisionData'));
  127. /* The menu fixed on left */
  128. div
  129. (
  130. setID('menu'),
  131. div
  132. (
  133. setID('spaceHeading'),
  134. icon('space'),
  135. div(setClass('text'))
  136. ),
  137. div
  138. (
  139. setID('menuNav'),
  140. ul(setClass('nav'), setID('menuMainNav')),
  141. ul
  142. (
  143. setClass('nav'),
  144. setID('menuMoreNav'),
  145. li(setClass('divider')),
  146. li
  147. (
  148. a
  149. (
  150. setID('menuMoreBtn'),
  151. set::title($lang->more),
  152. set::href('#menuMoreList'),
  153. icon('more-circle'),
  154. span(setClass('text'), $lang->more),
  155. toggle::dropdown(array('placement' => 'right-end', 'offset' => 12, 'shift' => true))
  156. ),
  157. ul(setClass('dropdown-menu menu scrollbar-light overflow-y-auto'), setID('menuMoreList'))
  158. )
  159. ),
  160. ul
  161. (
  162. setID('menuToggleNav'),
  163. setClass('nav'),
  164. li
  165. (
  166. setID('menuToggleMenu'),
  167. setClass('hint-right'),
  168. setData(array('collapse-text' => $lang->collapseMenu, 'hint' => $lang->unfoldMenu)),
  169. a
  170. (
  171. setClass('menu-toggle justify-center cursor-pointer'),
  172. icon('icon-menu-collapse icon-sm')
  173. )
  174. )
  175. )
  176. )
  177. );
  178. /* The div used to place the page iframes. */
  179. div(setID('apps'));
  180. /* The toolbar docked on the bottom. */
  181. div
  182. (
  183. setID('appsBar'),
  184. div(setID('visionSwitcher'), visionSwitcher(), setData('vision', $app->config->vision)),
  185. ul(setID('appTabs'), setClass('nav')),
  186. toolbar
  187. (
  188. setID('appsToolbar'),
  189. setClass('space-x-1'),
  190. hasPriv('search', 'index') ? globalSearch() : null,
  191. chatBtn(),
  192. item
  193. (
  194. setID('version'),
  195. setClass('ghost btn-zentao px-1'),
  196. set::icon('zentao text-2xl'),
  197. set::url($lang->website),
  198. set::target('_blank'),
  199. set::hint($version),
  200. set::text($versionName)
  201. ),
  202. $upgradeBtn,
  203. panel
  204. (
  205. setID('upgradeContent'),
  206. to::heading
  207. (
  208. setClass('justify-start items-center gap-1'),
  209. icon(setClass('version-upgrade'), setID('versionTitle')),
  210. span($lang->index->upgradeVersion)
  211. ),
  212. set::headingClass('border-b'),
  213. set::bodyClass('p-0'),
  214. div
  215. (
  216. setID('latestVersionList'),
  217. setClass('p-4'),
  218. $upgradeContent
  219. )
  220. )
  221. )
  222. );
  223. /* Inject zai config to index page. */
  224. $zaiLang = new stdClass();
  225. $this->app->loadLang('aiapp');
  226. if($zaiConfig && !empty($zaiConfig->host) && !empty($zaiConfig->token))
  227. {
  228. if(!hasPriv('aiapp', 'conversation')) $zaiConfig->privs = 'disable-all';
  229. $zaiLang = $lang->aiapp->langData;
  230. }
  231. else
  232. {
  233. $zaiLang->zaiConfigNotValid = $lang->aiapp->langData->zaiConfigNotValid;
  234. }
  235. $zaiConfigUrl = createLink('zai', 'setting');
  236. $zaiLang->zaiConfigNotValid = str_replace('{zaiConfigUrl}', $zaiConfigUrl, $lang->aiapp->langData->zaiConfigNotValid);
  237. if(isset($zaiLang->unauthorizedError)) $zaiLang->unauthorizedError = str_replace('{zaiConfigUrl}', $zaiConfigUrl, $lang->aiapp->langData->unauthorizedError);
  238. $enableAITeammate = !empty($config->enableAITeammate);
  239. h::jsVar('window.enableAITeammate', $enableAITeammate);
  240. if($config->edition != 'open' && $zaiConfig)
  241. {
  242. $this->app->loadLang('ai');
  243. $zaiLang->knowledgeLib = $lang->ai->knowledgeLib;
  244. $zaiConfig->teammateMap = array();
  245. if($enableAITeammate)
  246. {
  247. $zaiLang->teammate = $lang->ai->teammate;
  248. $zaiLang->teammatePromptPrefix = $lang->ai->teammatePromptPrefix;
  249. $zaiLang->teammateKnowledgePrefix = $lang->ai->teammateKnowledgePrefix;
  250. $zaiLang->teammateKnowledgeSuffix = $lang->ai->teammateKnowledgeSuffix;
  251. $zaiConfig->teammateMap = $this->loadModel('aiteammate')->getMap();
  252. }
  253. }
  254. to::headBefore(h::css('.icon-app-empty::before{content: "\ea6e"}'));
  255. to::head
  256. (
  257. $zaiConfig ? h::js('window.zai=' . js::value($zaiConfig) . ';') : null,
  258. h::js('window.zaiLang=', js::value($zaiLang)),
  259. h::importJs($app->getWebRoot() . 'js/zui3/ai.js', setID('aiJS'))
  260. );
  261. /**
  262. * Check if the tutorial mode is on, show confirm dialog if it is.
  263. * 检查是否处于教程模式,如果是则显示确认对话框是否继续。
  264. */
  265. if(common::isTutorialMode())
  266. {
  267. setData('tutorialTip', $lang->index->tutorialTip);
  268. to::head
  269. (
  270. js
  271. (<<<'JS'
  272. $(function()
  273. {
  274. if(window.top !== window) return;
  275. zui.Modal.confirm($('html').data('tutorialTip')).then(result =>
  276. {
  277. window.location = result ? $.createLink('tutorial', 'index') : $.createLink('tutorial', 'quit');
  278. });
  279. })
  280. JS
  281. )
  282. );
  283. }
  284. render('pagebase');