diff --git a/src/Common.js b/src/Common.js
index baa7a42..7866700 100644
--- a/src/Common.js
+++ b/src/Common.js
@@ -10,13 +10,13 @@ import {
TAG_RE,
split_text,
} from './text_splitter';
-import { save_config } from './Config';
import renderMd from './Markdown';
export { format_time, Time, TitleLine };
export const API_BASE = `${process.env.REACT_APP_BACKEND || '/'}_api/v1`;
export const API_BASE_2 = `${process.env.REACT_APP_BACKEND || '/'}_api/v2`;
+export const STORAGE_BASE = `${process.env.REACT_APP_STORAGE || ''}`;
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
function escape_regex(string) {
@@ -429,29 +429,3 @@ export class ClickHandler extends PureComponent {
);
}
}
-
-export function test_ipfs(hash) {
- let key = 'testing_' + hash;
- window[key] = { curr: 0 };
- window.config.ipfs_gateway_list.forEach((url) => {
- fetch(url.replaceAll('', hash), { method: 'HEAD' })
- .then((res) => {
- if (res.ok) {
- console.log(url, 'success!');
- if (window[key]) {
- window[key].curr += 1;
- window[key][url] = window[key].curr;
- let list = window.config.ipfs_gateway_list;
- list.sort(
- (x, y) => (window[key][x] || 9999) - (window[key][y] || 999),
- );
- window.config.ipfs_gateway_list = list;
- save_config(false);
- }
- }
- })
- .catch((e) => {
- console.log(url, 'fail!');
- });
- });
-}
diff --git a/src/Config.js b/src/Config.js
index acaddec..21240fc 100644
--- a/src/Config.js
+++ b/src/Config.js
@@ -33,16 +33,6 @@ const DEFAULT_CONFIG = {
block_cw: ['xxg', 'zzxg'],
block_words_v4: ['🕷️', '[系统自动代发]'],
whitelist_cw: [],
- ipfs_gateway_list: [
- 'https://.ipfs.dweb.link/',
- 'https://.ipfs.infura-ipfs.io/',
- 'https://gateway.pinata.cloud/ipfs/',
- 'https://ipfs.eth.aragon.network/ipfs/',
- 'https://gateway.ipfs.io/ipfs/',
- 'https://ipfs.fleek.co/ipfs/',
- 'https://cloudflare-ipfs.com/ipfs/',
- 'https://ipfs.2read.net/ipfs/',
- ],
};
export function load_config() {
@@ -70,6 +60,7 @@ export function load_config() {
console.log('config loaded', config);
window.config = config;
}
+
export function save_config(need_load = true) {
localStorage['hole_config'] = JSON.stringify(window.config);
if (need_load) load_config();
@@ -411,18 +402,6 @@ export class ConfigUI extends PureComponent {
parse={(string) => string.split('\n')}
/>
- 表示要替换的哈希值。下次上传文件会使用第一行的,上传后根据速度调整。'
- }
- display={(array) => array.join('\n')}
- sift={(array) => array.filter((v) => v)}
- parse={(string) => string.split('\n')}
- />
-
(无ipfs网关)').replaceAll(
- '',
- data.hash,
- ) +
- `?filename=${encodeURIComponent(file_name)}&filetype=${encodeURIComponent(
- file_type,
- )}`;
- test_ipfs(data.hash);
+ let url = `${STORAGE_BASE}/${data.path}?filename=${encodeURIComponent(
+ file_name,
+ )}&filetype=${encodeURIComponent(file_type)}`;
let new_text =
this.state.text +
'\n' +
- (file_type.startsWith('image/') ? `` : url) +
- ` [加载失败请点击此](${window.location.origin}/ipfs.html#${data.hash})\n\n---\n`;
+ (file_type.startsWith('image/') ? `` : url);
this.setState({ text: new_text });
this.area_ref.current.set(new_text);
}
@@ -884,28 +877,7 @@ export class PostForm extends Component {
-
- 首选ipfs网关可以在设置中修改,如效果不佳仍可使用图床,例如:
-
- 路过图床
-
- 、
-
- sm.ms
-
- 、
-
- 未名BBS
-
- 、
-
- 知乎
-
- 。
-
+ 上传文件限制200M,保留至少一个月。也可使用第三方图床。
);