Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed May 9, 2024
1 parent 1b1125f commit ef2e195
Show file tree
Hide file tree
Showing 145 changed files with 6,148 additions and 5,258 deletions.
4 changes: 2 additions & 2 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jsxBracketSameLine: false
arrowParens: always
# 每个文件格式化的范围是文件的全部内容
rangeStart: 0
rangeEnd: Infinity
# rangeEnd: Infinity
# 不需要写文件开头的 @prettier
requirePragma: false
# 不需要自动在文件开头插入 @prettier
Expand All @@ -34,4 +34,4 @@ htmlWhitespaceSensitivity: css
# vue 文件中的 script 和 style 内不用缩进
vueIndentScriptAndStyle: false
# 换行符使用 lf
endOfLine: lf
endOfLine: lf
38 changes: 19 additions & 19 deletions src/main/core/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { app } from "electron";
import _ from "lodash";
import LodashId from "lodash-id";
import Datastore from "lowdb";
import FileSync from "lowdb/adapters/FileSync";
import { join } from "path";
import { app } from 'electron';
import _ from 'lodash';
import LodashId from 'lodash-id';
import Datastore from 'lowdb';
import FileSync from 'lowdb/adapters/FileSync';
import { join } from 'path';

import { tblSetting } from "./init";
import logger from "../logger";
import magrite from "./magrite";
import { tblSetting } from './init';
import logger from '../logger';
import magrite from './magrite';

const STORE_PATH = join(app.getPath("userData"), "database.json");
const adapter = new FileSync(STORE_PATH); // 初始化lowdb读写的json文件名以及存储路径
const STORE_PATH = join(app.getPath('userData'), 'database.json');
const adapter = new FileSync(STORE_PATH); // 初始化lowdb读写的json文件名以及存储路径
const db = Datastore(adapter); // lowdb接管该文件

const init = () => {
db._.mixin(LodashId); //为每个新增的数据自动加上唯一标识的id字段

const hasTable = (tableName) => db.read().has(tableName).value();
if (!hasTable("tbl_setting")) {
db.set("tbl_setting", []).write();
_.forEach(tblSetting, (item) => {
db.get("tbl_setting").insert({ key: item.key, value: item.value }).write();
if (!hasTable('tbl_setting')) {
db.set('tbl_setting', []).write();
_.forEach(tblSetting, (item) => {
db.get('tbl_setting').insert({ key: item.key, value: item.value }).write();
});
}
// 用空数组初始化其他集合
const collections = ["tbl_site", "tbl_iptv", "tbl_channel", "tbl_star", "tbl_history", "tbl_drive", "tbl_analyze"];
const collections = ['tbl_site', 'tbl_iptv', 'tbl_channel', 'tbl_star', 'tbl_history', 'tbl_drive', 'tbl_analyze'];
for (const collection of collections) {
if (!hasTable(collection)) {
db.set(collection, []).write();
Expand All @@ -35,8 +35,8 @@ const init = () => {
const setup = () => {
init();
magrite();
}
};

logger.info(`[db] db module initialized; path: ${STORE_PATH}`)
logger.info(`[db] db module initialized; path: ${STORE_PATH}`);

export { db as default, setup };
export { db as default, setup };
4 changes: 1 addition & 3 deletions src/main/core/db/init/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import tblSetting from './tbl_setting.json';

export {
tblSetting,
};
export { tblSetting };
110 changes: 32 additions & 78 deletions src/main/core/db/init/tbl_setting.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
[
{ "key": "version",
"value": "3.3.4"
},
{ "key": "theme",
"value": "auto"
},
{ "key": "lang",
"value": "zh_CN"
},
{ "key": "defaultHot",
"value": "kylive"
},
{ "key": "defaultSearchRecommend",
"value": "site"
},
{ "key": "defaultSearchType",
"value": "site"
},
{ "key": "version", "value": "3.3.4" },
{ "key": "theme", "value": "auto" },
{ "key": "lang", "value": "zh_CN" },
{ "key": "defaultHot", "value": "kylive" },
{ "key": "defaultSearchRecommend", "value": "site" },
{ "key": "defaultSearchType", "value": "site" },
{
"key": "defaultViewCasual",
"value": ""
Expand All @@ -25,80 +13,45 @@
"key": "defaultDanMuKu",
"value": ""
},
{ "key": "defaultIptvEpg",
"value": "http://diyp.112114.xyz/"
},
{ "key": "defaultIptvLogo",
"value": "https://epg.112114.eu.org/logo/"
},
{ "key": "iptvSkipIpv6",
"value": true
},
{ "key": "iptvThumbnail",
"value": false
},
{ "key": "iptvStatus",
"value": false
},
{ "key": "defaultSite",
"value": null
},
{ "key": "defaultIptv",
"value": null
},
{ "key": "defaultAnalyze",
"value": null
},
{ "key": "analyzeFlag",
"value": [
"youku",
"qq",
"iqiyi",
"qiyi",
"letv",
"sohu",
"tudou",
"pptv",
"mgtv"
]},
{ "key": "defaultIptvEpg", "value": "http://diyp.112114.xyz/" },
{ "key": "defaultIptvLogo", "value": "https://epg.112114.eu.org/logo/" },
{ "key": "iptvSkipIpv6", "value": true },
{ "key": "iptvThumbnail", "value": false },
{ "key": "iptvStatus", "value": false },
{ "key": "defaultSite", "value": null },
{ "key": "defaultIptv", "value": null },
{ "key": "defaultAnalyze", "value": null },
{ "key": "analyzeFlag", "value": ["youku", "qq", "iqiyi", "qiyi", "letv", "sohu", "tudou", "pptv", "mgtv"] },
{
"key": "defaultDrive",
"value": ""
},
{ "key": "softSolution",
"value": false
},
{ "key": "skipStartEnd",
"value": false
},
{ "key": "agreementMask",
"value": false
},
{ "key": "recordShortcut",
"value": ""
},
{ "key": "selfBoot",
"value": false
},
{ "key": "hardwareAcceleration",
"value": true
},
{ "key": "ua",
{ "key": "softSolution", "value": false },
{ "key": "skipStartEnd", "value": false },
{ "key": "agreementMask", "value": false },
{ "key": "recordShortcut", "value": "" },
{ "key": "selfBoot", "value": false },
{ "key": "hardwareAcceleration", "value": true },
{
"key": "ua",
"value": "Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36"
},
{ "key": "playerMode",
{
"key": "playerMode",
"value": {
"type": "dplayer",
"external": ""
}
},
{ "key": "snifferMode",
{
"key": "snifferMode",
"value": {
"type": "pie",
"url": ""
}
},
{ "key": "webdev",
{
"key": "webdev",
"value": {
"sync": false,
"data": {
Expand All @@ -110,9 +63,10 @@
},
{
"key": "barrage",
"value": { "url": "", "key": "", "support": "", "start": "", "mode": "", "color": "", "content": ""}
"value": { "url": "", "key": "", "support": "", "start": "", "mode": "", "color": "", "content": "" }
},
{ "key": "windowPosition",
{
"key": "windowPosition",
"value": {
"status": false,
"position": {
Expand Down
12 changes: 4 additions & 8 deletions src/main/core/db/magrite/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import update3_3_1_to3_3_2 from "./update3_3_1_to3_3_2";
import update3_3_3_to3_3_4 from "./update3_3_3_to3_3_4";
import update3_3_4_to3_3_5 from "./update3_3_4_to3_3_5";
import update3_3_1_to3_3_2 from './update3_3_1_to3_3_2';
import update3_3_3_to3_3_4 from './update3_3_3_to3_3_4';
import update3_3_4_to3_3_5 from './update3_3_4_to3_3_5';

export {
update3_3_1_to3_3_2,
update3_3_3_to3_3_4,
update3_3_4_to3_3_5,
};
export { update3_3_1_to3_3_2, update3_3_3_to3_3_4, update3_3_4_to3_3_5 };
21 changes: 13 additions & 8 deletions src/main/core/db/magrite/data/update3_3_1_to3_3_2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import db from '../../index';

const update3_3_1_to3_3_2 = () => {
const TABLE_NAME = 'tbl_setting';
db.get(TABLE_NAME).find({ key: 'windowPosition' }).assign({ key: 'windowPosition', value: {
status: false,
position: { width: 1000, height: 640 }
}
}).write();
db.get(TABLE_NAME)
.find({ key: 'windowPosition' })
.assign({
key: 'windowPosition',
value: {
status: false,
position: { width: 1000, height: 640 },
},
})
.write();
db.get(TABLE_NAME).remove({ key: 'restoreWindowPositionAndSize' }).write();
db.get(TABLE_NAME).insert({ key: 'version', value: '3.3.2' }).write();

logger.info('[db][magrite][update3_3_1_to3_3_2]completed')
}
logger.info('[db][magrite][update3_3_1_to3_3_2]completed');
};

export default update3_3_1_to3_3_2;
export default update3_3_1_to3_3_2;
87 changes: 56 additions & 31 deletions src/main/core/db/magrite/data/update3_3_3_to3_3_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,71 @@ import db from '../../index';
const update3_3_3_to3_3_4 = () => {
const TABLE_NAME = 'tbl_setting';

if (db.get(TABLE_NAME).find({ key: "lang" }).value()?.value) {
if (db.get(TABLE_NAME).find({ key: 'lang' }).value()?.value) {
db.get(TABLE_NAME).remove({ key: 'lang' }).write();
}
db.get(TABLE_NAME).insert({ key: "lang", value: "zh_CN" }).write();
if (db.get(TABLE_NAME).find({ key: "defaultViewCasual" }).value()?.value) {
db.get(TABLE_NAME).insert({ key: 'lang', value: 'zh_CN' }).write();
if (db.get(TABLE_NAME).find({ key: 'defaultViewCasual' }).value()?.value) {
db.get(TABLE_NAME).remove({ key: 'defaultViewCasual' }).write();
}
db.get(TABLE_NAME).insert({ key: "defaultViewCasual", value: "" }).write();
if (db.get(TABLE_NAME).find({ key: "barrage" }).value()?.value) {
db.get(TABLE_NAME).insert({ key: 'defaultViewCasual', value: '' }).write();
if (db.get(TABLE_NAME).find({ key: 'barrage' }).value()?.value) {
db.get(TABLE_NAME).remove({ key: 'barrage' }).write();
}
db.get(TABLE_NAME).insert({ key: "barrage", value: { url: "", key: "danmuku", support: ["qq", "qiyi", "youku", "mgtv"], start: "0", mode: "1", color: "2", content: "4" } }).write();
if (db.get(TABLE_NAME).find({ key: "playerMode" }).value()?.value) {
db.get(TABLE_NAME)
.insert({
key: 'barrage',
value: {
url: '',
key: 'danmuku',
support: ['qq', 'qiyi', 'youku', 'mgtv'],
start: '0',
mode: '1',
color: '2',
content: '4',
},
})
.write();
if (db.get(TABLE_NAME).find({ key: 'playerMode' }).value()?.value) {
db.get(TABLE_NAME).remove({ key: 'playerMode' }).write();
}
db.get(TABLE_NAME).insert({ key: "playerMode", value: {
type: db.get(TABLE_NAME).find({ key: "broadcasterType" }).value()?.value || "xgplayer",
external: db.get(TABLE_NAME).find({ key: "externalPlayer" }).value()?.value || ""
}
}).write();
if (db.get(TABLE_NAME).find({ key: "snifferMode" }).value()?.value) {
db.get(TABLE_NAME)
.insert({
key: 'playerMode',
value: {
type: db.get(TABLE_NAME).find({ key: 'broadcasterType' }).value()?.value || 'xgplayer',
external: db.get(TABLE_NAME).find({ key: 'externalPlayer' }).value()?.value || '',
},
})
.write();
if (db.get(TABLE_NAME).find({ key: 'snifferMode' }).value()?.value) {
db.get(TABLE_NAME).remove({ key: 'snifferMode' }).write();
}
db.get(TABLE_NAME).insert({ key: "snifferMode", value: {
type: db.get(TABLE_NAME).find({ key: "snifferType" }).value()?.value || "pie",
url: ""
}
}).write();
if (db.get(TABLE_NAME).find({ key: "webdev" }).value()?.value) {
db.get(TABLE_NAME)
.insert({
key: 'snifferMode',
value: {
type: db.get(TABLE_NAME).find({ key: 'snifferType' }).value()?.value || 'pie',
url: '',
},
})
.write();
if (db.get(TABLE_NAME).find({ key: 'webdev' }).value()?.value) {
db.get(TABLE_NAME).remove({ key: 'webdev' }).write();
}
db.get(TABLE_NAME).insert({ key: "webdev", value: {
sync: false,
data: {
url: db.get(TABLE_NAME).find({ key: "webdevUrl" }).value()?.value || "https://dav.jianguoyun.com/dav/",
username: db.get(TABLE_NAME).find({ key: "webdevUsername" }).value()?.value || "",
password: db.get(TABLE_NAME).find({ key: "webdevPassword" }).value()?.value || ""
}
}
}).write();
db.get(TABLE_NAME)
.insert({
key: 'webdev',
value: {
sync: false,
data: {
url: db.get(TABLE_NAME).find({ key: 'webdevUrl' }).value()?.value || 'https://dav.jianguoyun.com/dav/',
username: db.get(TABLE_NAME).find({ key: 'webdevUsername' }).value()?.value || '',
password: db.get(TABLE_NAME).find({ key: 'webdevPassword' }).value()?.value || '',
},
},
})
.write();
db.get(TABLE_NAME).remove({ key: 'webdevUrl' }).write();
db.get(TABLE_NAME).remove({ key: 'webdevUsername' }).write();
db.get(TABLE_NAME).remove({ key: 'webdevPassword' }).write();
Expand All @@ -52,7 +77,7 @@ const update3_3_3_to3_3_4 = () => {
db.get(TABLE_NAME).remove({ key: 'externalPlayer' }).write();
db.get(TABLE_NAME).find({ key: 'version' }).assign({ key: 'version', value: '3.3.4' }).write();

logger.info('[db][magrite][update3_3_3_to3_3_4]completed')
}
logger.info('[db][magrite][update3_3_3_to3_3_4]completed');
};

export default update3_3_3_to3_3_4;
export default update3_3_3_to3_3_4;
Loading

0 comments on commit ef2e195

Please sign in to comment.