Showing
1 changed file
with
132 additions
and
57 deletions
@@ -4025,6 +4025,9 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | @@ -4025,6 +4025,9 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | ||
4025 | })(); | 4025 | })(); |
4026 | console.log(urlParams) | 4026 | console.log(urlParams) |
4027 | if (urlParams.userId) { | 4027 | if (urlParams.userId) { |
4028 | + /** | ||
4029 | + * @description 小程序第三方登录获取token | ||
4030 | + */ | ||
4028 | axios.get(`/api/yt/third/login/id/${urlParams.userId}`) | 4031 | axios.get(`/api/yt/third/login/id/${urlParams.userId}`) |
4029 | .then(res => { | 4032 | .then(res => { |
4030 | const { token, refreshToken } = res.data || {} | 4033 | const { token, refreshToken } = res.data || {} |
@@ -4033,83 +4036,155 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | @@ -4033,83 +4036,155 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | ||
4033 | getSaveContent() | 4036 | getSaveContent() |
4034 | }) | 4037 | }) |
4035 | } else { | 4038 | } else { |
4036 | - getSaveContent() | 4039 | + /** |
4040 | + * @description 分享页面获取token | ||
4041 | + */ | ||
4042 | + if (urlParams.share && urlParams.publicId) { | ||
4043 | + axios.post('/api/auth/login/public', { publicId: urlParams.publicId }) | ||
4044 | + .then(res => { | ||
4045 | + const { token, refreshToken } = res.data || {} | ||
4046 | + GLOBAL_TOKEN.token = token | ||
4047 | + GLOBAL_TOKEN.refreshToken = refreshToken | ||
4048 | + getSaveContent() | ||
4049 | + }) | ||
4050 | + } else { | ||
4051 | + getSaveContent() | ||
4052 | + } | ||
4037 | } | 4053 | } |
4038 | } | 4054 | } |
4039 | 4055 | ||
4040 | getToken() | 4056 | getToken() |
4041 | 4057 | ||
4042 | var updateButtonContainer = this.updateButtonContainer | 4058 | var updateButtonContainer = this.updateButtonContainer |
4043 | - // var lockUnlock = this.actions.actions.lockUnlock.funct | ||
4044 | - // var selectAll = this.actions.actions.selectAll.funct | ||
4045 | function getUserPermission() { | 4059 | function getUserPermission() { |
4046 | defHttp.get('/yt/role/me/permissions') | 4060 | defHttp.get('/yt/role/me/permissions') |
4047 | .then(res => { | 4061 | .then(res => { |
4048 | USER_PERMISSION.permission = res | 4062 | USER_PERMISSION.permission = res |
4049 | updateButtonContainer() | 4063 | updateButtonContainer() |
4050 | - // var flag = hasSavePermission() | ||
4051 | - // if (!flag) { | ||
4052 | - // selectAll() | ||
4053 | - // lockUnlock() | ||
4054 | - // } | ||
4055 | }) | 4064 | }) |
4056 | } | 4065 | } |
4057 | 4066 | ||
4067 | + function afterSaveContent(response) { | ||
4068 | + getUserPermission() | ||
4069 | + const { platform } = response || {} | ||
4070 | + const pageSizeControl = PageSetupDialog.getFormats | ||
4071 | + PageSetupDialog.getFormats = function () { | ||
4072 | + if (platform === 'phone') { | ||
4073 | + return [ | ||
4074 | + { key: 'iPhone 8', title: 'iPhone 8', format: new mxRectangle(0, 0, 375, 667) }, | ||
4075 | + { key: 'iPhone 8 Plus', title: 'iPhone 8 Plus', format: new mxRectangle(0, 0, 415, 737) }, | ||
4076 | + { key: 'iPhone X/XS', title: 'iPhone X/XS', format: new mxRectangle(0, 0, 376, 813) }, | ||
4077 | + { | ||
4078 | + key: 'iPhone XR/XS Max', | ||
4079 | + title: 'iPhone XR/XS Max', | ||
4080 | + format: new mxRectangle(0, 0, 415, 897) | ||
4081 | + }, | ||
4082 | + { key: 'iPad 4', title: 'iPad 4', format: new mxRectangle(0, 0, 709, 1025) }, | ||
4083 | + { key: 'Galaxy S9', title: 'Galaxy S9', format: new mxRectangle(0, 0, 361, 741) }, | ||
4084 | + { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) }, | ||
4085 | + { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) }, | ||
4086 | + { key: 'Galaxy S10/S10+', title: 'Galaxy S10/S10+', format: new mxRectangle(0, 0, 413, 870) }, | ||
4087 | + { key: 'Pixel 2', title: 'Pixel 2', format: new mxRectangle(0, 0, 413, 732) }, | ||
4088 | + { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) }, | ||
4089 | + { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) }, | ||
4090 | + { key: 'Pixel XL', title: 'Pixel XL', format: new mxRectangle(0, 0, 413, 848) }, | ||
4091 | + { key: 'custom', title: mxResources.get('custom'), format: null } | ||
4092 | + ] | ||
4093 | + } | ||
4094 | + return pageSizeControl.apply(this, arguments) | ||
4095 | + } | ||
4096 | + Editor.configurationName = response.configurationName + ".drawio"; | ||
4097 | + if (response.configurationContentList.length > 0) { | ||
4098 | + response.configurationContentList.forEach((item) => { | ||
4099 | + Editor.configurationContentId = item.id; | ||
4100 | + if (item.content) { | ||
4101 | + Editor.defaultContent = item.content; | ||
4102 | + } else { | ||
4103 | + //默认空白内容 | ||
4104 | + Editor.defaultContent = EditorUi.prototype.emptyDiagramXml; | ||
4105 | + } | ||
4106 | + }) | ||
4107 | + } | ||
4108 | + if (id == null || id.length == 0) { | ||
4109 | + fn(); | ||
4110 | + } else if (currentFile != null && !sameWindow) { | ||
4111 | + this.showDialog(new PopupDialog(this, this.getUrl() + '#' + id, | ||
4112 | + null, fn).container, 320, 140, true, true); | ||
4113 | + } else { | ||
4114 | + fn(); | ||
4115 | + } | ||
4116 | + | ||
4117 | + } | ||
4118 | + | ||
4058 | var pageFormat = this.editor.graph.pageFormat | 4119 | var pageFormat = this.editor.graph.pageFormat |
4059 | 4120 | ||
4060 | - // 调用API,获取保存的内容 | ||
4061 | - function getSaveContent() { | ||
4062 | - defHttp.get('/yt/configuration/center/get_configuration_info/' + Editor.configurationId) | 4121 | + function createAccessTokenFormLayer() { |
4122 | + var field = 'accessCredentials' | ||
4123 | + var formSubmitFilter = 'formData' | ||
4124 | + var index = layer.open({ | ||
4125 | + type: 1, | ||
4126 | + title: '访问令牌', | ||
4127 | + area: ['350px', '200px'], | ||
4128 | + closeBtn: 0, | ||
4129 | + content: ` | ||
4130 | + <section style="padding: 20px;display: flex;justify-content: center;align-items: center;flex-direction: column;"> | ||
4131 | + <form class="layui-form" action=""> | ||
4132 | + <div class="layui-form-item"> | ||
4133 | + <label class="layui-form-label" style="width: 60px;padding: 9px 0;">访问令牌</label> | ||
4134 | + <div class="layui-input-block" style="margin-left: 70px;"> | ||
4135 | + <input required lay-verify="required" type="text" name="${field}" lay-verify="title" autocomplete="off" placeholder="请输入访问令牌" class="layui-input"> | ||
4136 | + </div> | ||
4137 | + </div> | ||
4138 | + <button lay-submit lay-filter="${formSubmitFilter}" type="button" class="layui-btn layui-btn-normal" style="width: 100%; margin-top: 10px;">进入</button> | ||
4139 | + </form> | ||
4140 | + </section> | ||
4141 | + `, | ||
4142 | + }); | ||
4143 | + var form = layui.form | ||
4144 | + form.on(`submit(${formSubmitFilter})`, function (data) { | ||
4145 | + var value = data.field.accessCredentials | ||
4146 | + getShareContentData(value, index) | ||
4147 | + }) | ||
4148 | + } | ||
4149 | + | ||
4150 | + function getShareContentData(accessCredentials, index) { | ||
4151 | + var id = urlParams.configurationId | ||
4152 | + var share = urlParams.share | ||
4153 | + defHttp.get(`/yt/share/${share}/share_data/${id}${accessCredentials ? `?accessCredentials=${accessCredentials}` : ''}`) | ||
4154 | + .then(function (res) { | ||
4155 | + var layer = layui.layer | ||
4156 | + index && layer.close(index) | ||
4157 | + afterSaveContent(res.data) | ||
4158 | + }) | ||
4159 | + .catch(function (error) { | ||
4160 | + var msg = error.response ? (error.response.data || {}).msg || '' : error.message | ||
4161 | + var layer = layui.layer | ||
4162 | + layer.msg(msg, { icon: 5, offset: 't' }); | ||
4163 | + }) | ||
4164 | + } | ||
4165 | + | ||
4166 | + function checkSharePageNeedAccessToken() { | ||
4167 | + var id = urlParams.configurationId | ||
4168 | + var share = urlParams.share | ||
4169 | + defHttp.get(`/yt/share/check/${share}/${id}`) | ||
4063 | .then(function (response) { | 4170 | .then(function (response) { |
4064 | - getUserPermission() | ||
4065 | - const { platform } = response || {} | ||
4066 | - const pageSizeControl = PageSetupDialog.getFormats | ||
4067 | - PageSetupDialog.getFormats = function () { | ||
4068 | - if (platform === 'phone') { | ||
4069 | - return [ | ||
4070 | - { key: 'iPhone 8', title: 'iPhone 8', format: new mxRectangle(0, 0, 375, 667) }, | ||
4071 | - { key: 'iPhone 8 Plus', title: 'iPhone 8 Plus', format: new mxRectangle(0, 0, 415, 737) }, | ||
4072 | - { key: 'iPhone X/XS', title: 'iPhone X/XS', format: new mxRectangle(0, 0, 376, 813) }, | ||
4073 | - { | ||
4074 | - key: 'iPhone XR/XS Max', | ||
4075 | - title: 'iPhone XR/XS Max', | ||
4076 | - format: new mxRectangle(0, 0, 415, 897) | ||
4077 | - }, | ||
4078 | - { key: 'iPad 4', title: 'iPad 4', format: new mxRectangle(0, 0, 709, 1025) }, | ||
4079 | - { key: 'Galaxy S9', title: 'Galaxy S9', format: new mxRectangle(0, 0, 361, 741) }, | ||
4080 | - { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) }, | ||
4081 | - { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) }, | ||
4082 | - { key: 'Galaxy S10/S10+', title: 'Galaxy S10/S10+', format: new mxRectangle(0, 0, 413, 870) }, | ||
4083 | - { key: 'Pixel 2', title: 'Pixel 2', format: new mxRectangle(0, 0, 413, 732) }, | ||
4084 | - { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) }, | ||
4085 | - { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) }, | ||
4086 | - { key: 'Pixel XL', title: 'Pixel XL', format: new mxRectangle(0, 0, 413, 848) }, | ||
4087 | - { key: 'custom', title: mxResources.get('custom'), format: null } | ||
4088 | - ] | ||
4089 | - } | ||
4090 | - return pageSizeControl.apply(this, arguments) | ||
4091 | - } | ||
4092 | - Editor.configurationName = response.configurationName + ".drawio"; | ||
4093 | - if (response.configurationContentList.length > 0) { | ||
4094 | - response.configurationContentList.forEach((item) => { | ||
4095 | - Editor.configurationContentId = item.id; | ||
4096 | - if (item.content) { | ||
4097 | - Editor.defaultContent = item.content; | ||
4098 | - } else { | ||
4099 | - //默认空白内容 | ||
4100 | - Editor.defaultContent = EditorUi.prototype.emptyDiagramXml; | ||
4101 | - } | ||
4102 | - }) | ||
4103 | - } | ||
4104 | - if (id == null || id.length == 0) { | ||
4105 | - fn(); | ||
4106 | - } else if (currentFile != null && !sameWindow) { | ||
4107 | - this.showDialog(new PopupDialog(this, this.getUrl() + '#' + id, | ||
4108 | - null, fn).container, 320, 140, true, true); | 4171 | + if (response.data) { |
4172 | + createAccessTokenFormLayer() | ||
4109 | } else { | 4173 | } else { |
4110 | - fn(); | 4174 | + getShareContentData() |
4111 | } | 4175 | } |
4176 | + }) | ||
4177 | + } | ||
4112 | 4178 | ||
4179 | + // 调用API,获取保存的内容 | ||
4180 | + function getSaveContent() { | ||
4181 | + if (urlParams.share) { | ||
4182 | + checkSharePageNeedAccessToken() | ||
4183 | + return | ||
4184 | + } | ||
4185 | + defHttp.get('/yt/configuration/center/get_configuration_info/' + Editor.configurationId) | ||
4186 | + .then(function (response) { | ||
4187 | + afterSaveContent(response) | ||
4113 | }) | 4188 | }) |
4114 | .catch(function (error) { | 4189 | .catch(function (error) { |
4115 | }); | 4190 | }); |