mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-14 12:42:51 +00:00
no message
This commit is contained in:
parent
c178e36f9b
commit
b3abe8af9c
@ -301,11 +301,30 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生成微应用名称
|
||||
* @param config
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async generateAppName(config) {
|
||||
let name = config.id || 'micro-app'
|
||||
if (!this.apps.find(item => item.name == name)) {
|
||||
return name
|
||||
}
|
||||
name = `${config.id}_${await $A.getSHA256Hash(config.url, 8)}`
|
||||
if (!this.apps.find(item => item.name == name)) {
|
||||
return name
|
||||
}
|
||||
return `${config.id}_${await $A.getSHA256Hash(config.url)}`
|
||||
},
|
||||
|
||||
/**
|
||||
* 观察打开微应用
|
||||
* @param config
|
||||
*/
|
||||
async observeMicroApp(config) {
|
||||
config.name = await this.generateAppName(config)
|
||||
|
||||
if (config.url_type === 'inline_blank') {
|
||||
await this.inlineBlank(config)
|
||||
return
|
||||
@ -314,6 +333,7 @@ export default {
|
||||
await this.externalWindow(config)
|
||||
return
|
||||
}
|
||||
|
||||
const app = this.apps.find(({name}) => name == config.name);
|
||||
if (app) {
|
||||
// 更新微应用
|
||||
@ -345,6 +365,10 @@ export default {
|
||||
transparent: true,
|
||||
keep_alive: false,
|
||||
};
|
||||
if (windowConfig.url) {
|
||||
appConfig.url = windowConfig.url;
|
||||
delete windowConfig.url;
|
||||
}
|
||||
//
|
||||
const path = `/single/apps/${appConfig.name}`
|
||||
const apps = (await $A.IDBArray("cacheMicroApps")).filter(item => item.name != appConfig.name);
|
||||
|
||||
6
resources/assets/js/functions/common.js
vendored
6
resources/assets/js/functions/common.js
vendored
@ -1512,14 +1512,16 @@ const timezone = require("dayjs/plugin/timezone");
|
||||
/**
|
||||
* 获取SHA256哈希值
|
||||
* @param str
|
||||
* @param length
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getSHA256Hash(str) {
|
||||
async getSHA256Hash(str, length = 0) {
|
||||
const encoder = new TextEncoder();
|
||||
const data = encoder.encode(str);
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
const hash = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
return length > 0 ? hash.slice(0, length) : hash;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
1
resources/assets/js/store/actions.js
vendored
1
resources/assets/js/store/actions.js
vendored
@ -4679,7 +4679,6 @@ export default {
|
||||
$A.modalWarning(`应用「${config.id}」未安装`);
|
||||
return;
|
||||
}
|
||||
config.name = `${config.id}_${await $A.getSHA256Hash(config.url)}`
|
||||
config.url = config.url.replace(/\{user_id}/g, state.userId)
|
||||
.replace(/\{user_nickname}/g, encodeURIComponent(state.userInfo.nickname))
|
||||
.replace(/\{user_email}/g, encodeURIComponent(state.userInfo.email))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user