Url.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*用户使用www.1473.cn时,我们需要设置成: /#!/word/guid
  2. 用于推广运营时的链接如下:
  3. 电脑端
  4. word可编辑模式跳转 /word/guid。。
  5. word不可编辑模式 http://guid.1473.cn 或者短域名访问 http://123.1473.cn
  6. file的访问模式 /disk/guid
  7. 手机端
  8. word可编辑模式跳转: http://m.1473.cn/word/guid
  9. */
  10. Namespace.register("U.MD.N"); //Url执行区域
  11. /**
  12. * url指引函数
  13. * 此函数需要修改。。参数urlinfo的类型需要固定。
  14. */
  15. U.MD.N.urlGuide = function () {
  16. var _hash = U.UF.C.getUrlHash(), //获取传参
  17. _type; //类型
  18. //如果链接类型是 /#!/disk/13928417148/f6d7a4b6-e34c-4964-beed-24187b2cb1ba 的处理
  19. if (_hash[0] == "#!") {
  20. _hash.shift()
  21. }
  22. //链接类型是 /#disk/13928417148/f6d7a4b6-e34c-4964-beed-24187b2cb1ba 的处理
  23. else {
  24. _hash[0] = _hash[0].substr(1);
  25. }
  26. _type = _hash[0];
  27. switch (_type) {
  28. case "disk":
  29. //打开网盘的处理
  30. U.MD.D.I.openApplication(_type, { "userid": _hash[1], "directoryid": _hash[2] });
  31. break;
  32. case "file":
  33. U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _hash[1]]), function (r) {
  34. var _fileinfo = r.value[0];
  35. _fileinfo = new U.MD.DK.M.entity(_fileinfo.UserFilesID, _fileinfo.UserFilesSize, _fileinfo.UserDirectoryID, _fileinfo.UserFilesName, _fileinfo.UserFilesName, //创建US.disk.Disks里面的内容的数据结构
  36. _fileinfo.UserFilesExtendName, _fileinfo.UserFilesServerName, _fileinfo.UserFilesAddTime, null, 999, _fileinfo.UserFilesModifyTime, _fileinfo.UserDirectoryEncrypt,
  37. 1, _fileinfo.UserFilesExtendName, _fileinfo.GroupID, _fileinfo.UsOffice, _fileinfo.UserID, US.userInfo.UserNikeName, _fileinfo.UserName, _fileinfo.UserThumbnailImageHead);
  38. U.MD.DK.LE.openFileDirectory(_fileinfo);
  39. });
  40. break;
  41. case "excel":
  42. if (_hash[1] == 'join') { //如果地址栏有join进入加群流程
  43. U.MD.N.joinGuide(_hash, _type);
  44. }
  45. else if (_hash[1].length == 36) { //正常调用
  46. U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _hash[1]]), function (r) {
  47. if (r.value[0]) {
  48. //拼接word
  49. var _fileinfo = {
  50. UserDirectoryExtendType: r.value[0].UserFilesExtendName,
  51. UsOffice: r.value[0].UsOffice ? r.value[0].UsOffice.unEscapeQuotes() : null,
  52. UserId: r.value[0].UserID,
  53. UserallDirectoryName: r.value[0].UserFilesName,
  54. UserDirectoryID: r.value[0].UserFilesID,
  55. GroupID: r.value[0].UserDirectoryEncrypt
  56. };
  57. //获取word内容
  58. if (r.value && r.value.UsOffice !== undefined && r.value.UsOffice != null) {
  59. U.MD.D.I.openApplication(_type, _fileinfo);
  60. }
  61. }
  62. });
  63. }
  64. break
  65. case "word":
  66. if (_hash[1] == 'join') { //如果地址栏有join进入加群流程
  67. U.MD.N.joinGuide(_hash, _type);
  68. }
  69. else if (_hash[1].length == 36) { //正常调用
  70. U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _hash[1]]), function (r) {
  71. if (r.value[0]) {
  72. r = r.value[0];
  73. //拼接word
  74. var _fileinfo = {
  75. UserFilesServerName: r.UserFilesServerName,
  76. UserDirectoryExtendType: r.UserFilesExtendName,
  77. UsOffice: r.UsOffice ? r.UsOffice.unEscapeQuotes() : null,
  78. UserId: r.UserID,
  79. UserallDirectoryName: r.UserFilesName,
  80. UserDirectoryID: r.UserFilesID,
  81. GroupID: r.UserDirectoryEncrypt
  82. };
  83. //获取word内容
  84. if (r && r.UsOffice !== undefined && r.UsOffice != null) {
  85. U.MD.D.I.openApplication(_type, _fileinfo);
  86. }
  87. //如果内容不存在则去office系统中获取
  88. else {
  89. U.A.Request("http://office.1473.cn/Officetohtml.ashx", ["Open", _fileinfo.UserDirectoryExtendType, _fileinfo.UserFilesServerName], function (r) {
  90. if (r.value.value != undefined) {
  91. r = r.value;
  92. _fileinfo.UsOffice = r.value.getBodyHtml().replace(/src=[\'\"]?([^\'\"]*)[\'\"]?/ig, function (str1, str2) {
  93. return "src=\"http://office.1473.cn/usoffice/" + str2 + "\"";
  94. });
  95. U.MD.D.I.openApplication(_type, _fileinfo);
  96. } else {
  97. U.Alert('文档已丢失。。。');
  98. }
  99. });
  100. }
  101. }
  102. });
  103. }
  104. break;
  105. case "boomYun": case "txt": case "friend": case "lookupfriend": case "set": case "systemset":
  106. U.MD.D.I.openApplication(_type, { "directoryid": _hash[1] });
  107. if (_hash[1] == "template") {
  108. //打开模板函数
  109. if (_hash[2] != "undefined") {
  110. U.Boom.I.GetHomeTemp.particulars(_hash[2]);
  111. U.MD.N.urlWrite("boomYun/template/" + _hash[2], "互联办公"); //boomyun的url重写
  112. }
  113. }
  114. break;
  115. default: break;
  116. }
  117. }
  118. /**
  119. * 分享邀请链接加入群组
  120. * @param {hash} hash值
  121. * @param {type} 文件类型
  122. */
  123. U.MD.N.joinGuide = function (hash, type) {
  124. var _fileId = hash[2]; //获取文件id
  125. U.MD.U.L.setLoginCallBack(function () { //当用户登录后
  126. U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _fileId]), function (r) { //获取文档对的信息
  127. var _docinfo = r.value[0]; //文档信息
  128. if (!_docinfo) { //是否有文档信息
  129. return U.Alert('添加协同链接有误,请联系群主获取最新协同链接。。。');
  130. }
  131. if (US.friend.group) { //判断是否有群
  132. var _groupId = _docinfo.UserDirectoryEncrypt || _docinfo.UserDirectoryID, //获取群id
  133. _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": _groupId })[0], //判断用户是否加入了群
  134. _docId = _docinfo.UserFilesID; //文档ID
  135. if (!_groupinfo) { //如果没有加群
  136. U.A.Request(US.CD, ([US.DB, "UseStudio_Friends", "GetGroupInfo", _groupId]), function (r) { //取数据库获取群的信息
  137. U.MD.F.J.selectUserInfo.NeedUser = [US.userInfo]; //得到个人信息名并赋值NeeUser全局
  138. US.friend.group.push(r.value[0]); //添加到用户的群
  139. top.U.MD.F.J.determineCreateGroupAndAddGroupUser(r.value[0].GroupManageID, null, null, false, "", "", function (groupid, groupdata) { //添加群
  140. U.Json.del(groupdata[0], { UserId: US.userInfo.userid });
  141. US.friend.groupusers.push.apply(US.friend.groupusers, groupdata[0]);
  142. // US.disk.Disks[US.userInfo.userid].directoryOrFiles.push.apply(US.disk.Disks[US.userInfo.userid].directoryOrFiles, _groupuserinfo);
  143. U.MD.D.I.openApplication(type, U.Json.select(groupdata[1], { UserDirectoryID: _docId })[0], function (contentwindow) { contentwindow.U.MD.O.W.Panel.addUser(US.userInfo.userid); }); //打开应用
  144. });
  145. }); //获取群资料
  146. } else { //加入了群
  147. var _docdiskinfo = new U.MD.DK.M.entity(_docinfo.UserFilesID, _docinfo.UserFilesSize, _docinfo.UserDirectoryID, _docinfo.UserFilesName, _docinfo.UserFilesName, //创建US.disk.Disks里面的内容的数据结构
  148. _docinfo.UserFilesExtendName, _docinfo.UserFilesServerName, _docinfo.UserFilesAddTime, null, 999, _docinfo.UserFilesModifyTime, _docinfo.UserDirectoryEncrypt,
  149. 0, _docinfo.UserFilesExtendName, _groupId, _docinfo.UsOffice, _docinfo.UserID, US.userInfo.UserNikeName, _docinfo.UserName, _docinfo.UserThumbnailImageHead);
  150. U.Alert("你已经在该文档的群里了!");
  151. U.MD.D.I.openApplication(type, _docdiskinfo); //打开应用
  152. }
  153. }
  154. })
  155. });
  156. }
  157. //添加页面导航
  158. /*
  159. * @param {string} hash值
  160. * @param {string} document.title变化
  161. */
  162. U.MD.N.urlWrite = function (hash, title) {
  163. setTimeout(function () {
  164. U.UF.N.addHash(hash); //添加hash的处理
  165. document.title = title; //title的处理
  166. }, 0);
  167. }
  168. //seo模块.现有访问网址。/
  169. //论坛
  170. // 目录: /#!/pb/afa8621d-de5a-44db-8338-7d36168e7446
  171. // 文章:外网:/#!/pbt/e80c57a0-1c82-4f43-931d-b7c8fab982a8
  172. //硬盘
  173. // 目录: /#!/disk/13928417148/f6d7a4b6-e34c-4964-beed-24187b2cb1ba
  174. // txt文件:/#!/txt/63e6b0c9-aa72-1ef5-a9c0-a9d19b2b4c39
  175. // word文件:/#!/word/efb4be75-696b-27fe-f125-25eff5d2716f
  176. // img文件:/#!/img/efb4be75-696b-27fe-f125-25eff5d2716f
  177. //现有word直接查看形式。
  178. //http://disk.1473.cn/efb4be75-696b-27fe-f125-25eff5d2716f/Word
  179. //http://disk.1473.cn/efb4be75-696b-27fe-f125-25eff5d2716f/Txt
  180. //http://disk.1473.cn/efb4be75-696b-27fe-f125-25eff5d2716f/Excel
  181. //从这些网址派生短链接。
  182. //10001.1473.cn
  183. //网盘文件直接打开查看
  184. ///#!/file/38807b15-e721-4820-88b2-5f88da69813b