v2.4.456 → v5.3.31-legacy
// 找到defaultOptions对象的定义,增加属性hasRole,默认值为'0'
const defaultOptions = {
+ hasRole: {
+ value: '0',
+ kind: OptionKind.VIEWER
+ }
其他属性
}
// 找到run函数的定义,增加获取属性hasRole及获取后的权限控制逻辑
async run(config) {
await this.initialize(config);
const {
appConfig,
eventBus
} = this;
let file;
+ let hasRole;
const queryString = document.location.search.substring(1);
const params = parseQueryString(queryString);
file = params.get("file") ?? AppOptions.get("defaultUrl");
+ hasRole = params.get("hasrole") ?? AppOptions.get("hasRole");
+ // 取消文件同源校验
+ // validateFileURL(file);
- validateFileURL(file);
const fileInput = this._openFileInput = document.createElement("input");
fileInput.id = "fileInput";
fileInput.hidden = true;
fileInput.type = "file";
fileInput.value = null;
document.body.append(fileInput);
+ // 权限判定,无权限用户隐藏部分功能按钮
+ if (hasRole !== '1') {
+ appConfig.toolbar?.download.setAttribute("hidden", "true");
+ appConfig.toolbar?.print.setAttribute("hidden", "true");
+ appConfig.secondaryToolbar?.downloadButton.setAttribute("hidden", "true");
+ appConfig.secondaryToolbar?.printButton.setAttribute("hidden", "true");
+ appConfig.secondaryToolbar?.openFileButton.setAttribute("hidden", "true");
+ appConfig.secondaryToolbar?.viewBookmarkButton.setAttribute("hidden", "true");
+ }
// 其他代码
}