Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add share dir feature and other fixes #184

Merged
merged 23 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
670d37b
add share dir & deep link
lihsai0 Apr 12, 2024
31d9ab0
fix ak history button is hard to click
lihsai0 Apr 12, 2024
4a32309
improve sign in share form hint
lihsai0 Apr 12, 2024
c21c499
fix share dir can not custom expires
lihsai0 Apr 12, 2024
5f1ccaa
fix not compatible with old persistence
lihsai0 Apr 12, 2024
16ddb1b
support custom base share url
lihsai0 Apr 16, 2024
685e236
fix share dir button show condition
lihsai0 Apr 17, 2024
f314759
change deep link param name
lihsai0 Apr 18, 2024
508eec3
supply i18n for create directory share link
lihsai0 Apr 18, 2024
f835f54
refactor deep link scheme to kodobrowser from kodo-browser
lihsai0 May 9, 2024
b318a37
add determine base share url
lihsai0 May 23, 2024
87c4704
docs: fix typo
lihsai0 May 27, 2024
0c7d2da
fix: share directory input remount
lihsai0 May 28, 2024
88d14e8
feat: get object url with style by condition
lihsai0 May 30, 2024
82a86ed
fix: determine base share url when public environment
lihsai0 May 31, 2024
9fa3050
fix: validator of create directory share link
lihsai0 Jun 5, 2024
176fe4d
feat: prevent nav to up directory in share session and improve text
lihsai0 Jun 5, 2024
cb1689b
fix: data store compatible with remove disk table file but keep meta …
lihsai0 Jun 5, 2024
92d185b
feat: get share api host by portal
lihsai0 Jun 6, 2024
a662de5
chore: change i18n 文件夹 to 目录
lihsai0 Jun 6, 2024
9c7b33e
bump kodo-s3-adapter-sdk to v0.6.0
lihsai0 Jun 7, 2024
e0d23bb
fix: test cases for signIn deep link(by 92d185b)
lihsai0 Jun 7, 2024
4056003
build: fix github action reached heap limit Allocation failed
lihsai0 Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ jobs:
- name: test
run: make i test
- name: build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: make mac
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
- name: test
run: make i test
- name: build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: make win64 win32
- name: Upload Release Asset to Qiniu
run: |
Expand Down Expand Up @@ -159,6 +161,8 @@ jobs:
- name: test
run: make i test
- name: build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: make mac
- name: Upload Release Asset to Qiniu
run: |
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ kodo-browser/
* `maxDownloadJobConcurrency`,最大下载任务并发数
* `disable`,禁止某些功能;
* `nonOwnedDomain`,非自有域名;
* `baseShareUrl`,分享链接的基本 URL;

例如以下配置将修改默认登录私有云指定服务端:

Expand Down
20 changes: 20 additions & 0 deletions create-desktop-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -e
WORKING_DIR=$(pwd)
THIS_PATH=$(readlink -f "$0")
THIS_BASE_PATH=$(dirname "${THIS_PATH}")
cd "$THIS_BASE_PATH"
FULL_PATH=$(pwd)
cd "${WORKING_DIR}"
cat <<EOS > "kodo-browser.desktop"
[Desktop Entry]
Name=Kodo Browser
Comment=Kodo Browser for Linux
Exec="${FULL_PATH}/Kodo Browser" %U
Terminal=false
Type=Application
MimeType=x-scheme-handler/kodobrowser
Icon=${FULL_PATH}/resources/app/renderer/static/brand/qiniu.png
Categories=Utility;Development;
EOS
chmod +x "Kodo Browser.desktop"
22 changes: 20 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ELECTRON_VERSION = "18.3.3";
const ROOT = __dirname;
// https://github.com/qiniu/kodo-browser/issues/135
const WIN_NO_SANDBOX_NAME = "no-sandbox-shortcut.cmd";
const LINUX_DESKTOP_FILE = "create-desktop-file.sh";
const BRAND = `${ROOT}/src/renderer/static/brand`;
const DIST = `${ROOT}/dist`;
const TARGET = `${ROOT}/build`;
Expand Down Expand Up @@ -51,6 +52,13 @@ gulp.task("mac", done => {
options.arch = "x64";
options.icon = `${BRAND}/qiniu.icns`;

options.protocols = [{
name: 'com.qiniu.browser',
schemes: [
'kodo-browser'
]
}];

packager(options).then((paths) => {
console.log("--done");
done();
Expand Down Expand Up @@ -163,13 +171,18 @@ gulp.task("win32zip", done => {

gulp.task("linux64", done => {
console.log(`--package ${NAME}-linux-x64`);
const targetDir = `${TARGET}/${NAME}-linux-x64`;

plugins.run(`rm -rf ${TARGET}/${NAME}-linux-x64`).exec(() => {
plugins.run(`rm -rf ${targetDir}`).exec(() => {
let options = Object.assign({}, packagerOptions);
options.platform = "linux";
options.arch = "x64";

packager(options).then((paths) => {
fs.copyFileSync(
path.resolve(ROOT, `./${LINUX_DESKTOP_FILE}`),
path.resolve(targetDir, `./${LINUX_DESKTOP_FILE}`)
);
console.log("--done");
done();
}, (errs) => {
Expand All @@ -190,13 +203,18 @@ gulp.task("linux64zip", done => {

gulp.task("linux32", done => {
console.log(`--package ${NAME}-linux-ia32`);
const targetDir = `${TARGET}/${NAME}-linux-ia32`;

plugins.run(`rm -rf ${TARGET}/${NAME}-linux-ia32`).exec(() => {
plugins.run(`rm -rf ${targetDir}`).exec(() => {
let options = Object.assign({}, packagerOptions);
options.platform = "linux";
options.arch = "ia32";

packager(options).then((paths) => {
fs.copyFileSync(
path.resolve(ROOT, `./${LINUX_DESKTOP_FILE}`),
path.resolve(targetDir, `./${LINUX_DESKTOP_FILE}`)
);
console.log("--done");
done();
}, (errs) => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kodo-browser",
"version": "2.2.0",
"version": "2.3.0",
"license": "Apache-2.0",
"author": {
"name": "Rong Zhou",
Expand Down Expand Up @@ -111,7 +111,7 @@
"form-data": "^4.0.0",
"js-base64": "^3.4.5",
"js-md5": "^0.7.3",
"kodo-s3-adapter-sdk": "0.5.1",
"kodo-s3-adapter-sdk": "0.6.0",
"lockfile": "^1.0.4",
"lodash": "^4.17.21",
"mime": "^2.3.1",
Expand Down
5 changes: 5 additions & 0 deletions src/common/const/str.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const ALPHABET_UPPERCASE = "abcdefghijklmnopqrstuvwxyz";
export const ALPHABET_LOWERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
export const ALPHABET = ALPHABET_UPPERCASE + ALPHABET_LOWERCASE;
export const DIGITS = "0123456789";
export const ALPHANUMERIC = ALPHABET + DIGITS;
95 changes: 95 additions & 0 deletions src/common/ipc-actions/deep-link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import {Sender} from "./types";

export enum DeepLinkAction {
RendererReady = "RendererReady",
RendererClose = "RendererClose",
SignInWithShareLink = "SignInWithShareLink",
SignInWithShareSession = "SignInWithShareSession",
SignInDataInvalid = "SignInDataInvalid",
}

export interface DeepLinkSignInWithShareLinkMessage {
action: DeepLinkAction.SignInWithShareLink,
data: {
portalHost?: string,
shareId: string,
shareToken: string,
extractCode?: string,
},
}

export interface DeepLinkSignInWithShareSessionMessage {
action: DeepLinkAction.SignInWithShareSession,
data: {
accessKey: string,
accessSecret: string,
description?: string,

sessionToken: string,
bucketName: string,
bucketId: string,
regionS3Id: string,
endpoint: string,
prefix: string,
permission: 'READONLY' | 'READWRITE',
expires: string,
},
}

export interface DeepLinkSignInDataInvalidMessage {
action: DeepLinkAction.SignInDataInvalid,
}

export interface DeepLinkRendererReadyMessage {
action: DeepLinkAction.RendererReady,
}

export interface DeepLinkRendererCloseMessage {
action: DeepLinkAction.RendererClose,
}

export type DeepLinkMessage = DeepLinkSignInWithShareLinkMessage
| DeepLinkSignInWithShareSessionMessage
| DeepLinkSignInDataInvalidMessage
| DeepLinkRendererReadyMessage
| DeepLinkRendererCloseMessage;

export class DeepLinkActionFns {
constructor(
private readonly sender: Sender<DeepLinkMessage>,
private readonly channel: string,
) {
}

signInWithShareLink(data: DeepLinkSignInWithShareLinkMessage["data"]) {
this.sender.send(this.channel, {
action: DeepLinkAction.SignInWithShareLink,
data,
});
}

signInWithShareSession(data: DeepLinkSignInWithShareSessionMessage["data"]) {
this.sender.send(this.channel, {
action: DeepLinkAction.SignInWithShareSession,
data,
});
}

signInDataInvalid() {
this.sender.send(this.channel, {
action: DeepLinkAction.SignInDataInvalid,
});
}

rendererReady() {
this.sender.send(this.channel, {
action: DeepLinkAction.RendererReady,
});
}

rendererClose() {
this.sender.send(this.channel, {
action: DeepLinkAction.RendererClose,
});
}
}
38 changes: 21 additions & 17 deletions src/common/ipc-actions/download.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {IpcRenderer} from "electron";
import {NatureLanguage} from "kodo-s3-adapter-sdk/dist/uplog";
import {Domain} from "kodo-s3-adapter-sdk/dist/adapter";

Expand All @@ -7,6 +6,8 @@ import {Status} from "@common/models/job/types";
import DownloadJob from "@common/models/job/download-job";
import StorageClass from "@common/models/storage-class";

import {Sender} from "./types";

export interface RemoteObject {
name: string,
region: string,
Expand Down Expand Up @@ -70,7 +71,10 @@ export interface UpdateConfigMessage {
export interface LoadPersistJobsMessage {
action: DownloadAction.LoadPersistJobs,
data: {
clientOptions: Pick<ClientOptionsSerialized, "accessKey" | "secretKey" | "ucUrl" | "regions">
clientOptions: Pick<
ClientOptionsSerialized,
"accessKey" | "secretKey" | "sessionToken" | "bucketNameId" | "ucUrl" | "regions"
>
downloadOptions: Pick<DownloadOptions, "userNatureLanguage">,
}
}
Expand Down Expand Up @@ -207,104 +211,104 @@ export type DownloadReplyMessage = UpdateUiDataReplyMessage

export class DownloadActionFns {
constructor(
private readonly ipc: IpcRenderer,
private readonly sender: Sender<DownloadMessage>,
private readonly channel: string,
) {
}

updateConfig(data: UpdateConfigMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.UpdateConfig,
data: data,
});
}

loadPersistJobs(data: LoadPersistJobsMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.LoadPersistJobs,
data,
})
}

addJobs(data: AddJobsMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.AddJobs,
data,
});
}

updateUiData(data: UpdateUiDataMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.UpdateUiData,
data,
});
}

waitJob(data: WaitJobMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.WaitJob,
data,
});
}

startJob(data: StartJobMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.StartJob,
data,
});
}

stopJob(data: StopJobMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.StopJob,
data,
});
}

removeJob(data: RemoveJobMessage["data"]) {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.RemoveJob,
data,
});
}

cleanUpJobs() {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.CleanupJobs,
data: {},
});
}

startAllJobs() {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.StartAllJobs,
data: {},
});
}

stopAllJobs() {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.StopAllJobs,
data: {},
});
}

stopJobsByOffline() {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.StopJobsByOffline,
data: {},
});
}

startJobsByOnline() {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.StartJobsByOnline,
data: {},
});
}

removeAllJobs() {
this.ipc.send(this.channel, {
this.sender.send(this.channel, {
action: DownloadAction.RemoveAllJobs,
data: {},
});
Expand Down
3 changes: 3 additions & 0 deletions src/common/ipc-actions/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface Sender<T> {
send(channel: string, message: T): void,
}
Loading
Loading