Skip to content

Commit

Permalink
✨ 优化跨域资源确定逻辑 #56
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Apr 30, 2022
1 parent 8a8fef2 commit 9144e3b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
16 changes: 11 additions & 5 deletions src/apps/grant/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,23 @@ export class BackgroundGrant {
MsgCenter.removeListenerAll(
PermissionConfirm + confirm.uuid
);
next();
void next();
}, 300000);
}
// 处理下一个
const next = () => {
const next = async () => {
// 一个打开确定,一群不打开只监听消息
const item = list.pop();
if (item) {
// 使用已允许了的域名做确认
const perList = await _this.permissionModel.list(
(table) => {
return table.where({ scriptId: script.id });
}
);
void App.Cache.set('confirm:info:' + item.uuid, [
item,
list.length,
perList.length || list.length,
]);
void chrome.tabs.create({
url: chrome.runtime.getURL(
Expand Down Expand Up @@ -445,11 +451,11 @@ export class BackgroundGrant {
case 5:
case 3: {
ret.permissionValue = confirm.permissionValue || '';
next();
void next();
break;
}
default:
next();
void next();
break;
}
//临时 放入缓存
Expand Down
2 changes: 1 addition & 1 deletion src/apps/logger/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export class ConsoleTransports implements LoggerTransports {
catalogStr=catalogStr.substring(0, catalogStr.length - 1);
catalogStr += ']';
}
console.log('[%s]%s: %s', level, catalogStr, info);
console.log('[%s]%s - %s', level, catalogStr, info);
}
}
3 changes: 3 additions & 0 deletions src/model/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ export function migrate() {
db.version(14).stores({
value: '++id,[scriptId+key],[storageName+key]',
});
db.version(15).stores({
permission: '++id,scriptId,[scriptId+permission+permissionValue],createtime,updatetime',
});
}
4 changes: 2 additions & 2 deletions src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ InitApp({
const logger = createLogger({
level: process.env.NODE_ENV === 'development' ? 'debug' : 'info',
catalog: {
name: 'sandbox',
type: 'sandbox',
},
transports: [new ConsoleTransports()],
});
Expand Down Expand Up @@ -178,7 +178,7 @@ function runCrontab(script: ScriptCache) {
if (nextTime(val) == '错误的定时表达式') {
return;
}
logger.debug(`${script.name} corntab ${val}`);
logger.debug(`${script.name} corntab "${val}"`);

const cron = new CronJob(
val,
Expand Down
1 change: 1 addition & 0 deletions src/views/pages/Confirm/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default class Confirm extends Vue {
}
this.uuid = uuid;
[this.param, this.num] = await this.scriptConrtoller.getConfirmInfo(uuid);
console.log(this.num);
let i = setInterval(() => {
this.timeout--;
if (!this.timeout) {
Expand Down

0 comments on commit 9144e3b

Please sign in to comment.