Skip to content

Commit

Permalink
Merge branch 'fluent_ui' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
naaive committed Mar 27, 2022
2 parents 84805ef + 7580054 commit 32ea295
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 136 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"dependencies": {
"@fluentui/react": "^8.0.0",
"@fluentui/react-file-type-icons": "^8.6.6",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@right-menu/react": "0.0.5",
"@tauri-apps/api": "^1.0.0-rc.2",
"@testing-library/jest-dom": "^5.14.1",
Expand Down
24 changes: 11 additions & 13 deletions src-tauri/src/idx_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use tantivy::{doc, Index, IndexReader, IndexWriter, ReloadPolicy};
use crate::file_doc::FileDoc;
use crate::file_view::FileView;
use crate::utils;
use crate::utils::is_ascii_alphanumeric;
use jieba_rs::Jieba;
use pinyin::ToPinyin;
use std::sync::{Arc, Mutex};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use jieba_rs::Jieba;
use tantivy::merge_policy::NoMergePolicy;
use crate::utils::is_ascii_alphanumeric;
use pinyin::ToPinyin;

pub struct IdxStore {
pub writer: Arc<Mutex<IndexWriter>>,
Expand All @@ -38,7 +38,7 @@ pub struct IdxStore {
static mut IS_FULL_INDEXING: bool = true;

impl IdxStore {
pub fn search_tokenize(&self,hans: String) -> String {
pub fn search_tokenize(&self, hans: String) -> String {
if is_ascii_alphanumeric(hans.as_str()) {
return hans.as_str().to_lowercase();
}
Expand All @@ -55,7 +55,7 @@ impl IdxStore {
token_text.into_iter().collect::<Vec<String>>().join(" ")
}

pub fn tokenize(&self,hans: String) -> String {
pub fn tokenize(&self, hans: String) -> String {
// return hans;
if is_ascii_alphanumeric(hans.as_str()) {
return hans;
Expand Down Expand Up @@ -83,12 +83,9 @@ impl IdxStore {
if !all.is_empty() {
token_text.insert(all);
}

}
for pinyin in hans.as_str().to_pinyin() {

for pinyin in hans.as_str().to_pinyin() {
if let Some(full) = pinyin {

token_text.insert(full.first_letter().to_string());
token_text.insert(full.plain().to_string());
}
Expand All @@ -98,7 +95,6 @@ impl IdxStore {
}

pub fn disable_full_indexing(&self) {

unsafe {
IS_FULL_INDEXING = false;
}
Expand Down Expand Up @@ -339,7 +335,10 @@ impl IdxStore {
let writer = Arc::new(Mutex::new(
index.writer_with_num_threads(2, 140_000_000).unwrap(),
));
writer.lock().unwrap().set_merge_policy(Box::new(NoMergePolicy::default()));
writer
.lock()
.unwrap()
.set_merge_policy(Box::new(NoMergePolicy::default()));
let writer_bro = writer.clone();
std::thread::spawn(move || loop {
let _ = writer_bro.lock().unwrap().commit();
Expand Down Expand Up @@ -375,8 +374,7 @@ impl IdxStore {
is_dir_field,
query_parser,
ext_query_parser,
tokenizer:jieba
// parent_dirs_query_parser,
tokenizer: jieba, // parent_dirs_query_parser,
}
}

Expand Down
4 changes: 1 addition & 3 deletions src-tauri/src/walk_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,11 @@ fn walk(store: Arc<IdxStore>, path: &String, skip_path_opt: Option<String>) {
);
}


#[test]
fn t1() {
let dir = utils::data_dir();

let string = format!("{}/orangecachedata",dir);
let string = format!("{}/orangecachedata", dir);
println!("{}", string);
let dir_all = std::fs::remove_dir_all(string);
use crate::utils::init_log;
Expand All @@ -230,5 +229,4 @@ fn t1() {
let idx_store = Arc::new(IdxStore::new(&idx_path));

run(conf_store, idx_store);

}
42 changes: 21 additions & 21 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
.App {
text-align: center;
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
4 changes: 2 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import {useEffect, useState} from 'react';
import {useState} from 'react';
import './App.css';
import Items from "./Items";
import {Scrollbars} from 'react-custom-scrollbars';
Expand All @@ -18,7 +18,7 @@ const App = () => {
<Pivot aria-label="Count and Icon Pivot Example" selectedKey={String(selectedKey)} onLinkClick={(event) => {
let key = event.key.substr(1);
setSelectedKey(key)
search(kw,key).then(value => {
search(kw, key).then(value => {
setItems(value)
})
}}>
Expand Down
55 changes: 17 additions & 38 deletions src/Items.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import React, {useEffect, useState} from 'react';
import {
ContextualMenu, DefaultButton,
DetailsList,
DetailsListLayoutMode,
IColumn,
mergeStyleSets,
SelectionMode,
TooltipHost
} from "@fluentui/react";
import {invoke} from "@tauri-apps/api";
import React from 'react';
import {DetailsList, DetailsListLayoutMode, mergeStyleSets, SelectionMode, TooltipHost} from "@fluentui/react";
import * as R from "ramda";
import {getFileTypeIconProps, FileIconType, initializeFileTypeIcons} from '@fluentui/react-file-type-icons';
import {FileIconType, getFileTypeIconProps, initializeFileTypeIcons} from '@fluentui/react-file-type-icons';
import {Icon} from "office-ui-fabric-react";
import moment from "moment";
import copy from "copy-to-clipboard";
Expand Down Expand Up @@ -93,19 +84,19 @@ const columns = [
// let ext = "exe";
// item.name
return (
<div>
<TooltipHost content={`${item.fileType} file`}>
{
isDir ? <Icon {...getFileTypeIconProps({
type: FileIconType.folder,
size: 20,
imageFileType: 'svg'
})} /> :
<Icon {...getFileTypeIconProps({extension: ext, size: 20, imageFileType: 'png'})} />
}

</TooltipHost>
</div>
<div>
<TooltipHost content={`${item.fileType} file`}>
{
isDir ? <Icon {...getFileTypeIconProps({
type: FileIconType.folder,
size: 20,
imageFileType: 'svg'
})} /> :
<Icon {...getFileTypeIconProps({extension: ext, size: 20, imageFileType: 'png'})} />
}

</TooltipHost>
</div>
);
}
},
Expand Down Expand Up @@ -192,18 +183,6 @@ function options(row) {

function Items({items, setItems}) {

const menuProps = useConst(() => ({
shouldFocusOnMount: true,
shouldFocusOnContainer: true,
items: [
{key: 'rename', text: 'Rename', onClick: () => console.log('Rename clicked')},
{key: 'edit', text: 'Edit', onClick: () => console.log('Edit clicked')},
{key: 'properties', text: 'Properties', onClick: () => console.log('Properties clicked')},
{key: 'linkNoTarget', text: 'Link same window', href: 'http://bing.com'},
{key: 'linkWithTarget', text: 'Link new window', href: 'http://bing.com', target: '_blank'},
{key: 'disabled', text: 'Disabled item', disabled: true},
],
}));

return (
<div>
Expand All @@ -212,7 +191,7 @@ function Items({items, setItems}) {
let row = props.item;
return <RightMenu theme="mac" options={options(row)} maxWidth={200} style={{cursor: "pointer"}}>
<div onDoubleClick={() => open_file_location(row)}>
<Row persistMenu menuProps={menuProps} data-foo="bar" {...props} />
<Row persistMenu data-foo="bar" {...props} />
</div>
</RightMenu>;
}}
Expand Down
12 changes: 6 additions & 6 deletions src/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ async function filterSuggestedTags(filter, selectedItems) {
return top6(titles);
}

const SearchBox = ({setItems,kw,setKw,selectedKey}) => {
const SearchBox = ({setItems, kw, setKw, selectedKey}) => {
let [init, setInit] = useState(false);
let [handler, setHandler] = useState();
useEffect( () => {
useEffect(() => {
let number = setInterval(async () => {
if (!init) {
let kw0 = "*";
let items = await search(kw0,selectedKey);
let items = await search(kw0, selectedKey);
if (R.isEmpty(items) || R.isNil(items)) {
return;
}
Expand All @@ -47,7 +47,7 @@ const SearchBox = ({setItems,kw,setKw,selectedKey}) => {
setHandler(number);

}, [init])
useEffect( () => {
useEffect(() => {
if (init) {
clearInterval(handler);
}
Expand All @@ -58,7 +58,7 @@ const SearchBox = ({setItems,kw,setKw,selectedKey}) => {
onItemSelected={function (e) {
let kw0 = e.name;
setKw(kw0);
search(kw0,selectedKey).then(items => {
search(kw0, selectedKey).then(items => {
setItems(items);
});
return e;
Expand Down Expand Up @@ -88,7 +88,7 @@ const SearchBox = ({setItems,kw,setKw,selectedKey}) => {
let kw = event.target.value;
document.body.click();
setKw(kw);
let items = await search(kw,selectedKey);
let items = await search(kw, selectedKey);
setItems(items);
}
}
Expand Down
Loading

0 comments on commit 32ea295

Please sign in to comment.