Browse Source

change read icon

master
godo 9 months ago
parent
commit
4ebc2aae4b
  1. 45
      frontend/src/system/applist.ts
  2. 135
      frontend/src/system/index.ts
  3. 10
      frontend/src/util/Icon.ts

45
frontend/src/system/applist.ts

@ -11,7 +11,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: true,
isMenuList: true
},
{
@ -24,7 +23,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: true,
isMenuList: true,
dir: '/',
},
@ -41,7 +39,6 @@ export const appList = [
resizable: true,
backgroundColor: '#ffffff00',
isDeskTop: true,
isMagnet: true,
isMenuList: true,
},
{
@ -54,7 +51,6 @@ export const appList = [
center: true,
resizable: false,
isDeskTop: false,
isMagnet: true,
isMenuList: true,
},
{
@ -67,7 +63,6 @@ export const appList = [
center: true,
resizable: false,
isDeskTop: false,
isMagnet: true,
isMenuList: true,
},
@ -80,7 +75,6 @@ export const appList = [
resizable: true,
center: true,
isDeskTop: false,
isMagnet: false,
isContext: true
},
{
@ -176,7 +170,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: false,
ext: ['kb'],
eventType: "exportKanban"
},
@ -190,7 +183,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: false,
ext: ['bb'],
eventType: "exportBaiban"
},
@ -204,7 +196,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: false,
},
{
@ -217,7 +208,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: false,
ext: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'],
eventType: "exportPhoto"
},
@ -231,7 +221,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: false,
ext: ['gant'],
eventType: "exportGant"
},
@ -245,7 +234,7 @@ export const appList = [
center: true,
resizable: false,
isDeskTop: false,
isMagnet: true,
isMenuList: true,
},
{
name: 'calendar',
@ -257,7 +246,7 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: true,
isMenuList: true,
},
{
name: "PDF",
@ -269,7 +258,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: false,
isMaximize: true,
ext: ['pdf']
},
@ -283,7 +271,7 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: true
isMenuList: true,
},
{
name: "music",
@ -295,7 +283,7 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: false,
isMenuList: true,
ext: ['mp3']
},
{
@ -308,7 +296,7 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: true,
isMenuList: true,
},
{
name: "gallery",
@ -320,7 +308,7 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: false,
isMagnet: false,
isMenuList: true,
ext: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'],
},
{
@ -332,7 +320,7 @@ export const appList = [
height: 600,
center: true,
isDeskTop: false,
isMagnet: false,
isMenuList: true,
ext: ['mp4']
},
{
@ -345,23 +333,6 @@ export const appList = [
center: true,
resizable: true,
isDeskTop: true,
isMagnet: true
isMenuList: true,
},
// {
// name: "备份与恢复",
// appIcon: "backup",
// content: ZipBackup,
// view: ZipBackup,
// width: 300,
// height: 200,
// center: true,
// resizable: false,
// isDeskTop: false,
// isMagnet: false,
// isMenuList: false,
// isSetting: true
// }
];

135
frontend/src/system/index.ts

@ -60,6 +60,7 @@ export class System {
isFirstRun = true;
rootRef: HTMLElement | undefined = undefined;
fs!: any;
isReadyUpdateAppList = false;
constructor(options?: SystemOptions) {
@ -89,30 +90,26 @@ export class System {
* @description:
*/
private async initSystem() {
//await startApp();
/**
*
*/
this._rootState.state = SystemStateEnum.opening;
initBuiltinFileOpener(this); // 注册内建文件打开器
await this.initFileSystem(); // 初始化文件系统
this.fs = useOsFile(); // 初始化文件系统
initBuiltinApp(this);
await this.initSavedConfig(); // 初始化保存的配置
initBuiltinApp(this); // 初始化内建应用
//this.initApp(); // 初始化配置应用到app文件夹中
//this.initAppList(); // 刷新app文件夹,展示应用
// 初始化内建应用
// 判断是否登录
this.isLogin();
initEventListener(); // 初始化事件侦听
this._ready && this._ready(this);
//this.runPlugin(this); // 运行fs中插件
this.initBackground(); // 初始化壁纸
this.emit('start');
this.refershAppList();
setTimeout(() => {
const upgradeStore = useUpgradeStore();
upgradeStore.checkUpdate()
}, 6000);
this.emit('start');
this._ready && this._ready(this);
}
/**
@ -154,7 +151,6 @@ export class System {
} else {
this._rootState.options.background = background.color;
}
// this._rootState.options.background = '/image/bg/bg5.jpg';
}
/**
* @description:
@ -165,32 +161,7 @@ export class System {
*/
return initEventer();
}
private initApp() {
const fileUrl = getFileUrl();
if (!fileUrl) return;
fetch(`${fileUrl}/desktop`).then(res => res.json()).then(res => {
if (res && res.code == 0) {
this._rootState.apps = res.data.apps;
this._rootState.menulist = res.data.menulist;
res.data.apps.forEach((item: any) => {
this._rootState.windowMap['Desktop'].set(item.name, item);
})
res.data.apps.forEach((item: any) => {
this._rootState.windowMap['Menulist'].set(item.name, item);
})
// this._rootState.windowMap[loc].set(options.name, options);
// useSystem()._rootState.apps = res.data.apps;
// useSystem()._rootState.menulist = res.data.menulist;
}
})
// this._rootState.options.desktop?.forEach((item) => {
// this.addApp(item);
// });
// this._rootState.options.menulist?.forEach((item) => {
// this.addMenuList(item);
// });
}
refershAppList() {
@ -206,73 +177,25 @@ export class System {
system._rootState.menulist.splice(0, system._rootState.menulist.length, ...res.data.menulist);
}
})
//const APP_TYPE = ['apps', 'menulist'];
// console.log('refresh')
/*
for (let i = 0; i < APP_TYPE.length; i++) {
const element = APP_TYPE[i];
system?.fs
.readdir(
`${system._options.userLocation}${{
apps: 'Desktop',
menulist: 'Menulist',
}[element]
}`
)
.then((res: any) => {
if (res) {
const list = res;
const tempList: any = [];
for (let j = 0; j < list.length; j++) {
const item = list[j];
tempList.push(item);
}
switch (element) {
case 'apps':
useSystem()._rootState.apps.splice(0, useSystem()._rootState.apps.length, ...tempList);
break;
case 'magnet':
useSystem()._rootState.magnet.splice(0, useSystem()._rootState.magnet.length, ...tempList);
break;
case 'menulist':
useSystem()._rootState.menulist.splice(
0,
useSystem()._rootState.menulist.length,
...tempList
);
break;
default:
break;
}
}
});
}
*/
}
isReadyUpdateAppList = false;
initAppList() {
this.isReadyUpdateAppList = true;
nextTick(() => {
if (this.isReadyUpdateAppList) {
this.isReadyUpdateAppList = false;
this.refershAppList();
}
});
}
// initAppList() {
// this.isReadyUpdateAppList = true;
// nextTick(() => {
// if (this.isReadyUpdateAppList) {
// this.isReadyUpdateAppList = false;
// this.refershAppList();
// }
// });
// }
private async initFileSystem() {
this.fs = useOsFile();
// this.fs.registerWatcher(new RegExp(`^${this._options.userLocation}`), () => {
// this.initAppList();
// });
}
replaceFileSystem(fs: OsFileInterface) {
this.fs = fs;
this.initAppList();
//this.initAppList();
this.refershAppList();
}
mountVolume(path: string, fs: OsFileInterface) {
if (this.fs instanceof OsFileSystem) {
@ -307,11 +230,6 @@ export class System {
setConfig<T extends keyof SystemOptionsCertainly>(key: string, value: SystemOptionsCertainly[T]) {
this._rootState.options[key] = value;
if (Saveablekey.includes(key as any)) {
// return this.fs.writeFile(
// join(this._options.systemLocation || '', 'os/config.json'),
// JSON.stringify(pick(this._rootState.options, ...Saveablekey))
// );
return setSystemConfig(pick(this._rootState.options, ...Saveablekey))
} else {
return Promise.resolve();
@ -325,18 +243,11 @@ export class System {
}
private addWindowSysLink(loc: string, options: WinAppOptions, force = false) {
if (this.isFirstRun || force) {
if (force) {
this.fs.writeFile(
`${this._options.userLocation}${loc}/` + options.name + '.exe',
`link::${loc}::${options.name}::${options.icon}`
);
} else {
this.initAppList();
}
if (typeof options.window.content === 'string') {
// TODO: 当content是string的时候
} else {
options.window.content = markRaw(options.window.content);
}
this._rootState.windowMap[loc].set(options.name, options);
}

10
frontend/src/util/Icon.ts

@ -16,7 +16,7 @@ export function dealExeIcon(content: string | null | undefined) {
}
}
export async function dealIcon(
file: OsFileWithoutContent | null | undefined,
file: any,
system: System,
stopCircle = false
) {
@ -39,8 +39,12 @@ export async function dealIcon(
}
const ext = file.ext;
if (ext === 'exe' || ext === 'url') {
const content = await system?.fs.readFile(file.path);
return dealExeIcon(content);
//console.log(file)
if(!file.content){
file.content = await system?.fs.readFile(file.path);
}
return dealExeIcon(file.content);
}
if (ext === 'ln') {
if (stopCircle) {

Loading…
Cancel
Save